diff --git a/mallinkService/src/main/java/com/iformall/service/WxPayOrderService.java b/mallinkService/src/main/java/com/iformall/service/WxPayOrderService.java index 71a604958..1a3935099 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxPayOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxPayOrderService.java @@ -36,6 +36,9 @@ public interface WxPayOrderService { */ ResultData createPayOrder(WxAppinfo appInfo, WxCUserBasicInfo user, WxPayOrder record, EnumPayWay payWay,PayExtraParam params,boolean isCreatePay); + PayAdapterResult createPayOrder(WxAppinfo appInfo, WxCUserBasicInfo user,WxPayOrder record,WxComposeOrder composeOrder, + String productName, EnumPayWay payWay,PayExtraParam params,boolean isCreatePay); + /** * 刷卡支付订单 * diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index 1defb8e17..a69bb5a7c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -34,6 +34,8 @@ import com.iformall.service.order.entity.WxComposeOrder; import com.iformall.service.order.util.OrderHelper; import com.iformall.service.pay.PayServiceFactory; +import com.iformall.service.pay.entity.PayExtraParam; +import com.iformall.service.pay.service.pay.entity.PayAdapterResult; import com.iformall.utils.*; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -914,7 +916,7 @@ public class WxOrderServiceImpl implements WxOrderService { * * @param user * @param coupon - * @param couponIdStr + * @param */ @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) public StockReduceResult stockReduce(boolean allowUnPayOrder,WxCUserBasicInfo user, WxCoupon coupon, WxCouponChannel couponChannel,int number) { @@ -2770,7 +2772,8 @@ public class WxOrderServiceImpl implements WxOrderService { RedisTemplate cUserBasicInfoRedisTemplate; @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) - public WxComposeOrder savePlatPushOrderForCoupon(TenantEntity tenantEntity,boolean allowUnPayOrder,EnumComposeOrder composeOrderType,WxCUserBasicInfo user,String allExtParam,List platPushOrderList,EnumPayWay payWay) { + public WxComposeOrder savePlatPushOrderForCoupon(TenantEntity tenantEntity,boolean allowUnPayOrder,EnumComposeOrder composeOrderType, + WxCUserBasicInfo user,String allExtParam,List platPushOrderList,EnumPayWay payWay) throws Exception { WxOrderServiceImpl proxy = (WxOrderServiceImpl) AopContext.currentProxy(); // 防止同一用户重复下单,1秒内 String key = new StringBuilder().append("savePlatPushOrder:").append(user.getId()).toString(); @@ -2786,9 +2789,11 @@ public class WxOrderServiceImpl implements WxOrderService { WxComposeOrder composeOrder = orderAdapterService.createDBMainOrderByPushOrder(tenantEntity,user, allExtParam,platPushOrderList, payWay); Date orderDate = new Date(); WxOrder lastOrder = null; + WxCoupon lastCoupon = null; for (int i = 0 ; i < platPushOrderList.size(); i ++) { PlatPushOrderSaveDto orderdto = platPushOrderList.get(i); - + lastCoupon = orderdto.getWxCoupon(); + Map couponChannelMap = composeOrder.getCouponChannelMap(); Long couponChannelId = orderdto.getCouponChannelId(); WxCouponChannel couponChannel = couponChannelMap.get(couponChannelId); @@ -2824,7 +2829,19 @@ public class WxOrderServiceImpl implements WxOrderService { if (EnumComposeOrder.isSingle(composeOrderType.getCode())) { composeOrder.setSingleOrder(lastOrder); } - return composeOrder; + WxPayOrder record = new WxPayOrder(); + record.updateTenantInfo(tenantEntity); + record.setOrderId(composeOrder.getMainOrderId()); + record.setComposeOrder(composeOrder.getComposeOrderType()); + record.setOpenId((String) composeOrder.getMainOrder().getExpParamValue("open_id")); + String productName = orderAdapterService.getPayProductName(lastCoupon); + WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(tenantEntity, payWay.getPlat()); + PayAdapterResult payResult = wxPayOrderService.createPayOrder(cAppInfo, user, record,composeOrder,productName, payWay, new PayExtraParam("openId",record.getOpenId()),false); + if(payResult.isSuccess()){ + return composeOrder; + }else{ + throw new Exception(payResult.getMsg()); + } } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java index cab2b7a77..47683c3ff 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java @@ -322,8 +322,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { } return wxCoupon; } - - private PayAdapterResult createPayOrder(WxAppinfo appInfo, WxCUserBasicInfo user,WxPayOrder record,WxComposeOrder composeOrder, + @Override + public PayAdapterResult createPayOrder(WxAppinfo appInfo, WxCUserBasicInfo user,WxPayOrder record,WxComposeOrder composeOrder, String productName, EnumPayWay payWay,PayExtraParam params,boolean isCreatePay) { IdWorker idworker = IdWorker.get(); EnumPayShare isShare = EnumPayShare.NO;