| | |
| | | import com.java110.core.event.cmd.AbstractServiceCmdListener; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.core.factory.CallApiServiceFactory; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.utils.cache.MappingCache; |
| | | import com.java110.utils.constant.CommonConstant; |
| | | import com.java110.utils.constant.WechatConstant; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.factory.ApplicationContextFactory; |
| | | import com.java110.utils.util.Assert; |
| | |
| | | |
| | | @Override |
| | | public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | | String orderId = GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_orderId); |
| | | String orderId = reqJson.getString("orderId"); |
| | | double receivedAmount = Double.parseDouble(reqJson.getString("receivedAmount")); |
| | | String authCode = reqJson.getString("authCode"); |
| | | if (StringUtil.isEmpty(authCode) || authCode.length() < 2) { |
| | | throw new IllegalArgumentException("授权码错误"); |
| | | } |
| | | String payQrAdapt = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.PAY_QR_ADAPT); |
| | | |
| | | int pre = Integer.parseInt(authCode.substring(0, 2)); |
| | | if (pre > 24 && pre < 31) { // 支付宝 |
| | | qrCodePaymentSMOImpl = ApplicationContextFactory.getBean("qrCodeAliPaymentAdapt", IQrCodePaymentSMO.class); |
| | | if (StringUtil.isEmpty(payQrAdapt)) { |
| | | int pre = Integer.parseInt(authCode.substring(0, 2)); |
| | | if (pre > 24 && pre < 31) { // 支付宝 |
| | | qrCodePaymentSMOImpl = ApplicationContextFactory.getBean("qrCodeAliPaymentAdapt", IQrCodePaymentSMO.class); |
| | | } else { |
| | | qrCodePaymentSMOImpl = ApplicationContextFactory.getBean("qrCodeWechatPaymentAdapt", IQrCodePaymentSMO.class); |
| | | } |
| | | } else { |
| | | qrCodePaymentSMOImpl = ApplicationContextFactory.getBean("qrCodeWechatPaymentAdapt", IQrCodePaymentSMO.class); |
| | | qrCodePaymentSMOImpl = ApplicationContextFactory.getBean(payQrAdapt, IQrCodePaymentSMO.class); |
| | | } |
| | | |
| | | ResultVo resultVo = null; |
| | | try { |
| | | resultVo = qrCodePaymentSMOImpl.checkPayFinish(reqJson.getString("communityId"), orderId); |
| | |
| | | } |
| | | String appId = cmdDataFlowContext.getReqHeaders().get(CommonConstant.APP_ID); |
| | | String userId = cmdDataFlowContext.getReqHeaders().get(CommonConstant.USER_ID); |
| | | String paramOut = CallApiServiceFactory.postForApi(appId, reqJson.toJSONString(), "fee.payFee", String.class, userId); |
| | | cmdDataFlowContext.setResponseEntity(new ResponseEntity(paramOut, HttpStatus.OK)); |
| | | JSONObject paramOut = CallApiServiceFactory.postForApi(appId, reqJson, "fee.payFee", JSONObject.class, userId); |
| | | cmdDataFlowContext.setResponseEntity(ResultVo.createResponseEntity(paramOut)); |
| | | } |
| | | |
| | | } |