订单更新失败异步重新发起与通知
This commit is contained in:
parent
76f3d1eeef
commit
0376bf1453
@ -28,8 +28,10 @@ import com.github.binarywang.wxpay.exception.WxPayException;
|
|||||||
import com.github.binarywang.wxpay.service.WxPayService;
|
import com.github.binarywang.wxpay.service.WxPayService;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
|
import com.mybatisflex.core.row.Db;
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@ -314,7 +316,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|||||||
productRecords.forEach(item -> {
|
productRecords.forEach(item -> {
|
||||||
item.setRecordNum(item.getRecordNum() - orderNumMap.get(item.getId()));
|
item.setRecordNum(item.getRecordNum() - orderNumMap.get(item.getId()));
|
||||||
});
|
});
|
||||||
productRecordService.updateBatch(productRecords);
|
asyncUpdateRecords(productRecords,0);
|
||||||
//TODO:分账先注释
|
//TODO:分账先注释
|
||||||
/*ProfitSharing profitSharing = new ProfitSharing();
|
/*ProfitSharing profitSharing = new ProfitSharing();
|
||||||
profitSharing.setOrderId(orderId)
|
profitSharing.setOrderId(orderId)
|
||||||
@ -344,6 +346,30 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 异步更新数据库
|
||||||
|
* @param productRecords 产品记录
|
||||||
|
* @param flag 成功标志
|
||||||
|
* @return
|
||||||
|
* @Author DB
|
||||||
|
* @Date: 2023/11/1 0:09
|
||||||
|
*/
|
||||||
|
@Async("customAsyncThreadPool")
|
||||||
|
public void asyncUpdateRecords(List<ProductRecord> productRecords, Integer flag) {
|
||||||
|
ProductRecordService productRecordService = SpringUtils.getBean(ProductRecordService.class);
|
||||||
|
if (flag > 5) {
|
||||||
|
//TODO:通知到系统库存减扣失败,需要人为操作
|
||||||
|
throw new ServiceException("更新订单失败");
|
||||||
|
} else {
|
||||||
|
boolean tx = Db.tx(() -> productRecordService.updateBatch(productRecords));
|
||||||
|
if (!tx){
|
||||||
|
//更新失败
|
||||||
|
flag++;
|
||||||
|
asyncUpdateRecords(productRecords, flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @descriptions 取消订单
|
* @descriptions 取消订单
|
||||||
* @author DB
|
* @author DB
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user