58 Commits

Author SHA1 Message Date
6b3fb08036 打印 单价 2026-01-17 11:24:44 +08:00
484ffb07e5 多余 controller 2026-01-17 10:32:10 +08:00
e9ef1b0fac 支付参数 2026-01-17 10:25:19 +08:00
04be17d63e 暂时限制开通 2026-01-17 09:55:05 +08:00
21da0a344c Merge branch 'test' into prod
# Conflicts:
#	cash-api/account-server/src/main/java/com/czg/controller/admin/AuthorizationController.java
#	cash-api/order-server/src/main/java/com/czg/controller/DistributionPayController.java
#	cash-service/order-service/src/main/java/com/czg/service/order/service/impl/OrderInfoCustomServiceImpl.java
#	cash-service/order-service/src/main/java/com/czg/service/order/service/impl/PayServiceImpl.java
2026-01-17 09:52:55 +08:00
656db661ab 进件关联 2026-01-16 18:20:06 +08:00
4498108fb5 进件关联 2026-01-16 17:55:03 +08:00
235c442c6d 进件关联 2026-01-16 17:49:52 +08:00
592cc99db4 进件关联 2026-01-16 17:42:02 +08:00
f8db70ca43 支付回调问题 2026-01-16 16:24:41 +08:00
1f6593c957 进件查询问题 2026-01-16 16:16:48 +08:00
b22b9bd4d6 进件查询问题 2026-01-16 16:15:17 +08:00
d6ef8cfba9 店铺名称问题 2026-01-16 09:57:44 +08:00
gong
0fbe490178 微信支付 进件增加 h5支付域名 2026-01-15 16:04:22 +08:00
d693bb0dd3 Merge remote-tracking branch 'origin/test' into test 2026-01-15 15:46:14 +08:00
b6e3d109fc 常量 2026-01-15 15:45:57 +08:00
gong
b83c53fe04 微信退款 退款中处理4 2026-01-15 15:40:42 +08:00
gong
5b617b653b 微信退款 退款中处理3 2026-01-15 15:39:28 +08:00
gong
4866784afe 微信退款 退款中处理 2026-01-15 15:36:32 +08:00
gong
97bf69eb31 微信退款 退款中处理 2026-01-15 15:31:57 +08:00
gong
aca48f84d9 微信支付回调日期格式化 2026-01-15 15:17:57 +08:00
9834c59fc7 常量 2026-01-15 14:31:26 +08:00
c151a0188d 支付参数5 2026-01-15 14:15:32 +08:00
2c417daa3f 支付参数5 2026-01-15 14:12:57 +08:00
b3a161d643 支付参数4 2026-01-15 14:08:57 +08:00
df72bad0dc Merge remote-tracking branch 'origin/test' into test 2026-01-15 14:05:06 +08:00
071e7f5c82 支付参数3 2026-01-15 14:04:36 +08:00
gong
2259818ae1 修改查询订单状态封装 2026-01-15 14:04:36 +08:00
5541ed5da4 支付参数2 2026-01-15 14:01:10 +08:00
9143331267 支付参数 2026-01-15 13:54:06 +08:00
gong
98dfda0bca 修改退款申请封装 2026-01-15 13:32:55 +08:00
ee25493570 支付参数 2026-01-15 11:32:49 +08:00
a59ea2e841 获取进件信息 2026-01-15 11:05:33 +08:00
01aad45a2b 定时任务 修改进件信息处理 2026-01-15 10:47:51 +08:00
b8a6ce495c 定时任务 修改进件信息处理 2026-01-15 10:38:58 +08:00
gong
cdd012c2fe shopid 为1 2026-01-15 10:23:29 +08:00
gong
7f64a64dc8 shopid 为空 2026-01-15 10:17:58 +08:00
7351188660 支付平台 2026-01-15 09:52:30 +08:00
feee0f8534 去除<?> 2026-01-14 19:18:03 +08:00
gong
c4cb2989b3 集成 封装处理 2026-01-14 18:43:20 +08:00
c48c0f6d7d 常量 2026-01-14 18:31:52 +08:00
bfff341d17 团购扫码 token获取信息 2026-01-14 17:48:59 +08:00
e301f996ad 导入问题 2026-01-14 17:46:18 +08:00
af0df0d378 报错 2026-01-14 17:40:19 +08:00
721819c3e8 团购扫码 token获取信息 2026-01-14 17:35:13 +08:00
b473c82e4f 多余导入 2026-01-14 17:17:19 +08:00
1b975c2164 支付调整 2026-01-14 17:09:57 +08:00
c446d576be 支付调整 2026-01-14 17:06:11 +08:00
ab8877c9cf Merge remote-tracking branch 'origin/test' into test
# Conflicts:
#	cash-api/order-server/src/main/java/com/czg/controller/NotifyController.java
#	cash-sdk/aggregation-pay/src/main/java/com/czg/PayManager.java
2026-01-14 17:06:04 +08:00
4eaedcce41 支付调整 2026-01-14 17:04:48 +08:00
f85ac0815b 计算成本价问题 2026-01-05 14:31:32 +08:00
80fb367673 统计 2026-01-05 11:30:16 +08:00
574c73d0b5 shop_user查询多个的问题 2026-01-05 09:37:45 +08:00
cb18aa5670 退款问题 2025-12-26 17:09:34 +08:00
da3447cd0b 异步执行退款额外问题 2025-12-26 16:21:59 +08:00
9e946443ec sql问题 2025-12-26 16:18:17 +08:00
71ffdede19 分销退款问题 2025-12-26 16:02:31 +08:00
353404dde4 显式抛出 2025-12-26 14:53:38 +08:00
104 changed files with 1749 additions and 1189 deletions

View File

@@ -1,27 +1,18 @@
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.entity.ShopInfo;
import com.czg.account.service.*;
import com.czg.account.entity.SysUser;
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.annotation.SaAdminCheckPermission;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.config.RabbitPublisher;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
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.web.bind.annotation.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
@@ -35,11 +26,9 @@ public class AuthorizationController {
@Resource
private AuthorizationService authorizationService;
@Resource
private PermissionService permissionService;
@Resource
private ShopInfoService shopInfoService;
@Resource
private ShopStaffService shopStaffService;
private SysUserService sysUserService;
/**
@@ -77,27 +66,6 @@ public class AuthorizationController {
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());
}
/**
* 核销获取 信息使用
@@ -105,14 +73,11 @@ public class AuthorizationController {
*/
@GetMapping("/userInfo")
public CzgResult<Map<String, Object>> getUserInfo() {
String account = StpKit.USER.getAccount();
ShopInfo shopInfo = shopInfoService.queryChain()
.select(ShopInfo::getId, ShopInfo::getShopName)
.eq(ShopInfo::getId, StpKit.USER.getShopId()).one();
if (account.contains("@")) {
account = account.split("@")[1];
}
Map<String, Object> map = Map.of("shopId", shopInfo.getId(), "shopName", shopInfo.getShopName(), "account", account);
SysUser one = sysUserService.queryChain().eq(SysUser::getId, StpKit.USER.getShopId()).one();
Map<String, Object> map = Map.of("shopId", shopInfo.getId(), "shopName", shopInfo.getShopName(), "account", one.getAccount());
return CzgResult.success(map);
}
}

View File

