去除<?>
This commit is contained in:
@@ -1,28 +1,18 @@
|
|||||||
package com.czg.controller.admin;
|
package com.czg.controller.admin;
|
||||||
|
|
||||||
import cn.hutool.http.server.HttpServerRequest;
|
|
||||||
import cn.hutool.http.server.HttpServerResponse;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.czg.account.dto.SysLoginDTO;
|
import com.czg.account.dto.SysLoginDTO;
|
||||||
import com.czg.account.entity.ShopInfo;
|
import com.czg.account.entity.ShopInfo;
|
||||||
import com.czg.account.entity.SysUser;
|
import com.czg.account.entity.SysUser;
|
||||||
import com.czg.account.service.*;
|
import com.czg.account.service.AuthorizationService;
|
||||||
|
import com.czg.account.service.ShopInfoService;
|
||||||
|
import com.czg.account.service.SysUserService;
|
||||||
import com.czg.account.vo.LoginVO;
|
import com.czg.account.vo.LoginVO;
|
||||||
import com.czg.annotation.SaAdminCheckPermission;
|
|
||||||
import com.czg.annotation.SaStaffCheckPermission;
|
|
||||||
import com.czg.config.RabbitPublisher;
|
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,27 +66,6 @@ public class AuthorizationController {
|
|||||||
return CzgResult.success(StpKit.USER.getPermissionList());
|
return CzgResult.success(StpKit.USER.getPermissionList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Resource
|
|
||||||
RabbitPublisher rabbitPublisher;
|
|
||||||
@Resource
|
|
||||||
ShopTableService shopTableService;
|
|
||||||
|
|
||||||
@GetMapping("test")
|
|
||||||
public CzgResult<?> login(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
||||||
// shopTableService.createQrCode(1L, 1, response, request);
|
|
||||||
|
|
||||||
|
|
||||||
// rabbitPublisher.sendOrderPrintMsg("552");
|
|
||||||
// printMqListener.orderPrint("1");
|
|
||||||
// return CzgResult.success(Map.of("token", StpKit.USER.getShopId()));
|
|
||||||
return CzgResult.success(StpKit.USER.getLoginId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("test1")
|
|
||||||
public CzgResult<?> login1() throws IOException {
|
|
||||||
authorizationService.switchTo(86L);
|
|
||||||
return CzgResult.success(StpKit.USER.getLoginId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 核销获取 信息使用
|
* 核销获取 信息使用
|
||||||
|
|||||||
@@ -50,9 +50,8 @@ public class FastJson2Config implements WebMvcConfigurer {
|
|||||||
// 设置支持的媒体类型
|
// 设置支持的媒体类型
|
||||||
List<MediaType> supportedMediaTypes = new ArrayList<>();
|
List<MediaType> supportedMediaTypes = new ArrayList<>();
|
||||||
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
|
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
|
||||||
supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
|
|
||||||
converter.setSupportedMediaTypes(supportedMediaTypes);
|
converter.setSupportedMediaTypes(supportedMediaTypes);
|
||||||
// 将转换器添加到 Spring MVC 的消息转换器列表中
|
// 将转换器添加到 Spring MVC 的消息转换器列表中
|
||||||
converters.add(0, converter);
|
converters.addFirst(converter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import lombok.NonNull;
|
|||||||
* @author ww
|
* @author ww
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class CzgPayBaseReq<T> {
|
public class CzgPayBaseReq {
|
||||||
//必填范围
|
//必填范围
|
||||||
/**
|
/**
|
||||||
* 订单标题
|
* 订单标题
|
||||||
@@ -84,9 +84,9 @@ public class CzgPayBaseReq<T> {
|
|||||||
private String subAppid;
|
private String subAppid;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 额外参数
|
* 支付条码
|
||||||
*/
|
*/
|
||||||
private T data;
|
private String authCode;
|
||||||
|
|
||||||
public CzgPayBaseReq() {
|
public CzgPayBaseReq() {
|
||||||
|
|
||||||
@@ -107,27 +107,27 @@ public class CzgPayBaseReq<T> {
|
|||||||
this.notifyUrl = notifyUrl;
|
this.notifyUrl = notifyUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CzgPayBaseReq<?> ltPayReq(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount
|
public static CzgPayBaseReq ltPayReq(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount
|
||||||
, @NonNull String payType, @NonNull String openId, @NonNull String clientIp) {
|
, @NonNull String payType, @NonNull String openId, @NonNull String clientIp) {
|
||||||
return new CzgPayBaseReq<>(mchOrderNo, detail, amount, payType, openId, clientIp);
|
return new CzgPayBaseReq(mchOrderNo, detail, amount, payType, openId, clientIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CzgPayBaseReq<?> h5PayReq(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount, @NonNull String clientIp) {
|
public static CzgPayBaseReq h5PayReq(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount, @NonNull String clientIp) {
|
||||||
return new CzgPayBaseReq<>(mchOrderNo, detail, amount, null, null, clientIp);
|
return new CzgPayBaseReq(mchOrderNo, detail, amount, null, null, clientIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CzgPayBaseReq<?> jsPayReq(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount
|
public static CzgPayBaseReq jsPayReq(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount
|
||||||
, @NonNull String payType, @NonNull String openId, @NonNull String clientIp) {
|
, @NonNull String payType, @NonNull String openId, @NonNull String clientIp) {
|
||||||
return new CzgPayBaseReq<>(mchOrderNo, detail, amount, payType, openId, clientIp);
|
return new CzgPayBaseReq(mchOrderNo, detail, amount, payType, openId, clientIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CzgPayBaseReq<?> scanPayReq(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount, @NonNull String clientIp) {
|
public static CzgPayBaseReq scanPayReq(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount, @NonNull String clientIp) {
|
||||||
return new CzgPayBaseReq<>(mchOrderNo, detail, amount, null, null, clientIp);
|
return new CzgPayBaseReq(mchOrderNo, detail, amount, null, null, clientIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CzgPayBaseReq<String> microPay(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount, @NonNull String authCode) {
|
public static CzgPayBaseReq microPay(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount, @NonNull String authCode) {
|
||||||
CzgPayBaseReq<String> stringReq = new CzgPayBaseReq<>(mchOrderNo, detail, amount, null, null, null);
|
CzgPayBaseReq stringReq = new CzgPayBaseReq(mchOrderNo, detail, amount, null, null, null);
|
||||||
stringReq.setData(authCode);
|
stringReq.setAuthCode(authCode);
|
||||||
return stringReq;
|
return stringReq;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class PayManager {
|
|||||||
* @param paramsDto 参数
|
* @param paramsDto 参数
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> jsapiPay(CzgPayBaseReq<?> paramsDto, NativeMerchantDTO merchantDTO) {
|
public static Map<String, Object> jsapiPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||||
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
|
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
|
||||||
return WechatPayManager.jsapiPay(null, paramsDto, merchantDTO);
|
return WechatPayManager.jsapiPay(null, paramsDto, merchantDTO);
|
||||||
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
|
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
|
||||||
@@ -38,7 +38,7 @@ public class PayManager {
|
|||||||
* @param paramsDto 参数
|
* @param paramsDto 参数
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> barPay(CzgPayBaseReq<String> paramsDto, NativeMerchantDTO merchantDTO) {
|
public static Map<String, Object> barPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||||
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
|
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
|
||||||
return WechatPayManager.barPay(null, paramsDto, merchantDTO);
|
return WechatPayManager.barPay(null, paramsDto, merchantDTO);
|
||||||
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
|
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class AlipayIsvPayManager {
|
|||||||
* @param configDto 配置
|
* @param configDto 配置
|
||||||
* @param paramsDto 参数
|
* @param paramsDto 参数
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> jsapiPay(AlipayConfigDto configDto, CzgPayBaseReq<?> paramsDto, NativeMerchantDTO merchantDTO) {
|
public static Map<String, Object> jsapiPay(AlipayConfigDto configDto, CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||||
try {
|
try {
|
||||||
AlipayClient.setApiClient(configDto);
|
AlipayClient.setApiClient(configDto);
|
||||||
AlipayTradeApi api = new AlipayTradeApi();
|
AlipayTradeApi api = new AlipayTradeApi();
|
||||||
@@ -71,7 +71,7 @@ public class AlipayIsvPayManager {
|
|||||||
* @param configDto 配置
|
* @param configDto 配置
|
||||||
* @param paramsDto 参数
|
* @param paramsDto 参数
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> barPay(AlipayConfigDto configDto, CzgPayBaseReq<String> paramsDto, NativeMerchantDTO merchantDTO) {
|
public static Map<String, Object> barPay(AlipayConfigDto configDto, CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||||
try {
|
try {
|
||||||
AlipayClient.setApiClient(configDto);
|
AlipayClient.setApiClient(configDto);
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ public class AlipayIsvPayManager {
|
|||||||
data.setScene("bar_code");
|
data.setScene("bar_code");
|
||||||
// 设置产品码
|
// 设置产品码
|
||||||
data.setProductCode("FACE_TO_FACE_PAYMENT");
|
data.setProductCode("FACE_TO_FACE_PAYMENT");
|
||||||
data.setAuthCode(paramsDto.getData());
|
data.setAuthCode(paramsDto.getAuthCode());
|
||||||
// AlipayTradeCreateResponseModel responseModel = api.create(data);
|
// AlipayTradeCreateResponseModel responseModel = api.create(data);
|
||||||
|
|
||||||
return new JSONObject();
|
return new JSONObject();
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class WechatPayManager {
|
|||||||
* @param configDto 配置
|
* @param configDto 配置
|
||||||
* @param paramsDto 参数
|
* @param paramsDto 参数
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> jsapiPay(WechatPayConfigDto configDto, CzgPayBaseReq<?> paramsDto, NativeMerchantDTO merchantDTO) {
|
public static Map<String, Object> jsapiPay(WechatPayConfigDto configDto, CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||||
if (configDto == null) {
|
if (configDto == null) {
|
||||||
configDto = WechatPayConfigDto.getDefaultConfig();
|
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ public class WechatPayManager {
|
|||||||
* @param configDto 配置
|
* @param configDto 配置
|
||||||
* @param paramsDto 参数
|
* @param paramsDto 参数
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> barPay(WechatPayConfigDto configDto, CzgPayBaseReq<String> paramsDto, NativeMerchantDTO merchantDTO) {
|
public static Map<String, Object> barPay(WechatPayConfigDto configDto, CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||||
try {
|
try {
|
||||||
if (configDto == null) {
|
if (configDto == null) {
|
||||||
configDto = WechatPayConfigDto.getDefaultConfig();
|
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||||
@@ -136,8 +136,8 @@ public class WechatPayManager {
|
|||||||
payMap.put("total_fee", paramsDto.getAmount());
|
payMap.put("total_fee", paramsDto.getAmount());
|
||||||
addElementIfNotEmpty(xml, "spbill_create_ip", paramsDto.getClientIp());
|
addElementIfNotEmpty(xml, "spbill_create_ip", paramsDto.getClientIp());
|
||||||
payMap.put("spbill_create_ip", paramsDto.getClientIp());
|
payMap.put("spbill_create_ip", paramsDto.getClientIp());
|
||||||
addElementIfNotEmpty(xml, "auth_code", paramsDto.getData());
|
addElementIfNotEmpty(xml, "auth_code", paramsDto.getAuthCode());
|
||||||
payMap.put("auth_code", paramsDto.getData());
|
payMap.put("auth_code", paramsDto.getAuthCode());
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(paramsDto.getExtParam())) {
|
if (StrUtil.isNotBlank(paramsDto.getExtParam())) {
|
||||||
addElementIfNotEmpty(xml, "attach", paramsDto.getExtParam());
|
addElementIfNotEmpty(xml, "attach", paramsDto.getExtParam());
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class PolyPayUtils {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgH5PayResp>
|
* CzgResult<CzgH5PayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> h5Pay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
public static CzgResult<Map<String, Object>> h5Pay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq bizData) {
|
||||||
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.H5_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgH5PayResp.class));
|
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.H5_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgH5PayResp.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public class PolyPayUtils {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgJsPayResp>
|
* CzgResult<CzgJsPayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> jsPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
public static CzgResult<Map<String, Object>> jsPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq bizData) {
|
||||||
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.JS_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgJsPayResp.class));
|
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.JS_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgJsPayResp.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ public class PolyPayUtils {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgLtPayResp>
|
* CzgResult<CzgLtPayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> ltPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
public static CzgResult<Map<String, Object>> ltPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq bizData) {
|
||||||
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.LT_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgLtPayResp.class));
|
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.LT_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgLtPayResp.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ public class PolyPayUtils {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgScanPayResp>
|
* CzgResult<CzgScanPayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> scanPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
public static CzgResult<Map<String, Object>> scanPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq bizData) {
|
||||||
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.SCAN_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgScanPayResp.class));
|
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.SCAN_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgScanPayResp.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ public class PolyPayUtils {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgMicroPayResp>
|
* CzgResult<CzgMicroPayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> microPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
public static CzgResult<Map<String, Object>> microPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq bizData) {
|
||||||
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.MICRO_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgMicroPayResp.class));
|
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.MICRO_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgMicroPayResp.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public interface PayService {
|
|||||||
Long initPayment(OrderPayment payment);
|
Long initPayment(OrderPayment payment);
|
||||||
|
|
||||||
//-----------------------------------------------------------------付款 ----------------------------------------------------------
|
//-----------------------------------------------------------------付款 ----------------------------------------------------------
|
||||||
CzgResult<Map<String, Object>> pay(@NonNull Long shopId, CzgPayEnum payType, CzgPayBaseReq<?> bizData);
|
CzgResult<Map<String, Object>> pay(@NonNull Long shopId, CzgPayEnum payType, CzgPayBaseReq bizData);
|
||||||
//-----------------------------------------------------------------积分商品/拼团 付款 ----------------------------------------------------------
|
//-----------------------------------------------------------------积分商品/拼团 付款 ----------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class PayServiceImpl implements PayService {
|
|||||||
private OrderPaymentMapper paymentMapper;
|
private OrderPaymentMapper paymentMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CzgResult<Map<String, Object>> pay(@NonNull Long shopId, CzgPayEnum payType, CzgPayBaseReq<?> bizData) {
|
public CzgResult<Map<String, Object>> pay(@NonNull Long shopId, CzgPayEnum payType, CzgPayBaseReq bizData) {
|
||||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||||
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
|
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
|
||||||
String payData = null;
|
String payData = null;
|
||||||
@@ -66,7 +66,7 @@ public class PayServiceImpl implements PayService {
|
|||||||
}
|
}
|
||||||
bizData.setSubAppid(SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? shopMerchant.getAlipayAppId() : shopMerchant.getWechatAppId());
|
bizData.setSubAppid(SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? shopMerchant.getAlipayAppId() : shopMerchant.getWechatAppId());
|
||||||
if (payType.equals(CzgPayEnum.MICRO_PAY)) {
|
if (payType.equals(CzgPayEnum.MICRO_PAY)) {
|
||||||
checkMicroPay((CzgPayBaseReq<String>) bizData, shopMerchant);
|
checkMicroPay(bizData, shopMerchant);
|
||||||
}
|
}
|
||||||
return adapter.pay(payType, payData, getDomain(), getNotifyUrl(shopMerchant.getChannel()), bizData);
|
return adapter.pay(payType, payData, getDomain(), getNotifyUrl(shopMerchant.getChannel()), bizData);
|
||||||
}
|
}
|
||||||
@@ -217,8 +217,8 @@ public class PayServiceImpl implements PayService {
|
|||||||
return notifyUrl;
|
return notifyUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkMicroPay(CzgPayBaseReq<String> bizData, ShopMerchant shopMerchant) {
|
private void checkMicroPay(CzgPayBaseReq bizData, ShopMerchant shopMerchant) {
|
||||||
String data = bizData.getData();
|
String data = bizData.getAuthCode();
|
||||||
AssertUtil.isBlank(data, "扫码失败,请重试");
|
AssertUtil.isBlank(data, "扫码失败,请重试");
|
||||||
if (data.length() > 26) {
|
if (data.length() > 26) {
|
||||||
throw new CzgException("支付失败,不支持的条码");
|
throw new CzgException("支付失败,不支持的条码");
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public interface PayAdapter {
|
|||||||
* @param bizData 业务数据
|
* @param bizData 业务数据
|
||||||
*/
|
*/
|
||||||
CzgResult<Map<String, Object>> pay(@NonNull CzgPayEnum payType, @NotBlank String payData, @NotBlank String domain,
|
CzgResult<Map<String, Object>> pay(@NonNull CzgPayEnum payType, @NotBlank String payData, @NotBlank String domain,
|
||||||
@NotBlank String notifyUrl, CzgPayBaseReq<?> bizData);
|
@NotBlank String notifyUrl, CzgPayBaseReq bizData);
|
||||||
|
|
||||||
CzgResult<CzgRefundResp> refund(@NotBlank String domain, @NotBlank String payData, String notifyUrl, CzgRefundReq bizData);
|
CzgResult<CzgRefundResp> refund(@NotBlank String domain, @NotBlank String payData, String notifyUrl, CzgRefundReq bizData);
|
||||||
|
|
||||||
|
|||||||
@@ -34,24 +34,21 @@ public class NativePayAdapter implements PayAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CzgResult<Map<String, Object>> pay(@NonNull CzgPayEnum payType, String payData, String domain, String notifyUrl, CzgPayBaseReq<?> bizData) {
|
public CzgResult<Map<String, Object>> pay(@NonNull CzgPayEnum payType, String payData, String domain, String notifyUrl, CzgPayBaseReq bizData) {
|
||||||
try {
|
try {
|
||||||
NativeMerchantDTO polyMerchantDTO = JSONObject.parseObject(payData, NativeMerchantDTO.class);
|
NativeMerchantDTO polyMerchantDTO = JSONObject.parseObject(payData, NativeMerchantDTO.class);
|
||||||
switch (payType) {
|
return switch (payType) {
|
||||||
// case H5_PAY:
|
// case H5_PAY:
|
||||||
// return h5Pay(polyMerchantDTO, domain, notifyUrl, bizData);
|
// return h5Pay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
case JS_PAY:
|
case JS_PAY -> jsPay(polyMerchantDTO, notifyUrl, bizData);
|
||||||
return jsPay(polyMerchantDTO, notifyUrl, bizData);
|
case LT_PAY -> jsPay(polyMerchantDTO, notifyUrl, bizData);
|
||||||
case LT_PAY:
|
|
||||||
return jsPay(polyMerchantDTO, notifyUrl, bizData);
|
|
||||||
// case SCAN_PAY:
|
// case SCAN_PAY:
|
||||||
// return scanPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
// return scanPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
case MICRO_PAY:
|
case MICRO_PAY ->
|
||||||
//扫码支付 扫描码
|
//扫码支付 扫描码
|
||||||
return barPay(polyMerchantDTO, notifyUrl, (CzgPayBaseReq<String>) bizData);
|
barPay(polyMerchantDTO, notifyUrl, bizData);
|
||||||
default:
|
default -> throw new CzgException("原生支付不支持该支付方式: " + bizData.getPayType());
|
||||||
throw new CzgException("原生支付不支持该支付方式: " + bizData.getPayType());
|
};
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("聚合支付处理失败: {}", e.getMessage(), e);
|
log.error("聚合支付处理失败: {}", e.getMessage(), e);
|
||||||
return CzgResult.failure("聚合支付处理失败: " + e.getMessage());
|
return CzgResult.failure("聚合支付处理失败: " + e.getMessage());
|
||||||
@@ -73,12 +70,12 @@ public class NativePayAdapter implements PayAdapter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CzgResult<Map<String, Object>> jsPay(NativeMerchantDTO merchantDTO, String notifyUrl, CzgPayBaseReq<?> bizData) {
|
private CzgResult<Map<String, Object>> jsPay(NativeMerchantDTO merchantDTO, String notifyUrl, CzgPayBaseReq bizData) {
|
||||||
bizData.setNotifyUrl(notifyUrl);
|
bizData.setNotifyUrl(notifyUrl);
|
||||||
return CzgResult.success(PayManager.jsapiPay(bizData, merchantDTO));
|
return CzgResult.success(PayManager.jsapiPay(bizData, merchantDTO));
|
||||||
}
|
}
|
||||||
|
|
||||||
private CzgResult<Map<String, Object>> barPay(NativeMerchantDTO merchantDTO, String notifyUrl, CzgPayBaseReq<String> bizData) {
|
private CzgResult<Map<String, Object>> barPay(NativeMerchantDTO merchantDTO, String notifyUrl, CzgPayBaseReq bizData) {
|
||||||
bizData.setNotifyUrl(notifyUrl);
|
bizData.setNotifyUrl(notifyUrl);
|
||||||
return CzgResult.success(PayManager.barPay(bizData, merchantDTO));
|
return CzgResult.success(PayManager.barPay(bizData, merchantDTO));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class PolyPayAdapter implements PayAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CzgResult<Map<String, Object>> pay(@NonNull CzgPayEnum payType, @NotBlank String payData, @NotBlank String domain,
|
public CzgResult<Map<String, Object>> pay(@NonNull CzgPayEnum payType, @NotBlank String payData, @NotBlank String domain,
|
||||||
@NotBlank String notifyUrl, CzgPayBaseReq<?> bizData) {
|
@NotBlank String notifyUrl, CzgPayBaseReq bizData) {
|
||||||
try {
|
try {
|
||||||
PolyMerchantDTO polyMerchantDTO = JSONObject.parseObject(payData, PolyMerchantDTO.class);
|
PolyMerchantDTO polyMerchantDTO = JSONObject.parseObject(payData, PolyMerchantDTO.class);
|
||||||
return switch (payType) {
|
return switch (payType) {
|
||||||
@@ -40,8 +40,8 @@ public class PolyPayAdapter implements PayAdapter {
|
|||||||
case JS_PAY -> jsPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
case JS_PAY -> jsPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
case LT_PAY -> ltPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
case LT_PAY -> ltPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
case SCAN_PAY -> scanPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
case SCAN_PAY -> scanPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
case MICRO_PAY -> microPay(polyMerchantDTO, domain, notifyUrl, (CzgPayBaseReq<String>) bizData);
|
case MICRO_PAY -> microPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
default -> throw new CzgException("聚合支付不支持该支付方式: " + bizData.getPayType());
|
default -> throw new CzgException("聚合支付不支持该支付方式: " + payType);
|
||||||
};
|
};
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("聚合支付处理失败: {}", e.getMessage(), e);
|
log.error("聚合支付处理失败: {}", e.getMessage(), e);
|
||||||
@@ -70,12 +70,12 @@ public class PolyPayAdapter implements PayAdapter {
|
|||||||
return PolyPayUtils.queryRefundOrder(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), mchRefundNo, refundOrderId);
|
return PolyPayUtils.queryRefundOrder(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), mchRefundNo, refundOrderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CzgResult<Map<String, Object>> h5Pay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq<?> bizData) {
|
private CzgResult<Map<String, Object>> h5Pay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq bizData) {
|
||||||
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
||||||
return PolyPayUtils.h5Pay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
return PolyPayUtils.h5Pay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CzgResult<Map<String, Object>> jsPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq<?> bizData) {
|
private CzgResult<Map<String, Object>> jsPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq bizData) {
|
||||||
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + (SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
|
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + (SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
|
||||||
bizData.setPayType(SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? "ALIPAY" : "WECHAT");
|
bizData.setPayType(SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? "ALIPAY" : "WECHAT");
|
||||||
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
||||||
@@ -83,18 +83,18 @@ public class PolyPayAdapter implements PayAdapter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private CzgResult<Map<String, Object>> ltPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq<?> bizData) {
|
private CzgResult<Map<String, Object>> ltPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq bizData) {
|
||||||
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
|
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
|
||||||
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
||||||
return PolyPayUtils.ltPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
return PolyPayUtils.ltPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CzgResult<Map<String, Object>> scanPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq<?> bizData) {
|
private CzgResult<Map<String, Object>> scanPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq bizData) {
|
||||||
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
||||||
return PolyPayUtils.scanPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
return PolyPayUtils.scanPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CzgResult<Map<String, Object>> microPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq<String> bizData) {
|
private CzgResult<Map<String, Object>> microPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq bizData) {
|
||||||
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
||||||
return PolyPayUtils.microPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
return PolyPayUtils.microPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user