|
|
@@ -8,6 +8,7 @@ import com.java110.core.annotation.Java110Cmd;
|
|
|
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.GenerateCodeFactory;
|
|
|
import com.java110.core.log.LoggerFactory;
|
|
|
import com.java110.dto.fee.PayFeeDto;
|
|
|
import com.java110.dto.payment.PaymentOrderDto;
|
|
|
@@ -18,6 +19,7 @@ import com.java110.intf.acct.IPaymentPoolV1InnerServiceSMO;
|
|
|
import com.java110.intf.fee.IPayFeeV1InnerServiceSMO;
|
|
|
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.exception.CmdException;
|
|
|
import com.java110.utils.factory.ApplicationContextFactory;
|
|
|
@@ -66,7 +68,7 @@ public class NativeQrcodePaymentCmd extends Cmd {
|
|
|
logger.debug(">>>>>>>>>>>>>>>>支付参数报文,{}", reqJson.toJSONString());
|
|
|
String appId = context.getReqHeaders().get("app-id");
|
|
|
String userId = context.getReqHeaders().get("user-id");
|
|
|
-
|
|
|
+ reqJson.put("createUserId", userId);
|
|
|
|
|
|
//1.0 查询当前支付的业务
|
|
|
|
|
|
@@ -80,138 +82,19 @@ public class NativeQrcodePaymentCmd extends Cmd {
|
|
|
PaymentOrderDto paymentOrderDto = paymentBusiness.unified(context, reqJson);
|
|
|
paymentOrderDto.setAppId(appId);
|
|
|
paymentOrderDto.setUserId(userId);
|
|
|
+ reqJson.put("money", paymentOrderDto.getMoney());
|
|
|
|
|
|
+ String token = GenerateCodeFactory.getUUID();
|
|
|
|
|
|
- logger.debug(">>>>>>>>>>>>>>>>支付业务下单返回,{}", JSONObject.toJSONString(paymentOrderDto));
|
|
|
-
|
|
|
- // 3.0 寻找当前支付适配器
|
|
|
- String payAdapt = computeAdapt(reqJson.getString("business"), reqJson);//MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.NATIVE_QRCODE_PAYMENT_ADAPT);
|
|
|
- payAdapt = StringUtil.isEmpty(payAdapt) ? DEFAULT_PAYMENT_ADAPT : payAdapt;
|
|
|
-
|
|
|
- if (reqJson.containsKey("payAdapt") && !StringUtil.isEmpty(reqJson.getString("payAdapt"))) {
|
|
|
- payAdapt = reqJson.getString("payAdapt");
|
|
|
- }
|
|
|
-
|
|
|
- IPaymentFactoryAdapt tPayAdapt = ApplicationContextFactory.getBean(payAdapt, IPaymentFactoryAdapt.class);
|
|
|
-
|
|
|
- // 4.0 相应支付厂家下单
|
|
|
- Map result = null;
|
|
|
- try {
|
|
|
- result = tPayAdapt.java110Payment(paymentOrderDto, reqJson, context);
|
|
|
- } catch (Exception e) {
|
|
|
- logger.error("支付异常", e);
|
|
|
- throw new CmdException(e.getLocalizedMessage());
|
|
|
- }
|
|
|
- ResponseEntity<String> responseEntity = new ResponseEntity(JSONObject.toJSONString(result), HttpStatus.OK);
|
|
|
+ // redis 中 保存 请求参数
|
|
|
+ CommonCache.setValue("nativeQrcodePayment_" + token, reqJson.toJSONString(), CommonCache.PAY_DEFAULT_EXPIRE_TIME);
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ result.put("codeUrl", UrlCache.getOwnerUrl() + "/#/pages/fee/qrCodeCashier?qrToken=" + token);
|
|
|
+ ResponseEntity<String> responseEntity = new ResponseEntity(reqJson.toJSONString(), HttpStatus.OK);
|
|
|
|
|
|
logger.debug("调用支付厂家返回,{}", responseEntity);
|
|
|
context.setResponseEntity(responseEntity);
|
|
|
|
|
|
-
|
|
|
- // redis 中 保存 请求参数
|
|
|
- CommonCache.setValue("nativeQrcodePayment_" + paymentOrderDto.getOrderId(), reqJson.toJSONString(), CommonCache.PAY_DEFAULT_EXPIRE_TIME);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 计算适配器
|
|
|
- *
|
|
|
- * @param business
|
|
|
- * @param reqJson
|
|
|
- * @return
|
|
|
- */
|
|
|
- private String computeAdapt(String business, JSONObject reqJson) {
|
|
|
-
|
|
|
- String communityId = reqJson.getString("communityId");
|
|
|
- //todo 如果是单个费用缴费
|
|
|
- PaymentPoolDto paymentPoolDto = ifPayFeeBusiness(business, reqJson);
|
|
|
- if (paymentPoolDto != null) {
|
|
|
- reqJson.put("paymentPoolId", paymentPoolDto.getPpId());
|
|
|
- return paymentPoolDto.getBeanNative();
|
|
|
- }
|
|
|
-
|
|
|
- //todo 如果是临时车
|
|
|
- paymentPoolDto = ifTempCarFeeBusiness(business, communityId);
|
|
|
- if (paymentPoolDto != null) {
|
|
|
- reqJson.put("paymentPoolId", paymentPoolDto.getPpId());
|
|
|
- return paymentPoolDto.getBeanNative();
|
|
|
- }
|
|
|
-
|
|
|
- //todo 按小区查询 支付信息
|
|
|
- paymentPoolDto = new PaymentPoolDto();
|
|
|
- paymentPoolDto.setCommunityId(communityId);
|
|
|
- paymentPoolDto.setPayType(PaymentPoolDto.PAY_TYPE_COMMUNITY);
|
|
|
- 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).getBeanNative();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 临时车场景处理
|
|
|
- *
|
|
|
- * @param business
|
|
|
- * @param communityId
|
|
|
- * @return
|
|
|
- */
|
|
|
- private PaymentPoolDto ifTempCarFeeBusiness(String business, String communityId) {
|
|
|
- if (!"tempCarFee".equals(business)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- //todo 按小区查询 支付信息
|
|
|
- PaymentPoolDto paymentPoolDto = new PaymentPoolDto();
|
|
|
- paymentPoolDto.setCommunityId(communityId);
|
|
|
- paymentPoolDto.setPayType(PaymentPoolDto.PAY_TYPE_TEMP_CAT);
|
|
|
- paymentPoolDto.setState("Y");
|
|
|
- List<PaymentPoolDto> paymentPoolDtos = paymentPoolV1InnerServiceSMOImpl.queryPaymentPools(paymentPoolDto);
|
|
|
- if (paymentPoolDtos == null || paymentPoolDtos.isEmpty()) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- return paymentPoolDtos.get(0);
|
|
|
- }
|
|
|
-
|
|
|
- private PaymentPoolDto ifPayFeeBusiness(String business, JSONObject reqJson) {
|
|
|
- String feeId = "";
|
|
|
- if (!"payFee".equals(business) || !reqJson.containsKey("feeId")) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- feeId = reqJson.getString("feeId");
|
|
|
- if (StringUtil.isNumber(feeId)) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- PayFeeDto feeDto = new PayFeeDto();
|
|
|
- feeDto.setFeeId(feeId);
|
|
|
- feeDto.setCommunityId(reqJson.getString("communityId"));
|
|
|
- List<PayFeeDto> feeDtos = payFeeV1InnerServiceSMOImpl.queryPayFees(feeDto);
|
|
|
-
|
|
|
- if (feeDtos == null || feeDtos.isEmpty()) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- PaymentPoolConfigDto paymentPoolConfigDto = new PaymentPoolConfigDto();
|
|
|
- paymentPoolConfigDto.setConfigId(feeDtos.get(0).getConfigId());
|
|
|
- paymentPoolConfigDto.setCommunityId(feeDtos.get(0).getCommunityId());
|
|
|
- List<PaymentPoolConfigDto> paymentPoolConfigDtos = paymentPoolConfigV1InnerServiceSMOImpl.queryPaymentPoolConfigs(paymentPoolConfigDto);
|
|
|
- if (paymentPoolConfigDtos == null || paymentPoolConfigDtos.isEmpty()) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- PaymentPoolDto paymentPoolDto = new PaymentPoolDto();
|
|
|
- paymentPoolDto.setPpId(paymentPoolConfigDtos.get(0).getPpId());
|
|
|
- paymentPoolDto.setCommunityId(paymentPoolConfigDtos.get(0).getCommunityId());
|
|
|
- paymentPoolDto.setPayType(PaymentPoolDto.PAY_TYPE_FEE_CONFIG);
|
|
|
- paymentPoolDto.setState("Y");
|
|
|
- List<PaymentPoolDto> paymentPoolDtos = paymentPoolV1InnerServiceSMOImpl.queryPaymentPools(paymentPoolDto);
|
|
|
- if (paymentPoolDtos == null || paymentPoolDtos.isEmpty()) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- return paymentPoolDtos.get(0);
|
|
|
- }
|
|
|
}
|