jialh
8 小时以前 d0b19298e28a9b8b50c778704b77160f17e73950
service-acct/src/main/java/com/java110/acct/payment/adapt/icbc/IcbcPaymentFactoryAdapt.java.txt
@@ -20,10 +20,12 @@
import com.java110.dto.app.AppDto;
import com.java110.dto.owner.OwnerAppUserDto;
import com.java110.dto.payment.PaymentOrderDto;
import com.java110.dto.smallWeChat.SmallWeChatDto;
import com.java110.dto.wechat.SmallWeChatDto;
import com.java110.intf.store.ISmallWechatV1InnerServiceSMO;
import com.java110.intf.user.IOwnerAppUserInnerServiceSMO;
import com.java110.utils.cache.CommonCache;
import com.java110.utils.cache.MappingCache;
import com.java110.utils.cache.UrlCache;
import com.java110.utils.constant.WechatConstant;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.DateUtil;
@@ -160,7 +162,10 @@
        if (TRADE_TYPE_JSAPI.equals(tradeType)) {
            resultMap.putAll(JSONObject.toJavaObject(resMap, Map.class));
            resultMap.put("sign", resultMap.get("paySign"));
            //resultMap.put("sign", resultMap.get("paySign"));
            resultMap.put("appId", resultMap.get("appid"));
            resultMap.put("timeStamp", resultMap.get("timestamp"));
            resultMap.put("nonceStr", resultMap.get("noncestr"));
        } else if (TRADE_TYPE_APP.equals(tradeType)) {
            resultMap.put("appId", smallWeChatDto.getAppId());
            resultMap.put("timeStamp", PayUtil.getCurrentTimeStamp());
@@ -236,12 +241,17 @@
               bizContent.setOrder_apd_inf("");
        CardbusinessAggregatepayB2cOnlineConsumepurchaseResponseV1 response;
        System.out.println("request:" + JSON.toJSONString(request));
        response = client.execute(request, System.currentTimeMillis() + "");//msgId消息通讯唯一编号,要求每次调用独立生成,APP级唯一
        if (response.getReturnCode() == 0) {
            // 6、业务成功处理,请根据接口文档用response.getxxx()获取同步返回的业务数据
            System.out.println("ReturnCode:" + response.getReturnCode());
            System.out.println("response:" + JSON.toJSONString(response));
            CommonCache.setValue("icbc_"+icbcAppId,smallWeChatDto.getAppId(),CommonCache.PAY_DEFAULT_EXPIRE_TIME);
            CommonCache.setValue("icbc_community_"+icbcAppId,smallWeChatDto.getObjId(),CommonCache.PAY_DEFAULT_EXPIRE_TIME);
            return JSONObject.parseObject(response.getWx_data_package());
        } else {
            // 失败
@@ -252,22 +262,23 @@
    @Override
    public PaymentOrderDto java110NotifyPayment(String param) {
    public PaymentOrderDto java110NotifyPayment(NotifyPaymentOrderDto notifyPaymentOrderDto) {
        String param = notifyPaymentOrderDto.getParam();
        PaymentOrderDto paymentOrderDto = new PaymentOrderDto();
        JSONObject json = JSON.parseObject(param);
        String appId;
        if (json.containsKey("wId")) {
            String wId = json.get("wId").toString();
            wId = wId.replace(" ", "+");
            appId = WechatFactory.getAppId(wId);
        } else {
            appId = json.get("appid").toString();
        String appId = CommonCache.getAndRemoveValue("icbc_"+json.getString("app_id"));
        if(StringUtil.isEmpty(appId)){
            throw new IllegalArgumentException("支付通知失败");
        }
        String communityId =   CommonCache.getAndRemoveValue("icbc_community_"+json.getString("app_id"));
        JSONObject paramIn = new JSONObject();
        paramIn.put("appId", appId);
        paramIn.put("communityId", communityId);
        SmallWeChatDto smallWeChatDto = getSmallWechat(paramIn);
        if (smallWeChatDto == null) {
            throw new IllegalArgumentException("未配置公众号或者小程序信息");
@@ -280,12 +291,11 @@
        params.put("app_id", json.getString("app_id"));
        params.put("charset", json.getString("charset"));
        params.put("format", json.getString("format"));
        params.put("encrypt_type", json.getString("encrypt_type"));
        params.put("timestamp", json.getString("timestamp"));
        params.put("biz_content", json.getString("biz_content"));
        params.put("sign_type", json.getString("sign_type"));//目前上行网关签名暂时仅支持RSA
        String path = "/app/payment/notify/icbc/992020011134400001\"";
        String path ="/app/payment/notify/icbc/992020011134400001";
        String signStr = WebUtils.buildOrderedSignStr(path, params);
        String results = null;
        String responseBizContent = null;
@@ -298,6 +308,7 @@
        boolean flag = false;
        String content = "";
        System.out.println("signStr="+signStr);
        try {
            flag = IcbcSignature.verify(signStr, json.getString("sign_type"), apiPublicKey, json.getString("charset"), json.getString("sign"));
        } catch (IcbcApiException e) {
@@ -314,6 +325,8 @@
                } catch (IcbcApiException e) {
                    e.printStackTrace();
                }
            }else{
                content = json.getString("biz_content");
            }
            /**********合作方/分行 业务逻辑处理**********/
            JSONObject map = JSONObject.parseObject(content);
@@ -371,6 +384,7 @@
            smallWeChatDto.setAppSecret(MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, "appSecret"));
            smallWeChatDto.setMchId(MappingCache.getValue(MappingConstant.WECHAT_STORE_DOMAIN, "mchId"));
            smallWeChatDto.setPayPassword(MappingCache.getValue(MappingConstant.WECHAT_STORE_DOMAIN, "key"));
            smallWeChatDto.setObjId(paramIn.getString("communityId"));
            return smallWeChatDto;
        }