wuxw пре 2 година
родитељ
комит
05818a2567

+ 38 - 1
service-acct/src/main/java/com/java110/acct/cmd/payment/CheckPayFinishCmd.java

@@ -7,6 +7,8 @@ import com.java110.core.context.ICmdDataFlowContext;
 import com.java110.core.event.cmd.Cmd;
 import com.java110.core.event.cmd.CmdEvent;
 import com.java110.core.factory.CallApiServiceFactory;
+import com.java110.dto.paymentPool.PaymentPoolDto;
+import com.java110.intf.acct.IPaymentPoolV1InnerServiceSMO;
 import com.java110.utils.cache.MappingCache;
 import com.java110.utils.constant.CommonConstant;
 import com.java110.utils.constant.WechatConstant;
@@ -15,6 +17,9 @@ import com.java110.utils.factory.ApplicationContextFactory;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.StringUtil;
 import com.java110.vo.ResultVo;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
 
 /**
  * 扫码付
@@ -25,6 +30,9 @@ public class CheckPayFinishCmd extends Cmd {
 
     private IQrCodePaymentSMO qrCodePaymentSMOImpl;
 
+    @Autowired
+    private IPaymentPoolV1InnerServiceSMO paymentPoolV1InnerServiceSMOImpl;
+
     @Override
     public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) {
         Assert.hasKeyAndValue(reqJson, "authCode", "未包含授权码");
@@ -42,7 +50,9 @@ public class CheckPayFinishCmd extends Cmd {
         if (StringUtil.isEmpty(authCode) || authCode.length() < 2) {
             throw new IllegalArgumentException("授权码错误");
         }
-        String payQrAdapt = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.PAY_QR_ADAPT);
+        // String payQrAdapt = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.PAY_QR_ADAPT);
+        String payQrAdapt = computeAdapt(reqJson.getString("subServiceCode"),reqJson);//MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.PAY_QR_ADAPT);
+
 
         if (StringUtil.isEmpty(payQrAdapt)) {
             int pre = Integer.parseInt(authCode.substring(0, 2));
@@ -74,4 +84,31 @@ public class CheckPayFinishCmd extends Cmd {
         cmdDataFlowContext.setResponseEntity(ResultVo.createResponseEntity(paramOut));
     }
 
+    /**
+     * 计算适配器
+     *
+     * @param reqJson
+     * @return
+     */
+    private String computeAdapt(String business, JSONObject reqJson) {
+
+        String communityId = reqJson.getString("communityId");
+
+
+        //todo 按小区查询 支付信息
+        PaymentPoolDto paymentPoolDto = new PaymentPoolDto();
+        paymentPoolDto.setCommunityId(communityId);
+        paymentPoolDto.setPayType(PaymentPoolDto.PAY_TYPE_COMMUNITY);
+        paymentPoolDto.setPpId(reqJson.getString("paymentPoolId"));
+        paymentPoolDto.setState("Y");
+        List<PaymentPoolDto> paymentPoolDtos = paymentPoolV1InnerServiceSMOImpl.queryPaymentPools(paymentPoolDto);
+        if (paymentPoolDtos == null || paymentPoolDtos.isEmpty()) {
+            throw new IllegalArgumentException("小区未配置支付信息");
+        }
+
+        reqJson.put("paymentPoolId", paymentPoolDtos.get(0).getPpId());
+        return paymentPoolDtos.get(0).getBeanQrcode();
+    }
+
+
 }

+ 13 - 7
service-acct/src/main/java/com/java110/acct/payment/adapt/easypay/EasyPaymentFactoryAdapt.java

@@ -243,8 +243,10 @@ public class EasyPaymentFactoryAdapt implements IPaymentFactoryAdapt {
 
         JSONObject data = paramOut.getJSONObject("data");
 
-        if (!"10000".equals(paramOut.getJSONObject("data").getString("appendRetcode"))) {
-            throw new IllegalArgumentException("支付失败" + paramOut.getJSONObject("data").getString("appendRetmsg"));
+        String finRetcode = paramOut.getJSONObject("data").getString("finRetcode");
+
+        if (!"00".equals(finRetcode) && !"99".equals(finRetcode)) {
+            throw new IllegalArgumentException("支付失败,相应finRetcode为:" + finRetcode);
         }
 
         //wxWcPayData
@@ -271,14 +273,18 @@ public class EasyPaymentFactoryAdapt implements IPaymentFactoryAdapt {
         String param = notifyPaymentOrderDto.getParam();
         System.out.println("支付结果返回值:" + param);
 
-        JSONObject paramJson = JSONObject.parseObject(param);
-
-        String sign = BasePay.calSign(paramJson, EASYPAY_PUBLIC_KEY);
-
-        if (!sign.equals(paramJson.getString("sign"))) {
+        if(!BasePay.checkSign(param, EASYPAY_PUBLIC_KEY)){
             throw new IllegalArgumentException("签名错误");
         }
 
+        JSONObject paramJson = JSONObject.parseObject(param);
+
+//        String sign = BasePay.checkSign(paramJson, EASYPAY_PUBLIC_KEY);
+//
+//        if (!sign.equals(paramJson.getString("sign"))) {
+//            throw new IllegalArgumentException("签名错误");
+//        }
+
         JSONObject paramOut = paramJson.getJSONObject("data");
 
 

+ 1 - 2
service-acct/src/main/java/com/java110/acct/payment/adapt/easypay/QrCodeEasyPaymentAdapt.java

@@ -137,10 +137,9 @@ public class QrCodeEasyPaymentAdapt implements IQrCodePaymentSMO {
 
         if ("00".equals(resData.getString("finRetcode"))) {
             doUpdateOnlinePay(orderNum, OnlinePayDto.STATE_COMPILE, "支付成功");
-
             return new ResultVo(ResultVo.CODE_OK, "成功");
         } else {
-            return new ResultVo(ResultVo.CODE_ERROR, "等待用户支付中");
+            return new ResultVo(ResultVo.CODE_WAIT_PAY, "等待用户支付中");
         }
     }