| @@ -234,11 +234,12 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| } | |||
| List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); | |||
| WxCoupon lastCoupon = null; | |||
| for (WxOrder o : orderList) { | |||
| checkSinglePayOrder(o, user, payWay); | |||
| lastCoupon = checkSinglePayOrder(o, user, payWay); | |||
| } | |||
| PayAdapterResult payResult = createPayOrder(appInfo, user, record,composeOrder, payWay, params); | |||
| String productName = orderAdapterService.getPayProductName(lastCoupon); | |||
| PayAdapterResult payResult = createPayOrder(appInfo, user, record,composeOrder,productName, payWay, params); | |||
| if (payResult.isSuccess()) { | |||
| return new ResultData(Result.SUCCESS,"创建支付单成功",payResult.getData()); | |||
| }else { | |||
| @@ -247,7 +248,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| } | |||
| private void checkSinglePayOrder(WxOrder order,WxCUserBasicInfo user,EnumPayWay payWay) { | |||
| private WxCoupon checkSinglePayOrder(WxOrder order,WxCUserBasicInfo user,EnumPayWay payWay) { | |||
| if (!order.getOrderGroupId().equals(0L)) { | |||
| if (order.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_COOPERATING_COMPLETE.getCode())) { | |||
| logger.error("支付时拼团已满>>" + order.getOrderGroupId()); | |||
| @@ -309,9 +310,10 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| if (order.getPaymentType() != EnumPayType.PAY_PAYMENT.getCode()) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); | |||
| } | |||
| return wxCoupon; | |||
| } | |||
| private PayAdapterResult createPayOrder(WxAppinfo appInfo, WxCUserBasicInfo user,WxPayOrder record,WxComposeOrder composeOrder, EnumPayWay payWay,PayExtraParam params) { | |||
| private PayAdapterResult createPayOrder(WxAppinfo appInfo, WxCUserBasicInfo user,WxPayOrder record,WxComposeOrder composeOrder,String productName, EnumPayWay payWay,PayExtraParam params) { | |||
| IdWorker idworker = IdWorker.get(); | |||
| EnumPayShare isShare = EnumPayShare.NO; | |||
| @@ -411,7 +413,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| logger.debug("wxPayRecord md5 before:"+record.toString()); | |||
| String beforemd5 = HashUtil.md5(record.toString()); | |||
| PayAdapterResult payResult = payServiceFactory.getPayAdapterService(payWay.getCode()).pay(payAccount, record,composeOrder,isShare,appInfo, currentDate, params); | |||
| PayAdapterResult payResult = payServiceFactory.getPayAdapterService(payWay.getCode()).pay(payAccount, record,composeOrder,productName,isShare,appInfo, currentDate, params); | |||
| String aftermd5 = HashUtil.md5(record.toString()); | |||
| if (beforemd5.equals(aftermd5)) { | |||
| logger.error("支付方式["+payWay.getCode()+"]支付接口【pay】过程中 WxPayOrder 未做更新.record:"+record.toString()); | |||
| @@ -536,7 +538,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| logger.debug("wxPayRecord md5 before:"+record.toString()); | |||
| String beforemd5 = HashUtil.md5(record.toString()); | |||
| PayAdapterResult payResult = payServiceFactory.getPayAdapterService(payWay.getCode()).pay(payAccount, record,composeOrder,isShare,appInfo, currentDate, params); | |||
| PayAdapterResult payResult = payServiceFactory.getPayAdapterService(payWay.getCode()).pay(payAccount, record,composeOrder,"付款码支付",isShare,appInfo, currentDate, params); | |||
| String aftermd5 = HashUtil.md5(record.toString()); | |||
| if (beforemd5.equals(aftermd5)) { | |||
| logger.error("支付方式["+payWay.getCode()+"]支付接口【pay】过程中 WxPayOrder 未做更新.record:"+record.toString()); | |||
| @@ -19,6 +19,13 @@ public interface OrderAdapterService { | |||
| */ | |||
| WxComposeOrder createDBMainOrder(WxCUserBasicInfo user,List<OrderComposeSaveDto> orderSave,EnumPayWay payWay); | |||
| /** | |||
| * 获取支付时商品名称,供服务商API使用 | |||
| * @param lastCoupon | |||
| * @return | |||
| */ | |||
| String getPayProductName(WxCoupon lastCoupon); | |||
| /** | |||
| * 是否是一个数量一个订单。一个产品肯定是一个订单 | |||
| * @return | |||
| @@ -19,8 +19,10 @@ public class WxComposeOrder { | |||
| private Integer payment; | |||
| private String productName;//支付时调用服务商接口使用 | |||
| private WxOrder singleOrder;//单个模式时不用重复查询 | |||
| private Object mainOrder;//真正的主订单对象 | |||
| private Object mainOrder;//真正的主订单对象,批量下单时才有 | |||
| } | |||
| @@ -81,4 +81,9 @@ public class SingleOrderAdapterService implements OrderAdapterService { | |||
| public void doOthersAfterPaySuccess(WxOrder order, WxPayOrder record) { | |||
| } | |||
| @Override | |||
| public String getPayProductName(WxCoupon lastCoupon) { | |||
| return lastCoupon.getTitle(); | |||
| } | |||
| } | |||
| @@ -51,5 +51,10 @@ public class CouponPackageOrderAdapterService extends BaseBatchOrderAdapterServi | |||
| //手动核销发券 | |||
| } | |||
| @Override | |||
| public String getPayProductName(WxCoupon lastCoupon) { | |||
| return "[券包]"+lastCoupon.getTitle(); | |||
| } | |||
| } | |||
| @@ -7,6 +7,7 @@ import org.springframework.stereotype.Service; | |||
| import com.iformall.domain.dto.OrderComposeSaveDto; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxOrder; | |||
| import com.iformall.domain.po.WxPayOrder; | |||
| import com.iformall.enums.EnumComposeOrder; | |||
| @@ -45,5 +46,10 @@ public class MulityNumberOneOrderBatchOrderAdapterService extends BaseBatchOrder | |||
| @Override | |||
| public void doOthersAfterPaySuccess(WxOrder order, WxPayOrder record) { | |||
| } | |||
| @Override | |||
| public String getPayProductName(WxCoupon lastCoupon) { | |||
| return "批量支付商品"; | |||
| } | |||
| } | |||
| @@ -6,6 +6,7 @@ import org.springframework.stereotype.Service; | |||
| import com.iformall.domain.dto.OrderComposeSaveDto; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxOrder; | |||
| import com.iformall.domain.po.WxPayOrder; | |||
| import com.iformall.enums.EnumComposeOrder; | |||
| @@ -45,5 +46,10 @@ public class OneNumberOneOrderBatchOrderAdapterService extends BaseBatchOrderAda | |||
| public void doOthersAfterPaySuccess(WxOrder order, WxPayOrder record) { | |||
| } | |||
| @Override | |||
| public String getPayProductName(WxCoupon lastCoupon) { | |||
| return "批量支付商品"; | |||
| } | |||
| } | |||
| @@ -29,7 +29,7 @@ public interface PayAdapterService { | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record ,WxComposeOrder composeOrder,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception; | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record ,WxComposeOrder composeOrder,String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception; | |||
| /** | |||
| * 查询支付结果,调用对应端的API查询支付结果 | |||
| @@ -23,7 +23,7 @@ import com.iformall.service.pay.service.pay.wx.BaseWxPayAdapterService; | |||
| public class WxH5PayService extends BaseWxPayAdapterService implements CDrivingPayService{ | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record,WxComposeOrder composeOrder, EnumPayShare isShare, | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record,WxComposeOrder composeOrder,String productName, EnumPayShare isShare, | |||
| WxAppinfo appInfo, Date currentDate, PayExtraParam params) throws Exception { | |||
| // TODO Auto-generated method stub | |||
| return null; | |||
| @@ -61,7 +61,7 @@ public class WxMiniAppPayAdapterService extends BaseWxPayAdapterService implemen | |||
| "\"NOT_UTF8\":{\"detail\":\"编码格式错误\",\"reason\":\"未使用指定编码格式\",\"resolution\":\"请使用UTF-8编码格式\"}}"); | |||
| private WxPayOrderP generateWxPayOrderP(WxPayAccount payAccount,WxComposeOrder composeOrder, WxPayOrder record,String openId,String appId,Date currentDate) throws Exception { | |||
| private WxPayOrderP generateWxPayOrderP(WxPayAccount payAccount,WxComposeOrder composeOrder,String productName, WxPayOrder record,String openId,String appId,Date currentDate) throws Exception { | |||
| // 统一下单 普通商户模式 | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxPayOrderP wxPayOrderP = new WxPayOrderP(); | |||
| @@ -69,11 +69,11 @@ public class WxMiniAppPayAdapterService extends BaseWxPayAdapterService implemen | |||
| wxPayOrderP.setAppid(appId); | |||
| wxPayOrderP.setMch_id(payAccount.getMchId()); | |||
| wxPayOrderP.setNonce_str(noncestr); | |||
| wxPayOrderP.setBody("在线商品"); | |||
| wxPayOrderP.setBody(productName); | |||
| wxPayOrderP.setOut_trade_no(record.getPayOrderNo()); | |||
| wxPayOrderP.setTotal_fee(composeOrder.getPayment()); | |||
| wxPayOrderP.setSpbill_create_ip(record.getIp()); // 终端IP | |||
| wxPayOrderP.setGoods_tag("在线商品"); | |||
| wxPayOrderP.setGoods_tag(productName); | |||
| wxPayOrderP.setNotify_url(payAccount.getPayNotifyUrl()); | |||
| wxPayOrderP.setTrade_type(WxPay.TradeType.JSAPI.name()); // 终端类型 | |||
| wxPayOrderP.setProduct_id(String.valueOf(composeOrder.getMainOrderId())); // 订单ID | |||
| @@ -135,7 +135,7 @@ public class WxMiniAppPayAdapterService extends BaseWxPayAdapterService implemen | |||
| private WxPayOrderSP generateWxPayOrderSP(WxPayAccount payAccount, WxComposeOrder composeOrder,WxPayOrder record,WxAppinfo appInfo,String openId,String appId,Date currentDate,EnumPayShare isShare) throws Exception { | |||
| private WxPayOrderSP generateWxPayOrderSP(WxPayAccount payAccount, WxComposeOrder composeOrder,String productName,WxPayOrder record,WxAppinfo appInfo,String openId,String appId,Date currentDate,EnumPayShare isShare) throws Exception { | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxPayOrderSP wxPayOrderSP = new WxPayOrderSP(); | |||
| wxPayOrderSP.setSub_openid(openId); | |||
| @@ -144,11 +144,11 @@ public class WxMiniAppPayAdapterService extends BaseWxPayAdapterService implemen | |||
| wxPayOrderSP.setSub_appid(appId); | |||
| wxPayOrderSP.setSub_mch_id(payAccount.getSubMchId()); | |||
| wxPayOrderSP.setNonce_str(noncestr); | |||
| wxPayOrderSP.setBody("在线商品"); | |||
| wxPayOrderSP.setBody(productName); | |||
| wxPayOrderSP.setOut_trade_no(record.getPayOrderNo()); | |||
| wxPayOrderSP.setTotal_fee(composeOrder.getPayment().toString()); | |||
| wxPayOrderSP.setSpbill_create_ip(record.getIp()); // 终端IP | |||
| wxPayOrderSP.setGoods_tag("在线商品"); // 券ID | |||
| wxPayOrderSP.setGoods_tag(productName); // 券ID | |||
| wxPayOrderSP.setNotify_url(payAccount.getPayNotifyUrl()); | |||
| wxPayOrderSP.setTrade_type(WxPay.TradeType.JSAPI.name()); // 终端类型 | |||
| wxPayOrderSP.setProduct_id(String.valueOf(composeOrder.getMainOrderId())); // | |||
| @@ -214,7 +214,7 @@ public class WxMiniAppPayAdapterService extends BaseWxPayAdapterService implemen | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record,WxComposeOrder composeOrder,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception { | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record,WxComposeOrder composeOrder,String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception { | |||
| if (null == params ) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"openId为空"); | |||
| } | |||
| @@ -224,7 +224,7 @@ public class WxMiniAppPayAdapterService extends BaseWxPayAdapterService implemen | |||
| } | |||
| //普通商户模式 | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| WxPayOrderP wxPayOrderP = generateWxPayOrderP(payAccount,composeOrder,record,openId,appInfo.getAppId(),currentDate); | |||
| WxPayOrderP wxPayOrderP = generateWxPayOrderP(payAccount,composeOrder,productName,record,openId,appInfo.getAppId(),currentDate); | |||
| String response = WxPay.pushOrder(BeanUtils.toStringMap(wxPayOrderP)); | |||
| log.info("pay order, wechat pushOrder, " + wxPayOrderP.toString() + ", response: " + response.toString()); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| @@ -232,7 +232,7 @@ public class WxMiniAppPayAdapterService extends BaseWxPayAdapterService implemen | |||
| } else { | |||
| // 统一下单 // 服务商模式 | |||
| WxPayOrderSP wxPayOrderSP = generateWxPayOrderSP(payAccount,composeOrder,record,appInfo,openId,appInfo.getAppId(),currentDate,isShare); | |||
| WxPayOrderSP wxPayOrderSP = generateWxPayOrderSP(payAccount,composeOrder,productName,record,appInfo,openId,appInfo.getAppId(),currentDate,isShare); | |||
| String response = WxPay.pushOrder(BeanUtils.toStringMap(wxPayOrderSP)); | |||
| log.info("pay order, wechat pushOrder, " + wxPayOrderSP.toString() + ", response: " + response.toString()); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| @@ -47,7 +47,7 @@ import me.chanjar.weixin.common.error.WxErrorException; | |||
| @Service | |||
| public class WxMiniMaPayAdapterService extends BaseWxPayAdapterService implements CPassivePayService{ | |||
| private WxMicroPayOrderP generateWxMicroPayOrderP(WxPayAccount payAccount, WxComposeOrder composeOrder, WxPayOrder record, EnumPayShare isShare, | |||
| private WxMicroPayOrderP generateWxMicroPayOrderP(WxPayAccount payAccount, WxComposeOrder composeOrder, String productName,WxPayOrder record, EnumPayShare isShare, | |||
| WxAppinfo appInfo, Date currentDate,String bAppId,String bUserPhone) throws Exception { | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxMicroPayOrderP wxPayOrderP = new WxMicroPayOrderP(); | |||
| @@ -55,7 +55,7 @@ public class WxMiniMaPayAdapterService extends BaseWxPayAdapterService implement | |||
| wxPayOrderP.setMch_id(payAccount.getMchId()); | |||
| wxPayOrderP.setDevice_info(bUserPhone); | |||
| wxPayOrderP.setNonce_str(noncestr); | |||
| wxPayOrderP.setBody("在线商品"); | |||
| wxPayOrderP.setBody(productName); | |||
| wxPayOrderP.setOut_trade_no(record.getPayOrderNo()); | |||
| wxPayOrderP.setTotal_fee(record.getPayAmount()); | |||
| wxPayOrderP.setSpbill_create_ip(record.getIp()); // 终端IP | |||
| @@ -101,7 +101,7 @@ public class WxMiniMaPayAdapterService extends BaseWxPayAdapterService implement | |||
| } | |||
| private WxMicroPayOrderSP generateWxMicroPayOrderSP(WxPayAccount payAccount, WxComposeOrder composeOrder,WxPayOrder record, EnumPayShare isShare, | |||
| private WxMicroPayOrderSP generateWxMicroPayOrderSP(WxPayAccount payAccount, WxComposeOrder composeOrder, String productName,WxPayOrder record, EnumPayShare isShare, | |||
| WxAppinfo appInfo, Date currentDate,String bUserPhone) throws Exception { | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxMicroPayOrderSP wxPayOrderSP = new WxMicroPayOrderSP(); | |||
| @@ -111,7 +111,7 @@ public class WxMiniMaPayAdapterService extends BaseWxPayAdapterService implement | |||
| wxPayOrderSP.setSub_mch_id(payAccount.getSubMchId()); | |||
| wxPayOrderSP.setDevice_info(bUserPhone); | |||
| wxPayOrderSP.setNonce_str(noncestr); | |||
| wxPayOrderSP.setBody("在线商品"); | |||
| wxPayOrderSP.setBody(productName); | |||
| wxPayOrderSP.setOut_trade_no(record.getPayOrderNo()); | |||
| wxPayOrderSP.setTotal_fee(record.getPayAmount()); | |||
| wxPayOrderSP.setSpbill_create_ip(record.getIp()); | |||
| @@ -163,7 +163,7 @@ public class WxMiniMaPayAdapterService extends BaseWxPayAdapterService implement | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record, WxComposeOrder composeOrder, EnumPayShare isShare, | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record, WxComposeOrder composeOrder,String productName, EnumPayShare isShare, | |||
| WxAppinfo appInfo, Date currentDate, PayExtraParam params) throws Exception { | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| // 扫码支付 普通商户模式 | |||
| @@ -176,7 +176,7 @@ public class WxMiniMaPayAdapterService extends BaseWxPayAdapterService implement | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"bUserPhone 不能为空"); | |||
| } | |||
| WxMicroPayOrderP wxPayOrderP = generateWxMicroPayOrderP(payAccount, composeOrder,record, isShare, appInfo, currentDate, bAppId, bUserPhone); | |||
| WxMicroPayOrderP wxPayOrderP = generateWxMicroPayOrderP(payAccount, composeOrder,productName,record, isShare, appInfo, currentDate, bAppId, bUserPhone); | |||
| String response = WxPay.micropay(BeanUtils.toStringMap(wxPayOrderP)); | |||
| log.info("pay order, wechat micropay, " + wxPayOrderP.toString() + ", response: " + response.toString()); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| @@ -189,7 +189,7 @@ public class WxMiniMaPayAdapterService extends BaseWxPayAdapterService implement | |||
| if (StringUtils.isBlank(bUserPhone)) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"bUserPhone 不能为空"); | |||
| } | |||
| WxMicroPayOrderSP wxPayOrderSP = generateWxMicroPayOrderSP(payAccount, composeOrder,record, isShare, appInfo, currentDate, bUserPhone); | |||
| WxMicroPayOrderSP wxPayOrderSP = generateWxMicroPayOrderSP(payAccount, composeOrder,productName,record, isShare, appInfo, currentDate, bUserPhone); | |||
| String response = WxPay.micropay(BeanUtils.toStringMap(wxPayOrderSP)); | |||
| log.info("pay order, wechat micropay, " + wxPayOrderSP.toString() + ", response: " + response.toString()); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||