| | |
| | | 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; |
| | |
| | | logger.debug("【小程序支付】 统一下单开始, 订单编号=" + paymentOrderDto.getOrderId()); |
| | | SortedMap<String, String> resultMap = new TreeMap<String, String>(); |
| | | //生成支付金额,开发环境处理支付金额数到0.01、0.02、0.03元 |
| | | double payAmount = PayUtil.getPayAmountByEnv(MappingCache.getValue("HC_ENV"), paymentOrderDto.getMoney()); |
| | | double payAmount = PayUtil.getPayAmountByEnv(MappingCache.getValue(MappingConstant.ENV_DOMAIN,"HC_ENV"), paymentOrderDto.getMoney()); |
| | | //添加或更新支付记录(参数跟进自己业务需求添加) |
| | | |
| | | JSONObject resMap = null; |
| | |
| | | |
| | | 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()); |
| | |
| | | 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 { |
| | | // 失败 |
| | |
| | | |
| | | |
| | | @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("未配置公众号或者小程序信息"); |
| | |
| | | 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; |
| | |
| | | |
| | | 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) { |
| | |
| | | } catch (IcbcApiException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }else{ |
| | | content = json.getString("biz_content"); |
| | | } |
| | | /**********合作方/分行 业务逻辑处理**********/ |
| | | JSONObject map = JSONObject.parseObject(content); |
| | |
| | | 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; |
| | | } |
| | | |