Commit b99e29f1 by 查志伟

Merge branch '20211012-订单商户全程信息不直接查库改造-zhiwei.zha'

parents 18b9d363 1ed494fe
...@@ -31,9 +31,15 @@ public class KgdRedisKeyConstant { ...@@ -31,9 +31,15 @@ public class KgdRedisKeyConstant {
public static final String ORDER_COMPLAIN_TYPE = "orderComplaintType"; public static final String ORDER_COMPLAIN_TYPE = "orderComplaintType";
/**
* 下单时 支付商品名称redis缓存key,懒加载方式,有效时间为24小时
* {0}:商户号
*
* value:hash结构
* hashKey:小程序id wxAppId
* hashValue: 支付商户名称
*/
public static final String PARTNER_PAYMENT_PRINCIPAL_NAME = "kgd:order:payment:principalName:{0}";
} }
...@@ -3,6 +3,7 @@ package cn.freemud.service.impl; ...@@ -3,6 +3,7 @@ package cn.freemud.service.impl;
import cn.freemud.adapter.OrderAdapter; import cn.freemud.adapter.OrderAdapter;
import cn.freemud.base.entity.BaseResponse; import cn.freemud.base.entity.BaseResponse;
import cn.freemud.base.util.DateUtil; import cn.freemud.base.util.DateUtil;
import cn.freemud.constant.KgdRedisKeyConstant;
import cn.freemud.constant.RedisKeyConstant; import cn.freemud.constant.RedisKeyConstant;
import cn.freemud.constant.ResponseCodeConstant; import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.entities.dto.SvcComPayRequestDto; import cn.freemud.entities.dto.SvcComPayRequestDto;
...@@ -84,6 +85,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -84,6 +85,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.MessageFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
...@@ -457,15 +459,21 @@ public class PayServiceImpl { ...@@ -457,15 +459,21 @@ public class PayServiceImpl {
/** /**
* 处理定制化逻辑 * 查询支付配置
*/ */
private PaymentRequest orderBodyConvertToPaymentBody(String openId, String partnerId, String appId, String payCode, String storeId) { private PaymentRequest orderBodyConvertToPaymentBody(String openId, String partnerId, String appId, String payCode, String storeId) {
PaymentRequest paymentRequest = this.orderBodyConvertToPaymentBody(openId, partnerId, appId, payCode); //设置支付信息
// fisherman 2227 测试商户号, 下个版本需要删除 PaymentRequest paymentRequest = new PaymentRequest();
boolean isTrue = "2080".equals(partnerId); paymentRequest.setOpenId(openId);
if (isTrue) { paymentRequest.setWxAppId(appId);
paymentRequest.setReverseNotifyiDcUrl(reverseNotifyiDcUrl);
paymentRequest.setPayCode(payCode);
if ("2080".equals(partnerId)) {
//【ID1035981】【蜜雪冰城】订单C端,拼接order_body字段:蜜雪冰城+门店编号 //【ID1035981】【蜜雪冰城】订单C端,拼接order_body字段:蜜雪冰城+门店编号
paymentRequest.setPrincipalName("蜜雪冰城" + storeId + "店"); paymentRequest.setPrincipalName("蜜雪冰城" + storeId + "店");
} else {
// saas 查询小程序配置
paymentRequest.setPrincipalName(this.getPaymentPrincipalName(partnerId, appId));
} }
return paymentRequest; return paymentRequest;
} }
...@@ -473,20 +481,28 @@ public class PayServiceImpl { ...@@ -473,20 +481,28 @@ public class PayServiceImpl {
/** /**
* 查询支付配置 * 查询支付配置
*/ */
private PaymentRequest orderBodyConvertToPaymentBody(String openId, String partnerId, String appId, String payCode) { private String getPaymentPrincipalName(String partnerId, String appId) {
//设置支付信息 String redisKey = MessageFormat.format(KgdRedisKeyConstant.PARTNER_PAYMENT_PRINCIPAL_NAME, partnerId);
PaymentRequest paymentRequest = new PaymentRequest(); // 先从redis中查询支付商户名称
paymentRequest.setOpenId(openId); String principalName = redisCache.hashGet(redisKey, appId);
paymentRequest.setWxAppId(appId); if (StringUtils.isEmpty(principalName)) {
AssortmentOpenPlatformWxapp wxApp = openPlatformWxappManager.findByPartnerIdAndWxappId(partnerId, appId); AssortmentOpenPlatformWxapp wxApp = openPlatformWxappManager.findByPartnerIdAndWxappId(partnerId, appId);
AssortmentOpenPlatformPartner platformPartner = null; if (wxApp == null || StringUtils.isEmpty(wxApp.getPrincipalName())) {
if (wxApp == null) { // 小程序如果没有配置支付商户名称,则去商户名称替代
platformPartner = assortmentOpenPlatformPartnerManager.selectOpenPlatformPartner(partnerId); AssortmentOpenPlatformPartner platformPartner = assortmentOpenPlatformPartnerManager.selectOpenPlatformPartner(partnerId);
if (null != platformPartner) principalName = platformPartner.getCompanyName();
} else {
principalName = wxApp.getPrincipalName();
} }
paymentRequest.setPrincipalName(wxApp != null ? wxApp.getPrincipalName() : platformPartner != null ? platformPartner.getCompanyName() : "上海非码网络科技有限公司"); if (StringUtils.isEmpty(principalName)) {
paymentRequest.setReverseNotifyiDcUrl(reverseNotifyiDcUrl); //如果还是没有查到,就用非码代替
paymentRequest.setPayCode(payCode); principalName = "上海非码网络科技有限公司";
return paymentRequest; }
// 加载到redis,有效期一天
redisCache.hashPut(redisKey, appId, principalName);
redisCache.updateTTL(redisKey, 24, TimeUnit.HOURS);
}
return principalName;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment