diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java index 0e136f38a..a26235f6c 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCarController.java @@ -475,19 +475,40 @@ public class WxCarController extends BaseController { return new ResultData(Result.ERROR,"未设置停车商户."); } + String receiverAccount = null; + boolean isIsv = false; + String apiKey = null; + WxAppinfo cAppInfo = wxAppinfoService.getCAppInfoFromRedis(park.getTenantId(), EnumPayWay.PAY_WAY_WECHAT.getPlat()); + if(cAppInfo == null){ + throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未查询到C端小程序"); + } + WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(cAppInfo.getPayId()); + if(payAccount == null){ + throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND.getCode(),"未查询到payAccount."); + } + WxProfitPaymentReceiver receiver = wxProfitPaymentReceiverService.findReceiver(park, parkMerchant.getId(), EnumAppPlat.WX); if (null == receiver || StringUtils.isBlank(receiver.getReceiverAccount())) { + //查找小程序收款账户 + receiverAccount = payAccount.getSubMchId(); + isIsv = true; //查询商官商户 - WxMerchant adminMerchant = wxMerchantService.findAdmin(park); - if (null == adminMerchant) { - return new ResultData(Result.ERROR,"未找到商管商户."); - } - receiver = wxProfitPaymentReceiverService.findReceiver(park, adminMerchant.getId(), EnumAppPlat.WX); - if (null == receiver || StringUtils.isBlank(receiver.getReceiverAccount())) { - return new ResultData(Result.ERROR,"商管商户未设置收款账号."); - } +// WxMerchant adminMerchant = wxMerchantService.findAdmin(park); +// if (null == adminMerchant) { +// return new ResultData(Result.ERROR,"未找到商管商户."); +// } +// receiver = wxProfitPaymentReceiverService.findReceiver(park, adminMerchant.getId(), EnumAppPlat.WX); +// if (null == receiver || StringUtils.isBlank(receiver.getReceiverAccount())) { +// return new ResultData(Result.ERROR,"商管商户未设置收款账号."); +// } + }else { + receiverAccount = receiver.getReceiverAccount(); + Integer isvModel = (Integer)receiver.getReceiverParamValue(Constant.paymentReceiverParamIsv); + if (EnumYesOrNo.YES.getCode() == isvModel) { + isIsv = true; + } + apiKey = (String)receiver.getReceiverParamValue(Constant.paymentReceicerParamApiKey); } - String receiverAccount = receiver.getReceiverAccount(); int rlength = receiverAccount.length(); //最大128 cuserId,cuserPhone,carNumber,merchantId,merchantAccount,parkOrderNo StringBuffer attachSb = new StringBuffer() @@ -501,18 +522,12 @@ public class WxCarController extends BaseController { } attachSb.append(payOrder.getParkOrderNumber()); //创建微信支付订单 - boolean isIsv = false; - Integer isvModel = (Integer)receiver.getReceiverParamValue(Constant.paymentReceiverParamIsv); - if (EnumYesOrNo.YES.getCode() == isvModel) { - isIsv = true; - } final IdWorker idWorker = IdWorker.get(); String uniquePayOrderNo = carVendor.getMessage()+"_"+idWorker.nextId(); - String apiKey = (String)receiver.getReceiverParamValue(Constant.paymentReceicerParamApiKey); String attach = attachSb.toString(); String productPre = "停车费支付,车场订单号";//中文签名错误 //String productPre = "ParkOrderId"; - PayAdapterResult wxResult = wxParkPayService.createWxPayOrder(park,isIsv,false,user.getOpenId(), user.getAppId(), receiver.getReceiverAccount(), productPre+payOrder.getParkOrderNumber(), attach, uniquePayOrderNo, payOrder.getFee(), + PayAdapterResult wxResult = wxParkPayService.createWxPayOrder(payAccount,cAppInfo,isIsv,false,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); diff --git a/mallinkService/src/main/java/com/iformall/enums/EnumCarPayAmountType.java b/mallinkService/src/main/java/com/iformall/enums/EnumCarPayAmountType.java new file mode 100644 index 000000000..4436f53f9 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/enums/EnumCarPayAmountType.java @@ -0,0 +1,33 @@ +package com.iformall.enums; + +public enum EnumCarPayAmountType { + + CAR_MERCHANT(1, "停车商户"), + ADMIN_MERCHNAT(2, "商管商户"), + ; + + public static EnumCarPayAmountType getEnum(Integer code) { + for (EnumCarPayAmountType value : values()) { + if (value.getCode().equals(code)) { + return value; + } + } + return null; + } + + private Integer code; + private String message; + + EnumCarPayAmountType(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } +} diff --git a/mallinkService/src/main/java/com/iformall/service/park/pay/WxParkPayService.java b/mallinkService/src/main/java/com/iformall/service/park/pay/WxParkPayService.java index d87e63f99..23711c040 100644 --- a/mallinkService/src/main/java/com/iformall/service/park/pay/WxParkPayService.java +++ b/mallinkService/src/main/java/com/iformall/service/park/pay/WxParkPayService.java @@ -7,8 +7,10 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.WxAppinfo; import com.iformall.domain.po.WxCarPayOrder; import com.iformall.domain.po.WxPark; +import com.iformall.domain.po.WxPayAccount; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.WxCouponOrderBVo; import com.iformall.enums.EnumCarVendor; @@ -21,7 +23,7 @@ public interface WxParkPayService { public void exportData(WxCarPayOrder record, HttpServletRequest request, HttpServletResponse response); //share:是否分账,服务商模式下生效 - public PayAdapterResult createWxPayOrder(TenantEntity tenantEntity,boolean isIsvModel,boolean share,String openId,String appId,String mchId,String productName,String attach,String payOrderNo, + public PayAdapterResult createWxPayOrder(WxPayAccount payAccount,WxAppinfo cAppInfo,boolean isIsvModel,boolean share,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 paramMap); diff --git a/mallinkService/src/main/java/com/iformall/service/park/pay/WxParkPayServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/park/pay/WxParkPayServiceImpl.java index dc122ab89..db9156400 100644 --- a/mallinkService/src/main/java/com/iformall/service/park/pay/WxParkPayServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/park/pay/WxParkPayServiceImpl.java @@ -111,19 +111,11 @@ public class WxParkPayServiceImpl implements WxParkPayService { } @Override - public PayAdapterResult createWxPayOrder(TenantEntity tenantEntity,boolean isIsvModel,boolean share,String openId,String appId,String mchId,String productName,String attach,String payOrderNo, + public PayAdapterResult createWxPayOrder(WxPayAccount payAccount,WxAppinfo cAppInfo,boolean isIsvModel,boolean share,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, appId, mchId, productName, attach, payOrderNo, fee, ip, notifyUrl, apiKey, currentDate); + return wxMiniAppPayAdapterService.pay(openId, cAppInfo.getAppId(),mchId, productName, attach, payOrderNo, fee, ip, notifyUrl, apiKey, currentDate); }else { - WxAppinfo cAppInfo = wxAppinfoService.getCAppInfoFromRedis(tenantEntity.getTenantId(), EnumPayWay.PAY_WAY_WECHAT.getPlat()); - if(cAppInfo == null){ - throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未查询到C端小程序"); - } - WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(cAppInfo.getPayId()); - if(payAccount == null){ - throw new MallinkException(ErrorCode.API_KEY_NOT_FOUND.getCode(),"未查询到payAccount."); - } return wxMiniAppPayAdapterService.payIsv(payAccount, cAppInfo, mchId, openId, productName, attach, payOrderNo, fee, ip, notifyUrl, currentDate, share); } }