@@ -3,12 +3,13 @@ package com.czg.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.CzgPayUtils;
import com.czg.PayCst;
import com.czg.PolyPayUtils;
import com.czg.constant.PayChannelCst;
import com.czg.constants.PayTypeConstants;
import com.czg.dto.req.WechatNotifyReqDto;
import com.czg.dto.req.WechatPayNotifyDataDto;
import com.czg.entity.CzgBaseRespParams;
import com.czg.entity.PolyBaseResp;
import com.czg.exception.CzgException;
import com.czg.market.entity.MkShopConsumeDiscountRecord;
import com.czg.market.service.MkDistributionUserService;
@@ -18,6 +19,7 @@ import com.czg.order.entity.OrderInfo;
import com.czg.order.entity.OrderPayment;
import com.czg.order.service.OrderInfoCustomService;
import com.czg.order.service.OrderPaymentService;
import com.czg.pay.PayNotifyRespDTO;
import com.czg.service.market.service.impl.AppWxServiceImpl;
import com.czg.third.wechat.WechatReqUtils;
import com.czg.utils.AssertUtil;
@@ -75,6 +77,8 @@ public class NotifyController {
log.info("【微信支付回调】解密数据 {}", decrypted);
WechatPayNotifyDataDto dataDto = JSONObject.parseObject(decrypted, WechatPayNotifyDataDto.class);
PayNotifyRespDTO respDTO = dataDto.convertToPayNotifyRespDTO();
orderInfoCustomService.payCallBackOrder(respDTO.getMchOrderNo(), respDTO, PayChannelCst.NATIVE, 0);
return "success";
} else if (PayCst.Platform.ALIPAY.equalsIgnoreCase(platform)) {
// 支付宝
@@ -105,11 +109,11 @@ public class NotifyController {
@RequestMapping("/payCallBack")
public String notifyCallBack(@RequestBody CzgBaseRespParams respParams) {
JSONObject czg = CzgPayUtils.getCzg(respParams);
AssertUtil.isNull(czg, "支付回调数据为空");
log.info("支付回调数据为:{}", czg);
orderInfoCustomService.payCallBackOrder(czg.getString("mchOrderNo"), czg, 0);
public String notifyCallBack(@RequestBody PolyBaseResp respParams) {
PayNotifyRespDTO respDTO = PolyPayUtils.getNotifyResp(respParams);
AssertUtil.isNull(respDTO, "支付回调数据为空");
log.info("支付回调数据为:{}", respDTO);
orderInfoCustomService.payCallBackOrder(respDTO.getMchOrderNo(), respDTO, PayChannelCst.POLY, 0);
return SUCCESS;
}
@@ -131,12 +135,15 @@ public class NotifyController {
}
/**
* 微信原生支付回调
*/
@RequestMapping("/native/wx/pay/distributionRecharge")
public String nativeNotify(HttpServletRequest request) throws IOException {
String timestamp = request.getHeader("Wechatpay-Timestamp");
String nonce = request.getHeader("Wechatpay-Nonce");
String serialNo = request.getHeader("Wechatpay-Serial");
String signature = request.getHeader("Wechatpay-Signature");
// String timestamp = request.getHeader("Wechatpay-Timestamp");
// String nonce = request.getHeader("Wechatpay-Nonce");
// String serialNo = request.getHeader("Wechatpay-Serial");
// String signature = request.getHeader("Wechatpay-Signature");
String result = IoUtil.readUtf8(request.getInputStream());
JSONObject jsonObject = JSONObject.parseObject(result);
JSONObject resource = jsonObject.getJSONObject("resource");
@@ -171,8 +178,8 @@ public class NotifyController {
@RequestMapping("/refundCallBack")
public String refundCallBack(@RequestBody CzgBaseRespParams respParams) {
JSONObject czg = CzgPayUtils.getCzg(respParams);
public String refundCallBack(@RequestBody PolyBaseResp respParams) {
JSONObject czg = PolyPayUtils.getCzg(respParams);
AssertUtil.isNull(czg, "退款回调数据为空");
log.info("退款回调数据为:{}", czg);
orderInfoCustomService.refundCallBackOrder(czg.getString("mchOrderNo"), czg);

View File

@@ -3,7 +3,6 @@ package com.czg.controller.admin;
import com.alibaba.fastjson2.JSONObject;
import com.czg.EntryManager;
import com.czg.annotation.Debounce;
import com.czg.config.RabbitPublisher;
import com.czg.dto.req.AggregateMerchantDto;
import com.czg.dto.resp.WechatBankBranchRespDto;
import com.czg.order.entity.ShopDirectMerchant;
@@ -33,9 +32,6 @@ public class EntryManagerController {
@Resource
private EntryManagerTask entryManagerTask;
@Resource
private RabbitPublisher rabbitPublisher;
/**
* ocr识别填充
* 阿里 ocr识别图片
@@ -68,12 +64,6 @@ public class EntryManagerController {
return CzgResult.success(EntryManager.queryBankBranchList(bankAliceCode, cityCode));
}
@GetMapping("test")
public CzgResult<Void> test(String shopId, String licenceNo) {
rabbitPublisher.sendEntryManagerMsg(shopId + ":" + licenceNo);
return CzgResult.success();
}
/**
* 获取进件列表
*/
@@ -87,8 +77,8 @@ public class EntryManagerController {
* 获取进件信息
*/
@GetMapping
public CzgResult<AggregateMerchantVO> getEntry(Long shopId, String licenceNo) {
return CzgResult.success(shopDirectMerchantService.getEntry(shopId, licenceNo));
public CzgResult<AggregateMerchantVO> getEntry(Long shopId) {
return CzgResult.success(shopDirectMerchantService.getEntry(shopId));
}
/**
@@ -98,8 +88,8 @@ public class EntryManagerController {
*/
@GetMapping("queryEntry")
@Debounce(value = "#shopId", interval = 1000 * 60 * 3)
public CzgResult<Boolean> queryEntry(Long shopId, String licenceNo) {
entryManagerTask.entryManager(shopId, licenceNo);
public CzgResult<Boolean> queryEntry(Long shopId) {
entryManagerTask.entryManager(shopId);
return CzgResult.success();
}

View File

@@ -1,18 +1,19 @@
package com.czg.controller.admin;
import com.czg.account.dto.merchant.ShopMerchantEditDTO;
import com.czg.account.entity.ShopMerchant;
import com.czg.account.service.ShopMerchantService;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.annotation.SaAdminCheckRole;
import com.czg.constant.PayChannelCst;
import com.czg.exception.CzgException;
import com.czg.order.dto.ShopMerchantDTO;
import com.czg.order.entity.ShopDirectMerchant;
import com.czg.order.service.ShopMerchantService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 商户信息管理
*
* @author Administrator
*/
@RestController
@@ -24,25 +25,39 @@ public class ShopMerchantController {
/**
* 商户支付信息获取
* 权限标识: shopMerchant:detail
*
* @param shopId 店铺id
* @return 支付信息
*/
@SaAdminCheckRole("管理员")
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:detail", name = "商户支付信息获取")
@GetMapping
public CzgResult<ShopMerchant> detail(@RequestParam Integer shopId) {
public CzgResult<ShopMerchantDTO> detail(@RequestParam Long shopId) {
return CzgResult.success(shopMerchantService.detail(shopId));
}
/**
* 商户支付信息修改
* 权限标识: shopMerchant:edit
*
* @return 是否成功
*/
@SaAdminCheckRole("管理员")
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:edit", name = "商户支付信息修改")
@PutMapping
public CzgResult<Boolean> edit(@RequestBody @Validated ShopMerchantEditDTO shopMerchantEditDTO) {
return CzgResult.success(shopMerchantService.edit(shopMerchantEditDTO));
public CzgResult<Boolean> edit(@RequestBody ShopMerchantDTO shopMerchant) {
if (shopMerchant != null && shopMerchant.getChannel() != null && shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
throw new CzgException("原生支付渠道暂未开通");
}
return CzgResult.success(shopMerchantService.editEntry(shopMerchant, true));
}
/**
* 获取当前店铺的主店进件信息
*/
@SaAdminCheckRole("管理员")
@GetMapping("getMainMerchant")
public CzgResult<ShopDirectMerchant> getMainMerchant(Long shopId) {
return CzgResult.success(shopMerchantService.getMainMerchant(shopId));
}
}

View File

@@ -35,7 +35,7 @@ public class DistributionPayController {
*/
@PostMapping("/ltPayOrder")
@Debounce(value = "#payParam.userId")
public CzgResult<Map<String, Object>> ltPayOrder( HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
public CzgResult<Map<String, Object>> ltPayOrder(HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
return payService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
}
@@ -46,8 +46,8 @@ public class DistributionPayController {
*/
@PostMapping("/mchRecharge")
@Debounce(value = "#payParam.userId")
public CzgResult<Map<String, String>> mchRecharge(HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
public CzgResult<Map<String, String>> mchRecharge(@Validated @RequestBody MkDistributionPayDTO payParam) {
AssertUtil.isBlank(payParam.getCode(), "微信code不为空");
return CzgResult.success(payService.mchRecharge(ServletUtil.getClientIP(request), payParam));
return CzgResult.success(payService.mchRecharge(payParam));
}
}

View File

@@ -1,7 +1,9 @@
package com.czg.controller.pay;
import com.czg.annotation.Debounce;
import com.czg.entity.resp.CzgBaseResp;
import com.czg.order.entity.OrderPayment;
import com.czg.order.service.OrderPaymentService;
import com.czg.pay.QueryOrderRespDTO;
import com.czg.resp.CzgResult;
import com.czg.service.order.dto.VipMemberPayParamDTO;
import com.czg.service.order.dto.VipPayParamDTO;
@@ -10,6 +12,7 @@ import com.czg.service.order.service.PayService;
import com.czg.service.order.service.ShopUserPayService;
import com.czg.utils.AssertUtil;
import com.czg.utils.ServletUtil;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
@@ -32,6 +35,9 @@ public class VipPayController {
@Resource
private ShopUserPayService shopUserPayService;
@Resource
private OrderPaymentService paymentService;
/**
* 现金充值
* 如果shop_info的 is_member_in_pwd=1 则pwd必填 店铺操作密码
@@ -73,9 +79,6 @@ public class VipPayController {
/**
* 智慧充值
* @param request
* @param rechargeDTO
* @return
*/
@PostMapping("/recharge")
@Debounce(value = "#rechargeDTO.shopUserId")
@@ -89,9 +92,6 @@ public class VipPayController {
/**
* 会员购买支付
* @param request
* @param payParam
* @return
*/
@PostMapping("/ltPayMember")
@Debounce(value = "#payParam.shopUserId")
@@ -168,10 +168,16 @@ public class VipPayController {
public CzgResult<String> queryOrderStatus(Long shopId, String payOrderNo) {
AssertUtil.isNull(shopId, "店铺id不能为空");
AssertUtil.isBlank(payOrderNo, "支付单号不能为空");
OrderPayment payment = paymentService.getOne(QueryWrapper.create().eq(OrderPayment::getOrderNo, payOrderNo));
if (payment == null) {
return CzgResult.failure("支付单号不存在");
}
CzgResult<String> result = CzgResult.success();
CzgResult<CzgBaseResp> queryPayOrder = payService.queryPayOrder(shopId, null, payOrderNo);
if (queryPayOrder.getCode() == 200 && queryPayOrder.getData() != null) {
String state = queryPayOrder.getData().getState();
CzgResult<QueryOrderRespDTO> queryPayOrder = payService.queryPayOrder(shopId, null, payOrderNo, payment.getPlatformType());
if (queryPayOrder.isSuccess() && queryPayOrder.getData() != null) {
String state = queryPayOrder.getData().getStatus();
result.setData(state);
switch (state) {
case "TRADE_AWAIT" -> result.setMsg("等待用户付款");

View File

@@ -75,7 +75,7 @@ public class EntryManagerMqListener {
ThreadContext.put("traceId", String.valueOf(shopId));
log.info("进件2MQ对接开始shopId:{}", msg);
// 安全转换shopId
AggregateMerchantVO entry = shopDirectMerchantService.getEntry(shopId, split[1]);
AggregateMerchantVO entry = shopDirectMerchantService.getEntry(shopId);
log.info("进件3MQ对接开始shopId:{}", msg);
if (entry != null) {
EntryManager.uploadParamImage(entry);

View File

@@ -2,16 +2,18 @@ package com.czg.task;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.EntryManager;
import com.czg.PayCst;
import com.czg.account.service.ShopInfoService;
import com.czg.dto.resp.QueryStatusResp;
import com.czg.order.entity.ShopDirectMerchant;
import com.czg.order.service.ShopMerchantService;
import com.czg.pay.AlipayAuthInfoDto;
import com.czg.pay.NativeMerchantDTO;
import com.czg.service.order.service.ShopDirectMerchantService;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -27,25 +29,24 @@ import java.util.List;
public class EntryManagerTask {
@Resource
private ShopDirectMerchantService shopDirectMerchantService;
@DubboReference
private ShopInfoService shopInfoService;
@Resource
private ShopMerchantService shopMerchantService;
//每10分钟查一次
@Scheduled(cron = "0 0/10 * * * ? ")
public void run() {
log.info("进件查询,定时任务执行");
long start = System.currentTimeMillis();
entryManager(null, null);
entryManager(null);
log.info("进件查询,定时任务执行完毕,耗时:{}ms", start - System.currentTimeMillis());
}
/**
* 查询状态为待处理、待签约、待审核的进件
*/
public void entryManager(Long shopId, String licenceNo) {
public void entryManager(Long shopId) {
List<ShopDirectMerchant> list = shopDirectMerchantService.list(QueryWrapper.create()
.eq(ShopDirectMerchant::getShopId, shopId)
.eq(ShopDirectMerchant::getLicenceNo, licenceNo)
.in(ShopDirectMerchant::getWechatStatus, PayCst.EntryStatus.NEED_QUERY_LIST)
.or(ShopDirectMerchant::getAlipayStatus).in(PayCst.EntryStatus.NEED_QUERY_LIST));
if (CollUtil.isEmpty(list)) {
@@ -58,7 +59,8 @@ public class EntryManagerTask {
QueryStatusResp wechatStatus = EntryManager.queryWechatEntryStatus(shopDirectMerchant.getWechatApplyId());
shopDirectMerchant.setWechatStatus(wechatStatus.getStatus());
shopDirectMerchant.setWechatErrorMsg(wechatStatus.getFailReason());
shopDirectMerchant.setWechatSignUrl(wechatStatus.getSignUrl());
shopDirectMerchant.setWechatSignUrl("");
shopDirectMerchant.setWechatMerchantId(wechatStatus.getThirdMerchantId());
if (PayCst.EntryStatus.FINISH.equals(wechatStatus.getStatus())) {
wechatMerchantId = wechatStatus.getThirdMerchantId();
}
@@ -67,14 +69,28 @@ public class EntryManagerTask {
QueryStatusResp alipayStatus = EntryManager.queryAlipayEntryStatus(shopDirectMerchant.getAlipayOrderId());
shopDirectMerchant.setAlipayStatus(alipayStatus.getStatus());
shopDirectMerchant.setAlipayErrorMsg(alipayStatus.getFailReason());
shopDirectMerchant.setAlipaySignUrl(alipayStatus.getSignUrl());
shopDirectMerchant.setAlipaySignUrl("");
shopDirectMerchant.setAlipayMerchantId(alipayStatus.getThirdMerchantId());
if (PayCst.EntryStatus.FINISH.equals(alipayStatus.getStatus())) {
alipayMerchantId = alipayStatus.getThirdMerchantId();
}
}
shopDirectMerchantService.updateById(shopDirectMerchant);
if (StrUtil.isNotBlank(wechatMerchantId) || StrUtil.isNotBlank(alipayMerchantId)) {
shopInfoService.editEntry(shopDirectMerchant.getShopId(), wechatMerchantId, alipayMerchantId, shopDirectMerchant.getAlipayAuthInfo());
// ShopMerchantDTO shopMerchantDTO = new ShopMerchantDTO();
// shopMerchantDTO.setShopId(shopId);
// shopMerchantDTO.setChannel(PayChannelCst.NATIVE);
// shopMerchantDTO.setRelatedId(shopDirectMerchant.getShopId());
NativeMerchantDTO nativeMerchantDTO = new NativeMerchantDTO();
nativeMerchantDTO.setWechatMerchantId(wechatMerchantId);
nativeMerchantDTO.setAlipayMerchantId(alipayMerchantId);
if (StrUtil.isNotBlank(shopDirectMerchant.getAlipayAuthInfo())) {
AlipayAuthInfoDto alipayAuthInfoDto = JSONObject.parseObject(shopDirectMerchant.getAlipayAuthInfo(), AlipayAuthInfoDto.class);
nativeMerchantDTO.setAlipayAuthInfo(alipayAuthInfoDto);
}
// shopMerchantDTO.setNativeMerchantDTO(nativeMerchantDTO);
// shopMerchantService.editEntry(shopMerchantDTO, false);
shopMerchantService.upMerchant(shopDirectMerchant.getShopId(), nativeMerchantDTO);
}
}
}

View File

@@ -50,9 +50,8 @@ public class FastJson2Config implements WebMvcConfigurer {
// 设置支持的媒体类型
List<MediaType> supportedMediaTypes = new ArrayList<>();
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
converter.setSupportedMediaTypes(supportedMediaTypes);
// 将转换器添加到 Spring MVC 的消息转换器列表中
converters.add(0, converter);
converters.addFirst(converter);
}
}

View File

@@ -10,7 +10,7 @@
<artifactId>cash-common-service</artifactId>
<packaging>jar</packaging>
<name>global-service</name>
<name>common-service</name>
<url>https://maven.apache.org</url>

View File

@@ -32,7 +32,6 @@ public class ShopInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 使用系统用户 sys_user id
*/
@@ -142,18 +141,6 @@ public class ShopInfo implements Serializable {
* -1 平台禁用 0-过期1正式营业
*/
private Integer status;
/**
* 微信商户id
*/
private String wechatMerchantId;
/**
* 支付宝商户id
*/
private String alipayMerchantId;
/**
* 支付宝授权信息
*/
private String alipayAuthInfo;
/**
* 到期时间

View File

@@ -1,7 +0,0 @@
package com.czg.account.service;
/**
* @author Administrator
*/
public interface PermissionService {
}

View File

@@ -38,11 +38,6 @@ public interface ShopInfoService extends IService<ShopInfo> {
Boolean edit(ShopInfoEditDTO shopInfoEditDTO);
/**
* 进件结果保存
*/
Boolean editEntry(Long shopId, String wechatMerchantId, String alipayMerchantId, String alipayAuthInfo);
ShopDetailDTO detail(Long id) throws CzgException;
ShopInfoByCodeDTO getByCode(String tableCode, String lat, String lng, boolean checkState);

View File

@@ -1,22 +0,0 @@
package com.czg.account.service;
import com.czg.account.dto.merchant.ShopMerchantEditDTO;
import com.czg.account.entity.ShopMerchant;
import com.mybatisflex.core.service.IService;
import java.io.Serializable;
/**
* 第三方商户进件 服务层。
*
* @author Administrator
* @since 2025-02-11
*/
public interface ShopMerchantService extends IService<ShopMerchant> {
ShopMerchant detail(Integer shopId);
Boolean edit(ShopMerchantEditDTO shopMerchantEditDTO);
@Override
ShopMerchant getById(Serializable id);
}

View File

@@ -79,7 +79,27 @@ public interface ParamCodeCst {
* 超掌柜支付回调地址
* <p>支付宝/微信支付完成后,支付平台回调我方系统的地址</p>
*/
public static String PAY_CZG_NOTIFY_URL = "pay_czg_notify_url";
public static String NATIVE_PAY_NOTIFY_URL = "native_pay_notify_url";
public static String NATIVE_REFUND_NOTIFY_URL = "native_refund_notify_url";
/**
* 超掌柜支付域名
* <p>超掌柜支付相关接口的根域名</p>
*/
public static String POLY_DOMAIN = "poly_domain";
public static String POLY_PAY_NOTIFY_URL = "poly_pay_notify_url";
public static String POLY_REFUND_NOTIFY_URL = "poly_refund_notify_url";
/**
* 微信原生回调地址
* <p>微信原生支付接口的回调地址(区别于超掌柜封装的回调)</p>
*/
public static String NATIVE_NOTIFY_URL = "native_notify_url";
/**
* 店铺订单支付BaseUrl
* <p>店铺订单支付页面的基础域名</p>
*/
public static String SHOP_ORDER_PAY_BASE_URL = "shop_order_pay_base_url";
/**
* 排队到号通知
*/
@@ -111,11 +131,6 @@ public interface ParamCodeCst {
*/
public static String SMS_FEE = "sms_fee";
/**
* 店铺订单支付BaseUrl
* <p>店铺订单支付页面的基础域名</p>
*/
public static String SHOP_ORDER_PAY_BASE_URL = "shop_order_pay_base_url";
/**
* 平台名称
@@ -123,30 +138,12 @@ public interface ParamCodeCst {
*/
public static String PLATE_NAME = "plate_name";
/**
* 超掌柜退款回调地址
* <p>支付平台处理退款后,回调我方系统的地址</p>
*/
public static String PAY_CZG_REFUND_NOTIFY_URL = "pay_czg_refund_notify_url";
/**
* 超掌柜支付域名
* <p>超掌柜支付相关接口的根域名</p>
*/
public static String PAY_CZG_DOMAIN = "pay_czg_domain";
/**
* 叫号页面地址
* <p>餐厅叫号系统的前端页面地址</p>
*/
public static String CALL_PAGE_URL = "call_page_url";
/**
* 微信原生回调地址
* <p>微信原生支付接口的回调地址(区别于超掌柜封装的回调)</p>
*/
public static String NATIVE_NOTIFY_URL = "native_notify_url";
/**
* 公众号关注位置
* <p>公众号关注入口的展示位置可选值mine-我的页面、order-订单页面、eat-就餐页面</p>

View File

@@ -43,4 +43,30 @@ public interface SystemConstants {
*/
public static final String CUSTOM = "custom";
}
/**
* 三方支付类型
*/
class PayType {
/**
* 微信支付
*/
public static final String WECHAT = "wechatPay";
/**
* 支付宝支付
*/
public static final String ALIPAY = "alipay";
/**
* 微信小程序支付
*/
public static final String WECHAT_APP_ID = "wxd88fffa983758a30";
/**
* 支付宝小程序支付
*/
public static final String ALIPAY_APP_ID = "2021004145625815";
}
}

View File

@@ -1,6 +1,7 @@
package com.czg.market.service;
import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.exception.CzgException;
import com.czg.market.dto.MkShopRechargeDTO;
import com.czg.market.vo.MkShopRechargeShopListVO;
import com.czg.market.vo.MkShopRechargeVO;
@@ -21,7 +22,7 @@ import java.util.List;
*/
public interface MkShopRechargeService extends IService<MkShopRecharge> {
MkShopRechargeVO detail(Long shopId);
MkShopRechargeVO detail(Long shopId) throws CzgException;
MkShopRechargeVO detailApp(Long shopId);

View File

@@ -24,6 +24,10 @@ public class MkDistributionPayDTO implements Serializable {
private Long shopId;
private String platformType = "DIS";
private Long userId;
/**
* 支付类型
* {@link com.czg.constants.SystemConstants.PayType}
*/
private String payType;
private String returnUrl;
private String buyerRemark;

View File

@@ -28,6 +28,7 @@ public class OrderInfoAddDTO implements Serializable {
* 已出菜 SENT_OUT
* 已上菜 DELIVERED
* 已超时 EXPIRED
* 加急 URGENT
*/
private String subStatus;
//限时折扣部分

View File

@@ -0,0 +1,40 @@
package com.czg.order.dto;
import com.czg.order.entity.ShopDirectMerchant;
import com.czg.pay.NativeMerchantDTO;
import com.czg.pay.PolyMerchantDTO;
import lombok.Data;
/**
* 支付信息
*
* @author ww
*/
@Data
public class ShopMerchantDTO {
private Long shopId;
/**
* poly 聚合(支付平台) native 原生(wx/ali 原生)
* {@link com.czg.constant.PayChannelCst}
*/
private String channel;
/**
* 聚合支付商户
* native 必填 对应 tb_shop_direct_merchant 的 shopId
*/
private Long relatedId;
/**
* 原生支付参数
*/
private NativeMerchantDTO nativeMerchantDTO;
/**
* 聚合支付参数
*/
private PolyMerchantDTO polyMerchantDTO;
/**
* 店铺绑定的商户信息
*/
private ShopDirectMerchant shopDirectMerchant;
}

View File

@@ -5,6 +5,7 @@ import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@@ -40,6 +41,17 @@ public class OrderPayment implements Serializable {
*/
private Long shopId;
/**
* 支付渠道
* {@link com.czg.constant.PayChannelCst}
*/
private String channel;
/**
* 平台类型
* {@link com.czg.PayCst.Platform}
*/
private String platformType;
/**
* 来源Id 订单Id或充值id
*/
@@ -81,7 +93,7 @@ public class OrderPayment implements Serializable {
*/
private String tradeNumber;
@Column(onUpdateValue = "now()")
// @Column(onUpdateValue = "now()")
private LocalDateTime payTime;
/**
@@ -104,28 +116,67 @@ public class OrderPayment implements Serializable {
public OrderPayment() {
}
public OrderPayment(@NonNull Long shopId,@NonNull Long sourceId, @NotBlank String sourceType,@NotBlank String payType, @NotBlank String orderNo,
String authCode, @NonNull BigDecimal amount) {
this.shopId = shopId;
this.sourceId = sourceId;
this.sourceType = sourceType;
this.payType = payType;
this.orderNo = orderNo;
this.authCode = authCode;
this.amount = amount;
this.payStatus = PayTypeConstants.PayStatus.INIT;
/**
* 订单专用支付
*
* @param sourceId 订单Id
* @param amount 单元 元
* @param authCode 扫码支付时必填 扫描码
*/
public static OrderPayment orderPay(@NonNull Long shopId, @NonNull Long sourceId,
@NotBlank String orderNo, @NonNull BigDecimal amount, String authCode) {
OrderPayment orderPayment = getInstance(shopId, sourceId, PayTypeConstants.SourceType.ORDER, orderNo, amount, authCode, null);
orderPayment.setPayType(PayTypeConstants.PayType.PAY);
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
return orderPayment;
}
public OrderPayment(@NonNull Long shopId,@NonNull Long sourceId, @NotBlank String sourceType,@NotBlank String payType, @NotBlank String orderNo,
String authCode, @NonNull BigDecimal amount, Long relatedId) {
this.shopId = shopId;
this.sourceId = sourceId;
this.sourceType = sourceType;
this.payType = payType;
this.orderNo = orderNo;
this.authCode = authCode;
this.amount = amount;
this.relatedId = relatedId;
this.payStatus = PayTypeConstants.PayStatus.INIT;
/**
* 初始化支付参数
*
* @param sourceId 充值时为会员Id shopUserID
* 购买时为商品Id
* @param sourceType {@link PayTypeConstants.SourceType} 支付来源
* @param amount 单元 元
* @param authCode 扫码支付时必填 扫描码
* @param relatedId 霸王餐充值为 订单id 会员充值为 活动id 充值并支付时 为 MkShopRechargeDetail
*/
public static OrderPayment pay(@NonNull Long shopId, @NonNull Long sourceId, @NotBlank String sourceType,
@NotBlank String orderNo, @NonNull BigDecimal amount,
String authCode, Long relatedId) {
OrderPayment orderPayment = getInstance(shopId, sourceId, sourceType, orderNo, amount, authCode, relatedId);
orderPayment.setPayType(PayTypeConstants.PayType.PAY);
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
return orderPayment;
}
public static OrderPayment refund(@NonNull Long shopId, @NonNull Long sourceId, @NotBlank String sourceType,
@NotBlank String orderNo, @NonNull BigDecimal amount, Long relatedId, String platformType) {
OrderPayment orderPayment = getInstance(shopId, sourceId, sourceType, orderNo, amount, null, relatedId);
orderPayment.setPayType(PayTypeConstants.PayType.REFUND);
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
orderPayment.setPlatformType(platformType);
return orderPayment;
}
public static OrderPayment refundCompensate(@NonNull Long shopId, @NonNull Long sourceId, @NotBlank String sourceType,
@NotBlank String orderNo, @NonNull BigDecimal amount, Long relatedId) {
OrderPayment orderPayment = getInstance(shopId, sourceId, sourceType, orderNo, amount, null, relatedId);
orderPayment.setPayType(PayTypeConstants.PayType.REFUND_COMPENSATE);
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
return orderPayment;
}
private static OrderPayment getInstance(Long shopId, Long sourceId, String sourceType,
String orderNo, BigDecimal amount, String authCode, Long relatedId) {
OrderPayment orderPayment = new OrderPayment();
orderPayment.shopId = shopId;
orderPayment.sourceId = sourceId;
orderPayment.sourceType = sourceType;
orderPayment.orderNo = orderNo;
orderPayment.authCode = authCode;
orderPayment.amount = amount;
orderPayment.relatedId = relatedId;
return orderPayment;
}
}

View File

@@ -44,7 +44,6 @@ public class ShopDirectMerchant implements Serializable {
/**
* 营业执照编号
*/
@Id
private String licenceNo;
/**
* 支付宝账号
@@ -124,11 +123,6 @@ public class ShopDirectMerchant implements Serializable {
*/
private String alipayStatus;
/**
* 支付宝授信息
*/
private String alipayAuthInfo;
/**
* 支付宝进件错误信息
*/
@@ -138,4 +132,18 @@ public class ShopDirectMerchant implements Serializable {
*/
private String alipaySignUrl;
/**
* 支付宝授信息
*/
private String alipayAuthInfo;
/**
* 微信商户id
*/
private String wechatMerchantId;
/**
* 支付宝商户id
*/
private String alipayMerchantId;
}

View File

@@ -1,4 +1,4 @@
package com.czg.account.entity;
package com.czg.order.entity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
@@ -18,7 +18,6 @@ import java.time.LocalDateTime;
* @since 2025-02-11
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table("tb_shop_merchant")
@@ -27,48 +26,46 @@ public class ShopMerchant implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Id
private Long id;
/**
* 店铺id
*/
@Id
private Long shopId;
/**
* 支付系统商户id
* poly 聚合(支付平台) native 原生(wx/ali 原生)
* {@link com.czg.constant.PayChannelCst}
*/
private String storeId;
private String merchantName;
private String channel;
/**
* 商户应用id
* 聚合支付商户
* native 必填 对应 tb_shop_direct_merchant shopId
*/
private String appId;
private Long relatedId;
/**
* 商户token
* 微信appid
*/
private String appSecret;
private String wechatAppId;
/**
* 支付宝appid
*/
private String alipayAppId;
/**
* 微信小程序appid
* 聚合支付参数
*/
private String wechatSmallAppid;
private String polyPayJson;
/**
* 支付宝小程序appid
* 原生支付参数
*/
private String alipaySmallAppid;
/**
* 支付密码
*/
private String payPassword;
private String nativePayJson;
@Column(onInsertValue = "now()")
private LocalDateTime createTime;
@Column(onInsertValue = "now()", onUpdateValue = "now()")
private LocalDateTime updateTime;
}

View File

@@ -12,9 +12,9 @@ import com.czg.order.enums.PayEnums;
import com.czg.order.vo.HistoryOrderPrintVo;
import com.czg.order.vo.HistoryOrderVo;
import com.czg.order.vo.OrderInfoVo;
import com.czg.pay.PayNotifyRespDTO;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
import jakarta.validation.constraints.NotBlank;
import org.jetbrains.annotations.NotNull;
@@ -44,7 +44,7 @@ public interface OrderInfoCustomService {
CzgResult<Object> mergeOrder(MergeOrderDTO param);
void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson, int retryCount);
void payCallBackOrder(@NotBlank String orderNo, @NotNull PayNotifyRespDTO notifyRespDTO, String channel, int retryCount);
void refundCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson);

View File

@@ -0,0 +1,37 @@
package com.czg.order.service;
import com.czg.order.dto.ShopMerchantDTO;
import com.czg.order.entity.ShopDirectMerchant;
import com.czg.order.entity.ShopMerchant;
import com.czg.pay.NativeMerchantDTO;
import com.mybatisflex.core.service.IService;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
/**
* 第三方商户进件 服务层。
*
* @author Administrator
* @since 2025-02-11
*/
public interface ShopMerchantService extends IService<ShopMerchant> {
ShopMerchantDTO detail(Long shopId);
/**
* 进件结果保存/ 支付参数修改
*/
Boolean editEntry(ShopMerchantDTO shopMerchantParam, boolean isUp);
/**
* 已绑定的支付
* 更新商户支付参数
*/
void upMerchant(@NotBlank Long relatedId, @NotNull NativeMerchantDTO nativeMerchantDTO);
ShopMerchant getByShopId(Long shopId);
ShopDirectMerchant getMainMerchant(Long shopId);
}

View File

@@ -1,4 +1,4 @@
package com.czg.third.alipay.dto;
package com.czg.pay;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;

View File

@@ -0,0 +1,133 @@
package com.czg.pay;
import lombok.Data;
import lombok.NonNull;
/**
* @author ww
*/
@Data
public class CzgPayBaseReq {
//必填范围
/**
* 订单标题
*/
private String subject;
/**
* 订单描述 String(256)
*/
private String body;
/**
* 交易金额 分
*/
private Long amount;
/**
* 货币类型 cny
*/
private String currency = "cny";
/**
* 商户订单号 String(30)
* 操作方式+雪花算法
* 收银机客户端 PC+雪花ID
* 微信小程序 WX+雪花ID
* 支付宝小程序 ALI+雪花ID
* PC管理端 WEB+雪花ID
* APP管理端 APP+雪花ID
* <p>
* 退款 re+雪花ID
*/
private String mchOrderNo;
/**
* 异步通知地址 String(128)
* 支付结果异步回调URL,只有传了该值才会发起回调
*/
private String notifyUrl;
/**
* 扩展参数 String(512)
* 商户扩展参数,回调时会原样返回
* * 扩展参数
* * {
* * "pay_type": "order/vip"
* * }
*/
private String extParam;
/**
* 原生支付 不需要 store_id
*/
private String storeId;
/**
* 支付类型
* {@link com.czg.constants.SystemConstants.PayType}
*/
private String payType;
/**
* 用户唯一标识 String(30)
* 微信支付时传入用户的openId
* 支付宝支付和银联支付时传入用户的userId
*/
private String userId;
/**
* 用户IP
* 需要传付款用户客户端IP地址
*/
private String clientIp;
/**
* 子商户 appid ,微信付款支付的时候 需要上送
* isScreen 为 false 的情况下需要传入
*/
private String subAppid;
/**
* 支付条码
*/
private String authCode;
public CzgPayBaseReq() {
}
public CzgPayBaseReq(String mchOrderNo, String detail, Long amount, String payType, String userId, String clientIp) {
this.mchOrderNo = mchOrderNo;
this.subject = detail;
this.body = detail;
this.amount = amount;
this.payType = payType;
this.userId = userId;
this.clientIp = clientIp;
}
public void polyBase(@NonNull String storeId, @NonNull String notifyUrl) {
this.storeId = storeId;
this.notifyUrl = notifyUrl;
}
public static CzgPayBaseReq ltPayReq(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount
, @NonNull String payType, @NonNull String openId, @NonNull String 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) {
return new CzgPayBaseReq(mchOrderNo, detail, amount, null, null, clientIp);
}
public static CzgPayBaseReq jsPayReq(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount
, @NonNull String payType, @NonNull String openId, @NonNull String 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) {
return new CzgPayBaseReq(mchOrderNo, detail, amount, null, null, clientIp);
}
public static CzgPayBaseReq microPay(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount, @NonNull String authCode) {
CzgPayBaseReq stringReq = new CzgPayBaseReq(mchOrderNo, detail, amount, null, null, null);
stringReq.setAuthCode(authCode);
return stringReq;
}
}

View File

@@ -1,4 +1,4 @@
package com.czg.entity.req;
package com.czg.pay;
import lombok.Data;
import lombok.NonNull;
@@ -23,7 +23,10 @@ public class CzgRefundReq {
* 单位为分
*/
private Long refundAmount;
/**
* 原订单总金额 单位
*/
private Long orderTotalAmount;
//非必填范围
/**
@@ -47,15 +50,22 @@ public class CzgRefundReq {
*/
private String notifyUrl;
/**
* 支付平台
*/
private String platform;
/**
* payOrderId和mchOrderNo 二选一 必填
*/
public CzgRefundReq(@NonNull String mchRefundNo, @NonNull String refundReason, @NonNull Long refundAmount,
String mchOrderNo, String extParam) {
@NonNull Long orderTotalAmount, String mchOrderNo, String extParam, String platform) {
this.mchRefundNo = mchRefundNo;
this.refundReason = refundReason;
this.refundAmount = refundAmount;
this.orderTotalAmount = orderTotalAmount;
this.mchOrderNo = mchOrderNo;
this.extParam = extParam;
this.platform = platform;
}
}

View File

@@ -0,0 +1,17 @@
package com.czg.pay;
import lombok.Data;
/**
* 原生支付参数
* @author ww
*/
@Data
public class NativeMerchantDTO {
private String wechatMerchantId;
private String alipayMerchantId;
/**
* 支付宝 授权信息解析
*/
private AlipayAuthInfoDto alipayAuthInfo;
}

View File

@@ -0,0 +1,67 @@
package com.czg.pay;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 统一支付回调响应数据
* @author yjjie
* @date 2026/1/15 09:16
*/
@Data
@Accessors(chain = true)
public class PayNotifyRespDTO {
/**
* 商户订单号
*/
private String mchOrderNo;
/**
* 三方订单号
*/
private String thirdOrderNo;
/**
* 订单状态
* INIT - 订单初始化;
* TRADE_AWAIT - 待支付;
* TRADE_SUCCESS - 支付成功;
* TRADE_FAIL -支付失败;
* TRADE_CANCEL -交易取消;
* TRADE_REFUND -已退款;
* REFUND_ING - 退款中;
* TRADE_CLOSE -订单关闭
*/
private String status;
/**
* 支付平台
*/
private String platform;
/**
* 订单金额 分
*/
private Long amount;
/**
* 扩展数据
*/
private String extData;
/**
* 支付成功时间
*/
private String paySuccessTime;
/**
* 错误信息
*/
private String errorMsg;
/**
* 回调原始数据
*/
private String originalData;
}

View File

@@ -1,16 +1,14 @@
package com.czg.account.dto.merchant;
package com.czg.pay;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* @author Administrator
* 聚合支付参数
* @author ww
*/
@Data
public class ShopMerchantEditDTO {
@NotNull(message = "店铺id不为空")
private Long shopId;
public class PolyMerchantDTO {
@NotEmpty(message = "支付系统商户id不为空")
private String storeId;
@NotEmpty(message = "支付系统商户名称不为空")
@@ -20,12 +18,6 @@ public class ShopMerchantEditDTO {
@NotEmpty(message = "商户秘钥不为空")
private String appSecret;
// 支付密码
@NotEmpty(message = "支付密码不为空")
// @NotEmpty(message = "支付密码不为空")
private String payPassword;
// 微信appid
@NotEmpty(message = "微信appid")
private String wechatSmallAppid;
// 支付宝appid
@NotEmpty(message = "支付宝appid")
private String alipaySmallAppid;
}

View File

@@ -0,0 +1,39 @@
package com.czg.pay;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 查询订单响应参数
* @author yjjie
* @date 2026/1/15 13:56
*/
@Data
@Accessors(chain = true)
public class QueryOrderRespDTO {
/**
* 订单号
*/
private String orderNo;
/**
* 状态
*/
private String status;
/**
* 金额
*/
private Long amount;
/**
* 错误信息
*/
private String errorMsg;
/**
* 原始响应数据
*/
private String originResp;
}

View File

@@ -0,0 +1,59 @@
package com.czg.pay;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* 退款相应数据
* @author yjjie
* @date 2026/1/15 11:00
*/
@Data
@Accessors(chain = true)
public class RefundRespDTO {
/**
* 退款状态
* INIT初始化
* ING退款中
* SUCCESS退款成功
* FAIL退款失败
* CLOSE退款关闭
*/
private String status;
/**
* 退款金额
*/
private Long refundAmount;
/**
* 退款时间
*/
private String refundTime;
/**
* 三方退款订单号
*/
private String thirdRefundNo;
/**
* 商户退款订单号
*/
private String merchantRefundNo;
/**
* 退款失败原因
*/
private String errMessage;
/**
* 退款相应原始数据
*/
private String originalData;
/**
* 退款平台
*/
private String platform;
}

View File

@@ -37,6 +37,11 @@
</exclusion>
</exclusions>
</dependency>
<!-- 短信 -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
@@ -45,10 +50,6 @@
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>

View File

@@ -0,0 +1,18 @@
package com.czg.constant;
/**
* 支付渠道常量
* @author ww
*/
public interface PayChannelCst {
/**
* 聚合支付
* 对应 类 PolyPay
*/
String POLY = "poly";
/**
* 原生支付
* 对应 类 NativePay
*/
String NATIVE = "native";
}

View File

@@ -59,4 +59,8 @@ public class CzgResult<T> implements Serializable {
public static <T> CzgResult<T> failure(CzgRespCode respCode) {
return new CzgResult<>(respCode.getCode(), respCode.getMsg(), null);
}
public boolean isSuccess() {
return code == 200;
}
}

View File

@@ -44,7 +44,6 @@
<netty.version>4.1.128.Final</netty.version>
<wechatpay.version>0.2.17</wechatpay.version>
<apipay-v3.version>3.1.65.ALL</apipay-v3.version>
<dom4j.version>2.2.0</dom4j.version>
</properties>
<dependencyManagement>
@@ -283,13 +282,6 @@
<artifactId>alipay-sdk-java-v3</artifactId>
<version>${apipay-v3.version}</version>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>${dom4j.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</dependencyManagement>

View File

@@ -35,13 +35,6 @@
<artifactId>ocr_api20210707</artifactId>
<version>3.1.2</version>
</dependency>
<!-- Source: https://mvnrepository.com/artifact/org.dom4j/dom4j -->
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@@ -9,7 +9,6 @@ import com.czg.exception.CzgException;
import com.czg.third.alipay.AlipayEntryManager;
import com.czg.third.alipay.AlipayIsvEntryManager;
import com.czg.third.wechat.WechatEntryManager;
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryStoreInfoReqDto;
import com.czg.utils.AssertUtil;
import com.czg.utils.AsyncTaskExecutor;
import org.jetbrains.annotations.NotNull;
@@ -385,8 +384,8 @@ public class EntryManager {
// verifyEntryParam(merchantDto);
// uploadParamImage(merchantDto);
//// System.out.println(merchantDto);
// EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.WECHAT);
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.ALIPAY);
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.WECHAT);
// entryMerchant(merchantDto, PayCst.Platform.ALIPAY);
// entryMerchant(merchantDto, PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY);
System.out.println(respDto);
}

View File

@@ -27,11 +27,11 @@ public interface PayCst {
/**
* 微信
*/
public static final String WECHAT = "wechat";
public static final String WECHAT = "WECHAT";
/**
* 支付宝
*/
public static final String ALIPAY = "alipay";
public static final String ALIPAY = "ALIPAY";
}
/**

View File

@@ -1,8 +1,8 @@
package com.czg;
import com.czg.dto.req.PayParamsDto;
import com.czg.dto.req.RefundParamsDto;
import com.czg.constants.SystemConstants;
import com.czg.exception.CzgException;
import com.czg.pay.*;
import com.czg.third.alipay.AlipayIsvPayManager;
import com.czg.third.wechat.WechatPayManager;
@@ -20,13 +20,11 @@ public class PayManager {
* @param paramsDto 参数
* @return 结果
*/
public static Map<String, Object> jsapiPay(PayParamsDto paramsDto) {
paramsDto.verifyParams();
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
return WechatPayManager.jsapiPay(null, paramsDto);
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
return AlipayIsvPayManager.jsapiPay(null, paramsDto);
public static Map<String, Object> jsapiPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
return WechatPayManager.jsapiPay(null, paramsDto, merchantDTO);
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
return AlipayIsvPayManager.jsapiPay(null, paramsDto, merchantDTO);
} else {
throw new CzgException("不支持的支付平台");
}
@@ -38,13 +36,11 @@ public class PayManager {
* @param paramsDto 参数
* @return 结果
*/
public static Map<String, Object> barPay(PayParamsDto paramsDto) {
paramsDto.verifyParams();
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
return WechatPayManager.barPay(null, paramsDto);
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
return AlipayIsvPayManager.barPay(null, paramsDto);
public static Map<String, Object> barPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
return WechatPayManager.barPay(null, paramsDto, merchantDTO);
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
return AlipayIsvPayManager.barPay(null, paramsDto, merchantDTO);
} else {
throw new CzgException("不支持的支付平台");
}
@@ -53,11 +49,11 @@ public class PayManager {
/**
* 查询订单状态
*/
public static Map<String, Object> queryOrderStatus(String platform, String orderNo, String subMerchantId) {
if (PayCst.Platform.WECHAT.equals(platform)) {
return WechatPayManager.queryOrder(null, orderNo, subMerchantId);
} else if (PayCst.Platform.ALIPAY.equals(platform)) {
return AlipayIsvPayManager.queryOrder(null, orderNo, subMerchantId);
public static QueryOrderRespDTO queryOrderStatus(String platform, String orderNo, NativeMerchantDTO merchantDTO) {
if (SystemConstants.PayType.WECHAT.equals(platform)) {
return WechatPayManager.queryOrder(null, orderNo, merchantDTO);
} else if (SystemConstants.PayType.ALIPAY.equals(platform)) {
return AlipayIsvPayManager.queryOrder(null, orderNo, merchantDTO);
} else {
throw new CzgException("不支持的支付平台");
}
@@ -66,38 +62,16 @@ public class PayManager {
/**
* 退款
*/
public static Map<String, Object> refund(String platform, RefundParamsDto paramsDto) {
if (PayCst.Platform.WECHAT.equals(platform)) {
return WechatPayManager.refundOrder(null, paramsDto);
} else if (PayCst.Platform.ALIPAY.equals(platform)) {
return AlipayIsvPayManager.refundOrder(null, paramsDto);
public static RefundRespDTO refund(CzgRefundReq paramsDto, String notifyUrl, NativeMerchantDTO merchantDTO) {
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
return WechatPayManager.refundOrder(null, paramsDto, notifyUrl, merchantDTO);
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
return AlipayIsvPayManager.refundOrder(null, paramsDto, notifyUrl, merchantDTO);
} else {
throw new CzgException("不支持的支付平台");
}
}
public static void main(String[] args) {
// jsapiPay(new PayParamsDto()
// .setPlatform(PayCst.Platform.ALIPAY)
// .setAppId("2021004145625815")
// .setOpenId("123123123")
// .setOrderNo("1111231231213")
// .setTitle("1213")
// .setMerchantId("123312321")
// .setBody("1213")
// .setAmount(1000L)
// .setPayParams("{\"app_auth_token\": \"ssss\"}")
// .setNotifyUrl("https://www.baidu.com"));
jsapiPay(new PayParamsDto()
.setPlatform(PayCst.Platform.WECHAT)
.setAppId("wxd88fffa983758a30")
.setOpenId("or1l86yipGvwyfPhrKIAcQuSfAV8")
.setOrderNo("1111231231213")
.setTitle("1213")
.setMerchantId("1738216504")
.setBody("1213")
.setAmount(1000L)
.setPayParams("{\"app_auth_token\": \"ssss\"}")
.setNotifyUrl("https://www.baidu.com"));
}
}

View File

@@ -3,7 +3,7 @@ package com.czg.dto.req;
import com.alibaba.fastjson2.JSONObject;
import com.czg.PayCst;
import com.czg.exception.CzgException;
import com.czg.third.alipay.dto.AlipayAuthInfoDto;
import com.czg.pay.AlipayAuthInfoDto;
import com.czg.utils.AssertUtil;
import lombok.Data;
import lombok.experimental.Accessors;

View File

@@ -1,8 +1,13 @@
package com.czg.dto.req;
import com.alibaba.fastjson2.annotation.JSONField;
import com.czg.PayCst;
import com.czg.pay.PayNotifyRespDTO;
import lombok.Data;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
/**
* @author yjjie
* @date 2025/12/23 22:21
@@ -115,4 +120,38 @@ public class WechatPayNotifyDataDto {
public Long getPayAmount() {
return Long.valueOf(amount.getTotal());
}
public PayNotifyRespDTO convertToPayNotifyRespDTO() {
ZonedDateTime zonedDateTime = ZonedDateTime.parse(successTime);
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String time = zonedDateTime.format(outputFormatter);
PayNotifyRespDTO respDTO = new PayNotifyRespDTO()
.setMchOrderNo(outTradeNo)
.setThirdOrderNo(transactionId)
.setAmount(getPayAmount())
.setPlatform(PayCst.Platform.WECHAT)
.setExtData(attach)
.setPaySuccessTime(time)
.setErrorMsg(tradeStateDesc);
switch (tradeState) {
case "SUCCESS":
respDTO.setStatus("TRADE_SUCCESS");
break;
case "CLOSED":
respDTO.setStatus("TRADE_CLOSE");
break;
case "USERPAYING":
respDTO.setStatus("TRADE_AWAIT");
break;
case "NOTPAY":
respDTO.setStatus("TRADE_CANCEL");
break;
default:
respDTO.setStatus("TRADE_FAIL");
break;
}
return respDTO;
}
}

View File

@@ -9,13 +9,12 @@ import com.czg.dto.req.*;
import com.czg.dto.resp.EntryThirdRespDto;
import com.czg.dto.resp.QueryStatusResp;
import com.czg.exception.CzgException;
import com.czg.third.alipay.dto.AlipayAuthInfoDto;
import com.czg.pay.AlipayAuthInfoDto;
import com.czg.third.alipay.dto.config.AlipayConfigDto;
import com.czg.utils.UploadFileUtil;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.io.IOException;
/**
* 支付宝服务商进件管理

View File

@@ -5,12 +5,12 @@ import com.alipay.v3.ApiException;
import com.alipay.v3.api.AlipayTradeApi;
import com.alipay.v3.model.AlipayTradeCreateModel;
import com.alipay.v3.model.AlipayTradeCreateResponseModel;
import com.alipay.v3.model.AlipayTradePayModel;
import com.alipay.v3.model.ExtendParams;
import com.alipay.v3.util.model.CustomizedParams;
import com.czg.PayCst;
import com.czg.dto.req.PayParamsDto;
import com.czg.dto.req.RefundParamsDto;
import com.czg.exception.CzgException;
import com.czg.pay.*;
import com.czg.third.alipay.dto.config.AlipayConfigDto;
import lombok.extern.slf4j.Slf4j;
@@ -31,23 +31,23 @@ public class AlipayIsvPayManager {
* @param configDto 配置
* @param paramsDto 参数
*/
public static Map<String, Object> jsapiPay(AlipayConfigDto configDto, PayParamsDto paramsDto) {
public static Map<String, Object> jsapiPay(AlipayConfigDto configDto, CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
try {
AlipayClient.setApiClient(configDto);
AlipayTradeApi api = new AlipayTradeApi();
AlipayTradeCreateModel model = new AlipayTradeCreateModel();
model.setOutTradeNo(paramsDto.getOrderNo());
model.setOutTradeNo(paramsDto.getMchOrderNo());
model.setProductCode("JSAPI_PAY");
model.setOpAppId(paramsDto.getAppId());
model.setOpBuyerOpenId(paramsDto.getOpenId());
model.setOpAppId(merchantDTO.getAlipayMerchantId());
model.setOpBuyerOpenId(paramsDto.getUserId());
model.setTotalAmount(getYuanAmountByFen(paramsDto.getAmount()));
model.setSubject(paramsDto.getTitle());
model.setSubject(paramsDto.getSubject());
model.setBody(paramsDto.getBody());
model.setNotifyUrl(paramsDto.getNotifyUrl() + "/" + PayCst.Platform.ALIPAY);
model.setExtendParams(new ExtendParams());
CustomizedParams customizedParams = new CustomizedParams();
customizedParams.setAppAuthToken(paramsDto.getAlipayAuthInfo().getAppAuthToken());
customizedParams.setAppAuthToken(merchantDTO.getAlipayAuthInfo().getAppAuthToken());
AlipayTradeCreateResponseModel responseModel = api.create(model, customizedParams);
log.info("支付宝 jsapi 支付结果: {}", responseModel);
@@ -69,10 +69,26 @@ public class AlipayIsvPayManager {
* @param configDto 配置
* @param paramsDto 参数
*/
public static Map<String, Object> barPay(AlipayConfigDto configDto, PayParamsDto paramsDto) {
public static Map<String, Object> barPay(AlipayConfigDto configDto, CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
try {
AlipayClient.setApiClient(configDto);
// 构造请求参数以调用接口
AlipayTradeApi api = new AlipayTradeApi();
AlipayTradePayModel data = new AlipayTradePayModel();
data.setOutTradeNo(paramsDto.getMchOrderNo());
data.setTotalAmount(getYuanAmountByFen(paramsDto.getAmount()));
data.setSubject(paramsDto.getSubject());
// 设置支付授权码
data.setAuthCode(merchantDTO.getAlipayAuthInfo().getAppAuthToken());
// 设置支付场景
data.setScene("bar_code");
// 设置产品码
data.setProductCode("FACE_TO_FACE_PAYMENT");
data.setAuthCode(paramsDto.getAuthCode());
// AlipayTradeCreateResponseModel responseModel = api.create(data);
return new JSONObject();
// } catch (ApiException e) {
// String body = e.getResponseBody();
@@ -85,12 +101,12 @@ public class AlipayIsvPayManager {
}
}
public static Map<String, Object> queryOrder(AlipayConfigDto configDto, String orderNo, String subMerchantId) {
return new HashMap<>();
public static QueryOrderRespDTO queryOrder(AlipayConfigDto configDto, String orderNo, NativeMerchantDTO merchantDTO) {
return new QueryOrderRespDTO();
}
public static Map<String, Object> refundOrder(AlipayConfigDto configDto, RefundParamsDto paramsDto) {
return new HashMap<>();
public static RefundRespDTO refundOrder(AlipayConfigDto configDto, CzgRefundReq paramsDto, String notifyUrl, NativeMerchantDTO merchantDTO) {
return new RefundRespDTO();
}
/**

View File

@@ -15,9 +15,7 @@ import com.czg.third.wechat.dto.req.entry.*;
import com.czg.third.wechat.dto.req.entry.business.WechatEntryBusinessReqDto;
import com.czg.third.wechat.dto.req.entry.business.WechatEntryIdentityReqDto;
import com.czg.third.wechat.dto.req.entry.business.WechatEntryLicenseReqDto;
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryMiniProgramReqDto;
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntrySalesInfoReqDto;
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryStoreInfoReqDto;
import com.czg.third.wechat.dto.req.entry.business.sales.*;
import com.czg.third.wechat.dto.req.entry.id.WechatEntryIdCardReqDto;
import com.czg.third.wechat.dto.resp.WechatAuditDetail;
import com.czg.third.wechat.dto.resp.WechatQueryStateResp;
@@ -319,6 +317,9 @@ public class WechatEntryManager {
WechatEntryMiniProgramReqDto miniProgramInfo = new WechatEntryMiniProgramReqDto();
miniProgramInfo.setMiniProgramAppid("wxd88fffa983758a30");
salesInfo.setMiniProgramInfo(miniProgramInfo);
WechatEntryWebInfoReqDto webInfo = new WechatEntryWebInfoReqDto();
webInfo.setDomain("https://invoice.sxczgkj.cn/pay/");
salesInfo.setWebInfo(webInfo);
businessReqInfo.setSalesInfo(salesInfo);
entryParams.setBusinessInfo(businessReqInfo);

View File

@@ -5,9 +5,8 @@ import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.PayCst;
import com.czg.dto.req.PayParamsDto;
import com.czg.dto.req.RefundParamsDto;
import com.czg.exception.CzgException;
import com.czg.pay.*;
import com.czg.third.wechat.dto.config.WechatPayConfigDto;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.cipher.Signer;
@@ -45,31 +44,31 @@ public class WechatPayManager {
* @param configDto 配置
* @param paramsDto 参数
*/
public static Map<String, Object> jsapiPay(WechatPayConfigDto configDto, PayParamsDto paramsDto) {
public static Map<String, Object> jsapiPay(WechatPayConfigDto configDto, CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
if (configDto == null) {
configDto = WechatPayConfigDto.getDefaultConfig();
}
try {
JSONObject reqData = new JSONObject();
reqData.put("sp_appid", paramsDto.getAppId());
reqData.put("sp_appid", paramsDto.getSubAppid());
reqData.put("sp_mchid", configDto.getMerchantId());
reqData.put("sub_mchid", paramsDto.getMerchantId());
reqData.put("description", paramsDto.getTitle());
reqData.put("out_trade_no", paramsDto.getOrderNo());
reqData.put("sub_mchid", merchantDTO.getWechatMerchantId());
reqData.put("description", paramsDto.getSubject());
reqData.put("out_trade_no", paramsDto.getMchOrderNo());
reqData.put("notify_url", paramsDto.getNotifyUrl() + "/" + PayCst.Platform.WECHAT);
reqData.put("attach", paramsDto.getExtData());
reqData.put("attach", paramsDto.getExtParam());
JSONObject amount = new JSONObject();
amount.put("total", paramsDto.getAmount());
reqData.put("amount", amount);
JSONObject payer = new JSONObject();
payer.put("sp_openid", paramsDto.getOpenId());
payer.put("sp_openid", paramsDto.getUserId());
reqData.put("payer", payer);
String string = WechatReqUtils.postReq(configDto, "/v3/pay/partner/transactions/jsapi", reqData.toJSONString());
log.info("微信支付请求结果: orderNo = {}, res = {}", paramsDto.getOrderNo(), string);
log.info("微信支付请求结果: orderNo = {}, res = {}", paramsDto.getMchOrderNo(), string);
JSONObject object = JSONObject.parseObject(string);
@@ -77,23 +76,23 @@ public class WechatPayManager {
String nonceStr = NonceUtil.createNonce(32);
String packageVal = "prepay_id=" + object.getString("prepay_id");
String message =
paramsDto.getAppId() + "\n" + timestamp + "\n" + nonceStr + "\n" + packageVal + "\n";
paramsDto.getSubAppid() + "\n" + timestamp + "\n" + nonceStr + "\n" + packageVal + "\n";
Config config = WechatConfig.getRsaConfig(configDto);
Signer signer = config.createSigner();
String sign = signer.sign(message).getSign();
JSONObject res = new JSONObject();
res.put("appId", paramsDto.getAppId());
res.put("appId", paramsDto.getSubAppid());
res.put("timeStamp", String.valueOf(timestamp));
res.put("nonceStr", nonceStr);
res.put("package", packageVal);
res.put("signType", "RSA");
res.put("paySign", sign);
log.info("微信支付签名结果: orderNo = {}, res = {}", paramsDto.getOrderNo(), res);
log.info("微信支付签名结果: orderNo = {}, res = {}", paramsDto.getMchOrderNo(), res);
return res;
} catch (Exception e) {
log.error("微信支付异常: orderNo = {}, e = {}", paramsDto.getOrderNo(), e.getMessage());
log.error("微信支付异常: orderNo = {}, e = {}", paramsDto.getMchOrderNo(), e.getMessage());
throw new CzgException("微信支付异常");
}
}
@@ -105,7 +104,7 @@ public class WechatPayManager {
* @param configDto 配置
* @param paramsDto 参数
*/
public static Map<String, Object> barPay(WechatPayConfigDto configDto, PayParamsDto paramsDto) {
public static Map<String, Object> barPay(WechatPayConfigDto configDto, CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
try {
if (configDto == null) {
configDto = WechatPayConfigDto.getDefaultConfig();
@@ -119,28 +118,28 @@ public class WechatPayManager {
// 添加根元素
Element xml = document.addElement("xml");
addElementIfNotEmpty(xml, "appid", paramsDto.getAppId());
payMap.put("appid", paramsDto.getAppId());
addElementIfNotEmpty(xml, "appid", paramsDto.getSubAppid());
payMap.put("appid", paramsDto.getSubAppid());
addElementIfNotEmpty(xml, "mch_id", configDto.getMerchantId());
payMap.put("mch_id", configDto.getMerchantId());
addElementIfNotEmpty(xml, "sub_mch_id", paramsDto.getMerchantId());
payMap.put("sub_mch_id", paramsDto.getMerchantId());
addElementIfNotEmpty(xml, "sub_mch_id", merchantDTO.getWechatMerchantId());
payMap.put("sub_mch_id", merchantDTO.getWechatMerchantId());
addElementIfNotEmpty(xml, "nonce_str", nonceStr);
payMap.put("nonce_str", nonceStr);
addElementIfNotEmpty(xml, "body", paramsDto.getTitle());
payMap.put("body", paramsDto.getTitle());
addElementIfNotEmpty(xml, "out_trade_no", paramsDto.getOrderNo());
payMap.put("out_trade_no", paramsDto.getOrderNo());
addElementIfNotEmpty(xml, "body", paramsDto.getSubject());
payMap.put("body", paramsDto.getSubject());
addElementIfNotEmpty(xml, "out_trade_no", paramsDto.getMchOrderNo());
payMap.put("out_trade_no", paramsDto.getMchOrderNo());
addElementIfNotEmpty(xml, "total_fee", paramsDto.getAmount());
payMap.put("total_fee", paramsDto.getAmount());
addElementIfNotEmpty(xml, "spbill_create_ip", paramsDto.getClientIp());
payMap.put("spbill_create_ip", paramsDto.getClientIp());
addElementIfNotEmpty(xml, "auth_code", paramsDto.getBarCode());
payMap.put("auth_code", paramsDto.getBarCode());
addElementIfNotEmpty(xml, "auth_code", paramsDto.getAuthCode());
payMap.put("auth_code", paramsDto.getAuthCode());
if (StrUtil.isNotBlank(paramsDto.getExtData())) {
addElementIfNotEmpty(xml, "attach", paramsDto.getExtData());
payMap.put("attach", paramsDto.getExtData());
if (StrUtil.isNotBlank(paramsDto.getExtParam())) {
addElementIfNotEmpty(xml, "attach", paramsDto.getExtParam());
payMap.put("attach", paramsDto.getExtParam());
}
String sign = signBarPayParam(configDto, payMap);
@@ -154,10 +153,10 @@ public class WechatPayManager {
log.info("微信条码支付参数:{}", xmlStr);
String post = HttpUtil.post(BAR_PAY_URL, xmlStr);
log.info("微信条码支付请求结果: orderNo = {}, res = {}", paramsDto.getOrderNo(), post);
log.info("微信条码支付请求结果: orderNo = {}, res = {}", paramsDto.getMchOrderNo(), post);
JSONObject res = new JSONObject();
res.put("orderNo", paramsDto.getOrderNo());
res.put("orderNo", paramsDto.getMchOrderNo());
SAXReader saxReader = new SAXReader();
Document read = saxReader.read(stringToInputStream(post));
@@ -171,7 +170,7 @@ public class WechatPayManager {
if (StrUtil.isNotBlank(errCode)) {
if ("SYSTEMERROR".equals(errCode) || "BANKERROR".equals(errCode) || "USERPAYING".equals(errCode)) {
// 等待结果
log.info("微信条码支付等待结果: orderNo = {}, err {}", paramsDto.getOrderNo(), errCodeDes);
log.info("微信条码支付等待结果: orderNo = {}, err {}", paramsDto.getMchOrderNo(), errCodeDes);
res.put("status", "TRADE_AWAIT");
return res;
}
@@ -181,19 +180,19 @@ public class WechatPayManager {
}
if (!PAY_SUCCESS.equals(returnCode)) {
log.error("微信条码支付失败: orderNo = {}, msg = {}", paramsDto.getOrderNo(), rootElement.elementText("return_msg"));
log.error("微信条码支付失败: orderNo = {}, msg = {}", paramsDto.getMchOrderNo(), rootElement.elementText("return_msg"));
res.put("status", "TRADE_FAIL");
return res;
}
// 支付成功
log.info("微信条码支付成功: orderNo = {}, msg = {}", paramsDto.getOrderNo(), rootElement.elementText("return_msg"));
log.info("微信条码支付成功: orderNo = {}, msg = {}", paramsDto.getMchOrderNo(), rootElement.elementText("return_msg"));
res.put("status", "TRADE_SUCCESS");
return res;
} catch (CzgException e) {
throw e;
} catch (Exception e) {
log.error("微信条码支付异常: orderNo = {}, e = {}", paramsDto.getOrderNo(), e.getMessage());
log.error("微信条码支付异常: orderNo = {}, e = {}", paramsDto.getMchOrderNo(), e.getMessage());
throw new CzgException("微信支付异常");
}
}
@@ -203,7 +202,7 @@ public class WechatPayManager {
*
* @param configDto 配置
* @param orderNo 订单号
* @param subMerchantId 子商户号
* @param merchantDTO 支付商户信息
* SUCCESS支付成功
* REFUND转入退款
* NOTPAY未支付
@@ -212,34 +211,35 @@ public class WechatPayManager {
* USERPAYING用户支付中仅付款码支付会返回
* PAYERROR支付失败仅付款码支付会返回
*/
public static Map<String, Object> queryOrder(WechatPayConfigDto configDto, String orderNo, String subMerchantId) {
public static QueryOrderRespDTO queryOrder(WechatPayConfigDto configDto, String orderNo, NativeMerchantDTO merchantDTO) {
try {
if (configDto == null) {
configDto = WechatPayConfigDto.getDefaultConfig();
}
String resp = WechatReqUtils.getReq(configDto, "/v3/pay/partner/transactions/out-trade-no/" + orderNo,
Map.of("sp_mchid", configDto.getMerchantId(), "sub_mchid", subMerchantId));
Map.of("sp_mchid", configDto.getMerchantId(), "sub_mchid", merchantDTO.getWechatMerchantId()));
log.info("微信查询订单,订单号:{} 响应:{}", orderNo, resp);
JSONObject res = new JSONObject();
res.put("orderNo", orderNo);
QueryOrderRespDTO queryOrderRespDTO = new QueryOrderRespDTO()
.setOrderNo(orderNo)
.setOriginResp(resp);
JSONObject object = JSONObject.parseObject(resp);
String tradeState = object.getString("trade_state");
res.put("message", object.getString("trade_state_desc"));
queryOrderRespDTO.setErrorMsg(object.getString("trade_state_desc"));
if (PAY_SUCCESS.equals(tradeState)) {
res.put("status", "TRADE_SUCCESS");
return res;
queryOrderRespDTO.setStatus("TRADE_SUCCESS");
return queryOrderRespDTO;
}
if ("USERPAYING".equals(tradeState)) {
res.put("status", "TRADE_AWAIT");
return res;
queryOrderRespDTO.setStatus("TRADE_AWAIT");
return queryOrderRespDTO;
}
res.put("status", "TRADE_FAIL");
return res;
queryOrderRespDTO.setStatus("TRADE_FAIL");
return queryOrderRespDTO;
} catch (Exception e) {
log.error("微信查询订单异常: orderNo = {}, e = {}", orderNo, e.getMessage());
throw new CzgException("微信查询订单异常");
@@ -256,64 +256,69 @@ public class WechatPayManager {
* PROCESSING: 退款处理中
* ABNORMAL: 退款异常,退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往服务商平台-交易中心,手动处理此笔退款
*/
public static Map<String, Object> refundOrder(WechatPayConfigDto configDto, RefundParamsDto paramsDto) {
public static RefundRespDTO refundOrder(WechatPayConfigDto configDto, CzgRefundReq paramsDto, String notifyUrl, NativeMerchantDTO merchantDTO) {
try {
if (configDto == null) {
configDto = WechatPayConfigDto.getDefaultConfig();
}
JSONObject refundParam = new JSONObject();
refundParam.put("sub_mchid", paramsDto.getMerchantId());
refundParam.put("out_trade_no", paramsDto.getOrderNo());
refundParam.put("out_refund_no", paramsDto.getRefundOrderNo());
refundParam.put("sub_mchid", merchantDTO.getWechatMerchantId());
refundParam.put("out_trade_no", paramsDto.getMchOrderNo());
refundParam.put("out_refund_no", paramsDto.getMchRefundNo());
refundParam.put("reason", paramsDto.getRefundReason());
refundParam.put("notify_url", paramsDto.getRefundNotifyUrl() + "/" + PayCst.Platform.WECHAT);
refundParam.put("notify_url", notifyUrl + "/" + PayCst.Platform.WECHAT);
JSONObject amount = new JSONObject();
amount.put("total", paramsDto.getOrderAmount());
amount.put("total", paramsDto.getOrderTotalAmount());
amount.put("refund", paramsDto.getRefundAmount());
amount.put("currency", "CNY");
refundParam.put("amount", amount);
String resp = WechatReqUtils.postReq(configDto, "/v3/refund/domestic/refunds", refundParam.toJSONString());
log.info("微信退款,订单号:{} 响应:{}", paramsDto.getOrderNo(), resp);
log.info("微信退款,订单号:{} 响应:{}", paramsDto.getMchOrderNo(), resp);
JSONObject object = JSONObject.parseObject(resp);
JSONObject res = new JSONObject();
res.put("mchRefundNo", object.getString("out_refund_no"));
res.put("refundOrderId", object.getString("refund_id"));
res.put("oriPayOrderId", object.getString("out_trade_no"));
res.put("mercNo", paramsDto.getMerchantId());
res.put("refundReason", paramsDto.getRefundReason());
res.put("payType", PayCst.Platform.WECHAT);
res.put("refundTime", object.getString("success_time"));
switch (object.getString("status")) {
case "SUCCESS":
res.put("status", "SUCCESS");
break;
case "CLOSED":
res.put("status", "CLOSED");
break;
case "PROCESSING":
res.put("status", "ING");
break;
case "ABNORMAL":
res.put("status", "INIT");
break;
default:
res.put("status", "FAIL");
break;
}
JSONObject resAmount = object.getJSONObject("amount");
if (resAmount != null) {
res.put("refundAmt", resAmount.getLong("refund"));
res.put("oriAmount", resAmount.getLong("total"));
String code = object.getString("code");
String status = object.getString("status");
if ("INVALID_REQUEST".equalsIgnoreCase(code) || StrUtil.isNotBlank(status)) {
throw new CzgException("微信退款失败:" + object.getString("message"));
}
return res;
RefundRespDTO respDTO = new RefundRespDTO()
.setMerchantRefundNo(object.getString("out_refund_no"))
.setThirdRefundNo(object.getString("refund_id"))
.setRefundTime(object.getString("success_time"))
.setOriginalData(resp)
.setPlatform(PayCst.Platform.WECHAT);
JSONObject resAmount = object.getJSONObject("amount");
if (resAmount != null) {
respDTO.setRefundAmount(resAmount.getLong("refund"));
}
switch (status) {
case "SUCCESS":
case "PROCESSING":
respDTO.setStatus("SUCCESS");
break;
case "CLOSED":
respDTO.setStatus("CLOSED");
break;
case "ABNORMAL":
respDTO.setStatus("INIT");
break;
default:
respDTO.setStatus("FAIL");
break;
}
return respDTO;
} catch (CzgException e) {
throw e;
} catch (Exception e) {
log.error("微信退款异常: orderNo = {}, e = {}", paramsDto.getOrderNo(), e.getMessage());
log.error("微信退款异常: orderNo = {} ", paramsDto.getMchOrderNo(), e);
throw new CzgException("微信退款异常");
}
}
@@ -368,13 +373,13 @@ public class WechatPayManager {
// Map<String, Object> sss1 = queryOrder(null, "sa101293120sss1", "1738216504");
// System.out.println(sss1);
refundOrder(null, new RefundParamsDto()
.setMerchantId("1738216504")
.setOrderNo("sa101293120sss1")
.setRefundOrderNo("sa101293120sss1")
.setOrderAmount(1L)
.setRefundAmount(1L)
.setRefundReason("测试")
.setRefundNotifyUrl("https://www.baidu.com"));
// refundOrder(null, new RefundParamsDto()
// .setMerchantId("1738216504")
// .setOrderNo("sa101293120sss1")
// .setRefundOrderNo("sa101293120sss1")
// .setOrderAmount(1L)
// .setRefundAmount(1L)
// .setRefundReason("测试")
// .setRefundNotifyUrl("https://www.baidu.com"));
}
}

View File

@@ -56,7 +56,6 @@ public class WechatPayConfigDto {
return new WechatPayConfigDto()
.setMerchantId("1643779408")
.setApiV3Key("a92baac5eb7a36ed8ec198113e769a03")
.setApiV2Key("3caf37225b6ea77a624ee03b7e3d03bb")
.setSerialNumber("4DE9BAC2EA584C3F274F694C9753CA814C4E9BF4")
.setPublicKey("""
-----BEGIN PUBLIC KEY-----

View File

@@ -1,124 +0,0 @@
package com.czg.entity.req;
import lombok.Data;
import lombok.NonNull;
/**
* @author ww
*/
@Data
public class CzgBaseReq {
//必填范围
/**
* 订单标题
*/
private String subject;
/**
* 订单描述 String(256)
*/
private String body;
/**
* 交易金额
*/
private Long amount;
/**
* 货币类型 cny
*/
private String currency = "cny";
/**
* 商户订单号 String(30)
* 操作方式+雪花算法
* 收银机客户端 PC+雪花ID
* 微信小程序 WX+雪花ID
* 支付宝小程序 ALI+雪花ID
* PC管理端 WEB+雪花ID
* APP管理端 APP+雪花ID
* <p>
* 退款 re+雪花ID
*/
private String mchOrderNo;
/**
* 门店编号 tb_shop_merchant 的 store_id
*/
private String storeId;
//非必填项
/**
* 订单备注 String(50)
*/
private String buyerRemark;
/**
* 异步通知地址 String(128)
* 支付结果异步回调URL,只有传了该值才会发起回调
*/
private String notifyUrl;
/**
* 失效时间 int 15
* 订单失效时间,单位分钟,默认15小时.
* 取值范围 5-1440 分钟
* 订单在(创建时间+失效时间)后失效
*/
private Integer expiredTime;
/**
* 分账模式:
* 0-该笔订单不允许分账[默认],
* 1-实时分账
* 2-延时分账
*/
private Integer divisionMode;
/**
* 分账详情
*/
private String divisionDetail;
/**
* 扩展参数 String(512)
* 商户扩展参数,回调时会原样返回
* * 扩展参数
* * {
* * "pay_type": "order/vip"
* * }
*/
private String extParam;
/**
* 花呗分期数
* 支付宝交易时可传 而且金额需要大于或等于 100.00元时生效
* 3/6/12
*/
private Integer hbFqNum;
/**
* 卖家是否承担手续费
* 100卖家承担手续费
* 0买家承担手续费
*/
private Integer hbFqPercent;
/**
* 是否禁用信用卡
* -1不禁用 1禁用
* 不传默认为不限制
*/
private Integer limitPay;
public CzgBaseReq() {
}
public CzgBaseReq(String mchOrderNo, Long amount, String body,
String buyerRemark, String extParam) {
this.mchOrderNo = mchOrderNo;
this.body = body;
this.amount = amount;
this.buyerRemark = buyerRemark;
this.extParam = extParam;
}
public void assignMerchant(@NonNull String storeId, @NonNull String subject, @NonNull String notifyUrl) {
this.storeId = storeId;
this.subject = subject;
this.notifyUrl = notifyUrl;
}
}

View File

@@ -1,39 +0,0 @@
package com.czg.entity.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
/**
* h5支付请求参数
*
* @author ww
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class CzgH5PayReq extends CzgBaseReq {
//必填范围
/**
* 用户IP 支付的用户IP
*/
private String clientIp;
private String payType;
//?
private String openId;
//非必填范围
/**
* 跳转通知地址
* 支付结果同步跳转通知URL
*/
private String returnUrl;
public CzgH5PayReq(@NonNull String mchOrderNo, @NonNull Long amount, String body, @NonNull String clientIp,
String returnUrl, String buyerRemark, @NonNull String extParam) {
super(mchOrderNo, amount, body, buyerRemark, extParam);
this.clientIp = clientIp;
this.returnUrl = returnUrl;
}
}

View File

@@ -1,71 +0,0 @@
package com.czg.entity.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
/**
* 公众号/生活号/银联js支付
*
* @author ww
* <p>
* ● 码牌、台卡、立牌等
* 用户通过扫描微信/支付宝/云闪付APP静态二维码输入订单金额进行付款动作。
* ● 公众号 / 生活号商城
* 用户通过公众号下单,输入密码完成付款动作。适用于自有公众号主体交易
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class CzgJsPayReq extends CzgBaseReq {
//必填范围
/**
* 用户唯一标识 String(30)
* 微信支付时传入用户的openId
* 支付宝支付和银联支付时传入用户的userId
*/
private String userId;
/**
* 用户IP
* 需要传付款用户客户端IP地址
*/
private String clientIp;
/**
* 微信 WECHAT
* 支付宝 ALIPAY
* 银联云闪付 UNIONPAY
*/
private String payType;
//非必填范围
/**
* 子商户appid ,微信付款支付的时候 需要上送
*/
private String subAppid;
/**
* 跳转通知地址
* 支付结果同步跳转通知URL
*/
private String returnUrl;
/**
* 银联js支付成功前端跳转
*/
private String frontUrl;
/**
* 银联js支付失败前端跳转地址
*/
private String frontFailUrl;
public CzgJsPayReq(@NonNull String mchOrderNo,
@NonNull Long amount, String body,
@NonNull String openId, @NonNull String clientIp,
String returnUrl, String buyerRemark,@NonNull String extParam) {
super(mchOrderNo, amount, body, buyerRemark, extParam);
this.userId = openId;
this.clientIp = clientIp;
this.returnUrl = returnUrl;
}
}

View File

@@ -1,63 +0,0 @@
package com.czg.entity.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
/**
* 小程序支付
*
* @author ww
* 自有小程序拉起支付
* 自有小程序拉起服务商小程序,(微信)半屏小程序支付
* 半屏小程序需要在商户自己的小程序中的半屏小程序配置里面申请 否则会拉起全屏小程序支付
* <p>
* 半屏小程序支付适用场景是商户自己的小程序被纳入微信实物电商类型小程序导致间联商户无法绑定这类的小程序APPID
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class CzgLtPayReq extends CzgBaseReq {
//必填范围
/**
* 用户唯一标识 String(30)
* 微信支付时,传入用户的 openId
* 支付宝支付和银联支付时,传入用户的 userId
*/
private String userId;
private String payType;
/**
* 用户 IP 支付的用户 IP
*/
private String clientIp;
//非必填范围
/**
* 跳转通知地址
* 支付结果同步跳转通知 URL
*/
private String returnUrl;
/**
* 子商户 appid ,微信付款支付的时候 需要上送
* isScreen 为 false 的情况下需要传入
*/
private String subAppid;
/**
* 是否半屏
* 是否使用半屏小程序,默认为 false
* 前提小程序被纳入了实物电商类型的小程序,间联商户无法绑定这类的小程序的 appid
*/
private boolean isScreen;
public CzgLtPayReq(@NonNull String mchOrderNo, @NonNull Long amount, @NonNull String payType,
String body, @NonNull String openId, @NonNull String clientIp,
String returnUrl, String buyerRemark, @NonNull String extParam) {
super(mchOrderNo, amount, body, buyerRemark, extParam);
this.userId = openId;
this.payType = "aliPay".equals(payType) ? "ALIPAY" : "WECHAT";
this.clientIp = clientIp;
this.returnUrl = returnUrl;
}
}

View File

@@ -1,37 +0,0 @@
package com.czg.entity.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
/**
* 反扫请求参数
*
* @author ww
* <p>
* 被扫免密同步返回支付结果,不推送异步通知。
* 被扫输密,推送异步通知。
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class CzgMicroPayReq extends CzgBaseReq {
//必填范围
/**
* 付款码信息 String(30)
* 扫码设备获取微信或支付宝上付款的信息
*/
private String authCode;
//非必填范围
/**
* 子商户appid ,微信付款支付的时候 需要上送
*/
private String subAppid;
public CzgMicroPayReq(@NonNull String mchOrderNo, @NonNull Long amount, String body,
@NonNull String authCode, String buyerRemark, @NonNull String extParam) {
super(mchOrderNo, amount, body, buyerRemark, extParam);
this.authCode = authCode;
}
}

View File

@@ -1,35 +0,0 @@
package com.czg.entity.req;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
/**
* 正扫支付请求参数
*
* @author ww
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class CzgScanPayReq extends CzgBaseReq {
// 必填项
/**
* 用户IP 支付的用户IP
*/
private String clientIp;
//非必填项
/**
* 跳转通知地址
* String(128)
*/
private String returnUrl;
public CzgScanPayReq(@NonNull String mchOrderNo, @NonNull Long amount, String body,
@NonNull String clientIp, String returnUrl, String buyerRemark, @NonNull String extParam) {
super(mchOrderNo, amount, body, buyerRemark, extParam);
this.clientIp = clientIp;
this.returnUrl = returnUrl;
}
}

View File

@@ -9,7 +9,7 @@
<version>1.0.0</version>
</parent>
<artifactId>czg-pay</artifactId>
<artifactId>poly-pay</artifactId>
<properties>
<maven.compiler.source>21</maven.compiler.source>

View File

@@ -8,11 +8,14 @@ import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.TypeReference;
import com.czg.entity.CzgBaseReqParams;
import com.czg.entity.CzgBaseRespParams;
import com.czg.entity.req.*;
import com.czg.entity.PolyBaseReq;
import com.czg.entity.PolyBaseResp;
import com.czg.entity.notify.CzgPayNotifyDTO;
import com.czg.entity.resp.*;
import com.czg.enums.CzgPayEnum;
import com.czg.pay.CzgPayBaseReq;
import com.czg.pay.CzgRefundReq;
import com.czg.pay.PayNotifyRespDTO;
import com.czg.resp.CzgRespCode;
import com.czg.resp.CzgResult;
import com.czg.utils.AssertUtil;
@@ -26,10 +29,10 @@ import java.util.stream.Collectors;
/**
* @author ww
* @description 超掌柜支付类
* @description 聚合支付类
*/
@Slf4j
public class CzgPayUtils {
public class PolyPayUtils {
/**
* h5支付
@@ -39,8 +42,8 @@ public class CzgPayUtils {
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
* CzgResult<CzgH5PayResp>
*/
public static CzgResult<Map<String, Object>> h5Pay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgH5PayReq bizData) {
return execPayResult(sendCzg(domain.concat(CzgPayEnum.H5PAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgH5PayResp.class));
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));
}
/**
@@ -51,8 +54,8 @@ public class CzgPayUtils {
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
* CzgResult<CzgJsPayResp>
*/
public static CzgResult<Map<String, Object>> jsPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgJsPayReq bizData) {
return execPayResult(sendCzg(domain.concat(CzgPayEnum.JSPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgJsPayResp.class));
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));
}
/**
@@ -63,8 +66,8 @@ public class CzgPayUtils {
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
* CzgResult<CzgLtPayResp>
*/
public static CzgResult<Map<String, Object>> ltPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgLtPayReq bizData) {
return execPayResult(sendCzg(domain.concat(CzgPayEnum.LTPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgLtPayResp.class));
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));
}
/**
@@ -75,8 +78,8 @@ public class CzgPayUtils {
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
* CzgResult<CzgScanPayResp>
*/
public static CzgResult<Map<String, Object>> scanPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgScanPayReq bizData) {
return execPayResult(sendCzg(domain.concat(CzgPayEnum.SCANPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgScanPayResp.class));
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));
}
/**
@@ -87,8 +90,8 @@ public class CzgPayUtils {
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
* CzgResult<CzgMicroPayResp>
*/
public static CzgResult<Map<String, Object>> microPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgMicroPayReq bizData) {
return execPayResult(sendCzg(domain.concat(CzgPayEnum.MICROPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgMicroPayResp.class));
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));
}
/**
@@ -105,7 +108,7 @@ public class CzgPayUtils {
JSONObject queryPayOrder = new JSONObject();
queryPayOrder.put("payOrderId", payOrderId);
queryPayOrder.put("mchOrderNo", mchOrderNo);
return sendCzg(domain.concat(CzgPayEnum.TRADE.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, queryPayOrder), CzgBaseResp.class);
return sendPolyPay(domain.concat(CzgPayEnum.TRADE.getUri()), PolyBaseReq.getInstance(appId, appSecret, queryPayOrder), CzgBaseResp.class);
}
@@ -117,7 +120,7 @@ public class CzgPayUtils {
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
*/
public static CzgResult<CzgRefundResp> refundOrder(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgRefundReq bizData) {
return sendCzg(domain.concat(CzgPayEnum.REFUND.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgRefundResp.class);
return sendPolyPay(domain.concat(CzgPayEnum.REFUND.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgRefundResp.class);
}
/**
@@ -134,29 +137,55 @@ public class CzgPayUtils {
JSONObject queryPayOrder = new JSONObject();
queryPayOrder.put("mchRefundNo", mchRefundNo);
queryPayOrder.put("refundOrderId", refundOrderId);
return sendCzg(domain.concat(CzgPayEnum.QUERY_REFUND.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, queryPayOrder), CzgRefundResp.class);
return sendPolyPay(domain.concat(CzgPayEnum.QUERY_REFUND.getUri()), PolyBaseReq.getInstance(appId, appSecret, queryPayOrder), CzgRefundResp.class);
}
/**
* 回调数据处理
*/
public static JSONObject getCzg(CzgBaseRespParams respParams) {
AssertUtil.isNull(respParams, "超掌柜交易 回调数据为空");
log.info("超掌柜交易请求响应,{}", respParams);
public static JSONObject getCzg(PolyBaseResp respParams) {
AssertUtil.isNull(respParams, "聚合交易 回调数据为空");
log.info("聚合交易请求响应,{}", respParams);
if (!"000000".equals(respParams.getCode())) {
log.error("超掌柜回调响应失败,{}", respParams);
log.error("聚合回调响应失败,{}", respParams);
return null;
}
// if (StrUtil.isNotBlank(respParams.getSign())) {
// if (validateSign(respParams.getSign(), respParams.getBizData())) {
// log.error("超掌柜回调 验签失败");
// log.error("聚合回调 验签失败");
// }
// }
return JSONObject.parse(respParams.getBizData());
}
/**
* 回调数据处理
*/
public static PayNotifyRespDTO getNotifyResp(PolyBaseResp respParams) {
AssertUtil.isNull(respParams, "聚合交易 回调数据为空");
log.info("聚合交易请求响应,{}", respParams);
if (!"000000".equals(respParams.getCode())) {
log.error("聚合回调响应失败,{}", respParams);
return null;
}
CzgPayNotifyDTO dto = JSONObject.parseObject(respParams.getBizData(), CzgPayNotifyDTO.class);
return new PayNotifyRespDTO()
.setMchOrderNo(dto.getMchOrderNo())
.setThirdOrderNo(dto.getPayOrderId())
.setAmount(dto.getAmount())
.setPlatform(dto.getPayType())
.setExtData(dto.getExtParam())
.setPaySuccessTime(dto.getPayTime())
.setErrorMsg("")
.setStatus(dto.getState())
.setOriginalData(respParams.getBizData());
}
/**
* 默认Post
*
@@ -168,19 +197,19 @@ public class CzgPayUtils {
* "data": "返回Json数据",
* }
*/
private static <T> CzgResult<T> sendCzg(String url, CzgBaseReqParams params, Class<T> clazz) {
private static <T> CzgResult<T> sendPolyPay(String url, PolyBaseReq params, Class<T> clazz) {
CzgResult<T> result = CzgResult.success();
Map<String, Object> reqMap = BeanUtil.beanToMap(params, false, false);
params.setSign(MD5.create().digestHex(sortFields(new TreeMap<>(reqMap))));
log.info("超掌柜交易请求参数,{}", JSONObject.toJSONString(params));
log.info("聚合交易请求参数,{}", JSONObject.toJSONString(params));
try (HttpResponse resp = HttpRequest.post(url).body(JSONObject.toJSONString(params)).execute()) {
if (resp.isOk()) {
// 获取响应体
String respStr = resp.body();
if (StrUtil.isNotEmpty(respStr)) {
log.info("超掌柜交易请求响应元数据,{}", respStr);
CzgBaseRespParams respParams = JSONObject.parseObject(respStr, CzgBaseRespParams.class);
log.info("超掌柜交易请求响应,{}", respParams);
log.info("聚合交易请求响应元数据,{}", respStr);
PolyBaseResp respParams = JSONObject.parseObject(respStr, PolyBaseResp.class);
log.info("聚合交易请求响应,{}", respParams);
result.setCode("000000".equals(respParams.getCode()) ? 200 : Integer.parseInt(respParams.getCode()));
result.setMsg(respParams.getMsg());
@@ -194,15 +223,15 @@ public class CzgPayUtils {
}
} else {
result.setCode(resp.getStatus());
result.setMsg("超掌柜交易请求失败");
log.error("超掌柜交易请求失败,状态码: {}", resp.getStatus());
result.setMsg("聚合交易请求失败");
log.error("聚合交易请求失败,状态码: {}", resp.getStatus());
}
} else {
result.setCode(resp.getStatus());
result.setMsg("超掌柜交易请求失败");
result.setMsg("聚合交易请求失败");
}
} catch (Exception e) {
log.error("超掌柜交易请求异常", e);
log.error("聚合交易请求异常", e);
}
return result;
}
@@ -221,7 +250,7 @@ public class CzgPayUtils {
private static String sortFields(TreeMap<String, Object> map) {
if (CollectionUtil.isEmpty(map)) {
log.error("超掌柜支付参数为空!!!");
log.error("聚合支付参数为空!!!");
throw new RuntimeException("参数为空");
}
String sortParam = map.entrySet().stream()

View File

@@ -12,7 +12,7 @@ import lombok.Data;
* @author ww
*/
@Data
public class CzgBaseReqParams {
public class PolyBaseReq {
/**
* 应用ID tb_shop_merchant 表中的 app_id
@@ -69,7 +69,7 @@ public class CzgBaseReqParams {
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
* @param bizData JSON 形式的字符串
*/
public CzgBaseReqParams(String appId, String bizData, String appSecret) {
public PolyBaseReq(String appId, String bizData, String appSecret) {
this.appId = appId;
this.bizData = bizData;
this.appSecret = appSecret;
@@ -82,8 +82,8 @@ public class CzgBaseReqParams {
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
* @param bizData JSON 形式的字符串
*/
public static CzgBaseReqParams getInstance(String appId, String appSecret, Object bizData) {
return new CzgBaseReqParams(appId, ObjectUtil.isNotEmpty(bizData) ? JSONObject.toJSONString(bizData) : "", appSecret);
public static PolyBaseReq getInstance(String appId, String appSecret, Object bizData) {
return new PolyBaseReq(appId, ObjectUtil.isNotEmpty(bizData) ? JSONObject.toJSONString(bizData) : "", appSecret);
}
}

View File

@@ -6,7 +6,7 @@ import lombok.Data;
* @author ww
*/
@Data
public class CzgBaseRespParams {
public class PolyBaseResp {
/**

View File

@@ -8,11 +8,11 @@ import lombok.Getter;
@Getter
public enum CzgPayEnum {
SCANPAY("/api/open/payment/scanpay", "PC扫码支付"),
MICROPAY("/api/open/payment/micropay", "聚合反扫B扫C/ 快捷收款"),
JSPAY("/api/open/payment/jspay", "公众号/生活号/银联js支付"),
LTPAY("/api/open/payment/ltpay", "小程序支付"),
H5PAY("/api/open/payment/h5pay", "手机网页支付"),
SCAN_PAY("/api/open/payment/scanpay", "PC扫码支付"),
MICRO_PAY("/api/open/payment/micropay", "聚合反扫B扫C/ 快捷收款"),
JS_PAY("/api/open/payment/jspay", "公众号/生活号/银联js支付"),
LT_PAY("/api/open/payment/ltpay", "小程序支付"),
H5_PAY("/api/open/payment/h5pay", "手机网页支付"),
TRADE("/api/open/query/trade", "订单状态查询"),
REFUND("/api/open/order/refund", "统一退款 D0退款需要使用平台户退款"),

View File

@@ -12,7 +12,7 @@
<name>third sdk</name>
<description>第三方内容</description>
<modules>
<module>czg-pay</module>
<module>poly-pay</module>
<module>aggregation-pay</module>
</modules>
<artifactId>cash-sdk</artifactId>
@@ -29,5 +29,10 @@
<artifactId>cash-common-tools</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.czg</groupId>
<artifactId>cash-common-service</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -29,6 +29,7 @@ import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.io.ByteArrayOutputStream;
import java.util.*;
@@ -41,7 +42,7 @@ import java.util.stream.Collectors;
* @author zs
* @since 2025-02-21
*/
@DubboService
@Service
public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable> implements CallTableService {
@DubboReference
private SysParamsService sysParamsService;

View File

@@ -1,11 +0,0 @@
package com.czg.service.account.service.impl;
import com.czg.account.service.PermissionService;
import org.springframework.stereotype.Service;
/**
* @author zs
*/
@Service
public class PermissionServiceImpl implements PermissionService {
}

View File

@@ -253,6 +253,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
@Override
@CacheEvict(key = "#shopInfoEditDTO.id")
public Boolean edit(ShopInfoEditDTO shopInfoEditDTO) {
shopInfoEditDTO.setIsMemberPrice(null);
ShopInfo shopInfo;
if (!StpKit.USER.isAdmin()) {
shopInfo = queryChain().eq(ShopInfo::getId, StpKit.USER.getShopId()).one();
@@ -319,21 +320,9 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
rabbitPublisher.sendOrderDetailStatusMsg(shopInfo.getId().toString(), "shopInfoUpdate");
return true;
}
return false;
}
@Override
@CacheEvict(key = "#shopId")
public Boolean editEntry(Long shopId, String wechatMerchantId, String alipayMerchantId, String alipayAuthInfo) {
ShopInfo shopInfo = new ShopInfo();
shopInfo.setWechatMerchantId(wechatMerchantId);
shopInfo.setAlipayMerchantId(alipayMerchantId);
shopInfo.setAlipayAuthInfo(alipayAuthInfo);
return update(shopInfo, new QueryWrapper().eq(ShopInfo::getId, shopId));
}
@Override
public ShopDetailDTO detail(Long id) throws CzgException {
ShopInfo shopInfo = queryChain().eq(ShopInfo::getId, id == null ? StpKit.USER.getShopId() : id).one();

View File

@@ -1,55 +0,0 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.czg.account.dto.merchant.ShopMerchantEditDTO;
import com.czg.account.entity.ShopMerchant;
import com.czg.account.service.ShopMerchantService;
import com.czg.sa.StpKit;
import com.czg.service.account.mapper.ShopMerchantMapper;
import com.czg.utils.AssertUtil;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import java.io.Serializable;
/**
* 第三方商户进件 服务层实现。
*
* @author Administrator
* @since 2025-02-11
*/
@CacheConfig(cacheNames = "shop:merchant")
@DubboService
public class ShopMerchantServiceImpl extends ServiceImpl<ShopMerchantMapper, ShopMerchant> implements ShopMerchantService {
@Override
public ShopMerchant detail(Integer shopId) {
ShopMerchant one = queryChain().eq(ShopMerchant::getShopId, shopId).one();
return one == null ? new ShopMerchant() : one;
}
@CacheEvict(key = "#shopMerchantEditDTO.shopId")
@Override
public Boolean edit(ShopMerchantEditDTO shopMerchantEditDTO) {
ShopMerchant shopMerchant = queryChain().eq(ShopMerchant::getShopId, shopMerchantEditDTO.getShopId()).one();
if (shopMerchant == null) {
shopMerchant = new ShopMerchant();
shopMerchant.setShopId(shopMerchantEditDTO.getShopId());
BeanUtil.copyProperties(shopMerchantEditDTO, shopMerchant);
return save(shopMerchant);
}
BeanUtil.copyProperties(shopMerchantEditDTO, shopMerchant);
return updateById(shopMerchant);
}
@Cacheable(key = "#id")
@Override
public ShopMerchant getById(Serializable id) {
ShopMerchant shopMerchant = getMapper().selectOneById(id);
AssertUtil.isNull(shopMerchant, "暂未开通支付");
return shopMerchant;
}
}

View File

@@ -18,9 +18,8 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.czg</groupId>
<artifactId>pay-service</artifactId>
<version>1.0.0</version>
<groupId>com.github.javen205</groupId>
<artifactId>IJPay-All</artifactId>
</dependency>
<dependency>

View File

@@ -1,12 +1,12 @@
package com.czg.service.market.service.impl;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.constants.ParamCodeCst;
import com.czg.exception.CzgException;
import com.czg.service.RedisService;
import com.czg.system.service.SysParamsService;
import com.ijpay.core.kit.RsaKit;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
@@ -14,7 +14,6 @@ import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.Set;
/**
* 微信支付service
@@ -80,7 +79,7 @@ public class AppWxServiceImpl extends BaseWx {
// api支付证书公钥
config.apiCert = payKeyMap.get(ParamCodeCst.Wechat.Pay.WX_API_CLIENT_CERT);
try {
config.privateKey = RsaKit.loadPrivateKey(config.apiCertKey);
config.privateKey = SecureUtil.rsa(config.apiCertKey, null).getPrivateKey();
} catch (Exception e) {
log.warn("微信加载api证书失败");
}
@@ -98,10 +97,6 @@ public class AppWxServiceImpl extends BaseWx {
config.refundNotifyUrl = "";
config.transferNotifyUrl = payKeyMap.get(ParamCodeCst.System.NATIVE_NOTIFY_URL) + "/wx/transfer";
}
public BaseWx getAppService() {
return this;
}
}

View File

@@ -26,8 +26,6 @@ import com.czg.market.vo.InviteUserVO;
import com.czg.market.vo.MkDistributionConfigVO;
import com.czg.order.dto.MkDistributionPayDTO;
import com.czg.order.entity.OrderInfo;
import com.czg.market.service.OrderInfoService;
import com.czg.order.service.OrderPaymentService;
import com.czg.sa.StpKit;
import com.czg.service.market.enums.OrderStatusEnums;
import com.czg.service.market.mapper.MkDistributionUserMapper;
@@ -685,22 +683,15 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
.ne(MkDistributionFlow::getStatus, TableValueConstant.DistributionFlow.Status.REFUND.getCode()));
list.forEach(item -> {
MkDistributionFlow refundFlow = BeanUtil.copyProperties(item, MkDistributionFlow.class);
refundFlow.setStatus(TableValueConstant.DistributionFlow.Status.REFUND.getCode());
refundFlow.setSourceId(item.getId());
refundFlow.setId(null);
refundFlow.setCreateTime(DateUtil.date().toLocalDateTime());
refundFlow.setUpdateTime(DateUtil.date().toLocalDateTime());
if (TableValueConstant.DistributionFlow.Status.PENDING.getCode().equals(item.getStatus())) {
item.setStatus(TableValueConstant.DistributionFlow.Status.SUCCESS.getCode());
// updateIncome(item.getRewardAmount().negate(), BigDecimal.ZERO, BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel());
item.setStatus(TableValueConstant.DistributionFlow.Status.REFUND.getCode());
distributionFlowService.updateById(item);
mapper.updateIncome(item.getRewardAmount().negate(), null, null, item.getDistributionUserId(), item.getShopId());
} else {
// 执行扣款
updateIncome(BigDecimal.ZERO, item.getRewardAmount().negate(), BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel());
updateShopInfoAmount(item.getShopId(), item.getRewardAmount(), orderId, TableValueConstant.DistributionAmountFlow.Type.REFUND, "分销回退");
}
distributionFlowService.save(refundFlow);
});
}
@@ -738,6 +729,13 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
distributionDeliverService.save(deliver);
}
/**
* 分销金额修改
*
* @param pendingIncome 待入账金额
* @param receivedIncome 已入账
* @param withdrawIncome 已提现
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Long shopUserId, Long shopId, Integer isOne) {

View File

@@ -72,7 +72,7 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
}
@Override
public MkShopRechargeVO detail(Long shopId) {
public MkShopRechargeVO detail(Long shopId) throws CzgException{
shopId = shopInfoService.getMainIdByShopId(shopId);
ShopInfo shopInfo = shopInfoService.getById(shopId);
if (shopInfo.getMainId() != null) {

View File

@@ -45,36 +45,33 @@
order by a.create_time desc
</select>
<select id="totalAmount" resultType="java.math.BigDecimal">
select sum(a.amount) from mk_distribution_flow as a
left join mk_distribution_user as d on d.id=a.distribution_user_id
left join tb_shop_user as b on a.shop_user_id=b.id
left join tb_shop_user as c on c.id=a.shop_user_id
select sum(a.reward_amount)
from mk_distribution_flow as a
left join tb_shop_user as b on a.shop_user_id = b.id
where a.shop_id=#{shopId}
<if test="id != null">
and a.shop_user_id=#{id}
</if>
<if test="userId != null">
and a.user_id=#{userId}
</if>
<if test="status != null and status != ''">
and a.status=#{status}
</if>
<if test="type != null and type != ''">
and a.type=#{type}
</if>
<if test="startTime != null">
and a.create_time>=#{startTime}
</if>
<if test="endTime != null">
and a.create_time&lt;=#{endTime}
</if>
<if test="status != null and status != ''">
and a.status=#{status}
</if>
<if test="key != null and key != ''">
and (
b.nick_name like concat('%',#{key},'%')
or b.id like concat('%',#{key},'%')
or c.id like concat('%',#{key},'%')
or c.nick_name like concat('%',#{key},'%')
)
</if>
<if test="id != null">
and d.id=#{id}
</if>
<if test="type != null and type != ''">
and a.type=#{type}
</if>
<if test="userId != null">
and d.user_id=#{userId}
</if>
</select>
</mapper>

View File

@@ -5,16 +5,24 @@
<mapper namespace="com.czg.service.market.mapper.MkDistributionUserMapper">
<update id="updateIncome">
update mk_distribution_user
set
<set>
<if test="pendingIncome != null">
total_income = total_income + #{pendingIncome},
</if>
<if test="receivedIncome != null">
total_income = total_income + #{receivedIncome},
</if>
pending_income = pending_income + #{pendingIncome},
received_income = received_income + #{receivedIncome},
withdrawn_income = withdrawn_income + #{withdrawIncome}
<if test="pendingIncome != null">
pending_income = pending_income + #{pendingIncome},
</if>
<if test="receivedIncome != null">
received_income = received_income + #{receivedIncome},
</if>
<if test="withdrawIncome != null">
withdrawn_income = withdrawn_income + #{withdrawIncome}
</if>
</set>
where id = #{id} and shop_id = #{shopId}
</update>

View File

@@ -18,21 +18,16 @@
</properties>
<dependencies>
<dependency>
<groupId>com.czg</groupId>
<artifactId>czg-pay</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.czg</groupId>
<artifactId>aggregation-pay</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.czg</groupId>
<artifactId>market-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.czg</groupId>
<artifactId>pay-service</artifactId>
<version>${project.version}</version>
</dependency>
<!-- 订单服务依赖消息队列 从 market 拿 -->
<!-- <dependency>-->
<!-- <groupId>com.czg</groupId>-->

View File

@@ -1,6 +1,6 @@
package com.czg.service.account.mapper;
package com.czg.service.order.mapper;
import com.czg.account.entity.ShopMerchant;
import com.czg.order.entity.ShopMerchant;
import com.mybatisflex.core.BaseMapper;
/**

View File

@@ -261,7 +261,7 @@ public interface PrinterImpl {
// data.append("<OUT:15>");
// data.append("<BR>");
// 18个空格 12
data.append(getFormatLabel("品名 数量 小计 ", signLabelInfo.s))
data.append(getFormatLabel("品名 数量 单价 ", signLabelInfo.s))
.append(signLabelInfo.br);
// data.append("<S>品名 数量 小计</S><BR>");
data.append(getFormatLabel("--------------------------------", signLabelInfo.s))

View File

@@ -21,6 +21,6 @@ public interface DistributionPayService {
/**
* 运营端小程序余额充值
*/
Map<String, String> mchRecharge(String clientIP, MkDistributionPayDTO payParam);
Map<String, String> mchRecharge(MkDistributionPayDTO payParam);
}

View File

@@ -1,10 +1,12 @@
package com.czg.service.order.service;
import com.czg.entity.req.*;
import com.czg.entity.resp.CzgBaseResp;
import com.czg.entity.resp.CzgRefundResp;
import com.czg.enums.CzgPayEnum;
import com.czg.order.dto.LtPayOtherDTO;
import com.czg.order.entity.OrderPayment;
import com.czg.pay.CzgPayBaseReq;
import com.czg.pay.CzgRefundReq;
import com.czg.pay.QueryOrderRespDTO;
import com.czg.pay.RefundRespDTO;
import com.czg.resp.CzgResult;
import lombok.NonNull;
@@ -21,14 +23,10 @@ public interface PayService {
BigDecimal MONEY_RATE = new BigDecimal("100");
Long initOrderPayment(OrderPayment payment);
Long initPayment(OrderPayment payment);
//-----------------------------------------------------------------付款 ----------------------------------------------------------
CzgResult<Map<String, Object>> h5Pay(@NonNull Long shopId, CzgH5PayReq bizData);
CzgResult<Map<String, Object>> jsPay(@NonNull Long shopId, @NonNull String payType, CzgJsPayReq bizData);
CzgResult<Map<String, Object>> ltPay(@NonNull Long shopId, String payType, CzgLtPayReq bizData);
CzgResult<Map<String, Object>> scanPay(@NonNull Long shopId, CzgScanPayReq bizData);
CzgResult<Map<String, Object>> microPay(@NonNull Long shopId, CzgMicroPayReq bizData);
CzgResult<Map<String, Object>> pay(@NonNull Long shopId, CzgPayEnum payType, CzgPayBaseReq bizData);
//-----------------------------------------------------------------积分商品/拼团 付款 ----------------------------------------------------------
/**
@@ -46,7 +44,7 @@ public interface PayService {
* 退款
* 目前订单 会员 使用
*/
CzgResult<CzgRefundResp> refund(@NonNull Long shopId, CzgRefundReq bizData);
CzgResult<RefundRespDTO> refund(@NonNull Long shopId, CzgRefundReq bizData);
/**
* 统一退款接口
* 目前 拼团商品 积分商品 套餐推广 使用
@@ -69,7 +67,7 @@ public interface PayService {
* @param payOrderId 平台订单号
* @param mchOrderNo 商户订单号
*/
CzgResult<CzgBaseResp> queryPayOrder(Long shopId, String payOrderId, String mchOrderNo);
CzgResult<QueryOrderRespDTO> queryPayOrder(Long shopId, String payOrderId, String mchOrderNo, String platform);
/**
* 退款查询
@@ -77,5 +75,5 @@ public interface PayService {
* @param mchRefundNo 商户退款订单号 二选一
* @param refundOrderId 平台退款订单号 二选一
*/
CzgResult<CzgRefundResp> queryRefund(Long shopId, String mchRefundNo, String refundOrderId);
CzgResult<RefundRespDTO> queryRefund(Long shopId, String mchRefundNo, String refundOrderId);
}

View File

@@ -29,7 +29,7 @@ public interface ShopDirectMerchantService extends IService<ShopDirectMerchant>
/**
* 获取进件信息
*/
AggregateMerchantVO getEntry(Long shopId, String licenceNo);
AggregateMerchantVO getEntry(Long shopId);
/**
* 申请进件

View File

@@ -7,13 +7,15 @@ import com.czg.account.service.ShopUserService;
import com.czg.account.service.UserInfoService;
import com.czg.constant.TableValueConstant;
import com.czg.constants.PayTypeConstants;
import com.czg.entity.req.CzgLtPayReq;
import com.czg.constants.SystemConstants;
import com.czg.enums.CzgPayEnum;
import com.czg.exception.CzgException;
import com.czg.market.service.MkDistributionConfigService;
import com.czg.market.vo.MkDistributionConfigVO;
import com.czg.order.dto.MkDistributionPayDTO;
import com.czg.order.entity.OrderPayment;
import com.czg.order.service.OrderPaymentService;
import com.czg.pay.CzgPayBaseReq;
import com.czg.resp.CzgResult;
import com.czg.service.market.service.impl.WxServiceImpl;
import com.czg.service.order.service.DistributionPayService;
@@ -67,7 +69,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
ShopUser shopUserInfo = shopUserService.getShopUserInfo(payParam.getShopId(), userId);
OrderPayment orderPayment = new OrderPayment().setShopId(payParam.getShopId()).setSourceId(isRecharge ? payParam.getShopId() : shopUserInfo.getId())
.setSourceType(isRecharge ? PayTypeConstants.SourceType.DISTRIBUTION_RECHARGE : PayTypeConstants.SourceType.DISTRIBUTION )
.setSourceType(isRecharge ? PayTypeConstants.SourceType.DISTRIBUTION_RECHARGE : PayTypeConstants.SourceType.DISTRIBUTION)
.setPayType(PayTypeConstants.PayType.PAY)
.setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId())
.setAmount(isRecharge ? payParam.getAmount() : detail.getPayAmount());
@@ -81,7 +83,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
} else {
UserInfo userInfo = userInfoService.getById(userId);
initInfo.setPayment(orderPayment).setShopUser(shopUserInfo)
.setOpenId("aliPay".equals(payParam.getPayType()) ? userInfo.getAlipayOpenId() : userInfo.getWechatOpenId());
.setOpenId(SystemConstants.PayType.ALIPAY.equals(payParam.getPayType()) ? userInfo.getAlipayOpenId() : userInfo.getWechatOpenId());
}
return initInfo;
}
@@ -89,12 +91,13 @@ public class DistributionPayServiceImpl implements DistributionPayService {
@Override
public CzgResult<Map<String, Object>> ltPayOrder(String clintIp, MkDistributionPayDTO payParam) {
InitInfo initInfo = initPayment(payParam.getUserId(), payParam, false);
return payService.ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(initInfo.payment.getOrderNo(), initInfo.payment.getAmount().multiply(MONEY_RATE).longValue(),
payParam.getPayType(), "分销员开通", initInfo.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
CzgPayBaseReq.ltPayReq(initInfo.payment.getOrderNo(), "分销员开通", initInfo.payment.getAmount().multiply(MONEY_RATE).longValue(),
payParam.getPayType(), initInfo.getOpenId(), clintIp));
}
@Override
public Map<String, String> mchRecharge(String clientIP, MkDistributionPayDTO payParam) {
public Map<String, String> mchRecharge(MkDistributionPayDTO payParam) {
InitInfo initInfo = initPayment(payParam.getUserId() == null ? payParam.getShopId() : payParam.getUserId(), payParam, true);
return wxService.v3Pay(initInfo.openId, payParam.getAmount(), "商户运营余额充值", initInfo.payment.getOrderNo(), initInfo.payment.getSourceType());
}

View File

@@ -6,7 +6,10 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.exceptions.ValidateException;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.*;
import cn.hutool.core.util.EnumUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
@@ -17,9 +20,8 @@ import com.czg.config.RabbitPublisher;
import com.czg.config.RedisCst;
import com.czg.constant.MarketConstants;
import com.czg.constant.TableValueConstant;
import com.czg.entity.notify.CzgPayNotifyDTO;
import com.czg.entity.notify.CzgRefundNotifyDTO;
import com.czg.constants.PayTypeConstants;
import com.czg.entity.notify.CzgRefundNotifyDTO;
import com.czg.enums.ShopTableStatusEnum;
import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.exception.CzgException;
@@ -40,6 +42,7 @@ import com.czg.order.entity.OrderPayment;
import com.czg.order.enums.PayEnums;
import com.czg.order.service.*;
import com.czg.order.vo.*;
import com.czg.pay.PayNotifyRespDTO;
import com.czg.product.entity.Product;
import com.czg.product.service.ProductRpcService;
import com.czg.product.service.ProductService;
@@ -50,7 +53,6 @@ import com.czg.service.order.enums.OrderStatusEnums;
import com.czg.service.order.mapper.OrderInfoCustomMapper;
import com.czg.service.order.print.PrinterHandler;
import com.czg.utils.*;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
@@ -1028,13 +1030,12 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
@Override
@Transactional
public void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson, int retryCount) {
CzgPayNotifyDTO czgCallBackDto = JSONObject.parseObject(resultJson.toString(), CzgPayNotifyDTO.class);
public void payCallBackOrder(@NotBlank String orderNo, @NotNull PayNotifyRespDTO notifyRespDTO, String channel, int retryCount) {
OrderPayment payment = paymentService.getOne(new QueryWrapper().eq(OrderPayment::getOrderNo, orderNo));
if (payment == null) {
if (retryCount < MAX_RETRIES) {
log.info("支付记录不存在,第 {} 次重试,将在 {} 秒后进行", retryCount + 1, DELAY);
executorService.schedule(() -> payCallBackOrder(orderNo, resultJson, retryCount + 1), DELAY, TimeUnit.SECONDS);
executorService.schedule(() -> payCallBackOrder(orderNo, notifyRespDTO, channel, retryCount + 1), DELAY, TimeUnit.SECONDS);
} else {
log.error("订单支付回调失败, 达到最大重试次数, 支付记录不存在, orderNo: {}", orderNo);
}
@@ -1044,10 +1045,12 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
log.info("订单处理过payment id{}", payment.getId());
return;
}
payment.setTradeNumber(czgCallBackDto.getPayOrderId());
payment.setRespJson(resultJson.toString());
payment.setTradeNumber(notifyRespDTO.getThirdOrderNo());
payment.setRespJson(notifyRespDTO.getOriginalData());
payment.setPayStatus(PayTypeConstants.PayStatus.FAIL);
if ("TRADE_SUCCESS".equals(czgCallBackDto.getState())) {
payment.setPlatformType(notifyRespDTO.getPlatform());
payment.setChannel(channel);
if ("TRADE_SUCCESS".equals(notifyRespDTO.getStatus())) {
payment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS);
if (PayTypeConstants.SourceType.ORDER.equals(payment.getSourceType())) {
OrderInfo orderInfo = orderInfoService.getById(payment.getSourceId());
@@ -1055,8 +1058,8 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
log.error("订单支付回调失败,订单不存在,支付记录Id,{}", payment.getId());
return;
}
upOrderInfo(orderInfo, new BigDecimal(czgCallBackDto.getAmount()).divide(new BigDecimal(100), 2, RoundingMode.DOWN),
DateUtil.parseLocalDateTime(czgCallBackDto.getPayTime()), payment.getId(), null);
upOrderInfo(orderInfo, new BigDecimal(notifyRespDTO.getAmount()).divide(new BigDecimal(100), 2, RoundingMode.DOWN),
DateUtil.parseLocalDateTime(notifyRespDTO.getPaySuccessTime()), payment.getId(), null);
if (orderInfo.getUserId() != null) {
// 分销员升级等级
distributionUserService.costUpgradeLevelBefore(orderInfo.getUserId(), orderInfo.getShopId());
@@ -1066,14 +1069,14 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
} else if (PayTypeConstants.SourceType.MEMBER_IN.equals(payment.getSourceType()) || PayTypeConstants.SourceType.FREE.equals(payment.getSourceType())) {
boolean isFree = PayTypeConstants.SourceType.FREE.equals(payment.getSourceType());
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
OrderInfo orderInfo = null;
OrderInfo orderInfo;
if (shopUser == null) {
log.error("会员充值失败会员不存在会员id{}", payment.getSourceId());
} else {
ShopUserFlowBizEnum bizEnum;
if ("WECHAT".equals(czgCallBackDto.getPayType())) {
if ("WECHAT".equals(notifyRespDTO.getPlatform())) {
bizEnum = ShopUserFlowBizEnum.WECHAT_IN;
} else if ("ALIPAY".equals(czgCallBackDto.getPayType())) {
} else if ("ALIPAY".equals(notifyRespDTO.getPlatform())) {
bizEnum = ShopUserFlowBizEnum.ALIPAY_IN;
} else {
bizEnum = ShopUserFlowBizEnum.CASH_IN;
@@ -1089,7 +1092,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
.setType(1)
.setBizEnum(ShopUserFlowBizEnum.FREE_IN)
.setRelationId(orderInfo.getId())
.setMoney(BigDecimal.valueOf(czgCallBackDto.getAmount()).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN));
.setMoney(BigDecimal.valueOf(notifyRespDTO.getAmount()).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN));
shopUserService.updateMoney(shopUserMoneyEditDTO);
upOrderInfo(orderInfo, BigDecimal.ZERO,
LocalDateTime.now(), null, PayEnums.FREE_PAY);
@@ -1111,7 +1114,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
LocalDateTime.now(), null, PayEnums.VIP_PAY);
}
shopRechargeService.recharge(payment.getShopId(), payment.getSourceId(), payment.getRelatedId(),
BigDecimal.valueOf(czgCallBackDto.getAmount()).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN),
BigDecimal.valueOf(notifyRespDTO.getAmount()).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN),
payment.getId(), payment.getSourceType(), bizEnum, orderInfo == null);
}
}

View File

@@ -17,8 +17,7 @@ import com.czg.account.service.UserInfoService;
import com.czg.config.RabbitPublisher;
import com.czg.config.RedisCst;
import com.czg.constants.PayTypeConstants;
import com.czg.entity.req.*;
import com.czg.entity.resp.CzgRefundResp;
import com.czg.enums.CzgPayEnum;
import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.exception.CzgException;
import com.czg.exception.PaySuccessException;
@@ -36,6 +35,9 @@ import com.czg.order.service.CreditBuyerOrderService;
import com.czg.order.service.OrderDetailService;
import com.czg.order.service.OrderInfoCustomService;
import com.czg.order.service.OrderPaymentService;
import com.czg.pay.CzgPayBaseReq;
import com.czg.pay.CzgRefundReq;
import com.czg.pay.RefundRespDTO;
import com.czg.resp.CzgResult;
import com.czg.service.RedisService;
import com.czg.service.order.dto.OrderPayParamDTO;
@@ -62,6 +64,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author ww
*/
@Slf4j
@Service
public class OrderPayServiceImpl implements OrderPayService {
@@ -227,13 +232,15 @@ public class OrderPayServiceImpl implements OrderPayService {
return CzgResult.failure("支付失败 充值金额必须大雨订单金额");
}
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN, PayTypeConstants.PayType.PAY, payOrderNo,
"", rechargeDetail.getAmount(), rechargeDetail.getId()));
Long paymentId = payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN,
payOrderNo, rechargeDetail.getAmount(), "", rechargeDetail.getId()));
upOrderPayInfo(orderInfo.getId(), PayEnums.VIP_PAY, paymentId,
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
return payService.ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, rechargeDetail.getAmount().multiply(PayService.MONEY_RATE).longValue(),
payParam.getPayType(), "充值并支付", "wechatPay".equals(payParam.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId(),
clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
CzgPayBaseReq.ltPayReq(
payOrderNo, "充值并支付",
rechargeDetail.getAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getPayType(),
"wechatPay".equals(payParam.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId(), clintIp));
}
@Override
@@ -241,12 +248,10 @@ public class OrderPayServiceImpl implements OrderPayService {
public CzgResult<Map<String, Object>> h5PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
upOrderPayInfo(orderInfo.getId(), PayEnums.H5_PAY, paymentId,
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
return payService.h5Pay(payParam.getShopId(), new CzgH5PayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
"点餐支付", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
upOrderPayInfo(orderInfo.getId(), PayEnums.H5_PAY, paymentId, payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
return payService.pay(payParam.getShopId(), CzgPayEnum.H5_PAY,
CzgPayBaseReq.h5PayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), clintIp));
}
@@ -257,12 +262,12 @@ public class OrderPayServiceImpl implements OrderPayService {
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
CzgPayBaseReq.jsPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
payParam.getPayType(), payParam.getOpenId(), clintIp));
}
@Override
@@ -281,12 +286,12 @@ public class OrderPayServiceImpl implements OrderPayService {
orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId());
}
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
CzgPayBaseReq.jsPayReq(payOrderNo, "扫码支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
payParam.getPayType(), payParam.getOpenId(), clintIp));
}
@Override
@@ -296,12 +301,12 @@ public class OrderPayServiceImpl implements OrderPayService {
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
return payService.ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
payParam.getPayType(), "点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
CzgPayBaseReq.ltPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
payParam.getPayType(), payParam.getOpenId(), clintIp));
}
@Override
@@ -317,12 +322,11 @@ public class OrderPayServiceImpl implements OrderPayService {
BigDecimal amount = shopRechargeService.checkRecharge(mainShopId, payParam.getShopId(), shopUser.getUserId(), payParam.getRechargeDetailId(), payParam.getAmount());
payParam.setAmount(amount);
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
upOrderPayInfo(orderInfo.getId(), PayEnums.MAIN_SCAN, paymentId,
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
return payService.scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
"点餐支付", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
return payService.pay(payParam.getShopId(), CzgPayEnum.SCAN_PAY,
CzgPayBaseReq.scanPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), clintIp));
}
@Override
@@ -344,10 +348,9 @@ public class OrderPayServiceImpl implements OrderPayService {
}
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, payParam.getAuthCode(), orderInfo.getOrderAmount()));
CzgResult<Map<String, Object>> mapCzgResult = payService.microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
"点餐支付", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), payParam.getAuthCode()));
CzgResult<Map<String, Object>> mapCzgResult = payService.pay(payParam.getShopId(), CzgPayEnum.MICRO_PAY,
CzgPayBaseReq.microPay(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getAuthCode()));
if (mapCzgResult.getCode() == 200) {
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN);
@@ -508,19 +511,22 @@ public class OrderPayServiceImpl implements OrderPayService {
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
OrderPayment payment = paymentService.getById(payOrderId);
AssertUtil.isNull(payment, "退款失败支付记录不存在");
Long refundId = payService.initOrderPayment(new OrderPayment(shopId, orderId, PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refundAmount, payment.getId()));
CzgResult<CzgRefundResp> refund = payService.refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
if (refund.getData() != null && refund.getData().getNote() != null) {
throw new CzgException(refund.getData().getNote());
Long refundId = payService.initPayment(OrderPayment.refund(shopId, orderId, PayTypeConstants.SourceType.ORDER,
refPayOrderNo, refundAmount, payment.getId(), payment.getPlatformType()));
CzgResult<RefundRespDTO> refund = payService.refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(PayService.MONEY_RATE).longValue(),
payment.getAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), "", payment.getPlatformType()));
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getStatus())) {
if (refund.getData() != null && refund.getData().getErrMessage() != null) {
throw new CzgException(refund.getData().getErrMessage());
}
throw new CzgException(refund.getMsg());
} else {
paymentService.updateChain()
.eq(OrderPayment::getId, refundId)
.set(OrderPayment::getPayTime, refund.getData().getRefundTime())
.set(OrderPayment::getTradeNumber, refund.getData().getRefundOrderId())
.set(OrderPayment::getRespJson, JSONObject.toJSONString(refund.getData()))
.set(OrderPayment::getTradeNumber, refund.getData().getThirdRefundNo())
.set(OrderPayment::getRespJson, refund.getData().getOriginalData())
.update();
}
}

View File

@@ -2,19 +2,25 @@ package com.czg.service.order.service.impl;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.CzgPayUtils;
import com.czg.account.entity.ShopMerchant;
import com.czg.account.service.ShopMerchantService;
import com.czg.PayAdapter;
import com.czg.PayAdapterFactory;
import com.czg.constant.PayChannelCst;
import com.czg.constants.ParamCodeCst;
import com.czg.constants.PayTypeConstants;
import com.czg.entity.req.*;
import com.czg.entity.resp.CzgBaseResp;
import com.czg.entity.resp.CzgRefundResp;
import com.czg.constants.SystemConstants;
import com.czg.enums.CzgPayEnum;
import com.czg.exception.CzgException;
import com.czg.order.dto.LtPayOtherDTO;
import com.czg.order.entity.OrderPayment;
import com.czg.order.entity.ShopMerchant;
import com.czg.order.service.OrderPaymentService;
import com.czg.order.service.ShopMerchantService;
import com.czg.pay.CzgPayBaseReq;
import com.czg.pay.CzgRefundReq;
import com.czg.pay.QueryOrderRespDTO;
import com.czg.pay.RefundRespDTO;
import com.czg.resp.CzgResult;
import com.czg.service.order.mapper.OrderPaymentMapper;
import com.czg.service.order.service.PayService;
@@ -39,7 +45,7 @@ import java.util.Map;
@Service
public class PayServiceImpl implements PayService {
@DubboReference
@Resource
private ShopMerchantService shopMerchantService;
@DubboReference
private SysParamsService sysParamsService;
@@ -49,66 +55,20 @@ public class PayServiceImpl implements PayService {
private OrderPaymentMapper paymentMapper;
@Override
public CzgResult<Map<String, Object>> h5Pay(@NonNull Long shopId, CzgH5PayReq bizData) {
public CzgResult<Map<String, Object>> pay(@NonNull Long shopId, CzgPayEnum payType, CzgPayBaseReq bizData) {
ShopMerchant shopMerchant = getMerchant(shopId);
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
getNotifyUrl());
return CzgPayUtils.h5Pay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
}
@Override
public CzgResult<Map<String, Object>> jsPay(@NonNull Long shopId, @NonNull String payType, CzgJsPayReq bizData) {
ShopMerchant shopMerchant = getMerchant(shopId);
bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序");
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
getNotifyUrl());
bizData.setPayType("aliPay".equals(payType) ? "ALIPAY" : "WECHAT");
return CzgPayUtils.jsPay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
}
@Override
public CzgResult<Map<String, Object>> ltPay(@NonNull Long shopId, String payType, CzgLtPayReq bizData) {
ShopMerchant shopMerchant = getMerchant(shopId);
bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序");
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
getNotifyUrl());
return CzgPayUtils.ltPay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
}
@Override
public CzgResult<Map<String, Object>> scanPay(@NonNull Long shopId, CzgScanPayReq bizData) {
ShopMerchant shopMerchant = getMerchant(shopId);
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
getNotifyUrl());
return CzgPayUtils.scanPay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
}
@Override
public CzgResult<Map<String, Object>> microPay(@NonNull Long shopId, CzgMicroPayReq bizData) {
AssertUtil.isBlank(bizData.getAuthCode(), "扫码失败,请重试");
if (bizData.getAuthCode().length() > 26) {
throw new CzgException("支付失败,不支持的条码");
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
String payData = null;
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
payData = shopMerchant.getNativePayJson();
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
payData = shopMerchant.getPolyPayJson();
}
ShopMerchant shopMerchant = getMerchant(shopId);
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
getNotifyUrl());
String firstTwoDigitsStr = bizData.getAuthCode().substring(0, 2);
// 将截取的字符串转换为整数
int firstTwoDigits = Integer.parseInt(firstTwoDigitsStr);
// 判断范围
if (firstTwoDigits >= 10 && firstTwoDigits <= 15) {
//微信支付
bizData.setSubAppid(shopMerchant.getWechatSmallAppid());
} else if (firstTwoDigits >= 25 && firstTwoDigits <= 30) {
//支付宝支付
bizData.setSubAppid(shopMerchant.getAlipaySmallAppid());
} else {
throw new CzgException("扫描码非法或暂不支持");
bizData.setSubAppid(SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? shopMerchant.getAlipayAppId() : shopMerchant.getWechatAppId());
if (payType.equals(CzgPayEnum.MICRO_PAY)) {
checkMicroPay(bizData, shopMerchant);
}
return CzgPayUtils.microPay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
return adapter.pay(payType, payData, getDomain(), getNotifyUrl(shopMerchant.getChannel()), bizData);
}
@Override
@@ -117,17 +77,26 @@ public class PayServiceImpl implements PayService {
AssertUtil.isBlank(param.getOpenId(), "用户小程序ID不能为空");
AssertUtil.isBlank(param.getPayType(), "支付方式不能为空");
String payOrderNo = "LT" + IdUtil.getSnowflakeNextId();
initOrderPayment(new OrderPayment(param.getShopId(), param.getRecordId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
"", param.getPrice(), null));
return ltPay(param.getShopId(), param.getPayType(), new CzgLtPayReq(payOrderNo, param.getPrice().multiply(MONEY_RATE).longValue(),
param.getPayType(), detail, param.getOpenId(), param.getIp(), "", "", ""));
initPayment(OrderPayment.pay(param.getShopId(), param.getRecordId(), payType, payOrderNo,
param.getPrice(), "", null));
return pay(param.getShopId(), CzgPayEnum.LT_PAY,
CzgPayBaseReq.ltPayReq(payOrderNo, detail, param.getPrice().multiply(MONEY_RATE).longValue(),
param.getPayType(), param.getOpenId(), param.getIp()));
}
@Override
public CzgResult<CzgRefundResp> refund(@NonNull Long shopId, CzgRefundReq bizData) {
public CzgResult<RefundRespDTO> refund(@NonNull Long shopId, CzgRefundReq bizData) {
ShopMerchant shopMerchant = getMerchant(shopId);
bizData.setNotifyUrl(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_REFUND_NOTIFY_URL));
return CzgPayUtils.refundOrder(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
String payData = null;
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
payData = shopMerchant.getNativePayJson();
bizData.setNotifyUrl(sysParamsService.getSysParamValue(ParamCodeCst.System.NATIVE_REFUND_NOTIFY_URL));
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
payData = shopMerchant.getPolyPayJson();
bizData.setNotifyUrl(sysParamsService.getSysParamValue(ParamCodeCst.System.POLY_REFUND_NOTIFY_URL));
}
return adapter.refund(getDomain(), payData, bizData);
}
@Override
@@ -136,17 +105,18 @@ public class PayServiceImpl implements PayService {
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
OrderPayment payment = paymentService.getById(payOrderId);
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
Long refundId = initOrderPayment(new OrderPayment(shopId, sourceId, payment.getSourceType(), PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refundAmount, payment.getId()));
CzgResult<CzgRefundResp> refund = refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(MONEY_RATE).longValue(),
payment.getOrderNo(), ""));
Long refundId = initPayment(OrderPayment.refund(shopId, sourceId, payment.getSourceType(), refPayOrderNo, refundAmount, payment.getId(), payment.getPlatformType()));
CzgResult<RefundRespDTO> refund = refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(MONEY_RATE).longValue(),
payment.getAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), "", payment.getPlatformType()));
OrderPayment uOrderPayment = new OrderPayment();
uOrderPayment.setRespJson(JSONObject.toJSONString(refund.getData()));
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getStatus())) {
uOrderPayment.setPayStatus(PayTypeConstants.PayStatus.FAIL);
} else {
uOrderPayment.setTradeNumber(refund.getData().getRefundOrderId());
uOrderPayment.setTradeNumber(refund.getData().getThirdRefundNo());
uOrderPayment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS);
uOrderPayment.setPayTime(LocalDateTimeUtil.parse(refund.getData().getRefundTime(), "yyyy-MM-dd HH:mm:ss"));
uOrderPayment.setRespJson(refund.getData().getOriginalData());
}
paymentService.update(uOrderPayment, QueryWrapper.create().eq(OrderPayment::getId, refundId));
}
@@ -157,18 +127,19 @@ public class PayServiceImpl implements PayService {
//支付的 订单
OrderPayment payment = paymentService.getById(refundPayment.getRelatedId());
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
Long refundCompensate = initOrderPayment(new OrderPayment(refundPayment.getShopId(), refundPayment.getSourceId(), payment.getSourceType(), PayTypeConstants.PayType.REFUND_COMPENSATE,
refPayOrderNo, null, refundPayment.getAmount(), refundPayment.getId()));
CzgResult<CzgRefundResp> refund = refund(payment.getShopId(), new CzgRefundReq(refPayOrderNo, "退款补偿", refundPayment.getAmount().multiply(MONEY_RATE).longValue(),
payment.getOrderNo(), ""));
Long refundCompensate = initPayment(OrderPayment.refundCompensate(refundPayment.getShopId(), refundPayment.getSourceId(),
payment.getSourceType(), refPayOrderNo, refundPayment.getAmount(), refundPayment.getId()));
CzgResult<RefundRespDTO> refund = refund(payment.getShopId(), new CzgRefundReq(refPayOrderNo, "退款补偿", refundPayment.getAmount().multiply(MONEY_RATE).longValue(),
payment.getAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), "", payment.getPlatformType()));
OrderPayment uOrderPayment = new OrderPayment();
uOrderPayment.setTradeNumber(refund.getData().getRefundOrderId());
uOrderPayment.setTradeNumber(refund.getData().getThirdRefundNo());
uOrderPayment.setRespJson(JSONObject.toJSONString(refund.getData()));
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getStatus())) {
uOrderPayment.setPayStatus(PayTypeConstants.PayStatus.FAIL);
} else {
uOrderPayment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS);
uOrderPayment.setPayTime(LocalDateTimeUtil.parse(refund.getData().getRefundTime(), "yyyy-MM-dd HH:mm:ss"));
uOrderPayment.setRespJson(refund.getData().getOriginalData());
}
paymentService.update(uOrderPayment, QueryWrapper.create().eq(OrderPayment::getId, refundPayment.getId()));
paymentService.update(uOrderPayment, QueryWrapper.create().eq(OrderPayment::getId, refundCompensate));
@@ -176,38 +147,95 @@ public class PayServiceImpl implements PayService {
@Override
@Transactional
public CzgResult<CzgBaseResp> queryPayOrder(@NonNull Long shopId, String payOrderId, String mchOrderNo) {
public CzgResult<QueryOrderRespDTO> queryPayOrder(@NonNull Long shopId, String payOrderId, String mchOrderNo, String platform) {
ShopMerchant shopMerchant = getMerchant(shopId);
return CzgPayUtils.queryPayOrder(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), payOrderId, mchOrderNo);
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
String payData = null;
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
payData = shopMerchant.getNativePayJson();
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
payData = shopMerchant.getPolyPayJson();
}
return adapter.queryPayOrder(getDomain(), payData, payOrderId, mchOrderNo, platform);
}
@Override
@Transactional
public CzgResult<CzgRefundResp> queryRefund(@NonNull Long shopId, String mchRefundNo, String refundOrderId) {
public CzgResult<RefundRespDTO> queryRefund(@NonNull Long shopId, String mchRefundNo, String refundOrderId) {
ShopMerchant shopMerchant = getMerchant(shopId);
return CzgPayUtils.queryRefundOrder(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), mchRefundNo, refundOrderId);
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
String payData = null;
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
payData = shopMerchant.getNativePayJson();
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
payData = shopMerchant.getPolyPayJson();
}
return adapter.queryRefund(getDomain(), payData, mchRefundNo, refundOrderId);
}
@Override
public Long initOrderPayment(OrderPayment payment) {
public Long initPayment(OrderPayment payment) {
paymentMapper.insert(payment);
return payment.getId();
}
private ShopMerchant getMerchant(Long shopId) {
try {
return shopMerchantService.getById(shopId);
} catch (Exception e) {
throw new CzgException("暂未开通支付");
ShopMerchant shopMerchant = shopMerchantService.getByShopId(shopId);
if (shopMerchant == null || StrUtil.isBlank(shopMerchant.getChannel())) {
throw new CzgException("暂未开通支付!");
}
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
if (StrUtil.isBlank(shopMerchant.getNativePayJson())) {
throw new CzgException("原生支付未开通");
}
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
if (StrUtil.isBlank(shopMerchant.getPolyPayJson())) {
throw new CzgException("聚合支付未开通");
}
} else {
throw new CzgException("暂不支持的支付渠道");
}
return shopMerchant;
}
private String getDomain() {
return sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN);
return sysParamsService.getSysParamValue(ParamCodeCst.System.POLY_DOMAIN);
}
private String getNotifyUrl() {
return sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_NOTIFY_URL);
private String getNotifyUrl(String channel) {
String notifyUrl = "";
if (channel.equals(PayChannelCst.NATIVE)) {
notifyUrl = sysParamsService.getSysParamValue(ParamCodeCst.System.NATIVE_PAY_NOTIFY_URL);
} else if (channel.equals(PayChannelCst.POLY)) {
notifyUrl = sysParamsService.getSysParamValue(ParamCodeCst.System.POLY_PAY_NOTIFY_URL);
}
if (StrUtil.isBlank(notifyUrl)) {
throw new CzgException(channel.equals(PayChannelCst.NATIVE) ? "原生支付回调地址未配置" : "聚合支付回调地址未配置");
}
return notifyUrl;
}
private void checkMicroPay(CzgPayBaseReq bizData, ShopMerchant shopMerchant) {
String data = bizData.getAuthCode();
AssertUtil.isBlank(data, "扫码失败,请重试");
if (data.length() > 26) {
throw new CzgException("支付失败,不支持的条码");
}
String firstTwoDigitsStr = data.substring(0, 2);
// 将截取的字符串转换为整数
int firstTwoDigits = Integer.parseInt(firstTwoDigitsStr);
// 判断范围
if (firstTwoDigits >= 10 && firstTwoDigits <= 15) {
//微信支付
bizData.setSubAppid(shopMerchant.getWechatAppId());
bizData.setPayType(SystemConstants.PayType.WECHAT);
} else if (firstTwoDigits >= 25 && firstTwoDigits <= 30) {
//支付宝支付
bizData.setSubAppid(shopMerchant.getAlipayAppId());
bizData.setPayType(SystemConstants.PayType.ALIPAY);
} else {
throw new CzgException("扫描码非法或暂不支持");
}
}
}

View File

@@ -64,9 +64,8 @@ public class ShopDirectMerchantServiceImpl extends ServiceImpl<ShopDirectMerchan
}
@Override
public AggregateMerchantVO getEntry(Long shopId, String licenceNo) {
public AggregateMerchantVO getEntry(Long shopId) {
ShopDirectMerchant merchant = getOne(query()
.eq(ShopDirectMerchant::getLicenceNo, licenceNo)
.eq(ShopDirectMerchant::getShopId, shopId));
if (merchant == null) {
return null;

View File

@@ -0,0 +1,148 @@
package com.czg.service.order.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.service.ShopInfoService;
import com.czg.constants.SystemConstants;
import com.czg.order.dto.ShopMerchantDTO;
import com.czg.order.entity.ShopDirectMerchant;
import com.czg.order.entity.ShopMerchant;
import com.czg.order.service.ShopMerchantService;
import com.czg.pay.AlipayAuthInfoDto;
import com.czg.pay.NativeMerchantDTO;
import com.czg.pay.PolyMerchantDTO;
import com.czg.service.order.mapper.ShopMerchantMapper;
import com.czg.service.order.service.ShopDirectMerchantService;
import com.czg.utils.AssertUtil;
import com.czg.utils.CzgStrUtils;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
/**
* 第三方商户进件 服务层实现。
*
* @author Administrator
* @since 2025-02-11
*/
@CacheConfig(cacheNames = "shop:merchant")
@Service
public class ShopMerchantServiceImpl extends ServiceImpl<ShopMerchantMapper, ShopMerchant> implements ShopMerchantService {
@Resource
private ShopDirectMerchantService shopDirectMerchantService;
@DubboReference
private ShopInfoService shopInfoService;
@Override
public ShopMerchantDTO detail(Long shopId) {
ShopMerchantDTO shopMerchantVO = new ShopMerchantDTO();
ShopMerchant one = getOne(query().eq(ShopMerchant::getShopId, shopId));
if (one == null) {
return null;
}
shopMerchantVO.setShopId(shopId);
shopMerchantVO.setChannel(one.getChannel());
shopMerchantVO.setRelatedId(one.getRelatedId());
if (StrUtil.isNotBlank(one.getNativePayJson())) {
shopMerchantVO.setNativeMerchantDTO(JSONObject.parseObject(one.getNativePayJson(), NativeMerchantDTO.class));
}
if (StrUtil.isNotBlank(one.getPolyPayJson())) {
shopMerchantVO.setPolyMerchantDTO(JSONObject.parseObject(one.getPolyPayJson(), PolyMerchantDTO.class));
}
if (one.getRelatedId() != null) {
shopMerchantVO.setShopDirectMerchant(shopDirectMerchantService.getOne(query().eq(ShopDirectMerchant::getShopId, one.getRelatedId())));
}
return shopMerchantVO;
}
/**
* * shopId 修改的店铺Id
* * relatedLicenceNo 关联值 原生native必填 对应 tb_shop_direct_merchant 的 licence_no营业执照
* * channel {@link com.czg.constant.PayChannelCst}
* * jsonObject 支付参数 详情
* * isUp 是否要修改 传否时 如果存在支付数据 且与当前渠道不一致 则不修改
*/
@Override
@CacheEvict(key = "#shopMerchantParam.shopId")
public Boolean editEntry(ShopMerchantDTO shopMerchantParam, boolean isUp) {
ShopMerchant shopMerchant = getOne(query().eq(ShopMerchant::getShopId, shopMerchantParam.getShopId()));
if (shopMerchant == null) {
shopMerchant = new ShopMerchant();
shopMerchant.setAlipayAppId(SystemConstants.PayType.ALIPAY_APP_ID);
shopMerchant.setWechatAppId(SystemConstants.PayType.WECHAT_APP_ID);
shopMerchant.setRelatedId(shopMerchantParam.getShopId());
}
shopMerchant.setShopId(shopMerchantParam.getShopId());
if (isUp) {
shopMerchant.setChannel(CzgStrUtils.getStrOrNull(shopMerchantParam.getChannel()));
shopMerchant.setRelatedId(shopMerchantParam.getRelatedId());
if (shopMerchantParam.getRelatedId() == null || !shopMerchantParam.getRelatedId().equals(shopMerchant.getRelatedId())) {
ShopDirectMerchant shopDirectMerchant = shopDirectMerchantService.getById(shopMerchantParam.getRelatedId());
if (shopDirectMerchant != null) {
NativeMerchantDTO nativeMerchantDTO = new NativeMerchantDTO();
nativeMerchantDTO.setWechatMerchantId(shopDirectMerchant.getWechatMerchantId());
nativeMerchantDTO.setAlipayMerchantId(shopDirectMerchant.getAlipayMerchantId());
if (StrUtil.isNotBlank(shopDirectMerchant.getAlipayAuthInfo())) {
AlipayAuthInfoDto alipayAuthInfoDto = JSONObject.parseObject(shopDirectMerchant.getAlipayAuthInfo(), AlipayAuthInfoDto.class);
nativeMerchantDTO.setAlipayAuthInfo(alipayAuthInfoDto);
}
shopMerchant.setNativePayJson(JSONObject.toJSONString(nativeMerchantDTO));
} else {
shopMerchant.setNativePayJson(null);
shopMerchant.setWechatAppId(null);
shopMerchant.setAlipayAppId(null);
}
}
if (shopMerchantParam.getPolyMerchantDTO() != null) {
shopMerchant.setPolyPayJson(JSONObject.toJSONString(shopMerchantParam.getPolyMerchantDTO()));
}
} else {
//只有进件会进入这里
if (shopMerchant.getRelatedId() == null) {
shopMerchant.setRelatedId(shopMerchantParam.getShopId());
}
if (StrUtil.isBlank(shopMerchant.getNativePayJson()) && shopMerchantParam.getNativeMerchantDTO() != null) {
shopMerchant.setNativePayJson(JSONObject.toJSONString(shopMerchantParam.getNativeMerchantDTO()));
}
}
if (shopMerchant.getId() == null) {
return save(shopMerchant);
} else {
return updateById(shopMerchant, false);
}
}
@Override
@CacheEvict(allEntries = true)
public void upMerchant(@NotBlank Long relatedId, @NotNull NativeMerchantDTO nativeMerchantDTO) {
ShopMerchant upShopMerchant = new ShopMerchant();
upShopMerchant.setAlipayAppId(nativeMerchantDTO.getAlipayMerchantId());
upShopMerchant.setWechatAppId(nativeMerchantDTO.getWechatMerchantId());
upShopMerchant.setNativePayJson(JSONObject.toJSONString(nativeMerchantDTO));
update(upShopMerchant, query().eq(ShopMerchant::getRelatedId, relatedId));
}
@Cacheable(key = "#shopId")
@Override
public ShopMerchant getByShopId(Long shopId) {
ShopMerchant shopMerchant = getOne(query().eq(ShopMerchant::getShopId, shopId));
AssertUtil.isNull(shopMerchant, "暂未开通支付.");
return shopMerchant;
}
@Override
public ShopDirectMerchant getMainMerchant(Long shopId) {
Long mainIdByShopId = shopInfoService.getMainIdByShopId(shopId);
if (mainIdByShopId != null) {
return shopDirectMerchantService.getOne(query().eq(ShopDirectMerchant::getShopId, mainIdByShopId));
}
return null;
}
}

View File

@@ -2,13 +2,11 @@ package com.czg.service.order.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
import com.czg.account.entity.*;
import com.czg.account.service.*;
import com.czg.constants.PayTypeConstants;
import com.czg.entity.req.*;
import com.czg.entity.resp.CzgRefundResp;
import com.czg.enums.CzgPayEnum;
import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.exception.CzgException;
import com.czg.market.dto.MemberOrderDTO;
@@ -24,6 +22,9 @@ import com.czg.order.entity.OrderInfo;
import com.czg.order.entity.OrderPayment;
import com.czg.order.service.OrderInfoCustomService;
import com.czg.order.service.OrderPaymentService;
import com.czg.pay.CzgPayBaseReq;
import com.czg.pay.CzgRefundReq;
import com.czg.pay.RefundRespDTO;
import com.czg.resp.CzgResult;
import com.czg.service.order.dto.VipMemberPayParamDTO;
import com.czg.service.order.dto.VipPayParamDTO;
@@ -131,15 +132,16 @@ public class ShopUserServiceImpl implements ShopUserPayService {
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
"会员充值", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), payType, payOrderNo,
payParam.getAmount(), "", isFree ? payParam.getOrderId() : payParam.getActivateId()));
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
CzgPayBaseReq.jsPayReq(payOrderNo, "会员充值", payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
payParam.getPayType(), payParam.getOpenId(), clintIp));
}
@Override
@Transactional(rollbackFor = Exception.class)
public CzgResult<Map<String, Object>> ltPayMember(String clientIP, VipMemberPayParamDTO payParam) {
public CzgResult<Map<String, Object>> ltPayMember(String clientIp, VipMemberPayParamDTO payParam) {
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, shopInfoService.getMainIdByShopId(payParam.getShopId())).eq(ShopUser::getId, payParam.getShopUserId()));
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
MemberOrder memberOrder = memberOrderService.createMemberOrder(new MemberOrderDTO().setName(payParam.getName())
@@ -155,7 +157,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
.setShopId(payParam.getShopId())
.setRecordId(shopUser.getId())
.setPrice(memberOrder.getAmount())
.setIp(clientIP);
.setIp(clientIp);
return payService.ltPayOther(payParam1, PayTypeConstants.SourceType.MEMBER_PAY, "会员充值");
}
@@ -191,7 +193,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
}
@Override
public CzgResult<Map<String, Object>> recharge(String clientIP, VipPayParamDTO rechargeDTO, Long shopUserId) {
public CzgResult<Map<String, Object>> recharge(String clientIp, VipPayParamDTO rechargeDTO, Long shopUserId) {
boolean isFree = checkPayVip(rechargeDTO);
Long mainShopId = shopInfoService.getMainIdByShopId(rechargeDTO.getShopId());
@@ -212,7 +214,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
.setShopId(rechargeDTO.getShopId())
.setRecordId(shopUser.getId())
.setPrice(amount)
.setIp(clientIP);
.setIp(clientIp);
return payService.ltPayOther(payParam, payType, "会员充值");
}
@@ -224,10 +226,10 @@ public class ShopUserServiceImpl implements ShopUserPayService {
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
return payService.scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
"会员充值", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), payType, payOrderNo,
payParam.getAmount(), "", isFree ? payParam.getOrderId() : payParam.getActivateId()));
return payService.pay(payParam.getShopId(), CzgPayEnum.SCAN_PAY,
CzgPayBaseReq.scanPayReq(payOrderNo, "会员充值", payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(), clintIp));
}
@Override
@@ -239,10 +241,9 @@ public class ShopUserServiceImpl implements ShopUserPayService {
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
payParam.getAuthCode(), payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
CzgResult<Map<String, Object>> mapCzgResult = payService.microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
"会员充值", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), payType, payOrderNo, payParam.getAmount(), "", isFree ? payParam.getOrderId() : payParam.getActivateId()));
CzgResult<Map<String, Object>> mapCzgResult = payService.pay(payParam.getShopId(), CzgPayEnum.MICRO_PAY,
CzgPayBaseReq.microPay(payOrderNo, "会员充值", payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getAuthCode()));
mapCzgResult.setData(Map.of("payOrderNo", payOrderNo));
return mapCzgResult;
}
@@ -309,19 +310,20 @@ public class ShopUserServiceImpl implements ShopUserPayService {
return CzgResult.failure("退款失败,该充值记录不存在");
}
String refPayOrderNo = "REFVIP" + IdUtil.getSnowflakeNextId();
refPaymentId = payService.initOrderPayment(new OrderPayment(refPayParam.getShopId(), shopUser.getId(),
PayTypeConstants.SourceType.MEMBER_IN, PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refPayParam.getRefAmount()));
CzgResult<CzgRefundResp> refund = payService.refund(refPayParam.getShopId(), new CzgRefundReq(refPayOrderNo, refPayParam.getRemark(),
refPayParam.getRefAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
refPaymentId = payService.initPayment(OrderPayment.refund(refPayParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN,
refPayOrderNo, refPayParam.getRefAmount(), inFlow.getId(), payment.getPlatformType()));
CzgResult<RefundRespDTO> refund = payService.refund(refPayParam.getShopId(), new CzgRefundReq(refPayOrderNo, refPayParam.getRemark(),
refPayParam.getRefAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getAmount().multiply(PayService.MONEY_RATE).longValue(),
payment.getOrderNo(), "", payment.getPlatformType()));
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getStatus())) {
throw new CzgException(refund.getMsg());
} else {
paymentService.updateChain()
.eq(OrderPayment::getId, refPaymentId)
.set(OrderPayment::getPayTime, refund.getData().getRefundTime())
.set(OrderPayment::getTradeNumber, refund.getData().getRefundOrderId())
.set(OrderPayment::getTradeNumber, refund.getData().getThirdRefundNo())
.set(OrderPayment::getPayStatus, PayTypeConstants.PayStatus.SUCCESS)
.set(OrderPayment::getRespJson, JSONObject.toJSONString(refund.getData()))
.set(OrderPayment::getRespJson, refund.getData().getOriginalData())
.update();
}
}

View File

@@ -2,6 +2,6 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.account.mapper.ShopMerchantMapper">
<mapper namespace="com.czg.service.order.mapper.ShopMerchantMapper">
</mapper>

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.czg</groupId>
<artifactId>cash</artifactId>
<version>1.0.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>pay-service</artifactId>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.czg</groupId>
<artifactId>cash-common-tools</artifactId>
</dependency>
<dependency>
<groupId>com.czg</groupId>
<artifactId>poly-pay</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.czg</groupId>
<artifactId>aggregation-pay</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,45 @@
package com.czg;
import com.czg.enums.CzgPayEnum;
import com.czg.pay.*;
import com.czg.resp.CzgResult;
import jakarta.validation.constraints.NotBlank;
import lombok.NonNull;
import java.util.Map;
/**
* 支付适配器接口
*
* @author ww
*
*/
public interface PayAdapter {
/**
* 支付渠道
* {@link com.czg.constant.PayChannelCst}
*/
String getChannel();
/**
* 统一支付接口
*
* @param payType 支付类型
* @param payData 支付数据 Json类型
* 对应 聚合支付参数 {@link PolyMerchantDTO}
* 对应 原生支付参数 {@link NativeMerchantDTO}
* @param domain 域名 请求地址
* @param notifyUrl 通知地址
* @param bizData 业务数据
*/
CzgResult<Map<String, Object>> pay(@NonNull CzgPayEnum payType, @NotBlank String payData, @NotBlank String domain,
@NotBlank String notifyUrl, CzgPayBaseReq bizData);
CzgResult<RefundRespDTO> refund(@NotBlank String domain, @NotBlank String payData, CzgRefundReq bizData);
CzgResult<QueryOrderRespDTO> queryPayOrder(@NotBlank String domain, @NotBlank String payData, String payOrderId, String mchOrderNo, String platform);
CzgResult<RefundRespDTO> queryRefund(@NotBlank String domain, @NotBlank String payData, String mchRefundNo, String refundOrderId);
}

View File

@@ -0,0 +1,39 @@
package com.czg;
import com.czg.constant.PayChannelCst;
import com.czg.impl.NativePayAdapter;
import com.czg.impl.PolyPayAdapter;
import java.util.HashMap;
import java.util.Map;
/**
* 支付适配器工厂
*
* @author ww
*/
public class PayAdapterFactory {
private static final Map<String, PayAdapter> ADAPTER_MAP = new HashMap<>();
static {
ADAPTER_MAP.put(PayChannelCst.POLY, new PolyPayAdapter());
ADAPTER_MAP.put(PayChannelCst.NATIVE, new NativePayAdapter());
}
/**
* 获取支付适配器
*
* @param channel 支付渠道,仅支持 {@link PayChannelCst}
*/
public static PayAdapter getAdapter(String channel) {
PayAdapter adapter = ADAPTER_MAP.get(channel);
if (adapter == null) {
throw new IllegalStateException("支付渠道未注册适配器: " + channel);
}
return adapter;
}
}

Some files were not shown because too many files have changed in this diff Show More