Browse Source

fix order

release_toaliyun_real
lin 3 years ago
parent
commit
aa9ac199ae
1 changed files with 32 additions and 18 deletions
  1. +32
    -18
      mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java

+ 32
- 18
mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java View File

@@ -176,7 +176,9 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
if (isOneChildOrder) {
//处理其他信息
try {
proxy.handleOrderPaySingleOrderSuccess(composeOrder.getSingleOrder(),oldRecord, transactionId,isScheduleTask);
WxCoupon wxCoupon = wxCouponMapper.selectById(composeOrder.getSingleOrder().getProductId(),composeOrder.getSingleOrder().getTenantId());
proxy.handelPress(wxCoupon, composeOrder.getSingleOrder());
proxy.handleOrderPaySingleOrderSuccess(wxCoupon,composeOrder.getSingleOrder(),oldRecord, transactionId,isScheduleTask);
}catch(Exception e) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage());
}
@@ -184,7 +186,9 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
List<WxOrder> orderList = orderFactory.getOrderAdapterService(composeOrder.getComposeOrderType()).getChildOrders(composeOrder, oldRecord.getTenantId());
for (WxOrder o : orderList) {
try {
proxy.handleOrderPaySingleOrderSuccess(o,oldRecord, transactionId, isScheduleTask);
WxCoupon wxCoupon = wxCouponMapper.selectById(o.getProductId(),o.getTenantId());
proxy.handelPress(wxCoupon, o);
proxy.handleOrderPaySingleOrderSuccess(wxCoupon,o,oldRecord, transactionId, isScheduleTask);
}catch(Exception e) {
logger.error("handleSuccessOrder error.",e);
}
@@ -193,7 +197,9 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
}else {
//处理其他信息
try {
proxy.handleOrderPaySingleOrderSuccess(composeOrder.getSingleOrder(),oldRecord, transactionId,isScheduleTask);
WxCoupon wxCoupon = wxCouponMapper.selectById(composeOrder.getSingleOrder().getProductId(),composeOrder.getSingleOrder().getTenantId());
proxy.handelPress(wxCoupon, composeOrder.getSingleOrder());
proxy.handleOrderPaySingleOrderSuccess(wxCoupon,composeOrder.getSingleOrder(),oldRecord, transactionId,isScheduleTask);
}catch(Exception e) {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage());
}
@@ -203,7 +209,24 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
}
}

@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public boolean handelPress(WxCoupon coupon,WxOrder order) {
//如果是砍价,并且是付款扣库存
if (null != coupon && coupon.getType().intValue() == EnumCouponType.COUPON_PRESS.getCode().intValue()
&& null != coupon.getPressPayReduceStock() && coupon.getPressPayReduceStock().intValue() == EnumYesOrNo.YES.getCode().intValue()) {
try {
wxOrderServiceHelper.reduceStock(false,coupon,order.getCouponChannelId(), 1);
return true;
}catch(Exception e) {
//如果此时扣库存失败,则需要给订单退款
order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_SCHEDU_REFUND.getCode());
wxOrderMapper.updateById(order);
return false;
}
}
return true;
}
@Override
public WxPayOrder handleWxOrderQuery(WxPayOrder oldRecord,WxComposeOrder composeOrder,WxAppinfo appInfo,WxPayAccount payAccount,IdWorker idworker,boolean repeatPay) {
@@ -216,7 +239,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
logger.error("pay order service handleWxOrderQuery error: " ,e);
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(),e.getMessage());
}
if (EnumPayStatus.PAY_STATUS_SUCCESS.getCode()==wxpaystatus) {
//直接调用不会触发事务,spring事务基于AOP代理
WxPayOrderServiceImpl proxy = (WxPayOrderServiceImpl) AopContext.currentProxy();
@@ -279,12 +302,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
for (WxOrder o : orderList) {
productNames.add(o.getProductName());
checkSinglePayOrder(o, user, payWay);
//如果是砍价,并且是付款扣库存
WxCoupon coupon = wxCouponMapper.selectById(o.getProductId(), appInfo.getTenantId());
if (null != coupon && coupon.getType().intValue() == EnumCouponType.COUPON_PRESS.getCode().intValue()
&& null != coupon.getPressPayReduceStock() && coupon.getPressPayReduceStock().intValue() == EnumYesOrNo.YES.getCode().intValue()) {
wxOrderServiceHelper.reduceStock(false,coupon,o.getCouponChannelId(), 1);
}
}
PayAdapterResult payResult = createPayOrder(appInfo, user, record,composeOrder,orderList,JSON.toJSONString(productNames), payWay, params,isCreatePay);
if (payResult.isSuccess()) {
@@ -895,7 +912,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
if (!hasCompleted) {
//组合支付的订单,循环所有子订单
for (WxOrder o : orderList) {
proxy.handleOrderPaySingleOrderSuccess(o,record, transactionId, false);
WxCoupon wxCoupon = wxCouponMapper.selectById(o.getProductId(),o.getTenantId());
proxy.handleOrderPaySingleOrderSuccess(wxCoupon,o,record, transactionId, false);
}
}
}
@@ -951,16 +969,14 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class})
public void handleOrderPaySingleOrderSuccess(WxOrder order,WxPayOrder record, String transactionId,boolean isScheduleTask) {
Long productId = order.getProductId();
WxCoupon wxCoupon = wxCouponMapper.selectById(productId,order.getTenantId());
public void handleOrderPaySingleOrderSuccess(WxCoupon wxCoupon,WxOrder order,WxPayOrder record, String transactionId,boolean isScheduleTask) {
if(wxCoupon != null) {
if (isOrderGroupCoupon(record, wxCoupon)) {
// 如果是Coupon是拼团, 创建拼团信息, 不创建COUPON_ORDER
try {
wxOrderGroupService.createOrderGroup(order, wxCoupon,isScheduleTask);
} catch (Exception e) {
logger.error("参团失败" + e.getMessage());
logger.error("参团失败" ,e);
order.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_FAILD.getCode());
order.setUpdateDate(new Date());
wxOrderMapper.updateById(order);
@@ -991,8 +1007,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
throw new MallinkException(ErrorCode.MSG_INSIDE_ERROR);
}
}


}
}



Loading…
Cancel
Save