| @@ -533,7 +533,7 @@ public class WxCarController extends BaseController { | |||
| String attach = attachSb.toString(); | |||
| String productPre = "停车费支付,车场订单号";//中文签名错误 | |||
| //String productPre = "ParkOrderId"; | |||
| PayAdapterResult wxResult = wxParkPayService.createWxPayOrder(payAccount,cAppInfo,isIsv,false,user.getOpenId(), receiverAccount, productPre+payOrder.getParkOrderNumber(), attach, uniquePayOrderNo, payOrder.getFee(), | |||
| PayAdapterResult wxResult = wxParkPayService.createWxPayOrder(payAccount,cAppInfo,isIsv,user.getOpenId(), receiverAccount, productPre+payOrder.getParkOrderNumber(), attach, uniquePayOrderNo, payOrder.getFee(), | |||
| "127.0.0.1", park.getPaidCallBack(), apiKey, new Date()); | |||
| if (wxResult.isSuccess()) { | |||
| return new ResultData(wxResult); | |||
| @@ -1340,7 +1340,7 @@ public class PosServiceImpl implements PosService { | |||
| creditHistory.setFinalTenantId(couponOrderCVo.getFinalTenantId()); | |||
| creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); | |||
| creditHistory.setCouponId(couponOrderCVo.getCouponId()); | |||
| creditHistory.setBusinessId(coupon.getBusiness()); | |||
| creditHistory.setBusinessId(wxMerchant.getBusinessId()); | |||
| creditHistory.setSpend(couponOrderCVo.getCouponPrice()); | |||
| //如果券与商户一对一 则直接将消费商户更新为此商户 若一对多 则消费商户显示多商户 | |||
| creditHistory.setMerchantId(wxMerchant.getId()); | |||
| @@ -203,5 +203,5 @@ public class WxOrder extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="配送类型 0:默认(无) 1:自提 2:配送",name="shippingType") | |||
| private Integer shippingType; | |||
| } | |||
| @@ -13,26 +13,26 @@ public enum EnumCouponType { | |||
| // 1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.通用券, 8.砍价券 | |||
| // 100.消费卡 | |||
| COUPON_MANJIAN(1, "满减券"), | |||
| COUPON_DAIJIN(2, "代金券"), | |||
| COUPON_MANJIAN(1, "满减券",true), | |||
| COUPON_DAIJIN(2, "代金券",true), | |||
| // COUPON_TUANGOU(3, "团购券"),//弃用 | |||
| COUPON_LIPIN(4, "礼品券"), | |||
| COUPON_TINGCHE(5, "停车券"), | |||
| COUPON_MULTIMCH(6, "通用券"), | |||
| COUPON_DOUYIN(66, "抖音券"), | |||
| COUPON_PRESS(8, "砍价券"), | |||
| COUPON_GROUP(9, "拼团券"), | |||
| COUPON_PREORDER(10, "预购商品"), | |||
| COUPON_DISTRIBUTION(11, "可配送商品"), | |||
| COUPON_GIFT(12, "券礼包"), | |||
| COUPON_CREDIT(50,"积分券"), | |||
| COUPON_CREDIT_PARK(51,"积分停车券"), | |||
| COUPON_LIPIN(4, "礼品券",true), | |||
| COUPON_TINGCHE(5, "停车券",true), | |||
| COUPON_MULTIMCH(6, "通用券",true), | |||
| COUPON_DOUYIN(66, "抖音券",true), | |||
| COUPON_PRESS(8, "砍价券",true), | |||
| COUPON_GROUP(9, "拼团券",true), | |||
| COUPON_PREORDER(10, "预购商品",true), | |||
| COUPON_DISTRIBUTION(11, "可配送商品",true), | |||
| COUPON_GIFT(12, "券礼包",true), | |||
| COUPON_CREDIT(50,"积分券",true), | |||
| COUPON_CREDIT_PARK(51,"积分停车券",true), | |||
| // COUPON_CREDIT_DOUYIN(55,"抖音积分券"), | |||
| COUPON_DOUYIN_PLAT(67, "抖音集团平台券"), | |||
| COUPON_DOUYIN_BRAND(68, "抖音集团品牌券"), | |||
| COUPON_DOUYIN_PLAT(67, "抖音集团平台券",true), | |||
| COUPON_DOUYIN_BRAND(68, "抖音集团品牌券",true), | |||
| CARD_MULTIMCH(100, "消费卡"), | |||
| CARD_MULTIMCH(100, "消费卡",false), | |||
| ; | |||
| public static EnumCouponType getEnum(Integer code) { | |||
| @@ -64,10 +64,12 @@ public enum EnumCouponType { | |||
| private Integer code; | |||
| private String message; | |||
| private boolean isSupportRefund;//是否支持线上退款,如果支持线上退款,则购买时需要冻结该金额 | |||
| EnumCouponType(Integer code, String message) { | |||
| EnumCouponType(Integer code, String message,boolean isSupportRefund) { | |||
| this.code = code; | |||
| this.message = message; | |||
| this.isSupportRefund = isSupportRefund; | |||
| } | |||
| public Integer getCode() { | |||
| @@ -78,7 +80,11 @@ public enum EnumCouponType { | |||
| return message; | |||
| } | |||
| /** | |||
| public boolean isSupportRefund() { | |||
| return isSupportRefund; | |||
| } | |||
| /** | |||
| * 抖音平台的券 | |||
| * @return | |||
| */ | |||
| @@ -21,6 +21,7 @@ public class WxMicroPayOrderP { | |||
| private String time_start; // 开始时间 | |||
| private String time_expire; // 失效时间 | |||
| private String auth_code; // 扫码支付授权码 | |||
| private String profit_sharing; // 不传默认不分账 Y-是,需要分账 N-否,不分账 | |||
| @Override | |||
| public String toString() { | |||
| @@ -37,6 +38,7 @@ public class WxMicroPayOrderP { | |||
| sb.append(", time_start='").append(time_start).append('\''); | |||
| sb.append(", time_expire='").append(time_expire).append('\''); | |||
| sb.append(", auth_code='").append(auth_code).append('\''); | |||
| sb.append(", profit_sharing='").append(profit_sharing).append('\''); | |||
| sb.append('}'); | |||
| return sb.toString(); | |||
| } | |||
| @@ -24,6 +24,7 @@ public class WxPayOrderP { | |||
| private String time_start; // 开始时间 | |||
| private String time_expire; // 失效时间 | |||
| private String openid; // openId | |||
| private String profit_sharing; // 不传默认不分账 Y-是,需要分账 N-否,不分账 | |||
| @Override | |||
| public String toString() { | |||
| @@ -44,6 +45,7 @@ public class WxPayOrderP { | |||
| sb.append(", time_start='").append(time_start).append('\''); | |||
| sb.append(", time_expire='").append(time_expire).append('\''); | |||
| sb.append(", openid='").append(openid).append('\''); | |||
| sb.append(", profit_sharing='").append(profit_sharing).append('\''); | |||
| sb.append('}'); | |||
| return sb.toString(); | |||
| } | |||
| @@ -288,6 +288,8 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| } | |||
| // 有价储值卡消费时,如果未启用分账,金额也记入补贴表,可能会导致查询错误, | |||
| Long merchantId = couponMerchant.getMerchantId(); | |||
| WxMerchant merchant = wxMerchantMapper.selectById(merchantId); | |||
| if (cardInfo.getSaleAmount() > 0) { | |||
| if (payment > 0) { | |||
| try { | |||
| @@ -299,8 +301,6 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| //更新商户余额 | |||
| if (real_payment > 0) { | |||
| Long merchantId = couponMerchant.getMerchantId(); | |||
| WxMerchant merchant = wxMerchantMapper.selectById(merchantId); | |||
| wxCashOutService.addCashOut(merchant, real_payment); | |||
| } | |||
| } | |||
| @@ -317,7 +317,12 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| }else if(coupon.getCardScoreRule().intValue() == EnumCardScoreRule.BY_PRICE.getCode().intValue()){ | |||
| orderUpdate.setPayment(record.getDeductionAmount()); | |||
| } | |||
| wxScoreRulesService.addScore2(coupon,EnumScoreType.CONSUMPTION, orderUpdate, coupon.getBusiness()); | |||
| if (null != merchant) { | |||
| wxScoreRulesService.addScore2(coupon,EnumScoreType.CONSUMPTION, orderUpdate, merchant.getBusinessId()); | |||
| }else { | |||
| wxScoreRulesService.addScore2(coupon,EnumScoreType.CONSUMPTION, orderUpdate, coupon.getBusiness()); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("成长值:" + e.getMessage()); | |||
| } | |||
| @@ -334,7 +339,6 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| creditHistory.setTenantId(record.getFinalTenantId()); | |||
| creditHistory.setFinalTenantId(record.getFinalTenantId()); | |||
| creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); | |||
| creditHistory.setBusinessId(coupon.getBusiness()); | |||
| //看是按售价比例算还是按面额比例算 | |||
| if (coupon.getCardScoreRule().intValue() == EnumCardScoreRule.BY_SALE_PRICE.getCode().intValue()) { | |||
| creditHistory.setSpend(payment); | |||
| @@ -345,6 +349,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| creditHistory.setMerchantId(record.getMerchantId()); | |||
| WxMerchant wxMerchant = wxMerchantMapper.selectById(record.getMerchantId()); | |||
| creditHistory.setChangePurpose("卡消费:消费商户["+wxMerchant.getName()+"] 金额["+creditHistory.getSpendStr()+"元]"); | |||
| creditHistory.setBusinessId(wxMerchant.getBusinessId()); | |||
| wxCreditHistoryService.saveOrUpdate(creditHistory,record); | |||
| } catch (Exception e) { | |||
| logger.error("积分值:" + e.getMessage()); | |||
| @@ -1327,7 +1332,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||
| orderUpdate.setPayment(record.getRealPayment()); | |||
| orderUpdate.setPaymentTime(record.getUpdateDate()); | |||
| orderUpdate.setPaymentType(EnumPayType.PAY_PAYMENT.getCode()); | |||
| int point = wxScoreRulesService.addScore2(coupon,EnumScoreType.CONSUMPTION, orderUpdate, coupon.getBusiness()); | |||
| int point = wxScoreRulesService.addScore2(coupon,EnumScoreType.CONSUMPTION, orderUpdate, merchant.getBusinessId()); | |||
| scoreCreditCalc.setScore(scoreCreditCalc.getScore() + point); | |||
| } catch (Exception e) { | |||
| logger.error("成长值:" + e.getMessage()); | |||
| @@ -1629,10 +1629,18 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| * @param wxCoupon | |||
| */ | |||
| private void doAfterVerify(WxCouponOrder couponOrder, WxMerchantBUser bUser, WxCoupon wxCoupon) { | |||
| Integer businessId = wxCoupon.getBusiness(); | |||
| if (null != bUser) { | |||
| WxMerchant merchant = wxMerchantMapper.selectById(bUser.getMerchantId()); | |||
| if (null != merchant) { | |||
| businessId = merchant.getBusinessId(); | |||
| } | |||
| } | |||
| // 成长值 | |||
| try { | |||
| WxOrder order = wxOrderMapper.selectById(couponOrder.getOrderId(),couponOrder.getTenantId()); | |||
| wxScoreRulesService.addScore2(couponOrder,EnumScoreType.CONSUMPTION, order, wxCoupon.getBusiness()); | |||
| wxScoreRulesService.addScore2(couponOrder,EnumScoreType.CONSUMPTION, order, businessId); | |||
| } catch (Exception e) { | |||
| logger.error("成长值:" + e.getMessage()); | |||
| } | |||
| @@ -1648,9 +1656,16 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| creditHistory.setMerchantId(bUser.getMerchantId()); | |||
| creditHistory.setBuserId(bUser.getBuserId()); | |||
| }else{ | |||
| //礼包券,确认收货等 | |||
| creditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||
| creditHistory.setOperatorId(couponOrder.getCUserId()); | |||
| creditHistory.setMerchantId(couponOrder.getBMerchantId()); | |||
| if (null != couponOrder.getBMerchantId()) { | |||
| WxMerchant merchant1 = wxMerchantMapper.selectById(couponOrder.getBMerchantId()); | |||
| if (null != merchant1) { | |||
| businessId = merchant1.getBusinessId(); | |||
| } | |||
| } | |||
| } | |||
| creditHistory.setCUserId(couponOrder.getcUserId()); | |||
| @@ -1660,7 +1675,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| creditHistory.setFinalTenantId(couponOrder.getFinalTenantId()); | |||
| creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); | |||
| creditHistory.setCouponId(wxCoupon.getId()); | |||
| creditHistory.setBusinessId(wxCoupon.getBusiness()); | |||
| creditHistory.setBusinessId(businessId); | |||
| creditHistory.setSpend(couponOrder.getCouponPrice()); | |||
| creditHistory.setChangePurpose("券["+wxCoupon.getTitle()+"("+creditHistory.getSpendStr()+"元)] 使用成功"); | |||
| wxCreditHistoryService.saveOrUpdate(creditHistory,couponOrder); | |||
| @@ -2900,7 +2915,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| WxCouponOrder couponOrder = wxCouponOrderMapper.selectById(couponOrderId,tenantinfo.getTenantId()); | |||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(couponOrder.getcUserId(),couponOrder.getFinalTenantId()); | |||
| WxCoupon coupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId()); | |||
| doAfterVerify(couponOrder, coupon, wxCUserBasicInfo); | |||
| //doAfterVerify(couponOrder, coupon, wxCUserBasicInfo); | |||
| } | |||
| return 0; | |||
| } | |||
| @@ -1038,7 +1038,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||
| // 4. 计算积分 | |||
| if (record.getSpend() >= priceCondition.intValue()) { | |||
| Double dScoreT = Math.floor(record.getSpend() * 1.0D / priceCondition * baseScore); | |||
| Double dScoreT = Math.floor(record.getSpend() * 1.0D / priceCondition * baseScore); | |||
| addCreditNumber = dScoreT.intValue(); | |||
| log.info("CREDIT:" + busRule.toJSONString() + "\nAddCredit: " + addCreditNumber); | |||
| } else { | |||
| @@ -495,7 +495,15 @@ 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,childOrders,productName,isShare,appInfo, currentDate, params); | |||
| //如果只有一个订单,并且该产品是不支持线上退款的,则不用冻结金额 | |||
| boolean isFreezen = true; | |||
| if (null != composeOrder.getSingleOrder()) { | |||
| WxCoupon wxCoupon = wxCouponMapper.selectById(composeOrder.getSingleOrder().getProductId(),composeOrder.getSingleOrder().getTenantId()); | |||
| if (null != wxCoupon) { | |||
| isFreezen = EnumCouponType.getEnum(wxCoupon.getType()).isSupportRefund(); | |||
| } | |||
| } | |||
| PayAdapterResult payResult = payAdapterService.pay(payAccount, record,composeOrder,childOrders,productName,appInfo, currentDate, params,isFreezen); | |||
| String aftermd5 = HashUtil.md5(record.toString()); | |||
| if (beforemd5.equals(aftermd5)) { | |||
| logger.error("支付方式["+payWay.getCode()+"]支付接口【pay】过程中 WxPayOrder 未做更新.record:"+record.toString()); | |||
| @@ -618,7 +626,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| String beforemd5 = HashUtil.md5(record.toString()); | |||
| List<WxOrder> orderList = orderAdapterService.getChildOrders(composeOrder, cAppInfo.getTenantId()); | |||
| PayAdapterResult payResult = payServiceFactory.getPayAdapterService(payWay.getCode(),payAccount.getPayVersion()).pay(payAccount, record,composeOrder,orderList, | |||
| "付款码支付",isShare,cAppInfo, currentDate, params); | |||
| "付款码支付",cAppInfo, currentDate, params,false); | |||
| String aftermd5 = HashUtil.md5(record.toString()); | |||
| if (beforemd5.equals(aftermd5)) { | |||
| logger.error("支付方式["+payWay.getCode()+"]支付接口【pay】过程中 WxPayOrder 未做更新.record:"+record.toString()); | |||
| @@ -122,6 +122,10 @@ public abstract class BaseBatchOrderAdapterService implements OrderAdapterServic | |||
| WxComposeOrder corder = new WxComposeOrder(order.getId(),composeOrderType.getCode(),order.getPayment()); | |||
| corder.updateTenantInfo(order); | |||
| corder.setMainOrder(order); | |||
| List<WxOrder> orders = getChildOrders(corder, tenantId, composeOrderType); | |||
| if (null != orders && orders.size() == 1 ) { | |||
| corder.setSingleOrder(orders.get(0)); | |||
| } | |||
| return corder; | |||
| } | |||
| @@ -23,7 +23,7 @@ public interface WxParkPayService { | |||
| public void exportData(WxCarPayOrder record, HttpServletRequest request, HttpServletResponse response); | |||
| //share:是否分账,服务商模式下生效 | |||
| public PayAdapterResult createWxPayOrder(WxPayAccount payAccount,WxAppinfo cAppInfo,boolean isIsvModel,boolean share,String appId,String mchId,String productName,String attach,String payOrderNo, | |||
| public PayAdapterResult createWxPayOrder(WxPayAccount payAccount,WxAppinfo cAppInfo,boolean isIsvModel,String appId,String mchId,String productName,String attach,String payOrderNo, | |||
| Integer fee,String ip,String notifyUrl,String apiKey,Date currentDate) throws Exception; | |||
| public String handlePaidCallBack(String tenantId,Map<String, String> paramMap); | |||
| @@ -111,12 +111,12 @@ public class WxParkPayServiceImpl implements WxParkPayService { | |||
| } | |||
| @Override | |||
| public PayAdapterResult createWxPayOrder(WxPayAccount payAccount,WxAppinfo cAppInfo,boolean isIsvModel,boolean share,String openId,String mchId,String productName,String attach,String payOrderNo, | |||
| public PayAdapterResult createWxPayOrder(WxPayAccount payAccount,WxAppinfo cAppInfo,boolean isIsvModel,String openId,String mchId,String productName,String attach,String payOrderNo, | |||
| Integer fee,String ip,String notifyUrl,String apiKey,Date currentDate) throws Exception { | |||
| if (!isIsvModel) { | |||
| return wxMiniAppPayAdapterService.pay(openId, cAppInfo.getAppId(),mchId, productName, attach, payOrderNo, fee, ip, notifyUrl, apiKey, currentDate); | |||
| return wxMiniAppPayAdapterService.pay(openId, cAppInfo.getAppId(),mchId, productName, attach, payOrderNo, fee, ip, notifyUrl, apiKey, currentDate,false); | |||
| }else { | |||
| return wxMiniAppPayAdapterService.payIsv(payAccount, cAppInfo, mchId, openId, productName, attach, payOrderNo, fee, ip, notifyUrl, currentDate, share); | |||
| return wxMiniAppPayAdapterService.payIsv(payAccount, cAppInfo, mchId, openId, productName, attach, payOrderNo, fee, ip, notifyUrl, currentDate, false); | |||
| } | |||
| } | |||
| @@ -24,10 +24,11 @@ public interface PayAdapterService { | |||
| * @param appInfo C端app | |||
| * @param currentDate Date 当前时间,可能加密串用 | |||
| * @param params PayExtraParam 其他需要的参数 | |||
| * @param isFreezen 金额是否要冻结 | |||
| * @return | |||
| * @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; | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record ,WxComposeOrder composeOrder,List<WxOrder> childOrders,String productName,WxAppinfo appInfo,Date currentDate, PayExtraParam params,boolean isFreezen) throws Exception; | |||
| /** | |||
| * 查询支付结果,调用对应端的API查询支付结果 | |||
| @@ -79,7 +79,7 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception { | |||
| String productName,WxAppinfo appInfo,Date currentDate, PayExtraParam params,boolean isFreezen) throws Exception { | |||
| //抖音支付1.0,已经不再支持 | |||
| if(true){ | |||
| throw new MallinkException(ErrorCode.SYS_AUTH_ERROR.getCode(),"请升级抖音版本"); | |||
| @@ -24,7 +24,7 @@ public class WxH5PaySFTService extends BaseWxPaySFTAdapterService implements CDr | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| String productName, EnumPayShare isShare,WxAppinfo appInfo, Date currentDate, PayExtraParam params) throws Exception { | |||
| String productName, WxAppinfo appInfo, Date currentDate, PayExtraParam params,boolean isFreezen) throws Exception { | |||
| // TODO Auto-generated method stub | |||
| return null; | |||
| } | |||
| @@ -65,7 +65,8 @@ public class WxMiniAppPaySFTAdapterService extends BaseWxPaySFTAdapterService i | |||
| @Autowired | |||
| MaUtil maUtil; | |||
| private SFTPayCommonMiniAppReq generatePayCommonRequest(WxPayAccount payAccount,WxComposeOrder composeOrder,String productName, WxPayOrder record,String openId,WxAppinfo appInfo,Date currentDate) throws Exception { | |||
| private SFTPayCommonMiniAppReq generatePayCommonRequest(WxPayAccount payAccount,WxComposeOrder composeOrder,String productName, WxPayOrder record, | |||
| String openId,WxAppinfo appInfo,Date currentDate,boolean isFreezen) throws Exception { | |||
| SFTPayCommonMiniAppReq req = new SFTPayCommonMiniAppReq(); | |||
| req.setSp_appid(String.valueOf(appInfo.getId())); | |||
| req.setSp_mchid(payAccount.getMchId()); | |||
| @@ -80,7 +81,7 @@ public class WxMiniAppPaySFTAdapterService extends BaseWxPaySFTAdapterService i | |||
| req.setNotify_url(payAccount.getPayNotifyV3Url()); | |||
| SFTPaySettleReq settle = new SFTPaySettleReq(); | |||
| settle.setProfit_sharing(true); | |||
| settle.setProfit_sharing(isFreezen); | |||
| req.setSettle_info(settle); | |||
| SFTPayAmountReq amout = new SFTPayAmountReq(); | |||
| @@ -148,7 +149,7 @@ public class WxMiniAppPaySFTAdapterService extends BaseWxPaySFTAdapterService i | |||
| */ | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception { | |||
| String productName,WxAppinfo appInfo,Date currentDate, PayExtraParam params,boolean isFreezen) throws Exception { | |||
| if (null == params ) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"openId为空"); | |||
| } | |||
| @@ -176,7 +177,7 @@ public class WxMiniAppPaySFTAdapterService extends BaseWxPaySFTAdapterService i | |||
| * https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_2_3.shtml | |||
| */ | |||
| if (childOrders.size() == 1) { | |||
| SFTPayCommonMiniAppReq payReq = generatePayCommonRequest(payAccount,composeOrder,productName,record,openId,appInfo,currentDate); | |||
| SFTPayCommonMiniAppReq payReq = generatePayCommonRequest(payAccount,composeOrder,productName,record,openId,appInfo,currentDate,isFreezen); | |||
| try { | |||
| String response = WxPayV3SFT.payCommonWithMiniApp(payService, payReq); | |||
| return getOrderPResult(response,record); | |||
| @@ -23,7 +23,7 @@ public class WxH5PayService extends BaseWxPayV2AdapterService implements CDrivi | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| String productName, EnumPayShare isShare,WxAppinfo appInfo, Date currentDate, PayExtraParam params) throws Exception { | |||
| String productName, WxAppinfo appInfo, Date currentDate, PayExtraParam params,boolean isFreezen) throws Exception { | |||
| // TODO Auto-generated method stub | |||
| return null; | |||
| } | |||
| @@ -59,7 +59,8 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem | |||
| "\"POST_DATA_EMPTY\":{\"detail\":\"post数据为空\",\"reason\":\"post数据不能为空\",\"resolution\":\"请检查post数据是否为空\"}," + | |||
| "\"NOT_UTF8\":{\"detail\":\"编码格式错误\",\"reason\":\"未使用指定编码格式\",\"resolution\":\"请使用UTF-8编码格式\"}}"); | |||
| private WxPayOrderP generateWxPayOrderP(String openId,String appId,String mchId,String productName,String attach,String payOrderNo,Integer fee,String ip,String notifyUrl,String apiKey,Date currentDate,String productId)throws Exception { | |||
| private WxPayOrderP generateWxPayOrderP(String openId,String appId,String mchId,String productName,String attach,String payOrderNo, | |||
| Integer fee,String ip,String notifyUrl,String apiKey,Date currentDate,String productId,boolean isFreezen)throws Exception { | |||
| // 统一下单 普通商户模式 | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxPayOrderP wxPayOrderP = new WxPayOrderP(); | |||
| @@ -78,6 +79,11 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem | |||
| if (null != productId) { | |||
| wxPayOrderP.setProduct_id(productId); | |||
| } | |||
| if (isFreezen) { | |||
| wxPayOrderP.setProfit_sharing("Y"); | |||
| }else { | |||
| wxPayOrderP.setProfit_sharing("N"); | |||
| } | |||
| wxPayOrderP.setTime_start(Utility.getDataFormatStringYYYYMMDDHHmmss(currentDate)); | |||
| Date futureDate = new Date(); | |||
| futureDate.setTime(currentDate.getTime() + 15 * 60 * 1000); | |||
| @@ -87,9 +93,10 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem | |||
| return wxPayOrderP; | |||
| } | |||
| private WxPayOrderP generateWxPayOrderP(WxPayAccount payAccount,WxComposeOrder composeOrder,String productName, 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,boolean isFreezen) throws Exception { | |||
| // 统一下单 普通商户模式 | |||
| return generateWxPayOrderP(openId,appId,payAccount.getMchId(),productName,getAttach(record),record.getPayOrderNo(),composeOrder.getPayment(),record.getIp(),payAccount.getPayNotifyUrl(),payAccount.getApiKey(),currentDate,String.valueOf(composeOrder.getMainOrderId())); | |||
| return generateWxPayOrderP(openId,appId,payAccount.getMchId(),productName,getAttach(record),record.getPayOrderNo(),composeOrder.getPayment(),record.getIp(),payAccount.getPayNotifyUrl(), | |||
| payAccount.getApiKey(),currentDate,String.valueOf(composeOrder.getMainOrderId()),isFreezen); | |||
| } | |||
| private PayAdapterResult getOrderPResult(Map<String, String> returnMap,WxPayOrder record,WxPayAccount payAccount,String noncestr) { | |||
| @@ -150,7 +157,7 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem | |||
| ///////ISV模式 | |||
| private WxPayOrderSP generateWxPayOrderSP(String openId,String parentAppId,String mchId,String appId,String subMchId,String productName, | |||
| String attach,String payOrderNo,Integer fee,String ip,String notifyUrl,String productId,Date currentDate,boolean share,String apiKey) throws Exception{ | |||
| String attach,String payOrderNo,Integer fee,String ip,String notifyUrl,String productId,Date currentDate,String apiKey,boolean isFreezen) throws Exception{ | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxPayOrderSP wxPayOrderSP = new WxPayOrderSP(); | |||
| wxPayOrderSP.setSub_openid(openId); | |||
| @@ -175,7 +182,7 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem | |||
| futureDate.setTime(currentDate.getTime() + 15 * 60 * 1000); | |||
| wxPayOrderSP.setTime_expire(Utility.getDataFormatStringYYYYMMDDHHmmss(futureDate)); // 15分钟后结束 | |||
| wxPayOrderSP.setSign_type("HMAC-SHA256"); | |||
| if (share) { | |||
| if (isFreezen) { | |||
| wxPayOrderSP.setProfit_sharing("Y"); | |||
| }else { | |||
| wxPayOrderSP.setProfit_sharing("N"); | |||
| @@ -185,9 +192,9 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem | |||
| return wxPayOrderSP; | |||
| } | |||
| private WxPayOrderSP generateWxPayOrderSP(WxPayAccount payAccount, WxComposeOrder composeOrder,String productName,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,boolean isFreezen) throws Exception { | |||
| return generateWxPayOrderSP(openId,appInfo.getParentAppId(),payAccount.getMchId(),appId,payAccount.getSubMchId(),productName,getAttach(record),record.getPayOrderNo(),composeOrder.getPayment(), | |||
| record.getIp(),payAccount.getPayNotifyUrl(),String.valueOf(composeOrder.getMainOrderId()),currentDate,true,payAccount.getApiKey()); | |||
| record.getIp(),payAccount.getPayNotifyUrl(),String.valueOf(composeOrder.getMainOrderId()),currentDate,payAccount.getApiKey(),isFreezen); | |||
| } | |||
| private PayAdapterResult getOrderSPResult(Map<String, String> returnMap,WxPayOrder record,String appId,String noncestr,String apiKey) { | |||
| @@ -249,7 +256,7 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception { | |||
| String productName,WxAppinfo appInfo,Date currentDate, PayExtraParam params,boolean isFreezen) throws Exception { | |||
| if (null == params ) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"openId为空"); | |||
| } | |||
| @@ -265,7 +272,7 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem | |||
| //普通商户模式 | |||
| if (payAccount.getType() == EnumPayMode.MCH.getCode()) { | |||
| WxPayOrderP wxPayOrderP = generateWxPayOrderP(payAccount,composeOrder,productName,record,openId,appInfo.getAppId(),currentDate); | |||
| WxPayOrderP wxPayOrderP = generateWxPayOrderP(payAccount,composeOrder,productName,record,openId,appInfo.getAppId(),currentDate,isFreezen); | |||
| 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); | |||
| @@ -273,7 +280,7 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem | |||
| } else { | |||
| // 统一下单 // 服务商模式 | |||
| WxPayOrderSP wxPayOrderSP = generateWxPayOrderSP(payAccount,composeOrder,productName,record,appInfo,openId,appInfo.getAppId(),currentDate,isShare); | |||
| WxPayOrderSP wxPayOrderSP = generateWxPayOrderSP(payAccount,composeOrder,productName,record,appInfo,openId,appInfo.getAppId(),currentDate,isFreezen); | |||
| 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); | |||
| @@ -281,17 +288,17 @@ public class WxMiniAppPayAdapterService extends BaseWxPayV2AdapterService implem | |||
| } | |||
| } | |||
| public PayAdapterResult pay(String openId,String appId,String mchId,String productName,String attach,String payOrderNo,Integer fee,String ip,String notifyUrl,String apiKey,Date currentDate) throws Exception { | |||
| WxPayOrderP wxPayOrderP = generateWxPayOrderP(openId, appId, mchId, productName, attach, payOrderNo, fee, ip, notifyUrl, apiKey, currentDate,null); | |||
| public PayAdapterResult pay(String openId,String appId,String mchId,String productName,String attach,String payOrderNo,Integer fee,String ip,String notifyUrl,String apiKey,Date currentDate,boolean freezen) throws Exception { | |||
| WxPayOrderP wxPayOrderP = generateWxPayOrderP(openId, appId, mchId, productName, attach, payOrderNo, fee, ip, notifyUrl, apiKey, currentDate,null,freezen); | |||
| 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); | |||
| return getOrderPResult(returnMap,wxPayOrderP.getNonce_str(),apiKey,null); | |||
| } | |||
| public PayAdapterResult payIsv(WxPayAccount payAccount,WxAppinfo appInfo,String subMchId,String openId,String productName,String attach,String payOrderNo,Integer fee,String ip,String notifyUrl,Date currentDate,boolean share) throws Exception { | |||
| public PayAdapterResult payIsv(WxPayAccount payAccount,WxAppinfo appInfo,String subMchId,String openId,String productName,String attach,String payOrderNo,Integer fee,String ip,String notifyUrl,Date currentDate,boolean freezen) throws Exception { | |||
| String apiKey = payAccount.getApiKey(); | |||
| WxPayOrderSP wxPayOrderP = generateWxPayOrderSP(openId,appInfo.getParentAppId(),payAccount.getMchId(),appInfo.getAppId(),subMchId,productName,attach,payOrderNo,fee,ip,notifyUrl,null,currentDate,share,apiKey); | |||
| WxPayOrderSP wxPayOrderP = generateWxPayOrderSP(openId,appInfo.getParentAppId(),payAccount.getMchId(),appInfo.getAppId(),subMchId,productName,attach,payOrderNo,fee,ip,notifyUrl,null,currentDate,apiKey,freezen); | |||
| 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); | |||
| @@ -49,8 +49,8 @@ public class WxMiniMaPayAdapterService extends BaseWxPayV2AdapterService impleme | |||
| return share.getMerchantUid(); | |||
| } | |||
| private WxMicroPayOrderP generateWxMicroPayOrderP(WxPayAccount payAccount, WxComposeOrder composeOrder, String productName,WxPayOrder record, EnumPayShare isShare, | |||
| WxAppinfo appInfo, Date currentDate,String bAppId,String bUserPhone) throws Exception { | |||
| private WxMicroPayOrderP generateWxMicroPayOrderP(WxPayAccount payAccount, WxComposeOrder composeOrder, String productName,WxPayOrder record, | |||
| WxAppinfo appInfo, Date currentDate,String bAppId,String bUserPhone,boolean isFreezen) throws Exception { | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxMicroPayOrderP wxPayOrderP = new WxMicroPayOrderP(); | |||
| wxPayOrderP.setAppid(bAppId); | |||
| @@ -64,6 +64,11 @@ public class WxMiniMaPayAdapterService extends BaseWxPayV2AdapterService impleme | |||
| wxPayOrderP.setSpbill_create_ip(record.getIp()); // 终端IP | |||
| wxPayOrderP.setAuth_code(record.getAuthCode()); | |||
| wxPayOrderP.setTime_start(Utility.getDataFormatStringYYYYMMDDHHmmss(currentDate)); | |||
| if (isFreezen) { | |||
| wxPayOrderP.setProfit_sharing("Y"); | |||
| }else { | |||
| wxPayOrderP.setProfit_sharing("N"); | |||
| } | |||
| Date futureDate = new Date(); | |||
| futureDate.setTime(currentDate.getTime() + 15 * 60 * 1000); | |||
| wxPayOrderP.setTime_expire(Utility.getDataFormatStringYYYYMMDDHHmmss(futureDate)); // 15分钟后结束 | |||
| @@ -104,8 +109,8 @@ public class WxMiniMaPayAdapterService extends BaseWxPayV2AdapterService impleme | |||
| } | |||
| private WxMicroPayOrderSP generateWxMicroPayOrderSP(WxPayAccount payAccount, WxComposeOrder composeOrder, String productName,WxPayOrder record, EnumPayShare isShare, | |||
| WxAppinfo appInfo, Date currentDate,String bUserPhone) throws Exception { | |||
| private WxMicroPayOrderSP generateWxMicroPayOrderSP(WxPayAccount payAccount, WxComposeOrder composeOrder, String productName,WxPayOrder record, | |||
| WxAppinfo appInfo, Date currentDate,String bUserPhone,boolean isFreezen) throws Exception { | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxMicroPayOrderSP wxPayOrderSP = new WxMicroPayOrderSP(); | |||
| wxPayOrderSP.setAppid(appInfo.getParentAppId()); | |||
| @@ -132,7 +137,11 @@ public class WxMiniMaPayAdapterService extends BaseWxPayV2AdapterService impleme | |||
| futureDate.setTime(currentDate.getTime() + 15 * 60 * 1000); | |||
| wxPayOrderSP.setTime_expire(Utility.getDataFormatStringYYYYMMDDHHmmss(futureDate)); // 15分钟后结束 | |||
| wxPayOrderSP.setSign_type("HMAC-SHA256"); | |||
| wxPayOrderSP.setProfit_sharing("Y"); | |||
| if (isFreezen) { | |||
| wxPayOrderSP.setProfit_sharing("Y"); | |||
| }else { | |||
| wxPayOrderSP.setProfit_sharing("N"); | |||
| } | |||
| // wxPayOrderSP.setProfit_sharing(null); | |||
| // if (isShare == EnumPayShare.YES) { | |||
| // wxPayOrderSP.setProfit_sharing("Y"); | |||
| @@ -176,7 +185,7 @@ public class WxMiniMaPayAdapterService extends BaseWxPayV2AdapterService impleme | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record, WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| String productName, EnumPayShare isShare,WxAppinfo appInfo, Date currentDate, PayExtraParam params) throws Exception { | |||
| String productName, WxAppinfo appInfo, Date currentDate, PayExtraParam params,boolean isFreezen) throws Exception { | |||
| //2.0版本未对接直连模式, 小商户进件成为特约商户号 | |||
| // if (payAccount.getMchType() == EnumPayMchType.DIRECT.getCode()) { | |||
| @@ -193,7 +202,8 @@ public class WxMiniMaPayAdapterService extends BaseWxPayV2AdapterService impleme | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"bUserPhone 不能为空"); | |||
| } | |||
| WxMicroPayOrderP wxPayOrderP = generateWxMicroPayOrderP(payAccount, composeOrder,productName,record, isShare, appInfo, currentDate, bAppId, bUserPhone); | |||
| WxMicroPayOrderP wxPayOrderP = generateWxMicroPayOrderP(payAccount, composeOrder,productName,record, appInfo, currentDate, | |||
| bAppId, bUserPhone,isFreezen); | |||
| 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); | |||
| @@ -206,7 +216,7 @@ public class WxMiniMaPayAdapterService extends BaseWxPayV2AdapterService impleme | |||
| if (StringUtils.isBlank(bUserPhone)) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"bUserPhone 不能为空"); | |||
| } | |||
| WxMicroPayOrderSP wxPayOrderSP = generateWxMicroPayOrderSP(payAccount, composeOrder,productName,record, isShare, appInfo, currentDate, bUserPhone); | |||
| WxMicroPayOrderSP wxPayOrderSP = generateWxMicroPayOrderSP(payAccount, composeOrder,productName,record, appInfo, currentDate, bUserPhone,isFreezen); | |||
| 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); | |||
| @@ -71,7 +71,8 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl | |||
| @Autowired | |||
| MaUtil maUtil; | |||
| private V3PayCommonMiniAppReq generatePayCommonRequest(WxPayAccount payAccount,WxComposeOrder composeOrder,String productName, WxPayOrder record,String openId,WxAppinfo appInfo,Date currentDate) throws Exception { | |||
| private V3PayCommonMiniAppReq generatePayCommonRequest(WxPayAccount payAccount,WxComposeOrder composeOrder,String productName, | |||
| WxPayOrder record,String openId,WxAppinfo appInfo,Date currentDate,boolean isFreeze) throws Exception { | |||
| V3PayCommonMiniAppReq req = new V3PayCommonMiniAppReq(); | |||
| req.setSp_appid(String.valueOf(appInfo.getParentAppId())); | |||
| req.setSp_mchid(payAccount.getMchId()); | |||
| @@ -96,7 +97,7 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl | |||
| req.setNotify_url(payAccount.getPayNotifyV3Url()); | |||
| V3PaySettleReq settle = new V3PaySettleReq(); | |||
| settle.setProfit_sharing(true); | |||
| settle.setProfit_sharing(isFreeze); | |||
| req.setSettle_info(settle); | |||
| V3PayAmountReq amout = new V3PayAmountReq(); | |||
| @@ -184,7 +185,7 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl | |||
| @Override | |||
| public PayAdapterResult pay(WxPayAccount payAccount,WxPayOrder record,WxComposeOrder composeOrder,List<WxOrder> childOrders, | |||
| String productName,EnumPayShare isShare,WxAppinfo appInfo,Date currentDate, PayExtraParam params) throws Exception { | |||
| String productName,WxAppinfo appInfo,Date currentDate, PayExtraParam params,boolean isFreeze) throws Exception { | |||
| if (null == params ) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"openId为空"); | |||
| } | |||
| @@ -207,7 +208,7 @@ public class WxMiniAppPayV3AdapterService extends BaseWxPayV3AdapterService impl | |||
| * https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter4_5_1.shtml | |||
| */ | |||
| if (childOrders.size() == 1) { | |||
| V3PayCommonMiniAppReq payReq = generatePayCommonRequest(payAccount,composeOrder,productName,record,openId,appInfo,currentDate); | |||
| V3PayCommonMiniAppReq payReq = generatePayCommonRequest(payAccount,composeOrder,productName,record,openId,appInfo,currentDate,isFreeze); | |||
| try { | |||
| String response = WxPayV3.payCommonWithMiniApp(payService, payReq); | |||
| return getOrderPResult(response,record,payAccount,appInfo,payService); | |||