mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 03:55:17 +08:00
update订单逻辑改造工厂模式
This commit is contained in:
@@ -105,7 +105,7 @@ public class AdapayService {
|
||||
// 封装对象
|
||||
String amount = AdapayUtil.formatAmount(dto.getPayAmount()); // 用户支付金额
|
||||
// String payMode = Constants.ADAPAY_PAY_MODE_DELAY; // 汇付延时分账
|
||||
String payMode = pileMerchantInfoService.getDelayModeByWechatAppId(dto.getWechatAppId());
|
||||
// String payMode = pileMerchantInfoService.getDelayModeByWechatAppId(dto.getWechatAppId());
|
||||
CreateAdaPaymentParam createAdaPaymentParam = new CreateAdaPaymentParam();
|
||||
createAdaPaymentParam.setOrder_no(dto.getOrderCode());
|
||||
createAdaPaymentParam.setPay_amt(amount);
|
||||
|
||||
@@ -70,4 +70,9 @@ public class PayOrderDTO {
|
||||
* 这个字段是微信支付凭证的商品名
|
||||
*/
|
||||
private String goodsDesc;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String delayMode;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.entity.SysDept;
|
||||
import com.jsowell.common.core.domain.entity.SysUser;
|
||||
import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.DictUtils;
|
||||
@@ -395,16 +396,30 @@ public class PileMerchantInfoServiceImpl implements IPileMerchantInfoService {
|
||||
* @param wechatAppId 微信小程序id
|
||||
* @return
|
||||
*/
|
||||
// @Override
|
||||
// public String getDelayModeByWechatAppId(String wechatAppId) {
|
||||
// PileMerchantInfo merchant = getFirstLevelMerchantByAppId(wechatAppId);
|
||||
// if (merchant != null) {
|
||||
// String delayMode = merchant.getDelayMode();
|
||||
// if (StringUtils.equals(delayMode, Constants.ONE)) {
|
||||
// return Constants.ADAPAY_PAY_MODE_DELAY;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 通过wechatAppId查询一级运营商的延时支付模式配置
|
||||
* @param wechatAppId 微信小程序id
|
||||
* @return 延时分账模式(0-不延时;1-延时分账)
|
||||
*/
|
||||
@Override
|
||||
public String getDelayModeByWechatAppId(String wechatAppId) {
|
||||
PileMerchantInfo merchant = getFirstLevelMerchantByAppId(wechatAppId);
|
||||
if (merchant != null) {
|
||||
String delayMode = merchant.getDelayMode();
|
||||
if (StringUtils.equals(delayMode, Constants.ONE)) {
|
||||
return Constants.ADAPAY_PAY_MODE_DELAY;
|
||||
}
|
||||
if (merchant == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_GET_FIRST_LEVEL_MERCHANT_BY_APP_ID);
|
||||
}
|
||||
return null;
|
||||
return merchant.getDelayMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -85,25 +85,21 @@ public abstract class AbstractOrderLogic implements InitializingBean {
|
||||
protected RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 余额支付订单
|
||||
* 支付订单
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public abstract void balancePayOrder(PayOrderDTO dto);
|
||||
|
||||
/**
|
||||
* 在线支付订单
|
||||
*/
|
||||
public abstract Map<String, Object> onlinePaymentOrder(PayOrderDTO dto);
|
||||
|
||||
/**
|
||||
* 白名单支付订单
|
||||
*/
|
||||
public abstract void whitelistPaymentOrder(PayOrderDTO dto);
|
||||
public abstract Map<String, Object> payOrder(PayOrderDTO dto);
|
||||
|
||||
/**
|
||||
* 订单结算
|
||||
*/
|
||||
public abstract void orderSettle(TransactionRecordsData data, OrderBasicInfo orderBasicInfo);
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
*/
|
||||
|
||||
/**
|
||||
* 余额支付订单退款
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.jsowell.pile.service.orderlogic;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.adapay.operation.PaymentReverseOperation;
|
||||
import com.jsowell.adapay.response.PaymentReverseResponse;
|
||||
import com.jsowell.adapay.vo.OrderSettleResult;
|
||||
@@ -11,7 +12,7 @@ import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||
import com.jsowell.common.enums.AcquirerEnum;
|
||||
import com.jsowell.common.enums.DelFlagEnum;
|
||||
import com.jsowell.common.enums.MemberWalletEnum;
|
||||
import com.jsowell.common.enums.adapay.MerchantDelayModelEnum;
|
||||
import com.jsowell.common.enums.adapay.MerchantDelayModeEnum;
|
||||
import com.jsowell.common.enums.ykc.*;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
@@ -42,13 +43,43 @@ public class DelayMerchantOrderLogic extends AbstractOrderLogic {
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
OrderLogicFactory.register(MerchantDelayModelEnum.DELAY.getValue(), this);
|
||||
OrderLogicFactory.register(MerchantDelayModeEnum.DELAY.getValue(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> payOrder(PayOrderDTO dto) {
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
||||
if (orderInfo == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_INFO_IS_NULL);
|
||||
}
|
||||
if (!StringUtils.equals(orderInfo.getPayStatus(), OrderPayStatusEnum.unpaid.getValue())) {
|
||||
// 订单已支付
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_ORDER_IS_NOT_TO_BE_PAID_ERROR);
|
||||
}
|
||||
Map<String, Object> resultMap = Maps.newHashMap();
|
||||
if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue())) {
|
||||
// 余额支付
|
||||
balancePayOrder(dto);
|
||||
} else if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())) {
|
||||
// 2023-07-11 全部改为汇付支付
|
||||
dto.setGoodsTitle("充电费用");
|
||||
dto.setGoodsDesc("充电桩预付款金额");
|
||||
dto.setType(ScenarioEnum.ORDER.getValue());
|
||||
Map<String, Object> weixinMap = onlinePaymentOrder(dto);
|
||||
|
||||
// 返回微信支付参数
|
||||
resultMap.put("weixinMap", weixinMap);
|
||||
} else if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_WHITELIST.getValue())) { // 白名单支付
|
||||
// 白名单支付可以直接调支付回调方法
|
||||
dto.setPayAmount(new BigDecimal("500"));
|
||||
whitelistPaymentOrder(dto);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 余额支付订单
|
||||
*/
|
||||
@Override
|
||||
public void balancePayOrder(PayOrderDTO dto) {
|
||||
String orderCode = dto.getOrderCode(); // 订单编号
|
||||
BigDecimal chargeAmount = dto.getPayAmount(); // 支付金额
|
||||
@@ -132,11 +163,11 @@ public class DelayMerchantOrderLogic extends AbstractOrderLogic {
|
||||
/**
|
||||
* 在线支付订单
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> onlinePaymentOrder(PayOrderDTO dto) {
|
||||
|
||||
// 2023-07-11 全部改为汇付支付
|
||||
dto.setGoodsTitle("充电费用");
|
||||
dto.setGoodsDesc("充电桩预付款金额");
|
||||
// dto.setGoodsTitle("充电费用");
|
||||
// dto.setGoodsDesc("充电桩预付款金额");
|
||||
Map<String, Object> weixinMap = adapayService.createPayment(dto);
|
||||
return weixinMap;
|
||||
}
|
||||
@@ -144,7 +175,6 @@ public class DelayMerchantOrderLogic extends AbstractOrderLogic {
|
||||
/**
|
||||
* 白名单支付订单
|
||||
*/
|
||||
@Override
|
||||
public void whitelistPaymentOrder(PayOrderDTO dto) {
|
||||
String orderCode = dto.getOrderCode();
|
||||
BigDecimal payAmount = dto.getPayAmount();
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.jsowell.pile.service.orderlogic;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.adapay.response.RefundResponse;
|
||||
import com.jsowell.adapay.vo.OrderSettleResult;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
@@ -10,7 +11,7 @@ import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||
import com.jsowell.common.enums.AcquirerEnum;
|
||||
import com.jsowell.common.enums.DelFlagEnum;
|
||||
import com.jsowell.common.enums.MemberWalletEnum;
|
||||
import com.jsowell.common.enums.adapay.MerchantDelayModelEnum;
|
||||
import com.jsowell.common.enums.adapay.MerchantDelayModeEnum;
|
||||
import com.jsowell.common.enums.ykc.*;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
@@ -41,15 +42,46 @@ public class NotDelayMerchantOrderLogic extends AbstractOrderLogic{
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
OrderLogicFactory.register(MerchantDelayModelEnum.NOT_DELAY.getValue(), this);
|
||||
OrderLogicFactory.register(MerchantDelayModeEnum.NOT_DELAY.getValue(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> payOrder(PayOrderDTO dto) {
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
||||
if (orderInfo == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_INFO_IS_NULL);
|
||||
}
|
||||
if (!StringUtils.equals(orderInfo.getPayStatus(), OrderPayStatusEnum.unpaid.getValue())) {
|
||||
// 订单已支付
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_ORDER_IS_NOT_TO_BE_PAID_ERROR);
|
||||
}
|
||||
Map<String, Object> resultMap = Maps.newHashMap();
|
||||
if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue())) {
|
||||
// 余额支付
|
||||
balancePayOrder(dto);
|
||||
} else if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())) {
|
||||
// 2023-07-11 全部改为汇付支付
|
||||
dto.setGoodsTitle("充电费用");
|
||||
dto.setGoodsDesc("充电桩预付款金额");
|
||||
dto.setType(ScenarioEnum.ORDER.getValue());
|
||||
Map<String, Object> weixinMap = onlinePaymentOrder(dto);
|
||||
|
||||
// 返回微信支付参数
|
||||
resultMap.put("weixinMap", weixinMap);
|
||||
} else if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_WHITELIST.getValue())) { // 白名单支付
|
||||
// 白名单支付可以直接调支付回调方法
|
||||
dto.setPayAmount(new BigDecimal("500"));
|
||||
whitelistPaymentOrder(dto);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 余额支付订单
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public void balancePayOrder(PayOrderDTO dto) {
|
||||
String orderCode = dto.getOrderCode(); // 订单编号
|
||||
BigDecimal chargeAmount = dto.getPayAmount(); // 支付金额
|
||||
@@ -135,7 +167,6 @@ public class NotDelayMerchantOrderLogic extends AbstractOrderLogic{
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> onlinePaymentOrder(PayOrderDTO dto) {
|
||||
// 2023-07-11 全部改为汇付支付
|
||||
dto.setGoodsTitle("充电费用");
|
||||
@@ -149,7 +180,6 @@ public class NotDelayMerchantOrderLogic extends AbstractOrderLogic{
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public void whitelistPaymentOrder(PayOrderDTO dto) {
|
||||
String orderCode = dto.getOrderCode();
|
||||
BigDecimal payAmount = dto.getPayAmount();
|
||||
|
||||
Reference in New Issue
Block a user