| @@ -2035,5 +2035,4 @@ alter table wx_pay_account_bill drop column real_rate; | |||
| alter table wx_appinfo drop column pay_bill_id; | |||
| redis清除token | |||
| @@ -47,16 +47,6 @@ public enum EnumComposeOrder { | |||
| } | |||
| } | |||
| //支付时是否是多个商家的 | |||
| public static boolean isMulityMerchantPay(Integer type) { | |||
| if (type.intValue() == ONE_NUMBER_ORDER_BATCH.getCode().intValue() || | |||
| type.intValue() == MULITY_NUMBER_ORDER_BATCH.getCode().intValue()) { | |||
| return true; | |||
| }else { | |||
| return false; | |||
| } | |||
| } | |||
| //子订单是单个还是一起,购物车的子订单是单个,可以单个支付,券包的子订单不能单个支付 | |||
| // public static boolean childOrderIsSingle(Integer type) { | |||
| // if (type.intValue() == SINGLE.getCode().intValue() || type.intValue() == ONE_NUMBER_ORDER_BATCH.getCode().intValue() | |||
| @@ -32,7 +32,7 @@ import com.iformall.service.order.OrderFactory; | |||
| 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.service.pay.douyin.miniApp.EnumTtPayChannel; | |||
| import com.iformall.service.pay.service.pay.douyin.v1.miniApp.EnumTtPayChannel; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.PayUtils; | |||
| @@ -357,6 +357,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| try { | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | |||
| PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion()); | |||
| EnumPayMchType payMchTypeEnum = EnumPayMchType.getEnum(payAccount.getMchType()); | |||
| if(payMchTypeEnum != null){ | |||
| payMchType = payMchTypeEnum; | |||
| @@ -406,8 +407,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_PAYING.getCode(),"该订单状态不允许支付!"); | |||
| } | |||
| }else { | |||
| { | |||
| // 3.1 创建支付订单 | |||
| // Long id = idworker.nextId(); | |||
| // if (null == id || id.longValue() <=0) { | |||
| @@ -434,8 +433,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| record.setShare(isShare.getCode()); | |||
| record.setComposeOrder(composeOrder.getComposeOrderType()); | |||
| // if (isShare == EnumPayShare.YES) { | |||
| PayShareAdapterService payShareServie = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion()); | |||
| // PayShareCalculateAmount recordShareAmount = payShareServie.calculateAmount(record.getPayAmount(), payAccount); | |||
| // // 分账金额 | |||
| // Integer share_amount = recordShareAmount.getShareAmount(); | |||
| @@ -451,6 +448,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| } | |||
| int share_amount = 0; | |||
| int rate_amount = 0; | |||
| 11111111111111111111 | |||
| //todo 注意购物车模式(需测试)每笔子订单算法可能与总订单算法有差 | |||
| for (WxOrder o : orderList) { | |||
| Long merchant_id = null; | |||
| @@ -481,11 +479,9 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| logger.error("pay order insert error: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| } | |||
| } | |||
| PayAdapterService payAdapterService = payServiceFactory.getPayAdapterService(payWay.getCode(),payAccount.getPayVersion()); | |||
| if(!isCreatePay){ | |||
| PayAdapterResult payResult = payAdapterService.noCreatePay(record,composeOrder,childOrders); | |||
| return payResult; | |||
| @@ -493,7 +489,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| logger.debug("wxPayRecord md5 before:"+record.toString()); | |||
| String beforemd5 = HashUtil.md5(record.toString()); | |||
| PayAdapterResult payResult = payAdapterService.pay(payAccount, record,composeOrder,productName,isShare,appInfo, currentDate, params); | |||
| WxProfitSharingReceiver receiver = payShareServie.getPayReceiver(); | |||
| PayAdapterResult payResult = payAdapterService.pay(payAccount, record,composeOrder,childOrders,productName,isShare,appInfo, currentDate, params); | |||
| String aftermd5 = HashUtil.md5(record.toString()); | |||
| if (beforemd5.equals(aftermd5)) { | |||
| logger.error("支付方式["+payWay.getCode()+"]支付接口【pay】过程中 WxPayOrder 未做更新.record:"+record.toString()); | |||
| @@ -529,7 +526,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| try { | |||
| // 1. check 订单 | |||
| WxComposeOrder composeOrder = orderFactory.getOrderAdapterService(EnumComposeOrder.SINGLE.getCode()).getComposeOrder(record.getOrderId(), appInfo.getTenantId()); | |||
| OrderAdapterService orderAdapterService = orderFactory.getOrderAdapterService(EnumComposeOrder.SINGLE.getCode()); | |||
| WxComposeOrder composeOrder = orderAdapterService.getComposeOrder(record.getOrderId(), appInfo.getTenantId()); | |||
| if (composeOrder == null) { | |||
| logger.error("pay order, order not allow, repaymentReq: " + record.toString() + ", payWay: " + payWay.toString()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||
| @@ -617,7 +615,10 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| logger.debug("wxPayRecord md5 before:"+record.toString()); | |||
| String beforemd5 = HashUtil.md5(record.toString()); | |||
| PayAdapterResult payResult = payServiceFactory.getPayAdapterService(payWay.getCode(),payAccount.getPayVersion()).pay(payAccount, record,composeOrder,"付款码支付",isShare,appInfo, currentDate, params); | |||
| WxProfitSharingReceiver receiver = payServiceFactory.getPayShareAdapterService(payWay.getCode(),payAccount.getPayVersion()).getPayReceiver(); | |||
| List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, appInfo.getTenantId()); | |||
| PayAdapterResult payResult = payServiceFactory.getPayAdapterService(payWay.getCode(),payAccount.getPayVersion()).pay(payAccount,receiver, record,composeOrder,orderList, | |||
| "付款码支付",isShare,appInfo, currentDate, params); | |||
| String aftermd5 = HashUtil.md5(record.toString()); | |||
| if (beforemd5.equals(aftermd5)) { | |||
| logger.error("支付方式["+payWay.getCode()+"]支付接口【pay】过程中 WxPayOrder 未做更新.record:"+record.toString()); | |||
| @@ -4,7 +4,6 @@ import java.util.Map; | |||
| import java.util.concurrent.ConcurrentHashMap; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumPayVersion; | |||
| import com.iformall.service.pay.service.pay.douyin.miniApp.TtMiniAppPayAdapterService; | |||
| import com.iformall.service.pay.service.refund.douyin.TtRefundAdapterService; | |||
| import com.iformall.service.pay.service.refund.wx.v2.WxRefundAdapterService; | |||
| import com.iformall.service.pay.service.refund.wx.v3.WxRefundV3AdapterService; | |||
| @@ -22,6 +21,7 @@ import com.iformall.service.pay.service.cashout.wx.v3.WxCashOutV3AdapterService; | |||
| import com.iformall.service.pay.service.pay.CDrivingPayService; | |||
| import com.iformall.service.pay.service.pay.CPassivePayService; | |||
| import com.iformall.service.pay.service.pay.PayAdapterService; | |||
| import com.iformall.service.pay.service.pay.douyin.v1.miniApp.TtMiniAppPayAdapterService; | |||
| import com.iformall.service.pay.service.pay.wx.v2.h5.WxH5PayService; | |||
| import com.iformall.service.pay.service.pay.wx.v2.miniApp.appPay.WxMiniAppPayAdapterService; | |||
| import com.iformall.service.pay.service.pay.wx.v2.miniApp.maPay.WxMiniMaPayAdapterService; | |||
| @@ -1,15 +1,33 @@ | |||
| package com.iformall.service.pay.service.cashout.wx.v3.entity; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxOrder; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import lombok.Data; | |||
| @Data | |||
| public class CombineItemOrder { | |||
| private String mchid;//子单商户号 | |||
| private String mchid;//子单发起方商户号,必须与发起方appid有绑定关系 | |||
| private String attach;//附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用 | |||
| private CombinePayAmountReq amount;//订单金额 | |||
| private String out_trade_no;//子单商户订单号 | |||
| private String sub_mchid;//二级商户号,服务商子商户的商户号,被合单方。直连商户不用传二级商户号 | |||
| private String description;//商品描述,需传入应用市场上的APP名字-实际商品名称 | |||
| private PaySettleReq settle_info;//结算信息 | |||
| public void initByWxOrder(WxPayAccount payAccount,WxOrder order,String subMchId,WxAppinfo appInfo,String productName,String extParam) { | |||
| this.mchid = payAccount.getMchId(); | |||
| this.attach = extParam; | |||
| CombinePayAmountReq amount = new CombinePayAmountReq(); | |||
| amount.setTotal_amount(order.getPayment()); | |||
| this.setAmount(amount); | |||
| this.out_trade_no = String.valueOf(order.getId()); | |||
| this.sub_mchid = subMchId; | |||
| this.description = appInfo.getName()+"-"+productName; | |||
| PaySettleReq settle = new PaySettleReq(); | |||
| settle.setProfit_sharing(true); | |||
| this.setSettle_info(settle); | |||
| } | |||
| } | |||
| @@ -27,7 +27,7 @@ public interface PayAdapterService { | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record ,WxComposeOrder composeOrder,String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception; | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record ,WxComposeOrder composeOrder,List<WxOrder> childOrders,String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception; | |||
| /** | |||
| * 查询支付结果,调用对应端的API查询支付结果 | |||
| @@ -1,4 +1,4 @@ | |||
| package com.iformall.service.pay.service.pay.douyin; | |||
| package com.iformall.service.pay.service.pay.douyin.v1; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| @@ -1,4 +1,4 @@ | |||
| package com.iformall.service.pay.service.pay.douyin.miniApp; | |||
| package com.iformall.service.pay.service.pay.douyin.v1.miniApp; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| @@ -1,4 +1,4 @@ | |||
| package com.iformall.service.pay.service.pay.douyin.miniApp; | |||
| package com.iformall.service.pay.service.pay.douyin.v1.miniApp; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| @@ -1,4 +1,4 @@ | |||
| package com.iformall.service.pay.service.pay.douyin.miniApp; | |||
| package com.iformall.service.pay.service.pay.douyin.v1.miniApp; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| @@ -1,4 +1,4 @@ | |||
| package com.iformall.service.pay.service.pay.douyin.miniApp; | |||
| package com.iformall.service.pay.service.pay.douyin.v1.miniApp; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| @@ -22,7 +22,7 @@ import com.iformall.service.order.OrderFactory; | |||
| import com.iformall.service.order.entity.WxComposeOrder; | |||
| import com.iformall.service.pay.entity.PayExtraParam; | |||
| import com.iformall.service.pay.service.pay.CDrivingPayService; | |||
| import com.iformall.service.pay.service.pay.douyin.BaseTtPayAdapterService; | |||
| import com.iformall.service.pay.service.pay.douyin.v1.BaseTtPayAdapterService; | |||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||
| import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | |||
| import com.iformall.utils.Constant; | |||
| @@ -72,7 +72,9 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||
| private MaUtil maUtil; | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record,WxComposeOrder composeOrder,String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception { | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception { | |||
| //抖音支付1.0,已经不再支持 | |||
| if(true){ | |||
| throw new MallinkException(ErrorCode.SYS_AUTH_ERROR.getCode(),"请升级抖音版本"); | |||
| } | |||
| @@ -22,8 +22,8 @@ import com.iformall.service.pay.service.pay.wx.v2.BaseWxPayAdapterService; | |||
| public class WxH5PayService extends BaseWxPayAdapterService implements CDrivingPayService{ | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record,WxComposeOrder composeOrder,String productName, EnumPayShare isShare, | |||
| WxAppinfo appInfo, Date currentDate, PayExtraParam params) throws Exception { | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| String productName, EnumPayShare isShare,WxAppinfo appInfo, Date currentDate, PayExtraParam params) throws Exception { | |||
| // TODO Auto-generated method stub | |||
| return null; | |||
| } | |||
| @@ -15,6 +15,7 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.enums.EnumOrderStatus; | |||
| import com.iformall.enums.EnumPayMchType; | |||
| import com.iformall.enums.EnumPayMode; | |||
| import com.iformall.enums.EnumPayShare; | |||
| import com.iformall.enums.EnumPayStatus; | |||
| @@ -211,7 +212,8 @@ public class WxMiniAppPayAdapterService extends BaseWxPayAdapterService implemen | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record,WxComposeOrder composeOrder,String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception { | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| 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为空"); | |||
| } | |||
| @@ -219,6 +221,12 @@ public class WxMiniAppPayAdapterService extends BaseWxPayAdapterService implemen | |||
| if (StringUtils.isBlank(openId) ) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"openId为空"); | |||
| } | |||
| //2.0版本未对接直连模式, 小商户进件成为特约商户号 | |||
| if (payAccount.getMchType() == EnumPayMchType.DIRECT.getCode()) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"当前支付版本不支持直连模式"); | |||
| } | |||
| //普通商户模式 | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| WxPayOrderP wxPayOrderP = generateWxPayOrderP(payAccount,composeOrder,productName,record,openId,appInfo.getAppId(),currentDate); | |||
| @@ -13,6 +13,7 @@ import org.springframework.stereotype.Service; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumPayMchType; | |||
| import com.iformall.enums.EnumPayMode; | |||
| import com.iformall.enums.EnumPayShare; | |||
| import com.iformall.enums.EnumUserIsSubscribe; | |||
| @@ -158,8 +159,13 @@ public class WxMiniMaPayAdapterService extends BaseWxPayAdapterService implement | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record, WxComposeOrder composeOrder,String productName, EnumPayShare isShare, | |||
| WxAppinfo appInfo, Date currentDate, PayExtraParam params) throws Exception { | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record, WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| String productName, EnumPayShare isShare,WxAppinfo appInfo, Date currentDate, PayExtraParam params) throws Exception { | |||
| //2.0版本未对接直连模式, 小商户进件成为特约商户号 | |||
| if (payAccount.getMchType() == EnumPayMchType.DIRECT.getCode()) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"当前支付版本不支持直连模式"); | |||
| } | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| // 扫码支付 普通商户模式 | |||
| String bAppId = (String) params.getValue("bAppId"); | |||
| @@ -22,8 +22,8 @@ import com.iformall.service.pay.service.pay.wx.v2.BaseWxPayAdapterService; | |||
| public class WxH5PayV3Service implements CDrivingPayService{ | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record,WxComposeOrder composeOrder,String productName, EnumPayShare isShare, | |||
| WxAppinfo appInfo, Date currentDate, PayExtraParam params) throws Exception { | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| String productName, EnumPayShare isShare,WxAppinfo appInfo, Date currentDate, PayExtraParam params) throws Exception { | |||
| // TODO Auto-generated method stub | |||
| return null; | |||
| } | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.service.pay.service.pay.wx.v3.miniApp.appPay; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -18,6 +19,7 @@ import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.enums.EnumComposeOrder; | |||
| import com.iformall.enums.EnumOrderStatus; | |||
| import com.iformall.enums.EnumPayMchType; | |||
| import com.iformall.enums.EnumPayMode; | |||
| import com.iformall.enums.EnumPayShare; | |||
| import com.iformall.enums.EnumPayStatus; | |||
| @@ -27,10 +29,15 @@ import com.iformall.pay.WxPayOrderP; | |||
| import com.iformall.pay.WxPayOrderSP; | |||
| import com.iformall.pay.WxPayV3; | |||
| import com.iformall.pay.WxPayment; | |||
| import com.iformall.service.order.entity.WxComposeChildOrderShare; | |||
| import com.iformall.service.order.entity.WxComposeOrder; | |||
| import com.iformall.service.pay.entity.PayExtraParam; | |||
| import com.iformall.service.pay.service.cashout.wx.v3.entity.CombineItemOrder; | |||
| import com.iformall.service.pay.service.cashout.wx.v3.entity.CombinePayCommonMiniAppReq; | |||
| import com.iformall.service.pay.service.cashout.wx.v3.entity.PayAmountReq; | |||
| import com.iformall.service.pay.service.cashout.wx.v3.entity.PayCommonMiniAppReq; | |||
| import com.iformall.service.pay.service.cashout.wx.v3.entity.PaySettleReq; | |||
| import com.iformall.service.pay.service.cashout.wx.v3.entity.PayerReq; | |||
| import com.iformall.service.pay.service.pay.CDrivingPayService; | |||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||
| import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | |||
| @@ -49,34 +56,49 @@ public class WxMiniAppPayV3AdapterService implements CDrivingPayService{ | |||
| @Autowired | |||
| MaUtil maUtil; | |||
| private PayCommonMiniAppReq generatePayCommonRequest(WxPayAccount payAccount,WxComposeOrder composeOrder,String productName, WxPayOrder record,String openId,String appId,Date currentDate) throws Exception { | |||
| private PayCommonMiniAppReq generatePayCommonRequest(WxPayAccount payAccount,WxComposeOrder composeOrder,String productName, WxPayOrder record,String openId,WxAppinfo appInfo,Date currentDate) throws Exception { | |||
| PayCommonMiniAppReq req = new PayCommonMiniAppReq(); | |||
| req.setSp_appid(appId); | |||
| req.set | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxPayOrderP wxPayOrderP = new WxPayOrderP(); | |||
| wxPayOrderP.setOpenid(openId); | |||
| wxPayOrderP.setAppid(appId); | |||
| wxPayOrderP.setMch_id(payAccount.getMchId()); | |||
| wxPayOrderP.setNonce_str(noncestr); | |||
| wxPayOrderP.setBody(productName); | |||
| wxPayOrderP.setOut_trade_no(record.getPayOrderNo()); | |||
| wxPayOrderP.setTotal_fee(composeOrder.getPayment()); | |||
| wxPayOrderP.setSpbill_create_ip(record.getIp()); // 终端IP | |||
| wxPayOrderP.setGoods_tag(productName); | |||
| wxPayOrderP.setNotify_url(payAccount.getPayNotifyUrl()); | |||
| wxPayOrderP.setTrade_type(WxPay.TradeType.JSAPI.name()); // 终端类型 | |||
| wxPayOrderP.setProduct_id(String.valueOf(composeOrder.getMainOrderId())); // 订单ID | |||
| wxPayOrderP.setTime_start(Utility.getDataFormatStringYYYYMMDDHHmmss(currentDate)); | |||
| Date futureDate = new Date(); | |||
| futureDate.setTime(currentDate.getTime() + 15 * 60 * 1000); | |||
| wxPayOrderP.setTime_expire(Utility.getDataFormatStringYYYYMMDDHHmmss(futureDate)); // 15分钟后结束 | |||
| Map<String, String> payOrderMap = BeanUtils.toStringMap(wxPayOrderP); | |||
| wxPayOrderP.setSign(WxPayment.createSign(payOrderMap, payAccount.getApiKey())); | |||
| return wxPayOrderP; | |||
| req.setSp_appid(String.valueOf(appInfo.getId())); | |||
| req.setSp_mchid(payAccount.getMchId()); | |||
| WxComposeChildOrderShare share = record.getChildOrderShare(composeOrder.getSingleOrder().getId()); | |||
| req.setSub_mchid(share.getMerchantUid()); | |||
| req.setDescription(appInfo.getName()+"-"+productName); | |||
| req.setOut_trade_no(String.valueOf(composeOrder.getMainOrderId())); | |||
| req.setNotify_url(payAccount.getPayNotifyUrl()); | |||
| PaySettleReq settle = new PaySettleReq(); | |||
| settle.setProfit_sharing(true); | |||
| req.setSettle_info(settle); | |||
| PayAmountReq amout = new PayAmountReq(); | |||
| amout.setTotal(record.getPayAmount()); | |||
| req.setAmount(amout); | |||
| PayerReq payer = new PayerReq(); | |||
| payer.setSp_openid(openId); | |||
| req.setPayer(payer); | |||
| return req; | |||
| } | |||
| private CombinePayCommonMiniAppReq generateCombinePayReqeust(WxPayAccount payAccount, WxComposeOrder composeOrder,String productName,WxPayOrder record,WxAppinfo appInfo,String openId,String appId,Date currentDate,EnumPayShare isShare) throws Exception { | |||
| private CombinePayCommonMiniAppReq generateCombinePayReqeust(WxPayAccount payAccount,WxComposeOrder composeOrder,List<WxOrder> childOrders,String productName, | |||
| WxPayOrder record,WxAppinfo appInfo,String openId,String appId,Date currentDate,EnumPayShare isShare) throws Exception { | |||
| CombinePayCommonMiniAppReq req = new CombinePayCommonMiniAppReq(); | |||
| req.setCombine_appid(appInfo.getAppId()); | |||
| req.setCombine_mchid(payAccount.getMchId()); | |||
| req.setCombine_out_trade_no(String.valueOf(composeOrder.getMainOrderId())); | |||
| List<CombineItemOrder> suborders = new ArrayList<CombineItemOrder>(); | |||
| for (WxOrder order : childOrders) { | |||
| CombineItemOrder so = new CombineItemOrder(); | |||
| so.initByWxOrder(payAccount, order, subMchId, appInfo, productName, String.valueOf(record.getId())); | |||
| } | |||
| //composeOrder. | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxPayOrderSP wxPayOrderSP = new WxPayOrderSP(); | |||
| wxPayOrderSP.setSub_openid(openId); | |||
| @@ -104,7 +126,7 @@ public class WxMiniAppPayV3AdapterService implements CDrivingPayService{ | |||
| } | |||
| Map<String, String> payOrderMap = BeanUtils.toStringMap(wxPayOrderSP); | |||
| wxPayOrderSP.setSign(WxPayment.createSignHMAC(payOrderMap, payAccount.getApiKey())); | |||
| return wxPayOrderSP; | |||
| return null; | |||
| } | |||
| private PayAdapterResult getOrderPResult(String response) { | |||
| @@ -131,7 +153,8 @@ public class WxMiniAppPayV3AdapterService implements CDrivingPayService{ | |||
| * https://pay.weixin.qq.com/wiki/doc/apiv3_partner/open/pay/chapter3_3_0.shtml | |||
| */ | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record,WxComposeOrder composeOrder,String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception { | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| 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为空"); | |||
| } | |||
| @@ -141,23 +164,31 @@ public class WxMiniAppPayV3AdapterService implements CDrivingPayService{ | |||
| } | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"当前商户号非服务商模式,不能使用该产品."); | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"当前支付配置非服务商模式,不能使用该产品."); | |||
| } | |||
| //只能直连模式, | |||
| if (payAccount.getMchType() != EnumPayMchType.DIRECT.getCode()) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"当前支付版本不支持非直连模式"); | |||
| } | |||
| WxPayService payService = maUtil.getWxPayService(appInfo, payAccount); | |||
| if (null == childOrders || childOrders.size() <= 0 ) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"子订单为空"); | |||
| } | |||
| /* | |||
| * 普通支付/小程序支付 | |||
| * https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_2_3.shtml | |||
| */ | |||
| if (!EnumComposeOrder.isMulityMerchantPay(composeOrder.getComposeOrderType())) { | |||
| PayCommonMiniAppReq payReq = generatePayCommonRequest(payAccount,composeOrder,productName,record,openId,appInfo.getAppId(),currentDate); | |||
| if (childOrders.size() == 1) { | |||
| PayCommonMiniAppReq payReq = generatePayCommonRequest(payAccount,composeOrder,productName,record,openId,appInfo,currentDate); | |||
| String response = WxPayV3.payCommonWithMiniApp(payService, payReq); | |||
| log.info("pay order v3, " + payReq.toString() + ", response: " + response.toString()); | |||
| return getOrderPResult(response); | |||
| } else { | |||
| //合单支付/小程序支付 | |||
| CombinePayCommonMiniAppReq payReq = generateCombinePayReqeust(payAccount,composeOrder,productName,record,appInfo,openId,appInfo.getAppId(),currentDate,isShare); | |||
| CombinePayCommonMiniAppReq payReq = generateCombinePayReqeust(payAccount,composeOrder,childOrders,productName,record,appInfo,openId,appInfo.getAppId(),currentDate,isShare); | |||
| String response = WxPayV3.payCombineCommonWithMiniApp(payService, payReq); | |||
| log.info("pay order v3," + payReq.toString() + ", response: " + response.toString()); | |||
| return getOrderPResult(response); | |||
| @@ -158,8 +158,8 @@ public class WxMiniMaPayV3AdapterService implements CPassivePayService{ | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount, WxPayOrder record, WxComposeOrder composeOrder,String productName, EnumPayShare isShare, | |||
| WxAppinfo appInfo, Date currentDate, PayExtraParam params) throws Exception { | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record, WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| String productName, EnumPayShare isShare,WxAppinfo appInfo, Date currentDate, PayExtraParam params) throws Exception { | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| // 扫码支付 普通商户模式 | |||
| String bAppId = (String) params.getValue("bAppId"); | |||
| @@ -23,7 +23,7 @@ import com.iformall.service.pay.service.share.entity.ShareNotifyAdapterResult; | |||
| * @author alascor | |||
| */ | |||
| public interface PayShareAdapterService { | |||
| /** | |||
| * 账单类型, 对账单类型 | |||
| * @return | |||
| @@ -22,9 +22,10 @@ import com.iformall.douyin.payv2.result.ProfitSharingResult; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.WxProfitSharingReceiverService; | |||
| import com.iformall.service.order.entity.WxComposeChildOrderShare; | |||
| import com.iformall.service.order.util.OrderHelper; | |||
| import com.iformall.service.pay.service.pay.douyin.miniApp.EnumTtPayChannel; | |||
| import com.iformall.service.pay.service.pay.douyin.v1.miniApp.EnumTtPayChannel; | |||
| import com.iformall.service.pay.service.share.PayShareBaseAdapterService; | |||
| import com.iformall.service.pay.service.share.entity.PayShareCalculateAmount; | |||
| import com.iformall.service.pay.service.share.entity.PayShareQueryResult; | |||
| @@ -36,6 +37,7 @@ import com.iformall.utils.MaUtil; | |||
| import com.iformall.utils.PayUtils; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Lazy; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.*; | |||
| @@ -73,7 +75,12 @@ public class TtPayShareService extends PayShareBaseAdapterService{ | |||
| @Autowired | |||
| OrderCpsMapper orderCpsMapper; | |||
| @Lazy | |||
| @Autowired | |||
| WxProfitSharingReceiverService wxProfitSharingReceiverService; | |||
| @Override | |||
| public Integer getSubsidyType() { | |||
| return EnumMerchantSubsidyType.DOUYIN.getCode(); | |||
| @@ -11,7 +11,7 @@ import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.douyin.pay.enums.MerchantImportStatus; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.pay.service.pay.douyin.miniApp.EnumTtPayChannel; | |||
| import net.sf.saxon.trans.Err; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -30,6 +30,7 @@ import com.iformall.pay.WxProfitSharingP; | |||
| import com.iformall.pay.WxProfitSharingQueryP; | |||
| import com.iformall.pay.WxProfitSharingReceiverP; | |||
| import com.iformall.service.order.util.OrderHelper; | |||
| import com.iformall.service.pay.service.pay.douyin.v1.miniApp.EnumTtPayChannel; | |||
| import com.iformall.service.pay.service.share.PayShareAdapterService; | |||
| import com.iformall.service.pay.service.share.PayShareBaseAdapterService; | |||
| import com.iformall.service.pay.service.share.entity.ShareAccountResult; | |||
| @@ -57,6 +58,7 @@ public class WxPayShareService extends PayShareBaseAdapterService{ | |||
| "\"CLOSED\": 6}"); | |||
| @Override | |||
| public Integer getSubsidyType() { | |||
| return EnumMerchantSubsidyType.WECHAT.getCode(); | |||
| @@ -11,10 +11,11 @@ import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.douyin.pay.enums.MerchantImportStatus; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.pay.service.pay.douyin.miniApp.EnumTtPayChannel; | |||
| import net.sf.saxon.trans.Err; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Lazy; | |||
| import org.springframework.stereotype.Service; | |||
| import com.alibaba.fastjson.JSON; | |||
| @@ -29,7 +30,9 @@ import com.iformall.pay.WxProfitSharingFinishP; | |||
| import com.iformall.pay.WxProfitSharingP; | |||
| import com.iformall.pay.WxProfitSharingQueryP; | |||
| import com.iformall.pay.WxProfitSharingReceiverP; | |||
| import com.iformall.service.WxProfitSharingReceiverService; | |||
| import com.iformall.service.order.util.OrderHelper; | |||
| import com.iformall.service.pay.service.pay.douyin.v1.miniApp.EnumTtPayChannel; | |||
| import com.iformall.service.pay.service.share.PayShareAdapterService; | |||
| import com.iformall.service.pay.service.share.PayShareBaseAdapterService; | |||
| import com.iformall.service.pay.service.share.entity.ShareAccountResult; | |||
| @@ -49,6 +52,10 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{ | |||
| @Autowired | |||
| WxProfitSharingOrderMapper wxProfitSharingOrderMapper; | |||
| @Lazy | |||
| @Autowired | |||
| WxProfitSharingReceiverService wxProfitSharingReceiverService; | |||
| final JSONObject statusMap = JSON.parseObject( | |||
| "{\"ACCEPTED\":3," + | |||
| @@ -57,6 +64,8 @@ public class WxPayShareV3Service extends PayShareBaseAdapterService{ | |||
| "\"CLOSED\": 6}"); | |||
| @Override | |||
| public Integer getSubsidyType() { | |||
| return EnumMerchantSubsidyType.WECHAT.getCode(); | |||