mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
微信支付参数放缓存
This commit is contained in:
@@ -10,6 +10,7 @@ import com.jsowell.common.core.domain.vo.AuthorizedDeptVO;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.MemberWalletEnum;
|
||||
import com.jsowell.common.enums.ykc.ActionTypeEnum;
|
||||
import com.jsowell.common.enums.ykc.OrderPayModeEnum;
|
||||
@@ -82,6 +83,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -125,6 +127,9 @@ public class OrderService {
|
||||
@Autowired
|
||||
private IPileStationInfoService pileStationInfoService;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 生成订单
|
||||
*
|
||||
@@ -164,7 +169,8 @@ public class OrderService {
|
||||
balancePayOrder(dto);
|
||||
} else if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())) {
|
||||
// 微信支付
|
||||
Map<String, Object> weixinMap = wechatPayOrder(dto, orderInfo);
|
||||
dto.setOrderBasicInfo(orderInfo);
|
||||
Map<String, Object> weixinMap = wechatPayOrder(dto);
|
||||
// 返回微信支付参数
|
||||
resultMap.put("weixinMap", weixinMap);
|
||||
} else if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_ALIPAY.getValue())) { // 支付宝支付
|
||||
@@ -195,11 +201,20 @@ public class OrderService {
|
||||
/**
|
||||
* 微信支付订单逻辑 获取支付参数
|
||||
* @param dto
|
||||
* @param orderInfo
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private Map<String, Object> wechatPayOrder(PayOrderDTO dto, OrderBasicInfo orderInfo) throws Exception {
|
||||
private Map<String, Object> wechatPayOrder(PayOrderDTO dto) throws Exception {
|
||||
String redisKey = "WECHAT_PAY_ORDER_PARAM:" + dto.getOrderCode();
|
||||
Map<String, Object> cacheObject = redisCache.getCacheObject(redisKey);
|
||||
if (cacheObject != null) {
|
||||
return cacheObject;
|
||||
}
|
||||
|
||||
OrderBasicInfo orderInfo = dto.getOrderBasicInfo();
|
||||
if (orderInfo == null) {
|
||||
orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
||||
}
|
||||
String openId = memberService.getOpenIdByCode(dto.getCode());
|
||||
if (StringUtils.isBlank(openId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_GET_OPEN_ID_BY_CODE_ERROR);
|
||||
@@ -215,7 +230,12 @@ public class OrderService {
|
||||
.build();
|
||||
weixinPayDTO.setAttach(JSONObject.toJSONString(paymentScenarioDTO));
|
||||
weixinPayDTO.setDescription("充电费用");
|
||||
return this.weixinPayV3(weixinPayDTO);
|
||||
Map<String, Object> payV3 = this.weixinPayV3(weixinPayDTO);
|
||||
if (payV3 != null) {
|
||||
// 表示已经获取到支付参数了,后续再有支付请求就拒绝
|
||||
redisCache.setCacheObject(redisKey, payV3, 15, TimeUnit.MINUTES);
|
||||
}
|
||||
return payV3;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user