Compare commits
58 Commits
a5982abe20
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b3fb08036 | |||
| 484ffb07e5 | |||
| e9ef1b0fac | |||
| 04be17d63e | |||
| 21da0a344c | |||
| 656db661ab | |||
| 4498108fb5 | |||
| 235c442c6d | |||
| 592cc99db4 | |||
| f8db70ca43 | |||
| 1f6593c957 | |||
| b22b9bd4d6 | |||
| d6ef8cfba9 | |||
|
|
0fbe490178 | ||
| d693bb0dd3 | |||
| b6e3d109fc | |||
|
|
b83c53fe04 | ||
|
|
5b617b653b | ||
|
|
4866784afe | ||
|
|
97bf69eb31 | ||
|
|
aca48f84d9 | ||
| 9834c59fc7 | |||
| c151a0188d | |||
| 2c417daa3f | |||
| b3a161d643 | |||
| df72bad0dc | |||
| 071e7f5c82 | |||
|
|
2259818ae1 | ||
| 5541ed5da4 | |||
| 9143331267 | |||
|
|
98dfda0bca | ||
| ee25493570 | |||
| a59ea2e841 | |||
| 01aad45a2b | |||
| b8a6ce495c | |||
|
|
cdd012c2fe | ||
|
|
7f64a64dc8 | ||
| 7351188660 | |||
| feee0f8534 | |||
|
|
c4cb2989b3 | ||
| c48c0f6d7d | |||
| bfff341d17 | |||
| e301f996ad | |||
| af0df0d378 | |||
| 721819c3e8 | |||
| b473c82e4f | |||
| 1b975c2164 | |||
| c446d576be | |||
| ab8877c9cf | |||
| 4eaedcce41 | |||
| f85ac0815b | |||
| 80fb367673 | |||
| 574c73d0b5 | |||
| cb18aa5670 | |||
| da3447cd0b | |||
| 9e946443ec | |||
| 71ffdede19 | |||
| 353404dde4 |
@@ -1,27 +1,18 @@
|
|||||||
package com.czg.controller.admin;
|
package com.czg.controller.admin;
|
||||||
|
|
||||||
import cn.hutool.http.server.HttpServerRequest;
|
|
||||||
import cn.hutool.http.server.HttpServerResponse;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.czg.account.dto.SysLoginDTO;
|
import com.czg.account.dto.SysLoginDTO;
|
||||||
import com.czg.account.entity.ShopInfo;
|
import com.czg.account.entity.ShopInfo;
|
||||||
import com.czg.account.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.account.vo.LoginVO;
|
||||||
import com.czg.annotation.SaAdminCheckPermission;
|
|
||||||
import com.czg.annotation.SaStaffCheckPermission;
|
|
||||||
import com.czg.config.RabbitPublisher;
|
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,11 +26,9 @@ public class AuthorizationController {
|
|||||||
@Resource
|
@Resource
|
||||||
private AuthorizationService authorizationService;
|
private AuthorizationService authorizationService;
|
||||||
@Resource
|
@Resource
|
||||||
private PermissionService permissionService;
|
|
||||||
@Resource
|
|
||||||
private ShopInfoService shopInfoService;
|
private ShopInfoService shopInfoService;
|
||||||
@Resource
|
@Resource
|
||||||
private ShopStaffService shopStaffService;
|
private SysUserService sysUserService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,27 +66,6 @@ public class AuthorizationController {
|
|||||||
return CzgResult.success(StpKit.USER.getPermissionList());
|
return CzgResult.success(StpKit.USER.getPermissionList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Resource
|
|
||||||
RabbitPublisher rabbitPublisher;
|
|
||||||
@Resource
|
|
||||||
ShopTableService shopTableService;
|
|
||||||
|
|
||||||
@GetMapping("test")
|
|
||||||
public CzgResult<?> login(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
|
||||||
// shopTableService.createQrCode(1L, 1, response, request);
|
|
||||||
|
|
||||||
|
|
||||||
// rabbitPublisher.sendOrderPrintMsg("552");
|
|
||||||
// printMqListener.orderPrint("1");
|
|
||||||
// return CzgResult.success(Map.of("token", StpKit.USER.getShopId()));
|
|
||||||
return CzgResult.success(StpKit.USER.getLoginId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("test1")
|
|
||||||
public CzgResult<?> login1() throws IOException {
|
|
||||||
authorizationService.switchTo(86L);
|
|
||||||
return CzgResult.success(StpKit.USER.getLoginId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 核销获取 信息使用
|
* 核销获取 信息使用
|
||||||
@@ -105,14 +73,11 @@ public class AuthorizationController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/userInfo")
|
@GetMapping("/userInfo")
|
||||||
public CzgResult<Map<String, Object>> getUserInfo() {
|
public CzgResult<Map<String, Object>> getUserInfo() {
|
||||||
String account = StpKit.USER.getAccount();
|
|
||||||
ShopInfo shopInfo = shopInfoService.queryChain()
|
ShopInfo shopInfo = shopInfoService.queryChain()
|
||||||
.select(ShopInfo::getId, ShopInfo::getShopName)
|
.select(ShopInfo::getId, ShopInfo::getShopName)
|
||||||
.eq(ShopInfo::getId, StpKit.USER.getShopId()).one();
|
.eq(ShopInfo::getId, StpKit.USER.getShopId()).one();
|
||||||
if (account.contains("@")) {
|
SysUser one = sysUserService.queryChain().eq(SysUser::getId, StpKit.USER.getShopId()).one();
|
||||||
account = account.split("@")[1];
|
Map<String, Object> map = Map.of("shopId", shopInfo.getId(), "shopName", shopInfo.getShopName(), "account", one.getAccount());
|
||||||
}
|
|
||||||
Map<String, Object> map = Map.of("shopId", shopInfo.getId(), "shopName", shopInfo.getShopName(), "account", account);
|
|
||||||
return CzgResult.success(map);
|
return CzgResult.success(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ package com.czg.controller;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.CzgPayUtils;
|
|
||||||
import com.czg.PayCst;
|
import com.czg.PayCst;
|
||||||
|
import com.czg.PolyPayUtils;
|
||||||
|
import com.czg.constant.PayChannelCst;
|
||||||
import com.czg.constants.PayTypeConstants;
|
import com.czg.constants.PayTypeConstants;
|
||||||
import com.czg.dto.req.WechatNotifyReqDto;
|
import com.czg.dto.req.WechatNotifyReqDto;
|
||||||
import com.czg.dto.req.WechatPayNotifyDataDto;
|
import com.czg.dto.req.WechatPayNotifyDataDto;
|
||||||
import com.czg.entity.CzgBaseRespParams;
|
import com.czg.entity.PolyBaseResp;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
||||||
import com.czg.market.service.MkDistributionUserService;
|
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.entity.OrderPayment;
|
||||||
import com.czg.order.service.OrderInfoCustomService;
|
import com.czg.order.service.OrderInfoCustomService;
|
||||||
import com.czg.order.service.OrderPaymentService;
|
import com.czg.order.service.OrderPaymentService;
|
||||||
|
import com.czg.pay.PayNotifyRespDTO;
|
||||||
import com.czg.service.market.service.impl.AppWxServiceImpl;
|
import com.czg.service.market.service.impl.AppWxServiceImpl;
|
||||||
import com.czg.third.wechat.WechatReqUtils;
|
import com.czg.third.wechat.WechatReqUtils;
|
||||||
import com.czg.utils.AssertUtil;
|
import com.czg.utils.AssertUtil;
|
||||||
@@ -75,6 +77,8 @@ public class NotifyController {
|
|||||||
log.info("【微信支付回调】解密数据 {}", decrypted);
|
log.info("【微信支付回调】解密数据 {}", decrypted);
|
||||||
|
|
||||||
WechatPayNotifyDataDto dataDto = JSONObject.parseObject(decrypted, WechatPayNotifyDataDto.class);
|
WechatPayNotifyDataDto dataDto = JSONObject.parseObject(decrypted, WechatPayNotifyDataDto.class);
|
||||||
|
PayNotifyRespDTO respDTO = dataDto.convertToPayNotifyRespDTO();
|
||||||
|
orderInfoCustomService.payCallBackOrder(respDTO.getMchOrderNo(), respDTO, PayChannelCst.NATIVE, 0);
|
||||||
return "success";
|
return "success";
|
||||||
} else if (PayCst.Platform.ALIPAY.equalsIgnoreCase(platform)) {
|
} else if (PayCst.Platform.ALIPAY.equalsIgnoreCase(platform)) {
|
||||||
// 支付宝
|
// 支付宝
|
||||||
@@ -105,11 +109,11 @@ public class NotifyController {
|
|||||||
|
|
||||||
|
|
||||||
@RequestMapping("/payCallBack")
|
@RequestMapping("/payCallBack")
|
||||||
public String notifyCallBack(@RequestBody CzgBaseRespParams respParams) {
|
public String notifyCallBack(@RequestBody PolyBaseResp respParams) {
|
||||||
JSONObject czg = CzgPayUtils.getCzg(respParams);
|
PayNotifyRespDTO respDTO = PolyPayUtils.getNotifyResp(respParams);
|
||||||
AssertUtil.isNull(czg, "支付回调数据为空");
|
AssertUtil.isNull(respDTO, "支付回调数据为空");
|
||||||
log.info("支付回调数据为:{}", czg);
|
log.info("支付回调数据为:{}", respDTO);
|
||||||
orderInfoCustomService.payCallBackOrder(czg.getString("mchOrderNo"), czg, 0);
|
orderInfoCustomService.payCallBackOrder(respDTO.getMchOrderNo(), respDTO, PayChannelCst.POLY, 0);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,12 +135,15 @@ public class NotifyController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信原生支付回调
|
||||||
|
*/
|
||||||
@RequestMapping("/native/wx/pay/distributionRecharge")
|
@RequestMapping("/native/wx/pay/distributionRecharge")
|
||||||
public String nativeNotify(HttpServletRequest request) throws IOException {
|
public String nativeNotify(HttpServletRequest request) throws IOException {
|
||||||
String timestamp = request.getHeader("Wechatpay-Timestamp");
|
// String timestamp = request.getHeader("Wechatpay-Timestamp");
|
||||||
String nonce = request.getHeader("Wechatpay-Nonce");
|
// String nonce = request.getHeader("Wechatpay-Nonce");
|
||||||
String serialNo = request.getHeader("Wechatpay-Serial");
|
// String serialNo = request.getHeader("Wechatpay-Serial");
|
||||||
String signature = request.getHeader("Wechatpay-Signature");
|
// String signature = request.getHeader("Wechatpay-Signature");
|
||||||
String result = IoUtil.readUtf8(request.getInputStream());
|
String result = IoUtil.readUtf8(request.getInputStream());
|
||||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||||
JSONObject resource = jsonObject.getJSONObject("resource");
|
JSONObject resource = jsonObject.getJSONObject("resource");
|
||||||
@@ -171,8 +178,8 @@ public class NotifyController {
|
|||||||
|
|
||||||
|
|
||||||
@RequestMapping("/refundCallBack")
|
@RequestMapping("/refundCallBack")
|
||||||
public String refundCallBack(@RequestBody CzgBaseRespParams respParams) {
|
public String refundCallBack(@RequestBody PolyBaseResp respParams) {
|
||||||
JSONObject czg = CzgPayUtils.getCzg(respParams);
|
JSONObject czg = PolyPayUtils.getCzg(respParams);
|
||||||
AssertUtil.isNull(czg, "退款回调数据为空");
|
AssertUtil.isNull(czg, "退款回调数据为空");
|
||||||
log.info("退款回调数据为:{}", czg);
|
log.info("退款回调数据为:{}", czg);
|
||||||
orderInfoCustomService.refundCallBackOrder(czg.getString("mchOrderNo"), czg);
|
orderInfoCustomService.refundCallBackOrder(czg.getString("mchOrderNo"), czg);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.czg.controller.admin;
|
|||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.EntryManager;
|
import com.czg.EntryManager;
|
||||||
import com.czg.annotation.Debounce;
|
import com.czg.annotation.Debounce;
|
||||||
import com.czg.config.RabbitPublisher;
|
|
||||||
import com.czg.dto.req.AggregateMerchantDto;
|
import com.czg.dto.req.AggregateMerchantDto;
|
||||||
import com.czg.dto.resp.WechatBankBranchRespDto;
|
import com.czg.dto.resp.WechatBankBranchRespDto;
|
||||||
import com.czg.order.entity.ShopDirectMerchant;
|
import com.czg.order.entity.ShopDirectMerchant;
|
||||||
@@ -33,9 +32,6 @@ public class EntryManagerController {
|
|||||||
@Resource
|
@Resource
|
||||||
private EntryManagerTask entryManagerTask;
|
private EntryManagerTask entryManagerTask;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private RabbitPublisher rabbitPublisher;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ocr识别填充
|
* ocr识别填充
|
||||||
* 阿里 ocr识别图片
|
* 阿里 ocr识别图片
|
||||||
@@ -68,12 +64,6 @@ public class EntryManagerController {
|
|||||||
return CzgResult.success(EntryManager.queryBankBranchList(bankAliceCode, cityCode));
|
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
|
@GetMapping
|
||||||
public CzgResult<AggregateMerchantVO> getEntry(Long shopId, String licenceNo) {
|
public CzgResult<AggregateMerchantVO> getEntry(Long shopId) {
|
||||||
return CzgResult.success(shopDirectMerchantService.getEntry(shopId, licenceNo));
|
return CzgResult.success(shopDirectMerchantService.getEntry(shopId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,8 +88,8 @@ public class EntryManagerController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("queryEntry")
|
@GetMapping("queryEntry")
|
||||||
@Debounce(value = "#shopId", interval = 1000 * 60 * 3)
|
@Debounce(value = "#shopId", interval = 1000 * 60 * 3)
|
||||||
public CzgResult<Boolean> queryEntry(Long shopId, String licenceNo) {
|
public CzgResult<Boolean> queryEntry(Long shopId) {
|
||||||
entryManagerTask.entryManager(shopId, licenceNo);
|
entryManagerTask.entryManager(shopId);
|
||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
package com.czg.controller.admin;
|
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.SaAdminCheckPermission;
|
||||||
import com.czg.annotation.SaAdminCheckRole;
|
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.resp.CzgResult;
|
||||||
import com.czg.sa.StpKit;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商户信息管理
|
* 商户信息管理
|
||||||
|
*
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@@ -24,25 +25,39 @@ public class ShopMerchantController {
|
|||||||
/**
|
/**
|
||||||
* 商户支付信息获取
|
* 商户支付信息获取
|
||||||
* 权限标识: shopMerchant:detail
|
* 权限标识: shopMerchant:detail
|
||||||
|
*
|
||||||
* @param shopId 店铺id
|
* @param shopId 店铺id
|
||||||
* @return 支付信息
|
* @return 支付信息
|
||||||
*/
|
*/
|
||||||
@SaAdminCheckRole("管理员")
|
@SaAdminCheckRole("管理员")
|
||||||
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:detail", name = "商户支付信息获取")
|
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:detail", name = "商户支付信息获取")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public CzgResult<ShopMerchant> detail(@RequestParam Integer shopId) {
|
public CzgResult<ShopMerchantDTO> detail(@RequestParam Long shopId) {
|
||||||
return CzgResult.success(shopMerchantService.detail(shopId));
|
return CzgResult.success(shopMerchantService.detail(shopId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商户支付信息修改
|
* 商户支付信息修改
|
||||||
* 权限标识: shopMerchant:edit
|
* 权限标识: shopMerchant:edit
|
||||||
|
*
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
@SaAdminCheckRole("管理员")
|
@SaAdminCheckRole("管理员")
|
||||||
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:edit", name = "商户支付信息修改")
|
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:edit", name = "商户支付信息修改")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public CzgResult<Boolean> edit(@RequestBody @Validated ShopMerchantEditDTO shopMerchantEditDTO) {
|
public CzgResult<Boolean> edit(@RequestBody ShopMerchantDTO shopMerchant) {
|
||||||
return CzgResult.success(shopMerchantService.edit(shopMerchantEditDTO));
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ public class DistributionPayController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/ltPayOrder")
|
@PostMapping("/ltPayOrder")
|
||||||
@Debounce(value = "#payParam.userId")
|
@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);
|
return payService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,8 +46,8 @@ public class DistributionPayController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/mchRecharge")
|
@PostMapping("/mchRecharge")
|
||||||
@Debounce(value = "#payParam.userId")
|
@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不为空");
|
AssertUtil.isBlank(payParam.getCode(), "微信code不为空");
|
||||||
return CzgResult.success(payService.mchRecharge(ServletUtil.getClientIP(request), payParam));
|
return CzgResult.success(payService.mchRecharge(payParam));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.czg.controller.pay;
|
package com.czg.controller.pay;
|
||||||
|
|
||||||
import com.czg.annotation.Debounce;
|
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.resp.CzgResult;
|
||||||
import com.czg.service.order.dto.VipMemberPayParamDTO;
|
import com.czg.service.order.dto.VipMemberPayParamDTO;
|
||||||
import com.czg.service.order.dto.VipPayParamDTO;
|
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.service.order.service.ShopUserPayService;
|
||||||
import com.czg.utils.AssertUtil;
|
import com.czg.utils.AssertUtil;
|
||||||
import com.czg.utils.ServletUtil;
|
import com.czg.utils.ServletUtil;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -32,6 +35,9 @@ public class VipPayController {
|
|||||||
@Resource
|
@Resource
|
||||||
private ShopUserPayService shopUserPayService;
|
private ShopUserPayService shopUserPayService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderPaymentService paymentService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 现金充值
|
* 现金充值
|
||||||
* 如果shop_info的 is_member_in_pwd=1 则pwd必填 店铺操作密码
|
* 如果shop_info的 is_member_in_pwd=1 则pwd必填 店铺操作密码
|
||||||
@@ -73,9 +79,6 @@ public class VipPayController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 智慧充值
|
* 智慧充值
|
||||||
* @param request
|
|
||||||
* @param rechargeDTO
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@PostMapping("/recharge")
|
@PostMapping("/recharge")
|
||||||
@Debounce(value = "#rechargeDTO.shopUserId")
|
@Debounce(value = "#rechargeDTO.shopUserId")
|
||||||
@@ -89,9 +92,6 @@ public class VipPayController {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员购买支付
|
* 会员购买支付
|
||||||
* @param request
|
|
||||||
* @param payParam
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@PostMapping("/ltPayMember")
|
@PostMapping("/ltPayMember")
|
||||||
@Debounce(value = "#payParam.shopUserId")
|
@Debounce(value = "#payParam.shopUserId")
|
||||||
@@ -168,10 +168,16 @@ public class VipPayController {
|
|||||||
public CzgResult<String> queryOrderStatus(Long shopId, String payOrderNo) {
|
public CzgResult<String> queryOrderStatus(Long shopId, String payOrderNo) {
|
||||||
AssertUtil.isNull(shopId, "店铺id不能为空");
|
AssertUtil.isNull(shopId, "店铺id不能为空");
|
||||||
AssertUtil.isBlank(payOrderNo, "支付单号不能为空");
|
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<String> result = CzgResult.success();
|
||||||
CzgResult<CzgBaseResp> queryPayOrder = payService.queryPayOrder(shopId, null, payOrderNo);
|
CzgResult<QueryOrderRespDTO> queryPayOrder = payService.queryPayOrder(shopId, null, payOrderNo, payment.getPlatformType());
|
||||||
if (queryPayOrder.getCode() == 200 && queryPayOrder.getData() != null) {
|
if (queryPayOrder.isSuccess() && queryPayOrder.getData() != null) {
|
||||||
String state = queryPayOrder.getData().getState();
|
String state = queryPayOrder.getData().getStatus();
|
||||||
result.setData(state);
|
result.setData(state);
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case "TRADE_AWAIT" -> result.setMsg("等待用户付款");
|
case "TRADE_AWAIT" -> result.setMsg("等待用户付款");
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class EntryManagerMqListener {
|
|||||||
ThreadContext.put("traceId", String.valueOf(shopId));
|
ThreadContext.put("traceId", String.valueOf(shopId));
|
||||||
log.info("进件2MQ对接开始shopId:{}", msg);
|
log.info("进件2MQ对接开始shopId:{}", msg);
|
||||||
// 安全转换shopId
|
// 安全转换shopId
|
||||||
AggregateMerchantVO entry = shopDirectMerchantService.getEntry(shopId, split[1]);
|
AggregateMerchantVO entry = shopDirectMerchantService.getEntry(shopId);
|
||||||
log.info("进件3MQ对接开始shopId:{}", msg);
|
log.info("进件3MQ对接开始shopId:{}", msg);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
EntryManager.uploadParamImage(entry);
|
EntryManager.uploadParamImage(entry);
|
||||||
|
|||||||
@@ -2,16 +2,18 @@ package com.czg.task;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.EntryManager;
|
import com.czg.EntryManager;
|
||||||
import com.czg.PayCst;
|
import com.czg.PayCst;
|
||||||
import com.czg.account.service.ShopInfoService;
|
|
||||||
import com.czg.dto.resp.QueryStatusResp;
|
import com.czg.dto.resp.QueryStatusResp;
|
||||||
import com.czg.order.entity.ShopDirectMerchant;
|
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.czg.service.order.service.ShopDirectMerchantService;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -27,25 +29,24 @@ import java.util.List;
|
|||||||
public class EntryManagerTask {
|
public class EntryManagerTask {
|
||||||
@Resource
|
@Resource
|
||||||
private ShopDirectMerchantService shopDirectMerchantService;
|
private ShopDirectMerchantService shopDirectMerchantService;
|
||||||
@DubboReference
|
@Resource
|
||||||
private ShopInfoService shopInfoService;
|
private ShopMerchantService shopMerchantService;
|
||||||
|
|
||||||
//每10分钟查一次
|
//每10分钟查一次
|
||||||
@Scheduled(cron = "0 0/10 * * * ? ")
|
@Scheduled(cron = "0 0/10 * * * ? ")
|
||||||
public void run() {
|
public void run() {
|
||||||
log.info("进件查询,定时任务执行");
|
log.info("进件查询,定时任务执行");
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
entryManager(null, null);
|
entryManager(null);
|
||||||
log.info("进件查询,定时任务执行完毕,耗时:{}ms", start - System.currentTimeMillis());
|
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()
|
List<ShopDirectMerchant> list = shopDirectMerchantService.list(QueryWrapper.create()
|
||||||
.eq(ShopDirectMerchant::getShopId, shopId)
|
.eq(ShopDirectMerchant::getShopId, shopId)
|
||||||
.eq(ShopDirectMerchant::getLicenceNo, licenceNo)
|
|
||||||
.in(ShopDirectMerchant::getWechatStatus, PayCst.EntryStatus.NEED_QUERY_LIST)
|
.in(ShopDirectMerchant::getWechatStatus, PayCst.EntryStatus.NEED_QUERY_LIST)
|
||||||
.or(ShopDirectMerchant::getAlipayStatus).in(PayCst.EntryStatus.NEED_QUERY_LIST));
|
.or(ShopDirectMerchant::getAlipayStatus).in(PayCst.EntryStatus.NEED_QUERY_LIST));
|
||||||
if (CollUtil.isEmpty(list)) {
|
if (CollUtil.isEmpty(list)) {
|
||||||
@@ -58,7 +59,8 @@ public class EntryManagerTask {
|
|||||||
QueryStatusResp wechatStatus = EntryManager.queryWechatEntryStatus(shopDirectMerchant.getWechatApplyId());
|
QueryStatusResp wechatStatus = EntryManager.queryWechatEntryStatus(shopDirectMerchant.getWechatApplyId());
|
||||||
shopDirectMerchant.setWechatStatus(wechatStatus.getStatus());
|
shopDirectMerchant.setWechatStatus(wechatStatus.getStatus());
|
||||||
shopDirectMerchant.setWechatErrorMsg(wechatStatus.getFailReason());
|
shopDirectMerchant.setWechatErrorMsg(wechatStatus.getFailReason());
|
||||||
shopDirectMerchant.setWechatSignUrl(wechatStatus.getSignUrl());
|
shopDirectMerchant.setWechatSignUrl("");
|
||||||
|
shopDirectMerchant.setWechatMerchantId(wechatStatus.getThirdMerchantId());
|
||||||
if (PayCst.EntryStatus.FINISH.equals(wechatStatus.getStatus())) {
|
if (PayCst.EntryStatus.FINISH.equals(wechatStatus.getStatus())) {
|
||||||
wechatMerchantId = wechatStatus.getThirdMerchantId();
|
wechatMerchantId = wechatStatus.getThirdMerchantId();
|
||||||
}
|
}
|
||||||
@@ -67,14 +69,28 @@ public class EntryManagerTask {
|
|||||||
QueryStatusResp alipayStatus = EntryManager.queryAlipayEntryStatus(shopDirectMerchant.getAlipayOrderId());
|
QueryStatusResp alipayStatus = EntryManager.queryAlipayEntryStatus(shopDirectMerchant.getAlipayOrderId());
|
||||||
shopDirectMerchant.setAlipayStatus(alipayStatus.getStatus());
|
shopDirectMerchant.setAlipayStatus(alipayStatus.getStatus());
|
||||||
shopDirectMerchant.setAlipayErrorMsg(alipayStatus.getFailReason());
|
shopDirectMerchant.setAlipayErrorMsg(alipayStatus.getFailReason());
|
||||||
shopDirectMerchant.setAlipaySignUrl(alipayStatus.getSignUrl());
|
shopDirectMerchant.setAlipaySignUrl("");
|
||||||
|
shopDirectMerchant.setAlipayMerchantId(alipayStatus.getThirdMerchantId());
|
||||||
if (PayCst.EntryStatus.FINISH.equals(alipayStatus.getStatus())) {
|
if (PayCst.EntryStatus.FINISH.equals(alipayStatus.getStatus())) {
|
||||||
alipayMerchantId = alipayStatus.getThirdMerchantId();
|
alipayMerchantId = alipayStatus.getThirdMerchantId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
shopDirectMerchantService.updateById(shopDirectMerchant);
|
shopDirectMerchantService.updateById(shopDirectMerchant);
|
||||||
if (StrUtil.isNotBlank(wechatMerchantId) || StrUtil.isNotBlank(alipayMerchantId)) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,9 +50,8 @@ public class FastJson2Config implements WebMvcConfigurer {
|
|||||||
// 设置支持的媒体类型
|
// 设置支持的媒体类型
|
||||||
List<MediaType> supportedMediaTypes = new ArrayList<>();
|
List<MediaType> supportedMediaTypes = new ArrayList<>();
|
||||||
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
|
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
|
||||||
supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
|
|
||||||
converter.setSupportedMediaTypes(supportedMediaTypes);
|
converter.setSupportedMediaTypes(supportedMediaTypes);
|
||||||
// 将转换器添加到 Spring MVC 的消息转换器列表中
|
// 将转换器添加到 Spring MVC 的消息转换器列表中
|
||||||
converters.add(0, converter);
|
converters.addFirst(converter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<artifactId>cash-common-service</artifactId>
|
<artifactId>cash-common-service</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>global-service</name>
|
<name>common-service</name>
|
||||||
<url>https://maven.apache.org</url>
|
<url>https://maven.apache.org</url>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ public class ShopInfo implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用系统用户 sys_user id
|
* 使用系统用户 sys_user id
|
||||||
*/
|
*/
|
||||||
@@ -142,18 +141,6 @@ public class ShopInfo implements Serializable {
|
|||||||
* -1 平台禁用 0-过期,1正式营业,
|
* -1 平台禁用 0-过期,1正式营业,
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
/**
|
|
||||||
* 微信商户id
|
|
||||||
*/
|
|
||||||
private String wechatMerchantId;
|
|
||||||
/**
|
|
||||||
* 支付宝商户id
|
|
||||||
*/
|
|
||||||
private String alipayMerchantId;
|
|
||||||
/**
|
|
||||||
* 支付宝授权信息
|
|
||||||
*/
|
|
||||||
private String alipayAuthInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 到期时间
|
* 到期时间
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.czg.account.service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Administrator
|
|
||||||
*/
|
|
||||||
public interface PermissionService {
|
|
||||||
}
|
|
||||||
@@ -38,11 +38,6 @@ public interface ShopInfoService extends IService<ShopInfo> {
|
|||||||
|
|
||||||
Boolean edit(ShopInfoEditDTO shopInfoEditDTO);
|
Boolean edit(ShopInfoEditDTO shopInfoEditDTO);
|
||||||
|
|
||||||
/**
|
|
||||||
* 进件结果保存
|
|
||||||
*/
|
|
||||||
Boolean editEntry(Long shopId, String wechatMerchantId, String alipayMerchantId, String alipayAuthInfo);
|
|
||||||
|
|
||||||
ShopDetailDTO detail(Long id) throws CzgException;
|
ShopDetailDTO detail(Long id) throws CzgException;
|
||||||
|
|
||||||
ShopInfoByCodeDTO getByCode(String tableCode, String lat, String lng, boolean checkState);
|
ShopInfoByCodeDTO getByCode(String tableCode, String lat, String lng, boolean checkState);
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
|
||||||
@@ -79,7 +79,27 @@ public interface ParamCodeCst {
|
|||||||
* 超掌柜支付回调地址
|
* 超掌柜支付回调地址
|
||||||
* <p>支付宝/微信支付完成后,支付平台回调我方系统的地址</p>
|
* <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";
|
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";
|
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>
|
* <p>餐厅叫号系统的前端页面地址</p>
|
||||||
*/
|
*/
|
||||||
public static String CALL_PAGE_URL = "call_page_url";
|
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>
|
* <p>公众号关注入口的展示位置,可选值:mine-我的页面、order-订单页面、eat-就餐页面</p>
|
||||||
|
|||||||
@@ -43,4 +43,30 @@ public interface SystemConstants {
|
|||||||
*/
|
*/
|
||||||
public static final String CUSTOM = "custom";
|
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";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.czg.market.service;
|
package com.czg.market.service;
|
||||||
|
|
||||||
import com.czg.enums.ShopUserFlowBizEnum;
|
import com.czg.enums.ShopUserFlowBizEnum;
|
||||||
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.market.dto.MkShopRechargeDTO;
|
import com.czg.market.dto.MkShopRechargeDTO;
|
||||||
import com.czg.market.vo.MkShopRechargeShopListVO;
|
import com.czg.market.vo.MkShopRechargeShopListVO;
|
||||||
import com.czg.market.vo.MkShopRechargeVO;
|
import com.czg.market.vo.MkShopRechargeVO;
|
||||||
@@ -21,7 +22,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface MkShopRechargeService extends IService<MkShopRecharge> {
|
public interface MkShopRechargeService extends IService<MkShopRecharge> {
|
||||||
|
|
||||||
MkShopRechargeVO detail(Long shopId);
|
MkShopRechargeVO detail(Long shopId) throws CzgException;
|
||||||
|
|
||||||
MkShopRechargeVO detailApp(Long shopId);
|
MkShopRechargeVO detailApp(Long shopId);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ public class MkDistributionPayDTO implements Serializable {
|
|||||||
private Long shopId;
|
private Long shopId;
|
||||||
private String platformType = "DIS";
|
private String platformType = "DIS";
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 支付类型
|
||||||
|
* {@link com.czg.constants.SystemConstants.PayType}
|
||||||
|
*/
|
||||||
private String payType;
|
private String payType;
|
||||||
private String returnUrl;
|
private String returnUrl;
|
||||||
private String buyerRemark;
|
private String buyerRemark;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class OrderInfoAddDTO implements Serializable {
|
|||||||
* 已出菜 SENT_OUT
|
* 已出菜 SENT_OUT
|
||||||
* 已上菜 DELIVERED
|
* 已上菜 DELIVERED
|
||||||
* 已超时 EXPIRED
|
* 已超时 EXPIRED
|
||||||
|
* 加急 URGENT
|
||||||
*/
|
*/
|
||||||
private String subStatus;
|
private String subStatus;
|
||||||
//限时折扣部分
|
//限时折扣部分
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import com.mybatisflex.annotation.Column;
|
|||||||
import com.mybatisflex.annotation.Id;
|
import com.mybatisflex.annotation.Id;
|
||||||
import com.mybatisflex.annotation.KeyType;
|
import com.mybatisflex.annotation.KeyType;
|
||||||
import com.mybatisflex.annotation.Table;
|
import com.mybatisflex.annotation.Table;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -40,6 +41,17 @@ public class OrderPayment implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Long shopId;
|
private Long shopId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付渠道
|
||||||
|
* {@link com.czg.constant.PayChannelCst}
|
||||||
|
*/
|
||||||
|
private String channel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平台类型
|
||||||
|
* {@link com.czg.PayCst.Platform}
|
||||||
|
*/
|
||||||
|
private String platformType;
|
||||||
/**
|
/**
|
||||||
* 来源Id 订单Id或充值id
|
* 来源Id 订单Id或充值id
|
||||||
*/
|
*/
|
||||||
@@ -81,7 +93,7 @@ public class OrderPayment implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String tradeNumber;
|
private String tradeNumber;
|
||||||
|
|
||||||
@Column(onUpdateValue = "now()")
|
// @Column(onUpdateValue = "now()")
|
||||||
private LocalDateTime payTime;
|
private LocalDateTime payTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,28 +116,67 @@ public class OrderPayment implements Serializable {
|
|||||||
public OrderPayment() {
|
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;
|
* @param sourceId 订单Id
|
||||||
this.sourceType = sourceType;
|
* @param amount 单元 元
|
||||||
this.payType = payType;
|
* @param authCode 扫码支付时必填 扫描码
|
||||||
this.orderNo = orderNo;
|
*/
|
||||||
this.authCode = authCode;
|
public static OrderPayment orderPay(@NonNull Long shopId, @NonNull Long sourceId,
|
||||||
this.amount = amount;
|
@NotBlank String orderNo, @NonNull BigDecimal amount, String authCode) {
|
||||||
this.payStatus = PayTypeConstants.PayStatus.INIT;
|
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;
|
* @param sourceId 充值时为会员Id shopUserID
|
||||||
this.sourceType = sourceType;
|
* 购买时为商品Id
|
||||||
this.payType = payType;
|
* @param sourceType {@link PayTypeConstants.SourceType} 支付来源
|
||||||
this.orderNo = orderNo;
|
* @param amount 单元 元
|
||||||
this.authCode = authCode;
|
* @param authCode 扫码支付时必填 扫描码
|
||||||
this.amount = amount;
|
* @param relatedId 霸王餐充值为 订单id 会员充值为 活动id 充值并支付时 为 MkShopRechargeDetail
|
||||||
this.relatedId = relatedId;
|
*/
|
||||||
this.payStatus = PayTypeConstants.PayStatus.INIT;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ public class ShopDirectMerchant implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 营业执照编号
|
* 营业执照编号
|
||||||
*/
|
*/
|
||||||
@Id
|
|
||||||
private String licenceNo;
|
private String licenceNo;
|
||||||
/**
|
/**
|
||||||
* 支付宝账号
|
* 支付宝账号
|
||||||
@@ -124,11 +123,6 @@ public class ShopDirectMerchant implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String alipayStatus;
|
private String alipayStatus;
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付宝授信息
|
|
||||||
*/
|
|
||||||
private String alipayAuthInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝进件错误信息
|
* 支付宝进件错误信息
|
||||||
*/
|
*/
|
||||||
@@ -138,4 +132,18 @@ public class ShopDirectMerchant implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String alipaySignUrl;
|
private String alipaySignUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付宝授信息
|
||||||
|
*/
|
||||||
|
private String alipayAuthInfo;
|
||||||
|
/**
|
||||||
|
* 微信商户id
|
||||||
|
*/
|
||||||
|
private String wechatMerchantId;
|
||||||
|
/**
|
||||||
|
* 支付宝商户id
|
||||||
|
*/
|
||||||
|
private String alipayMerchantId;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.czg.account.entity;
|
package com.czg.order.entity;
|
||||||
|
|
||||||
import com.mybatisflex.annotation.Column;
|
import com.mybatisflex.annotation.Column;
|
||||||
import com.mybatisflex.annotation.Id;
|
import com.mybatisflex.annotation.Id;
|
||||||
@@ -18,7 +18,6 @@ import java.time.LocalDateTime;
|
|||||||
* @since 2025-02-11
|
* @since 2025-02-11
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Table("tb_shop_merchant")
|
@Table("tb_shop_merchant")
|
||||||
@@ -27,48 +26,46 @@ public class ShopMerchant implements Serializable {
|
|||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* 店铺id
|
* 店铺id
|
||||||
*/
|
*/
|
||||||
@Id
|
|
||||||
private Long shopId;
|
private Long shopId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付系统商户id
|
* poly 聚合(支付平台) native 原生(wx/ali 原生)
|
||||||
|
* {@link com.czg.constant.PayChannelCst}
|
||||||
*/
|
*/
|
||||||
private String storeId;
|
private String channel;
|
||||||
|
|
||||||
private String merchantName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商户应用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 nativePayJson;
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付密码
|
|
||||||
*/
|
|
||||||
private String payPassword;
|
|
||||||
|
|
||||||
@Column(onInsertValue = "now()")
|
@Column(onInsertValue = "now()")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,9 +12,9 @@ import com.czg.order.enums.PayEnums;
|
|||||||
import com.czg.order.vo.HistoryOrderPrintVo;
|
import com.czg.order.vo.HistoryOrderPrintVo;
|
||||||
import com.czg.order.vo.HistoryOrderVo;
|
import com.czg.order.vo.HistoryOrderVo;
|
||||||
import com.czg.order.vo.OrderInfoVo;
|
import com.czg.order.vo.OrderInfoVo;
|
||||||
|
import com.czg.pay.PayNotifyRespDTO;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.mybatisflex.core.service.IService;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ public interface OrderInfoCustomService {
|
|||||||
|
|
||||||
CzgResult<Object> mergeOrder(MergeOrderDTO param);
|
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);
|
void refundCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson);
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.czg.third.alipay.dto;
|
package com.czg.pay;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.annotation.JSONField;
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.czg.entity.req;
|
package com.czg.pay;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@@ -23,7 +23,10 @@ public class CzgRefundReq {
|
|||||||
* 单位为分
|
* 单位为分
|
||||||
*/
|
*/
|
||||||
private Long refundAmount;
|
private Long refundAmount;
|
||||||
|
/**
|
||||||
|
* 原订单总金额 单位 分
|
||||||
|
*/
|
||||||
|
private Long orderTotalAmount;
|
||||||
|
|
||||||
//非必填范围
|
//非必填范围
|
||||||
/**
|
/**
|
||||||
@@ -47,15 +50,22 @@ public class CzgRefundReq {
|
|||||||
*/
|
*/
|
||||||
private String notifyUrl;
|
private String notifyUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付平台
|
||||||
|
*/
|
||||||
|
private String platform;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* payOrderId和mchOrderNo 二选一 必填
|
* payOrderId和mchOrderNo 二选一 必填
|
||||||
*/
|
*/
|
||||||
public CzgRefundReq(@NonNull String mchRefundNo, @NonNull String refundReason, @NonNull Long refundAmount,
|
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.mchRefundNo = mchRefundNo;
|
||||||
this.refundReason = refundReason;
|
this.refundReason = refundReason;
|
||||||
this.refundAmount = refundAmount;
|
this.refundAmount = refundAmount;
|
||||||
|
this.orderTotalAmount = orderTotalAmount;
|
||||||
this.mchOrderNo = mchOrderNo;
|
this.mchOrderNo = mchOrderNo;
|
||||||
this.extParam = extParam;
|
this.extParam = extParam;
|
||||||
|
this.platform = platform;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -1,16 +1,14 @@
|
|||||||
package com.czg.account.dto.merchant;
|
package com.czg.pay;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Administrator
|
* 聚合支付参数
|
||||||
|
* @author ww
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ShopMerchantEditDTO {
|
public class PolyMerchantDTO {
|
||||||
@NotNull(message = "店铺id不为空")
|
|
||||||
private Long shopId;
|
|
||||||
@NotEmpty(message = "支付系统商户id不为空")
|
@NotEmpty(message = "支付系统商户id不为空")
|
||||||
private String storeId;
|
private String storeId;
|
||||||
@NotEmpty(message = "支付系统商户名称不为空")
|
@NotEmpty(message = "支付系统商户名称不为空")
|
||||||
@@ -20,12 +18,6 @@ public class ShopMerchantEditDTO {
|
|||||||
@NotEmpty(message = "商户秘钥不为空")
|
@NotEmpty(message = "商户秘钥不为空")
|
||||||
private String appSecret;
|
private String appSecret;
|
||||||
// 支付密码
|
// 支付密码
|
||||||
@NotEmpty(message = "支付密码不为空")
|
// @NotEmpty(message = "支付密码不为空")
|
||||||
private String payPassword;
|
private String payPassword;
|
||||||
// 微信appid
|
|
||||||
@NotEmpty(message = "微信appid")
|
|
||||||
private String wechatSmallAppid;
|
|
||||||
// 支付宝appid
|
|
||||||
@NotEmpty(message = "支付宝appid")
|
|
||||||
private String alipaySmallAppid;
|
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
@@ -37,6 +37,11 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- 短信 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun</groupId>
|
||||||
|
<artifactId>dysmsapi20170525</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.zxing</groupId>
|
<groupId>com.google.zxing</groupId>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
@@ -45,10 +50,6 @@
|
|||||||
<groupId>cn.hutool</groupId>
|
<groupId>cn.hutool</groupId>
|
||||||
<artifactId>hutool-all</artifactId>
|
<artifactId>hutool-all</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.aliyun</groupId>
|
|
||||||
<artifactId>dysmsapi20170525</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.fastjson2</groupId>
|
<groupId>com.alibaba.fastjson2</groupId>
|
||||||
<artifactId>fastjson2</artifactId>
|
<artifactId>fastjson2</artifactId>
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.czg.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付渠道常量
|
||||||
|
* @author ww
|
||||||
|
*/
|
||||||
|
public interface PayChannelCst {
|
||||||
|
/**
|
||||||
|
* 聚合支付
|
||||||
|
* 对应 类 PolyPay
|
||||||
|
*/
|
||||||
|
String POLY = "poly";
|
||||||
|
/**
|
||||||
|
* 原生支付
|
||||||
|
* 对应 类 NativePay
|
||||||
|
*/
|
||||||
|
String NATIVE = "native";
|
||||||
|
}
|
||||||
@@ -59,4 +59,8 @@ public class CzgResult<T> implements Serializable {
|
|||||||
public static <T> CzgResult<T> failure(CzgRespCode respCode) {
|
public static <T> CzgResult<T> failure(CzgRespCode respCode) {
|
||||||
return new CzgResult<>(respCode.getCode(), respCode.getMsg(), null);
|
return new CzgResult<>(respCode.getCode(), respCode.getMsg(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSuccess() {
|
||||||
|
return code == 200;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@
|
|||||||
<netty.version>4.1.128.Final</netty.version>
|
<netty.version>4.1.128.Final</netty.version>
|
||||||
<wechatpay.version>0.2.17</wechatpay.version>
|
<wechatpay.version>0.2.17</wechatpay.version>
|
||||||
<apipay-v3.version>3.1.65.ALL</apipay-v3.version>
|
<apipay-v3.version>3.1.65.ALL</apipay-v3.version>
|
||||||
<dom4j.version>2.2.0</dom4j.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@@ -283,13 +282,6 @@
|
|||||||
<artifactId>alipay-sdk-java-v3</artifactId>
|
<artifactId>alipay-sdk-java-v3</artifactId>
|
||||||
<version>${apipay-v3.version}</version>
|
<version>${apipay-v3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dom4j</groupId>
|
|
||||||
<artifactId>dom4j</artifactId>
|
|
||||||
<version>${dom4j.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
@@ -35,13 +35,6 @@
|
|||||||
<artifactId>ocr_api20210707</artifactId>
|
<artifactId>ocr_api20210707</artifactId>
|
||||||
<version>3.1.2</version>
|
<version>3.1.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Source: https://mvnrepository.com/artifact/org.dom4j/dom4j -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dom4j</groupId>
|
|
||||||
<artifactId>dom4j</artifactId>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -9,7 +9,6 @@ import com.czg.exception.CzgException;
|
|||||||
import com.czg.third.alipay.AlipayEntryManager;
|
import com.czg.third.alipay.AlipayEntryManager;
|
||||||
import com.czg.third.alipay.AlipayIsvEntryManager;
|
import com.czg.third.alipay.AlipayIsvEntryManager;
|
||||||
import com.czg.third.wechat.WechatEntryManager;
|
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.AssertUtil;
|
||||||
import com.czg.utils.AsyncTaskExecutor;
|
import com.czg.utils.AsyncTaskExecutor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -385,8 +384,8 @@ public class EntryManager {
|
|||||||
// verifyEntryParam(merchantDto);
|
// verifyEntryParam(merchantDto);
|
||||||
// uploadParamImage(merchantDto);
|
// uploadParamImage(merchantDto);
|
||||||
//// System.out.println(merchantDto);
|
//// System.out.println(merchantDto);
|
||||||
// EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.WECHAT);
|
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.WECHAT);
|
||||||
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.ALIPAY);
|
// entryMerchant(merchantDto, PayCst.Platform.ALIPAY);
|
||||||
// entryMerchant(merchantDto, PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY);
|
// entryMerchant(merchantDto, PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY);
|
||||||
System.out.println(respDto);
|
System.out.println(respDto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.czg;
|
package com.czg;
|
||||||
|
|
||||||
import com.czg.dto.req.PayParamsDto;
|
import com.czg.constants.SystemConstants;
|
||||||
import com.czg.dto.req.RefundParamsDto;
|
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
|
import com.czg.pay.*;
|
||||||
import com.czg.third.alipay.AlipayIsvPayManager;
|
import com.czg.third.alipay.AlipayIsvPayManager;
|
||||||
import com.czg.third.wechat.WechatPayManager;
|
import com.czg.third.wechat.WechatPayManager;
|
||||||
|
|
||||||
@@ -20,13 +20,11 @@ public class PayManager {
|
|||||||
* @param paramsDto 参数
|
* @param paramsDto 参数
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> jsapiPay(PayParamsDto paramsDto) {
|
public static Map<String, Object> jsapiPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||||
paramsDto.verifyParams();
|
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
|
||||||
|
return WechatPayManager.jsapiPay(null, paramsDto, merchantDTO);
|
||||||
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
|
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
|
||||||
return WechatPayManager.jsapiPay(null, paramsDto);
|
return AlipayIsvPayManager.jsapiPay(null, paramsDto, merchantDTO);
|
||||||
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
|
|
||||||
return AlipayIsvPayManager.jsapiPay(null, paramsDto);
|
|
||||||
} else {
|
} else {
|
||||||
throw new CzgException("不支持的支付平台");
|
throw new CzgException("不支持的支付平台");
|
||||||
}
|
}
|
||||||
@@ -38,13 +36,11 @@ public class PayManager {
|
|||||||
* @param paramsDto 参数
|
* @param paramsDto 参数
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> barPay(PayParamsDto paramsDto) {
|
public static Map<String, Object> barPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||||
paramsDto.verifyParams();
|
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
|
||||||
|
return WechatPayManager.barPay(null, paramsDto, merchantDTO);
|
||||||
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
|
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
|
||||||
return WechatPayManager.barPay(null, paramsDto);
|
return AlipayIsvPayManager.barPay(null, paramsDto, merchantDTO);
|
||||||
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
|
|
||||||
return AlipayIsvPayManager.barPay(null, paramsDto);
|
|
||||||
} else {
|
} else {
|
||||||
throw new CzgException("不支持的支付平台");
|
throw new CzgException("不支持的支付平台");
|
||||||
}
|
}
|
||||||
@@ -53,11 +49,11 @@ public class PayManager {
|
|||||||
/**
|
/**
|
||||||
* 查询订单状态
|
* 查询订单状态
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> queryOrderStatus(String platform, String orderNo, String subMerchantId) {
|
public static QueryOrderRespDTO queryOrderStatus(String platform, String orderNo, NativeMerchantDTO merchantDTO) {
|
||||||
if (PayCst.Platform.WECHAT.equals(platform)) {
|
if (SystemConstants.PayType.WECHAT.equals(platform)) {
|
||||||
return WechatPayManager.queryOrder(null, orderNo, subMerchantId);
|
return WechatPayManager.queryOrder(null, orderNo, merchantDTO);
|
||||||
} else if (PayCst.Platform.ALIPAY.equals(platform)) {
|
} else if (SystemConstants.PayType.ALIPAY.equals(platform)) {
|
||||||
return AlipayIsvPayManager.queryOrder(null, orderNo, subMerchantId);
|
return AlipayIsvPayManager.queryOrder(null, orderNo, merchantDTO);
|
||||||
} else {
|
} else {
|
||||||
throw new CzgException("不支持的支付平台");
|
throw new CzgException("不支持的支付平台");
|
||||||
}
|
}
|
||||||
@@ -66,38 +62,16 @@ public class PayManager {
|
|||||||
/**
|
/**
|
||||||
* 退款
|
* 退款
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> refund(String platform, RefundParamsDto paramsDto) {
|
public static RefundRespDTO refund(CzgRefundReq paramsDto, String notifyUrl, NativeMerchantDTO merchantDTO) {
|
||||||
if (PayCst.Platform.WECHAT.equals(platform)) {
|
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
|
||||||
return WechatPayManager.refundOrder(null, paramsDto);
|
return WechatPayManager.refundOrder(null, paramsDto, notifyUrl, merchantDTO);
|
||||||
} else if (PayCst.Platform.ALIPAY.equals(platform)) {
|
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
|
||||||
return AlipayIsvPayManager.refundOrder(null, paramsDto);
|
return AlipayIsvPayManager.refundOrder(null, paramsDto, notifyUrl, merchantDTO);
|
||||||
} else {
|
} else {
|
||||||
throw new CzgException("不支持的支付平台");
|
throw new CzgException("不支持的支付平台");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
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"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.czg.dto.req;
|
|||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.PayCst;
|
import com.czg.PayCst;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.third.alipay.dto.AlipayAuthInfoDto;
|
import com.czg.pay.AlipayAuthInfoDto;
|
||||||
import com.czg.utils.AssertUtil;
|
import com.czg.utils.AssertUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
package com.czg.dto.req;
|
package com.czg.dto.req;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.annotation.JSONField;
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import com.czg.PayCst;
|
||||||
|
import com.czg.pay.PayNotifyRespDTO;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yjjie
|
* @author yjjie
|
||||||
* @date 2025/12/23 22:21
|
* @date 2025/12/23 22:21
|
||||||
@@ -115,4 +120,38 @@ public class WechatPayNotifyDataDto {
|
|||||||
public Long getPayAmount() {
|
public Long getPayAmount() {
|
||||||
return Long.valueOf(amount.getTotal());
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,12 @@ import com.czg.dto.req.*;
|
|||||||
import com.czg.dto.resp.EntryThirdRespDto;
|
import com.czg.dto.resp.EntryThirdRespDto;
|
||||||
import com.czg.dto.resp.QueryStatusResp;
|
import com.czg.dto.resp.QueryStatusResp;
|
||||||
import com.czg.exception.CzgException;
|
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.third.alipay.dto.config.AlipayConfigDto;
|
||||||
import com.czg.utils.UploadFileUtil;
|
import com.czg.utils.UploadFileUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝服务商进件管理
|
* 支付宝服务商进件管理
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import com.alipay.v3.ApiException;
|
|||||||
import com.alipay.v3.api.AlipayTradeApi;
|
import com.alipay.v3.api.AlipayTradeApi;
|
||||||
import com.alipay.v3.model.AlipayTradeCreateModel;
|
import com.alipay.v3.model.AlipayTradeCreateModel;
|
||||||
import com.alipay.v3.model.AlipayTradeCreateResponseModel;
|
import com.alipay.v3.model.AlipayTradeCreateResponseModel;
|
||||||
|
import com.alipay.v3.model.AlipayTradePayModel;
|
||||||
import com.alipay.v3.model.ExtendParams;
|
import com.alipay.v3.model.ExtendParams;
|
||||||
import com.alipay.v3.util.model.CustomizedParams;
|
import com.alipay.v3.util.model.CustomizedParams;
|
||||||
import com.czg.PayCst;
|
import com.czg.PayCst;
|
||||||
import com.czg.dto.req.PayParamsDto;
|
|
||||||
import com.czg.dto.req.RefundParamsDto;
|
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
|
import com.czg.pay.*;
|
||||||
import com.czg.third.alipay.dto.config.AlipayConfigDto;
|
import com.czg.third.alipay.dto.config.AlipayConfigDto;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@@ -31,23 +31,23 @@ public class AlipayIsvPayManager {
|
|||||||
* @param configDto 配置
|
* @param configDto 配置
|
||||||
* @param paramsDto 参数
|
* @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 {
|
try {
|
||||||
AlipayClient.setApiClient(configDto);
|
AlipayClient.setApiClient(configDto);
|
||||||
AlipayTradeApi api = new AlipayTradeApi();
|
AlipayTradeApi api = new AlipayTradeApi();
|
||||||
AlipayTradeCreateModel model = new AlipayTradeCreateModel();
|
AlipayTradeCreateModel model = new AlipayTradeCreateModel();
|
||||||
model.setOutTradeNo(paramsDto.getOrderNo());
|
model.setOutTradeNo(paramsDto.getMchOrderNo());
|
||||||
model.setProductCode("JSAPI_PAY");
|
model.setProductCode("JSAPI_PAY");
|
||||||
model.setOpAppId(paramsDto.getAppId());
|
model.setOpAppId(merchantDTO.getAlipayMerchantId());
|
||||||
model.setOpBuyerOpenId(paramsDto.getOpenId());
|
model.setOpBuyerOpenId(paramsDto.getUserId());
|
||||||
model.setTotalAmount(getYuanAmountByFen(paramsDto.getAmount()));
|
model.setTotalAmount(getYuanAmountByFen(paramsDto.getAmount()));
|
||||||
model.setSubject(paramsDto.getTitle());
|
model.setSubject(paramsDto.getSubject());
|
||||||
model.setBody(paramsDto.getBody());
|
model.setBody(paramsDto.getBody());
|
||||||
model.setNotifyUrl(paramsDto.getNotifyUrl() + "/" + PayCst.Platform.ALIPAY);
|
model.setNotifyUrl(paramsDto.getNotifyUrl() + "/" + PayCst.Platform.ALIPAY);
|
||||||
|
|
||||||
model.setExtendParams(new ExtendParams());
|
model.setExtendParams(new ExtendParams());
|
||||||
CustomizedParams customizedParams = new CustomizedParams();
|
CustomizedParams customizedParams = new CustomizedParams();
|
||||||
customizedParams.setAppAuthToken(paramsDto.getAlipayAuthInfo().getAppAuthToken());
|
customizedParams.setAppAuthToken(merchantDTO.getAlipayAuthInfo().getAppAuthToken());
|
||||||
|
|
||||||
AlipayTradeCreateResponseModel responseModel = api.create(model, customizedParams);
|
AlipayTradeCreateResponseModel responseModel = api.create(model, customizedParams);
|
||||||
log.info("支付宝 jsapi 支付结果: {}", responseModel);
|
log.info("支付宝 jsapi 支付结果: {}", responseModel);
|
||||||
@@ -69,10 +69,26 @@ public class AlipayIsvPayManager {
|
|||||||
* @param configDto 配置
|
* @param configDto 配置
|
||||||
* @param paramsDto 参数
|
* @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 {
|
try {
|
||||||
AlipayClient.setApiClient(configDto);
|
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();
|
return new JSONObject();
|
||||||
// } catch (ApiException e) {
|
// } catch (ApiException e) {
|
||||||
// String body = e.getResponseBody();
|
// String body = e.getResponseBody();
|
||||||
@@ -85,12 +101,12 @@ public class AlipayIsvPayManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Object> queryOrder(AlipayConfigDto configDto, String orderNo, String subMerchantId) {
|
public static QueryOrderRespDTO queryOrder(AlipayConfigDto configDto, String orderNo, NativeMerchantDTO merchantDTO) {
|
||||||
return new HashMap<>();
|
return new QueryOrderRespDTO();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Object> refundOrder(AlipayConfigDto configDto, RefundParamsDto paramsDto) {
|
public static RefundRespDTO refundOrder(AlipayConfigDto configDto, CzgRefundReq paramsDto, String notifyUrl, NativeMerchantDTO merchantDTO) {
|
||||||
return new HashMap<>();
|
return new RefundRespDTO();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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.WechatEntryBusinessReqDto;
|
||||||
import com.czg.third.wechat.dto.req.entry.business.WechatEntryIdentityReqDto;
|
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.WechatEntryLicenseReqDto;
|
||||||
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryMiniProgramReqDto;
|
import com.czg.third.wechat.dto.req.entry.business.sales.*;
|
||||||
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.id.WechatEntryIdCardReqDto;
|
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.WechatAuditDetail;
|
||||||
import com.czg.third.wechat.dto.resp.WechatQueryStateResp;
|
import com.czg.third.wechat.dto.resp.WechatQueryStateResp;
|
||||||
@@ -319,6 +317,9 @@ public class WechatEntryManager {
|
|||||||
WechatEntryMiniProgramReqDto miniProgramInfo = new WechatEntryMiniProgramReqDto();
|
WechatEntryMiniProgramReqDto miniProgramInfo = new WechatEntryMiniProgramReqDto();
|
||||||
miniProgramInfo.setMiniProgramAppid("wxd88fffa983758a30");
|
miniProgramInfo.setMiniProgramAppid("wxd88fffa983758a30");
|
||||||
salesInfo.setMiniProgramInfo(miniProgramInfo);
|
salesInfo.setMiniProgramInfo(miniProgramInfo);
|
||||||
|
WechatEntryWebInfoReqDto webInfo = new WechatEntryWebInfoReqDto();
|
||||||
|
webInfo.setDomain("https://invoice.sxczgkj.cn/pay/");
|
||||||
|
salesInfo.setWebInfo(webInfo);
|
||||||
businessReqInfo.setSalesInfo(salesInfo);
|
businessReqInfo.setSalesInfo(salesInfo);
|
||||||
entryParams.setBusinessInfo(businessReqInfo);
|
entryParams.setBusinessInfo(businessReqInfo);
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,8 @@ import cn.hutool.crypto.SecureUtil;
|
|||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.PayCst;
|
import com.czg.PayCst;
|
||||||
import com.czg.dto.req.PayParamsDto;
|
|
||||||
import com.czg.dto.req.RefundParamsDto;
|
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
|
import com.czg.pay.*;
|
||||||
import com.czg.third.wechat.dto.config.WechatPayConfigDto;
|
import com.czg.third.wechat.dto.config.WechatPayConfigDto;
|
||||||
import com.wechat.pay.java.core.Config;
|
import com.wechat.pay.java.core.Config;
|
||||||
import com.wechat.pay.java.core.cipher.Signer;
|
import com.wechat.pay.java.core.cipher.Signer;
|
||||||
@@ -45,31 +44,31 @@ public class WechatPayManager {
|
|||||||
* @param configDto 配置
|
* @param configDto 配置
|
||||||
* @param paramsDto 参数
|
* @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) {
|
if (configDto == null) {
|
||||||
configDto = WechatPayConfigDto.getDefaultConfig();
|
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONObject reqData = new JSONObject();
|
JSONObject reqData = new JSONObject();
|
||||||
reqData.put("sp_appid", paramsDto.getAppId());
|
reqData.put("sp_appid", paramsDto.getSubAppid());
|
||||||
reqData.put("sp_mchid", configDto.getMerchantId());
|
reqData.put("sp_mchid", configDto.getMerchantId());
|
||||||
reqData.put("sub_mchid", paramsDto.getMerchantId());
|
reqData.put("sub_mchid", merchantDTO.getWechatMerchantId());
|
||||||
reqData.put("description", paramsDto.getTitle());
|
reqData.put("description", paramsDto.getSubject());
|
||||||
reqData.put("out_trade_no", paramsDto.getOrderNo());
|
reqData.put("out_trade_no", paramsDto.getMchOrderNo());
|
||||||
reqData.put("notify_url", paramsDto.getNotifyUrl() + "/" + PayCst.Platform.WECHAT);
|
reqData.put("notify_url", paramsDto.getNotifyUrl() + "/" + PayCst.Platform.WECHAT);
|
||||||
reqData.put("attach", paramsDto.getExtData());
|
reqData.put("attach", paramsDto.getExtParam());
|
||||||
|
|
||||||
JSONObject amount = new JSONObject();
|
JSONObject amount = new JSONObject();
|
||||||
amount.put("total", paramsDto.getAmount());
|
amount.put("total", paramsDto.getAmount());
|
||||||
reqData.put("amount", amount);
|
reqData.put("amount", amount);
|
||||||
|
|
||||||
JSONObject payer = new JSONObject();
|
JSONObject payer = new JSONObject();
|
||||||
payer.put("sp_openid", paramsDto.getOpenId());
|
payer.put("sp_openid", paramsDto.getUserId());
|
||||||
reqData.put("payer", payer);
|
reqData.put("payer", payer);
|
||||||
|
|
||||||
String string = WechatReqUtils.postReq(configDto, "/v3/pay/partner/transactions/jsapi", reqData.toJSONString());
|
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);
|
JSONObject object = JSONObject.parseObject(string);
|
||||||
|
|
||||||
@@ -77,23 +76,23 @@ public class WechatPayManager {
|
|||||||
String nonceStr = NonceUtil.createNonce(32);
|
String nonceStr = NonceUtil.createNonce(32);
|
||||||
String packageVal = "prepay_id=" + object.getString("prepay_id");
|
String packageVal = "prepay_id=" + object.getString("prepay_id");
|
||||||
String message =
|
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);
|
Config config = WechatConfig.getRsaConfig(configDto);
|
||||||
Signer signer = config.createSigner();
|
Signer signer = config.createSigner();
|
||||||
String sign = signer.sign(message).getSign();
|
String sign = signer.sign(message).getSign();
|
||||||
|
|
||||||
JSONObject res = new JSONObject();
|
JSONObject res = new JSONObject();
|
||||||
res.put("appId", paramsDto.getAppId());
|
res.put("appId", paramsDto.getSubAppid());
|
||||||
res.put("timeStamp", String.valueOf(timestamp));
|
res.put("timeStamp", String.valueOf(timestamp));
|
||||||
res.put("nonceStr", nonceStr);
|
res.put("nonceStr", nonceStr);
|
||||||
res.put("package", packageVal);
|
res.put("package", packageVal);
|
||||||
res.put("signType", "RSA");
|
res.put("signType", "RSA");
|
||||||
res.put("paySign", sign);
|
res.put("paySign", sign);
|
||||||
log.info("微信支付签名结果: orderNo = {}, res = {}", paramsDto.getOrderNo(), res);
|
log.info("微信支付签名结果: orderNo = {}, res = {}", paramsDto.getMchOrderNo(), res);
|
||||||
return res;
|
return res;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("微信支付异常: orderNo = {}, e = {}", paramsDto.getOrderNo(), e.getMessage());
|
log.error("微信支付异常: orderNo = {}, e = {}", paramsDto.getMchOrderNo(), e.getMessage());
|
||||||
throw new CzgException("微信支付异常");
|
throw new CzgException("微信支付异常");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,7 +104,7 @@ public class WechatPayManager {
|
|||||||
* @param configDto 配置
|
* @param configDto 配置
|
||||||
* @param paramsDto 参数
|
* @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 {
|
try {
|
||||||
if (configDto == null) {
|
if (configDto == null) {
|
||||||
configDto = WechatPayConfigDto.getDefaultConfig();
|
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||||
@@ -119,28 +118,28 @@ public class WechatPayManager {
|
|||||||
// 添加根元素
|
// 添加根元素
|
||||||
Element xml = document.addElement("xml");
|
Element xml = document.addElement("xml");
|
||||||
|
|
||||||
addElementIfNotEmpty(xml, "appid", paramsDto.getAppId());
|
addElementIfNotEmpty(xml, "appid", paramsDto.getSubAppid());
|
||||||
payMap.put("appid", paramsDto.getAppId());
|
payMap.put("appid", paramsDto.getSubAppid());
|
||||||
addElementIfNotEmpty(xml, "mch_id", configDto.getMerchantId());
|
addElementIfNotEmpty(xml, "mch_id", configDto.getMerchantId());
|
||||||
payMap.put("mch_id", configDto.getMerchantId());
|
payMap.put("mch_id", configDto.getMerchantId());
|
||||||
addElementIfNotEmpty(xml, "sub_mch_id", paramsDto.getMerchantId());
|
addElementIfNotEmpty(xml, "sub_mch_id", merchantDTO.getWechatMerchantId());
|
||||||
payMap.put("sub_mch_id", paramsDto.getMerchantId());
|
payMap.put("sub_mch_id", merchantDTO.getWechatMerchantId());
|
||||||
addElementIfNotEmpty(xml, "nonce_str", nonceStr);
|
addElementIfNotEmpty(xml, "nonce_str", nonceStr);
|
||||||
payMap.put("nonce_str", nonceStr);
|
payMap.put("nonce_str", nonceStr);
|
||||||
addElementIfNotEmpty(xml, "body", paramsDto.getTitle());
|
addElementIfNotEmpty(xml, "body", paramsDto.getSubject());
|
||||||
payMap.put("body", paramsDto.getTitle());
|
payMap.put("body", paramsDto.getSubject());
|
||||||
addElementIfNotEmpty(xml, "out_trade_no", paramsDto.getOrderNo());
|
addElementIfNotEmpty(xml, "out_trade_no", paramsDto.getMchOrderNo());
|
||||||
payMap.put("out_trade_no", paramsDto.getOrderNo());
|
payMap.put("out_trade_no", paramsDto.getMchOrderNo());
|
||||||
addElementIfNotEmpty(xml, "total_fee", paramsDto.getAmount());
|
addElementIfNotEmpty(xml, "total_fee", paramsDto.getAmount());
|
||||||
payMap.put("total_fee", paramsDto.getAmount());
|
payMap.put("total_fee", paramsDto.getAmount());
|
||||||
addElementIfNotEmpty(xml, "spbill_create_ip", paramsDto.getClientIp());
|
addElementIfNotEmpty(xml, "spbill_create_ip", paramsDto.getClientIp());
|
||||||
payMap.put("spbill_create_ip", paramsDto.getClientIp());
|
payMap.put("spbill_create_ip", paramsDto.getClientIp());
|
||||||
addElementIfNotEmpty(xml, "auth_code", paramsDto.getBarCode());
|
addElementIfNotEmpty(xml, "auth_code", paramsDto.getAuthCode());
|
||||||
payMap.put("auth_code", paramsDto.getBarCode());
|
payMap.put("auth_code", paramsDto.getAuthCode());
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(paramsDto.getExtData())) {
|
if (StrUtil.isNotBlank(paramsDto.getExtParam())) {
|
||||||
addElementIfNotEmpty(xml, "attach", paramsDto.getExtData());
|
addElementIfNotEmpty(xml, "attach", paramsDto.getExtParam());
|
||||||
payMap.put("attach", paramsDto.getExtData());
|
payMap.put("attach", paramsDto.getExtParam());
|
||||||
}
|
}
|
||||||
|
|
||||||
String sign = signBarPayParam(configDto, payMap);
|
String sign = signBarPayParam(configDto, payMap);
|
||||||
@@ -154,10 +153,10 @@ public class WechatPayManager {
|
|||||||
log.info("微信条码支付参数:{}", xmlStr);
|
log.info("微信条码支付参数:{}", xmlStr);
|
||||||
|
|
||||||
String post = HttpUtil.post(BAR_PAY_URL, 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();
|
JSONObject res = new JSONObject();
|
||||||
res.put("orderNo", paramsDto.getOrderNo());
|
res.put("orderNo", paramsDto.getMchOrderNo());
|
||||||
|
|
||||||
SAXReader saxReader = new SAXReader();
|
SAXReader saxReader = new SAXReader();
|
||||||
Document read = saxReader.read(stringToInputStream(post));
|
Document read = saxReader.read(stringToInputStream(post));
|
||||||
@@ -171,7 +170,7 @@ public class WechatPayManager {
|
|||||||
if (StrUtil.isNotBlank(errCode)) {
|
if (StrUtil.isNotBlank(errCode)) {
|
||||||
if ("SYSTEMERROR".equals(errCode) || "BANKERROR".equals(errCode) || "USERPAYING".equals(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");
|
res.put("status", "TRADE_AWAIT");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -181,19 +180,19 @@ public class WechatPayManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!PAY_SUCCESS.equals(returnCode)) {
|
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");
|
res.put("status", "TRADE_FAIL");
|
||||||
return res;
|
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");
|
res.put("status", "TRADE_SUCCESS");
|
||||||
return res;
|
return res;
|
||||||
} catch (CzgException e) {
|
} catch (CzgException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("微信条码支付异常: orderNo = {}, e = {}", paramsDto.getOrderNo(), e.getMessage());
|
log.error("微信条码支付异常: orderNo = {}, e = {}", paramsDto.getMchOrderNo(), e.getMessage());
|
||||||
throw new CzgException("微信支付异常");
|
throw new CzgException("微信支付异常");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -203,7 +202,7 @@ public class WechatPayManager {
|
|||||||
*
|
*
|
||||||
* @param configDto 配置
|
* @param configDto 配置
|
||||||
* @param orderNo 订单号
|
* @param orderNo 订单号
|
||||||
* @param subMerchantId 子商户号
|
* @param merchantDTO 支付商户信息
|
||||||
* SUCCESS:支付成功
|
* SUCCESS:支付成功
|
||||||
* REFUND:转入退款
|
* REFUND:转入退款
|
||||||
* NOTPAY:未支付
|
* NOTPAY:未支付
|
||||||
@@ -212,34 +211,35 @@ public class WechatPayManager {
|
|||||||
* USERPAYING:用户支付中(仅付款码支付会返回)
|
* USERPAYING:用户支付中(仅付款码支付会返回)
|
||||||
* PAYERROR:支付失败(仅付款码支付会返回)
|
* PAYERROR:支付失败(仅付款码支付会返回)
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> queryOrder(WechatPayConfigDto configDto, String orderNo, String subMerchantId) {
|
public static QueryOrderRespDTO queryOrder(WechatPayConfigDto configDto, String orderNo, NativeMerchantDTO merchantDTO) {
|
||||||
try {
|
try {
|
||||||
if (configDto == null) {
|
if (configDto == null) {
|
||||||
configDto = WechatPayConfigDto.getDefaultConfig();
|
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
String resp = WechatReqUtils.getReq(configDto, "/v3/pay/partner/transactions/out-trade-no/" + orderNo,
|
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);
|
log.info("微信查询订单,订单号:{}, 响应:{}", orderNo, resp);
|
||||||
|
|
||||||
JSONObject res = new JSONObject();
|
QueryOrderRespDTO queryOrderRespDTO = new QueryOrderRespDTO()
|
||||||
res.put("orderNo", orderNo);
|
.setOrderNo(orderNo)
|
||||||
|
.setOriginResp(resp);
|
||||||
|
|
||||||
JSONObject object = JSONObject.parseObject(resp);
|
JSONObject object = JSONObject.parseObject(resp);
|
||||||
String tradeState = object.getString("trade_state");
|
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)) {
|
if (PAY_SUCCESS.equals(tradeState)) {
|
||||||
res.put("status", "TRADE_SUCCESS");
|
queryOrderRespDTO.setStatus("TRADE_SUCCESS");
|
||||||
return res;
|
return queryOrderRespDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("USERPAYING".equals(tradeState)) {
|
if ("USERPAYING".equals(tradeState)) {
|
||||||
res.put("status", "TRADE_AWAIT");
|
queryOrderRespDTO.setStatus("TRADE_AWAIT");
|
||||||
return res;
|
return queryOrderRespDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
res.put("status", "TRADE_FAIL");
|
queryOrderRespDTO.setStatus("TRADE_FAIL");
|
||||||
return res;
|
return queryOrderRespDTO;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("微信查询订单异常: orderNo = {}, e = {}", orderNo, e.getMessage());
|
log.error("微信查询订单异常: orderNo = {}, e = {}", orderNo, e.getMessage());
|
||||||
throw new CzgException("微信查询订单异常");
|
throw new CzgException("微信查询订单异常");
|
||||||
@@ -256,64 +256,69 @@ public class WechatPayManager {
|
|||||||
* PROCESSING: 退款处理中
|
* PROCESSING: 退款处理中
|
||||||
* ABNORMAL: 退款异常,退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往服务商平台-交易中心,手动处理此笔退款
|
* ABNORMAL: 退款异常,退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往服务商平台-交易中心,手动处理此笔退款
|
||||||
*/
|
*/
|
||||||
public static Map<String, Object> refundOrder(WechatPayConfigDto configDto, RefundParamsDto paramsDto) {
|
public static RefundRespDTO refundOrder(WechatPayConfigDto configDto, CzgRefundReq paramsDto, String notifyUrl, NativeMerchantDTO merchantDTO) {
|
||||||
try {
|
try {
|
||||||
if (configDto == null) {
|
if (configDto == null) {
|
||||||
configDto = WechatPayConfigDto.getDefaultConfig();
|
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject refundParam = new JSONObject();
|
JSONObject refundParam = new JSONObject();
|
||||||
refundParam.put("sub_mchid", paramsDto.getMerchantId());
|
refundParam.put("sub_mchid", merchantDTO.getWechatMerchantId());
|
||||||
refundParam.put("out_trade_no", paramsDto.getOrderNo());
|
refundParam.put("out_trade_no", paramsDto.getMchOrderNo());
|
||||||
refundParam.put("out_refund_no", paramsDto.getRefundOrderNo());
|
refundParam.put("out_refund_no", paramsDto.getMchRefundNo());
|
||||||
refundParam.put("reason", paramsDto.getRefundReason());
|
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();
|
JSONObject amount = new JSONObject();
|
||||||
amount.put("total", paramsDto.getOrderAmount());
|
amount.put("total", paramsDto.getOrderTotalAmount());
|
||||||
amount.put("refund", paramsDto.getRefundAmount());
|
amount.put("refund", paramsDto.getRefundAmount());
|
||||||
amount.put("currency", "CNY");
|
amount.put("currency", "CNY");
|
||||||
refundParam.put("amount", amount);
|
refundParam.put("amount", amount);
|
||||||
|
|
||||||
String resp = WechatReqUtils.postReq(configDto, "/v3/refund/domestic/refunds", refundParam.toJSONString());
|
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 object = JSONObject.parseObject(resp);
|
||||||
|
|
||||||
JSONObject res = new JSONObject();
|
String code = object.getString("code");
|
||||||
res.put("mchRefundNo", object.getString("out_refund_no"));
|
String status = object.getString("status");
|
||||||
res.put("refundOrderId", object.getString("refund_id"));
|
if ("INVALID_REQUEST".equalsIgnoreCase(code) || StrUtil.isNotBlank(status)) {
|
||||||
res.put("oriPayOrderId", object.getString("out_trade_no"));
|
throw new CzgException("微信退款失败:" + object.getString("message"));
|
||||||
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"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
} catch (Exception e) {
|
||||||
log.error("微信退款异常: orderNo = {}, e = {}", paramsDto.getOrderNo(), e.getMessage());
|
log.error("微信退款异常: orderNo = {} ", paramsDto.getMchOrderNo(), e);
|
||||||
throw new CzgException("微信退款异常");
|
throw new CzgException("微信退款异常");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -368,13 +373,13 @@ public class WechatPayManager {
|
|||||||
// Map<String, Object> sss1 = queryOrder(null, "sa101293120sss1", "1738216504");
|
// Map<String, Object> sss1 = queryOrder(null, "sa101293120sss1", "1738216504");
|
||||||
// System.out.println(sss1);
|
// System.out.println(sss1);
|
||||||
|
|
||||||
refundOrder(null, new RefundParamsDto()
|
// refundOrder(null, new RefundParamsDto()
|
||||||
.setMerchantId("1738216504")
|
// .setMerchantId("1738216504")
|
||||||
.setOrderNo("sa101293120sss1")
|
// .setOrderNo("sa101293120sss1")
|
||||||
.setRefundOrderNo("sa101293120sss1")
|
// .setRefundOrderNo("sa101293120sss1")
|
||||||
.setOrderAmount(1L)
|
// .setOrderAmount(1L)
|
||||||
.setRefundAmount(1L)
|
// .setRefundAmount(1L)
|
||||||
.setRefundReason("测试")
|
// .setRefundReason("测试")
|
||||||
.setRefundNotifyUrl("https://www.baidu.com"));
|
// .setRefundNotifyUrl("https://www.baidu.com"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ public class WechatPayConfigDto {
|
|||||||
return new WechatPayConfigDto()
|
return new WechatPayConfigDto()
|
||||||
.setMerchantId("1643779408")
|
.setMerchantId("1643779408")
|
||||||
.setApiV3Key("a92baac5eb7a36ed8ec198113e769a03")
|
.setApiV3Key("a92baac5eb7a36ed8ec198113e769a03")
|
||||||
.setApiV2Key("3caf37225b6ea77a624ee03b7e3d03bb")
|
|
||||||
.setSerialNumber("4DE9BAC2EA584C3F274F694C9753CA814C4E9BF4")
|
.setSerialNumber("4DE9BAC2EA584C3F274F694C9753CA814C4E9BF4")
|
||||||
.setPublicKey("""
|
.setPublicKey("""
|
||||||
-----BEGIN PUBLIC KEY-----
|
-----BEGIN PUBLIC KEY-----
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>czg-pay</artifactId>
|
<artifactId>poly-pay</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
@@ -8,11 +8,14 @@ import cn.hutool.http.HttpRequest;
|
|||||||
import cn.hutool.http.HttpResponse;
|
import cn.hutool.http.HttpResponse;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.alibaba.fastjson2.TypeReference;
|
import com.alibaba.fastjson2.TypeReference;
|
||||||
import com.czg.entity.CzgBaseReqParams;
|
import com.czg.entity.PolyBaseReq;
|
||||||
import com.czg.entity.CzgBaseRespParams;
|
import com.czg.entity.PolyBaseResp;
|
||||||
import com.czg.entity.req.*;
|
import com.czg.entity.notify.CzgPayNotifyDTO;
|
||||||
import com.czg.entity.resp.*;
|
import com.czg.entity.resp.*;
|
||||||
import com.czg.enums.CzgPayEnum;
|
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.CzgRespCode;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.utils.AssertUtil;
|
import com.czg.utils.AssertUtil;
|
||||||
@@ -26,10 +29,10 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ww
|
* @author ww
|
||||||
* @description 超掌柜支付类
|
* @description 聚合支付类
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CzgPayUtils {
|
public class PolyPayUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* h5支付
|
* h5支付
|
||||||
@@ -39,8 +42,8 @@ public class CzgPayUtils {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgH5PayResp>
|
* CzgResult<CzgH5PayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> h5Pay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgH5PayReq bizData) {
|
public static CzgResult<Map<String, Object>> h5Pay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq bizData) {
|
||||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.H5PAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgH5PayResp.class));
|
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
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgJsPayResp>
|
* CzgResult<CzgJsPayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> jsPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgJsPayReq bizData) {
|
public static CzgResult<Map<String, Object>> jsPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq bizData) {
|
||||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.JSPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgJsPayResp.class));
|
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
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgLtPayResp>
|
* CzgResult<CzgLtPayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> ltPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgLtPayReq bizData) {
|
public static CzgResult<Map<String, Object>> ltPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq bizData) {
|
||||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.LTPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgLtPayResp.class));
|
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
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgScanPayResp>
|
* CzgResult<CzgScanPayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> scanPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgScanPayReq bizData) {
|
public static CzgResult<Map<String, Object>> scanPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq bizData) {
|
||||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.SCANPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgScanPayResp.class));
|
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
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgMicroPayResp>
|
* CzgResult<CzgMicroPayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> microPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgMicroPayReq bizData) {
|
public static CzgResult<Map<String, Object>> microPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq bizData) {
|
||||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.MICROPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgMicroPayResp.class));
|
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();
|
JSONObject queryPayOrder = new JSONObject();
|
||||||
queryPayOrder.put("payOrderId", payOrderId);
|
queryPayOrder.put("payOrderId", payOrderId);
|
||||||
queryPayOrder.put("mchOrderNo", mchOrderNo);
|
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
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
*/
|
*/
|
||||||
public static CzgResult<CzgRefundResp> refundOrder(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgRefundReq bizData) {
|
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();
|
JSONObject queryPayOrder = new JSONObject();
|
||||||
queryPayOrder.put("mchRefundNo", mchRefundNo);
|
queryPayOrder.put("mchRefundNo", mchRefundNo);
|
||||||
queryPayOrder.put("refundOrderId", refundOrderId);
|
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) {
|
public static JSONObject getCzg(PolyBaseResp respParams) {
|
||||||
AssertUtil.isNull(respParams, "超掌柜交易 回调数据为空");
|
AssertUtil.isNull(respParams, "聚合交易 回调数据为空");
|
||||||
log.info("超掌柜交易请求响应,{}", respParams);
|
log.info("聚合交易请求响应,{}", respParams);
|
||||||
if (!"000000".equals(respParams.getCode())) {
|
if (!"000000".equals(respParams.getCode())) {
|
||||||
log.error("超掌柜回调响应失败,{}", respParams);
|
log.error("聚合回调响应失败,{}", respParams);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// if (StrUtil.isNotBlank(respParams.getSign())) {
|
// if (StrUtil.isNotBlank(respParams.getSign())) {
|
||||||
// if (validateSign(respParams.getSign(), respParams.getBizData())) {
|
// if (validateSign(respParams.getSign(), respParams.getBizData())) {
|
||||||
// log.error("超掌柜回调 验签失败");
|
// log.error("聚合回调 验签失败");
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
return JSONObject.parse(respParams.getBizData());
|
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
|
* 默认Post
|
||||||
*
|
*
|
||||||
@@ -168,19 +197,19 @@ public class CzgPayUtils {
|
|||||||
* "data": "返回Json数据",
|
* "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();
|
CzgResult<T> result = CzgResult.success();
|
||||||
Map<String, Object> reqMap = BeanUtil.beanToMap(params, false, false);
|
Map<String, Object> reqMap = BeanUtil.beanToMap(params, false, false);
|
||||||
params.setSign(MD5.create().digestHex(sortFields(new TreeMap<>(reqMap))));
|
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()) {
|
try (HttpResponse resp = HttpRequest.post(url).body(JSONObject.toJSONString(params)).execute()) {
|
||||||
if (resp.isOk()) {
|
if (resp.isOk()) {
|
||||||
// 获取响应体
|
// 获取响应体
|
||||||
String respStr = resp.body();
|
String respStr = resp.body();
|
||||||
if (StrUtil.isNotEmpty(respStr)) {
|
if (StrUtil.isNotEmpty(respStr)) {
|
||||||
log.info("超掌柜交易请求响应元数据,{}", respStr);
|
log.info("聚合交易请求响应元数据,{}", respStr);
|
||||||
CzgBaseRespParams respParams = JSONObject.parseObject(respStr, CzgBaseRespParams.class);
|
PolyBaseResp respParams = JSONObject.parseObject(respStr, PolyBaseResp.class);
|
||||||
log.info("超掌柜交易请求响应,{}", respParams);
|
log.info("聚合交易请求响应,{}", respParams);
|
||||||
|
|
||||||
result.setCode("000000".equals(respParams.getCode()) ? 200 : Integer.parseInt(respParams.getCode()));
|
result.setCode("000000".equals(respParams.getCode()) ? 200 : Integer.parseInt(respParams.getCode()));
|
||||||
result.setMsg(respParams.getMsg());
|
result.setMsg(respParams.getMsg());
|
||||||
@@ -194,15 +223,15 @@ public class CzgPayUtils {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.setCode(resp.getStatus());
|
result.setCode(resp.getStatus());
|
||||||
result.setMsg("超掌柜交易请求失败");
|
result.setMsg("聚合交易请求失败");
|
||||||
log.error("超掌柜交易请求失败,状态码: {}", resp.getStatus());
|
log.error("聚合交易请求失败,状态码: {}", resp.getStatus());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.setCode(resp.getStatus());
|
result.setCode(resp.getStatus());
|
||||||
result.setMsg("超掌柜交易请求失败");
|
result.setMsg("聚合交易请求失败");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("超掌柜交易请求异常", e);
|
log.error("聚合交易请求异常", e);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -221,7 +250,7 @@ public class CzgPayUtils {
|
|||||||
|
|
||||||
private static String sortFields(TreeMap<String, Object> map) {
|
private static String sortFields(TreeMap<String, Object> map) {
|
||||||
if (CollectionUtil.isEmpty(map)) {
|
if (CollectionUtil.isEmpty(map)) {
|
||||||
log.error("超掌柜支付参数为空!!!");
|
log.error("聚合支付参数为空!!!");
|
||||||
throw new RuntimeException("参数为空");
|
throw new RuntimeException("参数为空");
|
||||||
}
|
}
|
||||||
String sortParam = map.entrySet().stream()
|
String sortParam = map.entrySet().stream()
|
||||||
@@ -12,7 +12,7 @@ import lombok.Data;
|
|||||||
* @author ww
|
* @author ww
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class CzgBaseReqParams {
|
public class PolyBaseReq {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 应用ID tb_shop_merchant 表中的 app_id
|
* 应用ID tb_shop_merchant 表中的 app_id
|
||||||
@@ -69,7 +69,7 @@ public class CzgBaseReqParams {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* @param bizData JSON 形式的字符串
|
* @param bizData JSON 形式的字符串
|
||||||
*/
|
*/
|
||||||
public CzgBaseReqParams(String appId, String bizData, String appSecret) {
|
public PolyBaseReq(String appId, String bizData, String appSecret) {
|
||||||
this.appId = appId;
|
this.appId = appId;
|
||||||
this.bizData = bizData;
|
this.bizData = bizData;
|
||||||
this.appSecret = appSecret;
|
this.appSecret = appSecret;
|
||||||
@@ -82,8 +82,8 @@ public class CzgBaseReqParams {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* @param bizData JSON 形式的字符串
|
* @param bizData JSON 形式的字符串
|
||||||
*/
|
*/
|
||||||
public static CzgBaseReqParams getInstance(String appId, String appSecret, Object bizData) {
|
public static PolyBaseReq getInstance(String appId, String appSecret, Object bizData) {
|
||||||
return new CzgBaseReqParams(appId, ObjectUtil.isNotEmpty(bizData) ? JSONObject.toJSONString(bizData) : "", appSecret);
|
return new PolyBaseReq(appId, ObjectUtil.isNotEmpty(bizData) ? JSONObject.toJSONString(bizData) : "", appSecret);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
|||||||
* @author ww
|
* @author ww
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class CzgBaseRespParams {
|
public class PolyBaseResp {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -8,11 +8,11 @@ import lombok.Getter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum CzgPayEnum {
|
public enum CzgPayEnum {
|
||||||
SCANPAY("/api/open/payment/scanpay", "PC扫码支付"),
|
SCAN_PAY("/api/open/payment/scanpay", "PC扫码支付"),
|
||||||
MICROPAY("/api/open/payment/micropay", "聚合反扫(B扫C)/ 快捷收款"),
|
MICRO_PAY("/api/open/payment/micropay", "聚合反扫(B扫C)/ 快捷收款"),
|
||||||
JSPAY("/api/open/payment/jspay", "公众号/生活号/银联js支付"),
|
JS_PAY("/api/open/payment/jspay", "公众号/生活号/银联js支付"),
|
||||||
LTPAY("/api/open/payment/ltpay", "小程序支付"),
|
LT_PAY("/api/open/payment/ltpay", "小程序支付"),
|
||||||
H5PAY("/api/open/payment/h5pay", "手机网页支付"),
|
H5_PAY("/api/open/payment/h5pay", "手机网页支付"),
|
||||||
|
|
||||||
TRADE("/api/open/query/trade", "订单状态查询"),
|
TRADE("/api/open/query/trade", "订单状态查询"),
|
||||||
REFUND("/api/open/order/refund", "统一退款 D0退款需要使用平台户退款"),
|
REFUND("/api/open/order/refund", "统一退款 D0退款需要使用平台户退款"),
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<name>third sdk</name>
|
<name>third sdk</name>
|
||||||
<description>第三方内容</description>
|
<description>第三方内容</description>
|
||||||
<modules>
|
<modules>
|
||||||
<module>czg-pay</module>
|
<module>poly-pay</module>
|
||||||
<module>aggregation-pay</module>
|
<module>aggregation-pay</module>
|
||||||
</modules>
|
</modules>
|
||||||
<artifactId>cash-sdk</artifactId>
|
<artifactId>cash-sdk</artifactId>
|
||||||
@@ -29,5 +29,10 @@
|
|||||||
<artifactId>cash-common-tools</artifactId>
|
<artifactId>cash-common-tools</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.czg</groupId>
|
||||||
|
<artifactId>cash-common-service</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -29,6 +29,7 @@ import jakarta.annotation.Resource;
|
|||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.apache.dubbo.config.annotation.DubboService;
|
import org.apache.dubbo.config.annotation.DubboService;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -41,7 +42,7 @@ import java.util.stream.Collectors;
|
|||||||
* @author zs
|
* @author zs
|
||||||
* @since 2025-02-21
|
* @since 2025-02-21
|
||||||
*/
|
*/
|
||||||
@DubboService
|
@Service
|
||||||
public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable> implements CallTableService {
|
public class CallTableServiceImpl extends ServiceImpl<CallTableMapper, CallTable> implements CallTableService {
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private SysParamsService sysParamsService;
|
private SysParamsService sysParamsService;
|
||||||
|
|||||||
@@ -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 {
|
|
||||||
}
|
|
||||||
@@ -253,6 +253,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
|||||||
@Override
|
@Override
|
||||||
@CacheEvict(key = "#shopInfoEditDTO.id")
|
@CacheEvict(key = "#shopInfoEditDTO.id")
|
||||||
public Boolean edit(ShopInfoEditDTO shopInfoEditDTO) {
|
public Boolean edit(ShopInfoEditDTO shopInfoEditDTO) {
|
||||||
|
shopInfoEditDTO.setIsMemberPrice(null);
|
||||||
ShopInfo shopInfo;
|
ShopInfo shopInfo;
|
||||||
if (!StpKit.USER.isAdmin()) {
|
if (!StpKit.USER.isAdmin()) {
|
||||||
shopInfo = queryChain().eq(ShopInfo::getId, StpKit.USER.getShopId()).one();
|
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");
|
rabbitPublisher.sendOrderDetailStatusMsg(shopInfo.getId().toString(), "shopInfoUpdate");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
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
|
@Override
|
||||||
public ShopDetailDTO detail(Long id) throws CzgException {
|
public ShopDetailDTO detail(Long id) throws CzgException {
|
||||||
ShopInfo shopInfo = queryChain().eq(ShopInfo::getId, id == null ? StpKit.USER.getShopId() : id).one();
|
ShopInfo shopInfo = queryChain().eq(ShopInfo::getId, id == null ? StpKit.USER.getShopId() : id).one();
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,9 +18,8 @@
|
|||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.czg</groupId>
|
<groupId>com.github.javen205</groupId>
|
||||||
<artifactId>pay-service</artifactId>
|
<artifactId>IJPay-All</artifactId>
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.czg.service.market.service.impl;
|
package com.czg.service.market.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.constants.ParamCodeCst;
|
import com.czg.constants.ParamCodeCst;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.service.RedisService;
|
import com.czg.service.RedisService;
|
||||||
import com.czg.system.service.SysParamsService;
|
import com.czg.system.service.SysParamsService;
|
||||||
import com.ijpay.core.kit.RsaKit;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -14,7 +14,6 @@ import org.springframework.context.annotation.Primary;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付service
|
* 微信支付service
|
||||||
@@ -80,7 +79,7 @@ public class AppWxServiceImpl extends BaseWx {
|
|||||||
// api支付证书公钥
|
// api支付证书公钥
|
||||||
config.apiCert = payKeyMap.get(ParamCodeCst.Wechat.Pay.WX_API_CLIENT_CERT);
|
config.apiCert = payKeyMap.get(ParamCodeCst.Wechat.Pay.WX_API_CLIENT_CERT);
|
||||||
try {
|
try {
|
||||||
config.privateKey = RsaKit.loadPrivateKey(config.apiCertKey);
|
config.privateKey = SecureUtil.rsa(config.apiCertKey, null).getPrivateKey();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("微信加载api证书失败");
|
log.warn("微信加载api证书失败");
|
||||||
}
|
}
|
||||||
@@ -98,10 +97,6 @@ public class AppWxServiceImpl extends BaseWx {
|
|||||||
config.refundNotifyUrl = "";
|
config.refundNotifyUrl = "";
|
||||||
config.transferNotifyUrl = payKeyMap.get(ParamCodeCst.System.NATIVE_NOTIFY_URL) + "/wx/transfer";
|
config.transferNotifyUrl = payKeyMap.get(ParamCodeCst.System.NATIVE_NOTIFY_URL) + "/wx/transfer";
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseWx getAppService() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ import com.czg.market.vo.InviteUserVO;
|
|||||||
import com.czg.market.vo.MkDistributionConfigVO;
|
import com.czg.market.vo.MkDistributionConfigVO;
|
||||||
import com.czg.order.dto.MkDistributionPayDTO;
|
import com.czg.order.dto.MkDistributionPayDTO;
|
||||||
import com.czg.order.entity.OrderInfo;
|
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.sa.StpKit;
|
||||||
import com.czg.service.market.enums.OrderStatusEnums;
|
import com.czg.service.market.enums.OrderStatusEnums;
|
||||||
import com.czg.service.market.mapper.MkDistributionUserMapper;
|
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()));
|
.ne(MkDistributionFlow::getStatus, TableValueConstant.DistributionFlow.Status.REFUND.getCode()));
|
||||||
|
|
||||||
list.forEach(item -> {
|
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())) {
|
if (TableValueConstant.DistributionFlow.Status.PENDING.getCode().equals(item.getStatus())) {
|
||||||
item.setStatus(TableValueConstant.DistributionFlow.Status.SUCCESS.getCode());
|
item.setStatus(TableValueConstant.DistributionFlow.Status.REFUND.getCode());
|
||||||
// updateIncome(item.getRewardAmount().negate(), BigDecimal.ZERO, BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel());
|
|
||||||
distributionFlowService.updateById(item);
|
distributionFlowService.updateById(item);
|
||||||
|
mapper.updateIncome(item.getRewardAmount().negate(), null, null, item.getDistributionUserId(), item.getShopId());
|
||||||
} else {
|
} else {
|
||||||
// 执行扣款
|
// 执行扣款
|
||||||
updateIncome(BigDecimal.ZERO, item.getRewardAmount().negate(), BigDecimal.ZERO, item.getDistributionUserId(), item.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel());
|
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, "分销回退");
|
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);
|
distributionDeliverService.save(deliver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分销金额修改
|
||||||
|
*
|
||||||
|
* @param pendingIncome 待入账金额
|
||||||
|
* @param receivedIncome 已入账
|
||||||
|
* @param withdrawIncome 已提现
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Long shopUserId, Long shopId, Integer isOne) {
|
public void updateIncome(BigDecimal pendingIncome, BigDecimal receivedIncome, BigDecimal withdrawIncome, Long id, Long userId, Long shopUserId, Long shopId, Integer isOne) {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class MkShopRechargeServiceImpl extends ServiceImpl<MkShopRechargeMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MkShopRechargeVO detail(Long shopId) {
|
public MkShopRechargeVO detail(Long shopId) throws CzgException{
|
||||||
shopId = shopInfoService.getMainIdByShopId(shopId);
|
shopId = shopInfoService.getMainIdByShopId(shopId);
|
||||||
ShopInfo shopInfo = shopInfoService.getById(shopId);
|
ShopInfo shopInfo = shopInfoService.getById(shopId);
|
||||||
if (shopInfo.getMainId() != null) {
|
if (shopInfo.getMainId() != null) {
|
||||||
|
|||||||
@@ -45,36 +45,33 @@
|
|||||||
order by a.create_time desc
|
order by a.create_time desc
|
||||||
</select>
|
</select>
|
||||||
<select id="totalAmount" resultType="java.math.BigDecimal">
|
<select id="totalAmount" resultType="java.math.BigDecimal">
|
||||||
select sum(a.amount) from mk_distribution_flow as a
|
select sum(a.reward_amount)
|
||||||
left join mk_distribution_user as d on d.id=a.distribution_user_id
|
from mk_distribution_flow as a
|
||||||
left join tb_shop_user as b on a.shop_user_id=b.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
|
|
||||||
where a.shop_id=#{shopId}
|
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">
|
<if test="startTime != null">
|
||||||
and a.create_time>=#{startTime}
|
and a.create_time>=#{startTime}
|
||||||
</if>
|
</if>
|
||||||
<if test="endTime != null">
|
<if test="endTime != null">
|
||||||
and a.create_time<=#{endTime}
|
and a.create_time<=#{endTime}
|
||||||
</if>
|
</if>
|
||||||
<if test="status != null and status != ''">
|
|
||||||
and a.status=#{status}
|
|
||||||
</if>
|
|
||||||
<if test="key != null and key != ''">
|
<if test="key != null and key != ''">
|
||||||
and (
|
and (
|
||||||
b.nick_name like concat('%',#{key},'%')
|
b.nick_name like concat('%',#{key},'%')
|
||||||
or b.id like concat('%',#{key},'%')
|
or b.id like concat('%',#{key},'%')
|
||||||
or c.id like concat('%',#{key},'%')
|
|
||||||
or c.nick_name like concat('%',#{key},'%')
|
|
||||||
)
|
)
|
||||||
</if>
|
</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>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -5,16 +5,24 @@
|
|||||||
<mapper namespace="com.czg.service.market.mapper.MkDistributionUserMapper">
|
<mapper namespace="com.czg.service.market.mapper.MkDistributionUserMapper">
|
||||||
<update id="updateIncome">
|
<update id="updateIncome">
|
||||||
update mk_distribution_user
|
update mk_distribution_user
|
||||||
set
|
<set>
|
||||||
<if test="pendingIncome != null">
|
<if test="pendingIncome != null">
|
||||||
total_income = total_income + #{pendingIncome},
|
total_income = total_income + #{pendingIncome},
|
||||||
</if>
|
</if>
|
||||||
<if test="receivedIncome != null">
|
<if test="receivedIncome != null">
|
||||||
total_income = total_income + #{receivedIncome},
|
total_income = total_income + #{receivedIncome},
|
||||||
</if>
|
</if>
|
||||||
pending_income = pending_income + #{pendingIncome},
|
|
||||||
received_income = received_income + #{receivedIncome},
|
<if test="pendingIncome != null">
|
||||||
withdrawn_income = withdrawn_income + #{withdrawIncome}
|
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}
|
where id = #{id} and shop_id = #{shopId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|||||||
@@ -18,21 +18,16 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<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>
|
<dependency>
|
||||||
<groupId>com.czg</groupId>
|
<groupId>com.czg</groupId>
|
||||||
<artifactId>market-service</artifactId>
|
<artifactId>market-service</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.czg</groupId>
|
||||||
|
<artifactId>pay-service</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<!-- 订单服务依赖消息队列 从 market 拿 -->
|
<!-- 订单服务依赖消息队列 从 market 拿 -->
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>com.czg</groupId>-->
|
<!-- <groupId>com.czg</groupId>-->
|
||||||
|
|||||||
@@ -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;
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -261,7 +261,7 @@ public interface PrinterImpl {
|
|||||||
// data.append("<OUT:15>");
|
// data.append("<OUT:15>");
|
||||||
// data.append("<BR>");
|
// data.append("<BR>");
|
||||||
// 18个空格 12
|
// 18个空格 12
|
||||||
data.append(getFormatLabel("品名 数量 小计 ", signLabelInfo.s))
|
data.append(getFormatLabel("品名 数量 单价 ", signLabelInfo.s))
|
||||||
.append(signLabelInfo.br);
|
.append(signLabelInfo.br);
|
||||||
// data.append("<S>品名 数量 小计</S><BR>");
|
// data.append("<S>品名 数量 小计</S><BR>");
|
||||||
data.append(getFormatLabel("--------------------------------", signLabelInfo.s))
|
data.append(getFormatLabel("--------------------------------", signLabelInfo.s))
|
||||||
|
|||||||
@@ -21,6 +21,6 @@ public interface DistributionPayService {
|
|||||||
/**
|
/**
|
||||||
* 运营端小程序余额充值
|
* 运营端小程序余额充值
|
||||||
*/
|
*/
|
||||||
Map<String, String> mchRecharge(String clientIP, MkDistributionPayDTO payParam);
|
Map<String, String> mchRecharge(MkDistributionPayDTO payParam);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.czg.service.order.service;
|
package com.czg.service.order.service;
|
||||||
|
|
||||||
import com.czg.entity.req.*;
|
import com.czg.enums.CzgPayEnum;
|
||||||
import com.czg.entity.resp.CzgBaseResp;
|
|
||||||
import com.czg.entity.resp.CzgRefundResp;
|
|
||||||
import com.czg.order.dto.LtPayOtherDTO;
|
import com.czg.order.dto.LtPayOtherDTO;
|
||||||
import com.czg.order.entity.OrderPayment;
|
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 com.czg.resp.CzgResult;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
@@ -21,14 +23,10 @@ public interface PayService {
|
|||||||
BigDecimal MONEY_RATE = new BigDecimal("100");
|
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>> pay(@NonNull Long shopId, CzgPayEnum payType, CzgPayBaseReq 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);
|
|
||||||
//-----------------------------------------------------------------积分商品/拼团 付款 ----------------------------------------------------------
|
//-----------------------------------------------------------------积分商品/拼团 付款 ----------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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 payOrderId 平台订单号
|
||||||
* @param mchOrderNo 商户订单号
|
* @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 mchRefundNo 商户退款订单号 二选一
|
||||||
* @param refundOrderId 平台退款订单号 二选一
|
* @param refundOrderId 平台退款订单号 二选一
|
||||||
*/
|
*/
|
||||||
CzgResult<CzgRefundResp> queryRefund(Long shopId, String mchRefundNo, String refundOrderId);
|
CzgResult<RefundRespDTO> queryRefund(Long shopId, String mchRefundNo, String refundOrderId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public interface ShopDirectMerchantService extends IService<ShopDirectMerchant>
|
|||||||
/**
|
/**
|
||||||
* 获取进件信息
|
* 获取进件信息
|
||||||
*/
|
*/
|
||||||
AggregateMerchantVO getEntry(Long shopId, String licenceNo);
|
AggregateMerchantVO getEntry(Long shopId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 申请进件
|
* 申请进件
|
||||||
|
|||||||
@@ -7,13 +7,15 @@ import com.czg.account.service.ShopUserService;
|
|||||||
import com.czg.account.service.UserInfoService;
|
import com.czg.account.service.UserInfoService;
|
||||||
import com.czg.constant.TableValueConstant;
|
import com.czg.constant.TableValueConstant;
|
||||||
import com.czg.constants.PayTypeConstants;
|
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.exception.CzgException;
|
||||||
import com.czg.market.service.MkDistributionConfigService;
|
import com.czg.market.service.MkDistributionConfigService;
|
||||||
import com.czg.market.vo.MkDistributionConfigVO;
|
import com.czg.market.vo.MkDistributionConfigVO;
|
||||||
import com.czg.order.dto.MkDistributionPayDTO;
|
import com.czg.order.dto.MkDistributionPayDTO;
|
||||||
import com.czg.order.entity.OrderPayment;
|
import com.czg.order.entity.OrderPayment;
|
||||||
import com.czg.order.service.OrderPaymentService;
|
import com.czg.order.service.OrderPaymentService;
|
||||||
|
import com.czg.pay.CzgPayBaseReq;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.service.market.service.impl.WxServiceImpl;
|
import com.czg.service.market.service.impl.WxServiceImpl;
|
||||||
import com.czg.service.order.service.DistributionPayService;
|
import com.czg.service.order.service.DistributionPayService;
|
||||||
@@ -67,7 +69,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
|||||||
ShopUser shopUserInfo = shopUserService.getShopUserInfo(payParam.getShopId(), userId);
|
ShopUser shopUserInfo = shopUserService.getShopUserInfo(payParam.getShopId(), userId);
|
||||||
|
|
||||||
OrderPayment orderPayment = new OrderPayment().setShopId(payParam.getShopId()).setSourceId(isRecharge ? payParam.getShopId() : shopUserInfo.getId())
|
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)
|
.setPayType(PayTypeConstants.PayType.PAY)
|
||||||
.setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId())
|
.setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId())
|
||||||
.setAmount(isRecharge ? payParam.getAmount() : detail.getPayAmount());
|
.setAmount(isRecharge ? payParam.getAmount() : detail.getPayAmount());
|
||||||
@@ -81,7 +83,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
|||||||
} else {
|
} else {
|
||||||
UserInfo userInfo = userInfoService.getById(userId);
|
UserInfo userInfo = userInfoService.getById(userId);
|
||||||
initInfo.setPayment(orderPayment).setShopUser(shopUserInfo)
|
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;
|
return initInfo;
|
||||||
}
|
}
|
||||||
@@ -89,12 +91,13 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
|||||||
@Override
|
@Override
|
||||||
public CzgResult<Map<String, Object>> ltPayOrder(String clintIp, MkDistributionPayDTO payParam) {
|
public CzgResult<Map<String, Object>> ltPayOrder(String clintIp, MkDistributionPayDTO payParam) {
|
||||||
InitInfo initInfo = initPayment(payParam.getUserId(), payParam, false);
|
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(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
|
||||||
payParam.getPayType(), "分销员开通", initInfo.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.ltPayReq(initInfo.payment.getOrderNo(), "分销员开通", initInfo.payment.getAmount().multiply(MONEY_RATE).longValue(),
|
||||||
|
payParam.getPayType(), initInfo.getOpenId(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
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());
|
return wxService.v3Pay(initInfo.openId, payParam.getAmount(), "商户运营余额充值", initInfo.payment.getOrderNo(), initInfo.payment.getSourceType());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import cn.hutool.core.date.DateUtil;
|
|||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
import cn.hutool.core.exceptions.ValidateException;
|
import cn.hutool.core.exceptions.ValidateException;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
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 cn.hutool.json.JSONUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
@@ -17,9 +20,8 @@ import com.czg.config.RabbitPublisher;
|
|||||||
import com.czg.config.RedisCst;
|
import com.czg.config.RedisCst;
|
||||||
import com.czg.constant.MarketConstants;
|
import com.czg.constant.MarketConstants;
|
||||||
import com.czg.constant.TableValueConstant;
|
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.constants.PayTypeConstants;
|
||||||
|
import com.czg.entity.notify.CzgRefundNotifyDTO;
|
||||||
import com.czg.enums.ShopTableStatusEnum;
|
import com.czg.enums.ShopTableStatusEnum;
|
||||||
import com.czg.enums.ShopUserFlowBizEnum;
|
import com.czg.enums.ShopUserFlowBizEnum;
|
||||||
import com.czg.exception.CzgException;
|
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.enums.PayEnums;
|
||||||
import com.czg.order.service.*;
|
import com.czg.order.service.*;
|
||||||
import com.czg.order.vo.*;
|
import com.czg.order.vo.*;
|
||||||
|
import com.czg.pay.PayNotifyRespDTO;
|
||||||
import com.czg.product.entity.Product;
|
import com.czg.product.entity.Product;
|
||||||
import com.czg.product.service.ProductRpcService;
|
import com.czg.product.service.ProductRpcService;
|
||||||
import com.czg.product.service.ProductService;
|
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.mapper.OrderInfoCustomMapper;
|
||||||
import com.czg.service.order.print.PrinterHandler;
|
import com.czg.service.order.print.PrinterHandler;
|
||||||
import com.czg.utils.*;
|
import com.czg.utils.*;
|
||||||
import com.czg.utils.PageUtil;
|
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@@ -1028,13 +1030,12 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson, int retryCount) {
|
public void payCallBackOrder(@NotBlank String orderNo, @NotNull PayNotifyRespDTO notifyRespDTO, String channel, int retryCount) {
|
||||||
CzgPayNotifyDTO czgCallBackDto = JSONObject.parseObject(resultJson.toString(), CzgPayNotifyDTO.class);
|
|
||||||
OrderPayment payment = paymentService.getOne(new QueryWrapper().eq(OrderPayment::getOrderNo, orderNo));
|
OrderPayment payment = paymentService.getOne(new QueryWrapper().eq(OrderPayment::getOrderNo, orderNo));
|
||||||
if (payment == null) {
|
if (payment == null) {
|
||||||
if (retryCount < MAX_RETRIES) {
|
if (retryCount < MAX_RETRIES) {
|
||||||
log.info("支付记录不存在,第 {} 次重试,将在 {} 秒后进行", retryCount + 1, DELAY);
|
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 {
|
} else {
|
||||||
log.error("订单支付回调失败, 达到最大重试次数, 支付记录不存在, orderNo: {}", orderNo);
|
log.error("订单支付回调失败, 达到最大重试次数, 支付记录不存在, orderNo: {}", orderNo);
|
||||||
}
|
}
|
||||||
@@ -1044,10 +1045,12 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|||||||
log.info("订单处理过,payment id:{}", payment.getId());
|
log.info("订单处理过,payment id:{}", payment.getId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
payment.setTradeNumber(czgCallBackDto.getPayOrderId());
|
payment.setTradeNumber(notifyRespDTO.getThirdOrderNo());
|
||||||
payment.setRespJson(resultJson.toString());
|
payment.setRespJson(notifyRespDTO.getOriginalData());
|
||||||
payment.setPayStatus(PayTypeConstants.PayStatus.FAIL);
|
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);
|
payment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS);
|
||||||
if (PayTypeConstants.SourceType.ORDER.equals(payment.getSourceType())) {
|
if (PayTypeConstants.SourceType.ORDER.equals(payment.getSourceType())) {
|
||||||
OrderInfo orderInfo = orderInfoService.getById(payment.getSourceId());
|
OrderInfo orderInfo = orderInfoService.getById(payment.getSourceId());
|
||||||
@@ -1055,8 +1058,8 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|||||||
log.error("订单支付回调失败,订单不存在,支付记录Id,{}", payment.getId());
|
log.error("订单支付回调失败,订单不存在,支付记录Id,{}", payment.getId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
upOrderInfo(orderInfo, new BigDecimal(czgCallBackDto.getAmount()).divide(new BigDecimal(100), 2, RoundingMode.DOWN),
|
upOrderInfo(orderInfo, new BigDecimal(notifyRespDTO.getAmount()).divide(new BigDecimal(100), 2, RoundingMode.DOWN),
|
||||||
DateUtil.parseLocalDateTime(czgCallBackDto.getPayTime()), payment.getId(), null);
|
DateUtil.parseLocalDateTime(notifyRespDTO.getPaySuccessTime()), payment.getId(), null);
|
||||||
if (orderInfo.getUserId() != null) {
|
if (orderInfo.getUserId() != null) {
|
||||||
// 分销员升级等级
|
// 分销员升级等级
|
||||||
distributionUserService.costUpgradeLevelBefore(orderInfo.getUserId(), orderInfo.getShopId());
|
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())) {
|
} else if (PayTypeConstants.SourceType.MEMBER_IN.equals(payment.getSourceType()) || PayTypeConstants.SourceType.FREE.equals(payment.getSourceType())) {
|
||||||
boolean isFree = PayTypeConstants.SourceType.FREE.equals(payment.getSourceType());
|
boolean isFree = PayTypeConstants.SourceType.FREE.equals(payment.getSourceType());
|
||||||
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
|
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
|
||||||
OrderInfo orderInfo = null;
|
OrderInfo orderInfo;
|
||||||
if (shopUser == null) {
|
if (shopUser == null) {
|
||||||
log.error("会员充值失败,会员不存在,会员id:{}", payment.getSourceId());
|
log.error("会员充值失败,会员不存在,会员id:{}", payment.getSourceId());
|
||||||
} else {
|
} else {
|
||||||
ShopUserFlowBizEnum bizEnum;
|
ShopUserFlowBizEnum bizEnum;
|
||||||
if ("WECHAT".equals(czgCallBackDto.getPayType())) {
|
if ("WECHAT".equals(notifyRespDTO.getPlatform())) {
|
||||||
bizEnum = ShopUserFlowBizEnum.WECHAT_IN;
|
bizEnum = ShopUserFlowBizEnum.WECHAT_IN;
|
||||||
} else if ("ALIPAY".equals(czgCallBackDto.getPayType())) {
|
} else if ("ALIPAY".equals(notifyRespDTO.getPlatform())) {
|
||||||
bizEnum = ShopUserFlowBizEnum.ALIPAY_IN;
|
bizEnum = ShopUserFlowBizEnum.ALIPAY_IN;
|
||||||
} else {
|
} else {
|
||||||
bizEnum = ShopUserFlowBizEnum.CASH_IN;
|
bizEnum = ShopUserFlowBizEnum.CASH_IN;
|
||||||
@@ -1089,7 +1092,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|||||||
.setType(1)
|
.setType(1)
|
||||||
.setBizEnum(ShopUserFlowBizEnum.FREE_IN)
|
.setBizEnum(ShopUserFlowBizEnum.FREE_IN)
|
||||||
.setRelationId(orderInfo.getId())
|
.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);
|
shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||||
upOrderInfo(orderInfo, BigDecimal.ZERO,
|
upOrderInfo(orderInfo, BigDecimal.ZERO,
|
||||||
LocalDateTime.now(), null, PayEnums.FREE_PAY);
|
LocalDateTime.now(), null, PayEnums.FREE_PAY);
|
||||||
@@ -1111,7 +1114,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|||||||
LocalDateTime.now(), null, PayEnums.VIP_PAY);
|
LocalDateTime.now(), null, PayEnums.VIP_PAY);
|
||||||
}
|
}
|
||||||
shopRechargeService.recharge(payment.getShopId(), payment.getSourceId(), payment.getRelatedId(),
|
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);
|
payment.getId(), payment.getSourceType(), bizEnum, orderInfo == null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ import com.czg.account.service.UserInfoService;
|
|||||||
import com.czg.config.RabbitPublisher;
|
import com.czg.config.RabbitPublisher;
|
||||||
import com.czg.config.RedisCst;
|
import com.czg.config.RedisCst;
|
||||||
import com.czg.constants.PayTypeConstants;
|
import com.czg.constants.PayTypeConstants;
|
||||||
import com.czg.entity.req.*;
|
import com.czg.enums.CzgPayEnum;
|
||||||
import com.czg.entity.resp.CzgRefundResp;
|
|
||||||
import com.czg.enums.ShopUserFlowBizEnum;
|
import com.czg.enums.ShopUserFlowBizEnum;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.exception.PaySuccessException;
|
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.OrderDetailService;
|
||||||
import com.czg.order.service.OrderInfoCustomService;
|
import com.czg.order.service.OrderInfoCustomService;
|
||||||
import com.czg.order.service.OrderPaymentService;
|
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.resp.CzgResult;
|
||||||
import com.czg.service.RedisService;
|
import com.czg.service.RedisService;
|
||||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||||
@@ -62,6 +64,9 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ww
|
||||||
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class OrderPayServiceImpl implements OrderPayService {
|
public class OrderPayServiceImpl implements OrderPayService {
|
||||||
@@ -227,13 +232,15 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
return CzgResult.failure("支付失败 充值金额必须大雨订单金额");
|
return CzgResult.failure("支付失败 充值金额必须大雨订单金额");
|
||||||
}
|
}
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN, PayTypeConstants.PayType.PAY, payOrderNo,
|
Long paymentId = payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN,
|
||||||
"", rechargeDetail.getAmount(), rechargeDetail.getId()));
|
payOrderNo, rechargeDetail.getAmount(), "", rechargeDetail.getId()));
|
||||||
upOrderPayInfo(orderInfo.getId(), PayEnums.VIP_PAY, paymentId,
|
upOrderPayInfo(orderInfo.getId(), PayEnums.VIP_PAY, paymentId,
|
||||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||||
return payService.ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, rechargeDetail.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
|
||||||
payParam.getPayType(), "充值并支付", "wechatPay".equals(payParam.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId(),
|
CzgPayBaseReq.ltPayReq(
|
||||||
clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
payOrderNo, "充值并支付",
|
||||||
|
rechargeDetail.getAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getPayType(),
|
||||||
|
"wechatPay".equals(payParam.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -241,12 +248,10 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
public CzgResult<Map<String, Object>> h5PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> h5PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
upOrderPayInfo(orderInfo.getId(), PayEnums.H5_PAY, paymentId, payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||||
upOrderPayInfo(orderInfo.getId(), PayEnums.H5_PAY, paymentId,
|
return payService.pay(payParam.getShopId(), CzgPayEnum.H5_PAY,
|
||||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
CzgPayBaseReq.h5PayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), clintIp));
|
||||||
return payService.h5Pay(payParam.getShopId(), new CzgH5PayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
|
||||||
"点餐支付", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -257,12 +262,12 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
|
||||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||||
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
|
||||||
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.jsPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||||
|
payParam.getPayType(), payParam.getOpenId(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -281,12 +286,12 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId());
|
orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId());
|
||||||
}
|
}
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
|
||||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||||
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
|
||||||
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.jsPayReq(payOrderNo, "扫码支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||||
|
payParam.getPayType(), payParam.getOpenId(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -296,12 +301,12 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
|
||||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||||
return payService.ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
|
||||||
payParam.getPayType(), "点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.ltPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||||
|
payParam.getPayType(), payParam.getOpenId(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -317,12 +322,11 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
BigDecimal amount = shopRechargeService.checkRecharge(mainShopId, payParam.getShopId(), shopUser.getUserId(), payParam.getRechargeDetailId(), payParam.getAmount());
|
BigDecimal amount = shopRechargeService.checkRecharge(mainShopId, payParam.getShopId(), shopUser.getUserId(), payParam.getRechargeDetailId(), payParam.getAmount());
|
||||||
payParam.setAmount(amount);
|
payParam.setAmount(amount);
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
|
||||||
upOrderPayInfo(orderInfo.getId(), PayEnums.MAIN_SCAN, paymentId,
|
upOrderPayInfo(orderInfo.getId(), PayEnums.MAIN_SCAN, paymentId,
|
||||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||||
return payService.scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.SCAN_PAY,
|
||||||
"点餐支付", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.scanPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -344,10 +348,9 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), payParam.getAuthCode()));
|
||||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, payParam.getAuthCode(), orderInfo.getOrderAmount()));
|
CzgResult<Map<String, Object>> mapCzgResult = payService.pay(payParam.getShopId(), CzgPayEnum.MICRO_PAY,
|
||||||
CzgResult<Map<String, Object>> mapCzgResult = payService.microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
CzgPayBaseReq.microPay(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getAuthCode()));
|
||||||
"点餐支付", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
|
|
||||||
if (mapCzgResult.getCode() == 200) {
|
if (mapCzgResult.getCode() == 200) {
|
||||||
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||||
LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN);
|
LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN);
|
||||||
@@ -508,19 +511,22 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
|
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
|
||||||
OrderPayment payment = paymentService.getById(payOrderId);
|
OrderPayment payment = paymentService.getById(payOrderId);
|
||||||
AssertUtil.isNull(payment, "退款失败支付记录不存在");
|
AssertUtil.isNull(payment, "退款失败支付记录不存在");
|
||||||
Long refundId = payService.initOrderPayment(new OrderPayment(shopId, orderId, PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refundAmount, payment.getId()));
|
Long refundId = payService.initPayment(OrderPayment.refund(shopId, orderId, PayTypeConstants.SourceType.ORDER,
|
||||||
CzgResult<CzgRefundResp> refund = payService.refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
refPayOrderNo, refundAmount, payment.getId(), payment.getPlatformType()));
|
||||||
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
|
|
||||||
if (refund.getData() != null && refund.getData().getNote() != null) {
|
CzgResult<RefundRespDTO> refund = payService.refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(PayService.MONEY_RATE).longValue(),
|
||||||
throw new CzgException(refund.getData().getNote());
|
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());
|
throw new CzgException(refund.getMsg());
|
||||||
} else {
|
} else {
|
||||||
paymentService.updateChain()
|
paymentService.updateChain()
|
||||||
.eq(OrderPayment::getId, refundId)
|
.eq(OrderPayment::getId, refundId)
|
||||||
.set(OrderPayment::getPayTime, refund.getData().getRefundTime())
|
.set(OrderPayment::getPayTime, refund.getData().getRefundTime())
|
||||||
.set(OrderPayment::getTradeNumber, refund.getData().getRefundOrderId())
|
.set(OrderPayment::getTradeNumber, refund.getData().getThirdRefundNo())
|
||||||
.set(OrderPayment::getRespJson, JSONObject.toJSONString(refund.getData()))
|
.set(OrderPayment::getRespJson, refund.getData().getOriginalData())
|
||||||
.update();
|
.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,25 @@ package com.czg.service.order.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.CzgPayUtils;
|
import com.czg.PayAdapter;
|
||||||
import com.czg.account.entity.ShopMerchant;
|
import com.czg.PayAdapterFactory;
|
||||||
import com.czg.account.service.ShopMerchantService;
|
import com.czg.constant.PayChannelCst;
|
||||||
import com.czg.constants.ParamCodeCst;
|
import com.czg.constants.ParamCodeCst;
|
||||||
import com.czg.constants.PayTypeConstants;
|
import com.czg.constants.PayTypeConstants;
|
||||||
import com.czg.entity.req.*;
|
import com.czg.constants.SystemConstants;
|
||||||
import com.czg.entity.resp.CzgBaseResp;
|
import com.czg.enums.CzgPayEnum;
|
||||||
import com.czg.entity.resp.CzgRefundResp;
|
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.order.dto.LtPayOtherDTO;
|
import com.czg.order.dto.LtPayOtherDTO;
|
||||||
import com.czg.order.entity.OrderPayment;
|
import com.czg.order.entity.OrderPayment;
|
||||||
|
import com.czg.order.entity.ShopMerchant;
|
||||||
import com.czg.order.service.OrderPaymentService;
|
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.resp.CzgResult;
|
||||||
import com.czg.service.order.mapper.OrderPaymentMapper;
|
import com.czg.service.order.mapper.OrderPaymentMapper;
|
||||||
import com.czg.service.order.service.PayService;
|
import com.czg.service.order.service.PayService;
|
||||||
@@ -39,7 +45,7 @@ import java.util.Map;
|
|||||||
@Service
|
@Service
|
||||||
public class PayServiceImpl implements PayService {
|
public class PayServiceImpl implements PayService {
|
||||||
|
|
||||||
@DubboReference
|
@Resource
|
||||||
private ShopMerchantService shopMerchantService;
|
private ShopMerchantService shopMerchantService;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private SysParamsService sysParamsService;
|
private SysParamsService sysParamsService;
|
||||||
@@ -49,66 +55,20 @@ public class PayServiceImpl implements PayService {
|
|||||||
private OrderPaymentMapper paymentMapper;
|
private OrderPaymentMapper paymentMapper;
|
||||||
|
|
||||||
@Override
|
@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);
|
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
|
||||||
getNotifyUrl());
|
String payData = null;
|
||||||
return CzgPayUtils.h5Pay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
|
||||||
}
|
payData = shopMerchant.getNativePayJson();
|
||||||
|
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
|
||||||
@Override
|
payData = shopMerchant.getPolyPayJson();
|
||||||
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("支付失败,不支持的条码");
|
|
||||||
}
|
}
|
||||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
bizData.setSubAppid(SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? shopMerchant.getAlipayAppId() : shopMerchant.getWechatAppId());
|
||||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
if (payType.equals(CzgPayEnum.MICRO_PAY)) {
|
||||||
getNotifyUrl());
|
checkMicroPay(bizData, shopMerchant);
|
||||||
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("扫描码非法或暂不支持");
|
|
||||||
}
|
}
|
||||||
return CzgPayUtils.microPay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
return adapter.pay(payType, payData, getDomain(), getNotifyUrl(shopMerchant.getChannel()), bizData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -117,17 +77,26 @@ public class PayServiceImpl implements PayService {
|
|||||||
AssertUtil.isBlank(param.getOpenId(), "用户小程序ID不能为空");
|
AssertUtil.isBlank(param.getOpenId(), "用户小程序ID不能为空");
|
||||||
AssertUtil.isBlank(param.getPayType(), "支付方式不能为空");
|
AssertUtil.isBlank(param.getPayType(), "支付方式不能为空");
|
||||||
String payOrderNo = "LT" + IdUtil.getSnowflakeNextId();
|
String payOrderNo = "LT" + IdUtil.getSnowflakeNextId();
|
||||||
initOrderPayment(new OrderPayment(param.getShopId(), param.getRecordId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
initPayment(OrderPayment.pay(param.getShopId(), param.getRecordId(), payType, payOrderNo,
|
||||||
"", param.getPrice(), null));
|
param.getPrice(), "", null));
|
||||||
return ltPay(param.getShopId(), param.getPayType(), new CzgLtPayReq(payOrderNo, param.getPrice().multiply(MONEY_RATE).longValue(),
|
return pay(param.getShopId(), CzgPayEnum.LT_PAY,
|
||||||
param.getPayType(), detail, param.getOpenId(), param.getIp(), "", "", ""));
|
CzgPayBaseReq.ltPayReq(payOrderNo, detail, param.getPrice().multiply(MONEY_RATE).longValue(),
|
||||||
|
param.getPayType(), param.getOpenId(), param.getIp()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CzgResult<CzgRefundResp> refund(@NonNull Long shopId, CzgRefundReq bizData) {
|
public CzgResult<RefundRespDTO> refund(@NonNull Long shopId, CzgRefundReq bizData) {
|
||||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||||
bizData.setNotifyUrl(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_REFUND_NOTIFY_URL));
|
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
|
||||||
return CzgPayUtils.refundOrder(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
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
|
@Override
|
||||||
@@ -136,17 +105,18 @@ public class PayServiceImpl implements PayService {
|
|||||||
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
|
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
|
||||||
OrderPayment payment = paymentService.getById(payOrderId);
|
OrderPayment payment = paymentService.getById(payOrderId);
|
||||||
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
|
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
|
||||||
Long refundId = initOrderPayment(new OrderPayment(shopId, sourceId, payment.getSourceType(), PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refundAmount, payment.getId()));
|
Long refundId = initPayment(OrderPayment.refund(shopId, sourceId, payment.getSourceType(), refPayOrderNo, refundAmount, payment.getId(), payment.getPlatformType()));
|
||||||
CzgResult<CzgRefundResp> refund = refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(MONEY_RATE).longValue(),
|
CzgResult<RefundRespDTO> refund = refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(MONEY_RATE).longValue(),
|
||||||
payment.getOrderNo(), ""));
|
payment.getAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), "", payment.getPlatformType()));
|
||||||
OrderPayment uOrderPayment = new OrderPayment();
|
OrderPayment uOrderPayment = new OrderPayment();
|
||||||
uOrderPayment.setRespJson(JSONObject.toJSONString(refund.getData()));
|
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);
|
uOrderPayment.setPayStatus(PayTypeConstants.PayStatus.FAIL);
|
||||||
} else {
|
} else {
|
||||||
uOrderPayment.setTradeNumber(refund.getData().getRefundOrderId());
|
uOrderPayment.setTradeNumber(refund.getData().getThirdRefundNo());
|
||||||
uOrderPayment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS);
|
uOrderPayment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS);
|
||||||
uOrderPayment.setPayTime(LocalDateTimeUtil.parse(refund.getData().getRefundTime(), "yyyy-MM-dd HH:mm:ss"));
|
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));
|
paymentService.update(uOrderPayment, QueryWrapper.create().eq(OrderPayment::getId, refundId));
|
||||||
}
|
}
|
||||||
@@ -157,18 +127,19 @@ public class PayServiceImpl implements PayService {
|
|||||||
//支付的 订单
|
//支付的 订单
|
||||||
OrderPayment payment = paymentService.getById(refundPayment.getRelatedId());
|
OrderPayment payment = paymentService.getById(refundPayment.getRelatedId());
|
||||||
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
|
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
|
||||||
Long refundCompensate = initOrderPayment(new OrderPayment(refundPayment.getShopId(), refundPayment.getSourceId(), payment.getSourceType(), PayTypeConstants.PayType.REFUND_COMPENSATE,
|
Long refundCompensate = initPayment(OrderPayment.refundCompensate(refundPayment.getShopId(), refundPayment.getSourceId(),
|
||||||
refPayOrderNo, null, refundPayment.getAmount(), refundPayment.getId()));
|
payment.getSourceType(), refPayOrderNo, refundPayment.getAmount(), refundPayment.getId()));
|
||||||
CzgResult<CzgRefundResp> refund = refund(payment.getShopId(), new CzgRefundReq(refPayOrderNo, "退款补偿", refundPayment.getAmount().multiply(MONEY_RATE).longValue(),
|
CzgResult<RefundRespDTO> refund = refund(payment.getShopId(), new CzgRefundReq(refPayOrderNo, "退款补偿", refundPayment.getAmount().multiply(MONEY_RATE).longValue(),
|
||||||
payment.getOrderNo(), ""));
|
payment.getAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), "", payment.getPlatformType()));
|
||||||
OrderPayment uOrderPayment = new OrderPayment();
|
OrderPayment uOrderPayment = new OrderPayment();
|
||||||
uOrderPayment.setTradeNumber(refund.getData().getRefundOrderId());
|
uOrderPayment.setTradeNumber(refund.getData().getThirdRefundNo());
|
||||||
uOrderPayment.setRespJson(JSONObject.toJSONString(refund.getData()));
|
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);
|
uOrderPayment.setPayStatus(PayTypeConstants.PayStatus.FAIL);
|
||||||
} else {
|
} else {
|
||||||
uOrderPayment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS);
|
uOrderPayment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS);
|
||||||
uOrderPayment.setPayTime(LocalDateTimeUtil.parse(refund.getData().getRefundTime(), "yyyy-MM-dd HH:mm:ss"));
|
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, refundPayment.getId()));
|
||||||
paymentService.update(uOrderPayment, QueryWrapper.create().eq(OrderPayment::getId, refundCompensate));
|
paymentService.update(uOrderPayment, QueryWrapper.create().eq(OrderPayment::getId, refundCompensate));
|
||||||
@@ -176,38 +147,95 @@ public class PayServiceImpl implements PayService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@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);
|
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
|
@Override
|
||||||
@Transactional
|
@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);
|
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
|
@Override
|
||||||
public Long initOrderPayment(OrderPayment payment) {
|
public Long initPayment(OrderPayment payment) {
|
||||||
paymentMapper.insert(payment);
|
paymentMapper.insert(payment);
|
||||||
return payment.getId();
|
return payment.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ShopMerchant getMerchant(Long shopId) {
|
private ShopMerchant getMerchant(Long shopId) {
|
||||||
try {
|
ShopMerchant shopMerchant = shopMerchantService.getByShopId(shopId);
|
||||||
return shopMerchantService.getById(shopId);
|
if (shopMerchant == null || StrUtil.isBlank(shopMerchant.getChannel())) {
|
||||||
} catch (Exception e) {
|
throw new CzgException("暂未开通支付!");
|
||||||
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() {
|
private String getDomain() {
|
||||||
return sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN);
|
return sysParamsService.getSysParamValue(ParamCodeCst.System.POLY_DOMAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNotifyUrl() {
|
private String getNotifyUrl(String channel) {
|
||||||
return sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_NOTIFY_URL);
|
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("扫描码非法或暂不支持");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,9 +64,8 @@ public class ShopDirectMerchantServiceImpl extends ServiceImpl<ShopDirectMerchan
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AggregateMerchantVO getEntry(Long shopId, String licenceNo) {
|
public AggregateMerchantVO getEntry(Long shopId) {
|
||||||
ShopDirectMerchant merchant = getOne(query()
|
ShopDirectMerchant merchant = getOne(query()
|
||||||
.eq(ShopDirectMerchant::getLicenceNo, licenceNo)
|
|
||||||
.eq(ShopDirectMerchant::getShopId, shopId));
|
.eq(ShopDirectMerchant::getShopId, shopId));
|
||||||
if (merchant == null) {
|
if (merchant == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,13 +2,11 @@ package com.czg.service.order.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import cn.hutool.crypto.SecureUtil;
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||||
import com.czg.account.entity.*;
|
import com.czg.account.entity.*;
|
||||||
import com.czg.account.service.*;
|
import com.czg.account.service.*;
|
||||||
import com.czg.constants.PayTypeConstants;
|
import com.czg.constants.PayTypeConstants;
|
||||||
import com.czg.entity.req.*;
|
import com.czg.enums.CzgPayEnum;
|
||||||
import com.czg.entity.resp.CzgRefundResp;
|
|
||||||
import com.czg.enums.ShopUserFlowBizEnum;
|
import com.czg.enums.ShopUserFlowBizEnum;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.market.dto.MemberOrderDTO;
|
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.entity.OrderPayment;
|
||||||
import com.czg.order.service.OrderInfoCustomService;
|
import com.czg.order.service.OrderInfoCustomService;
|
||||||
import com.czg.order.service.OrderPaymentService;
|
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.resp.CzgResult;
|
||||||
import com.czg.service.order.dto.VipMemberPayParamDTO;
|
import com.czg.service.order.dto.VipMemberPayParamDTO;
|
||||||
import com.czg.service.order.dto.VipPayParamDTO;
|
import com.czg.service.order.dto.VipPayParamDTO;
|
||||||
@@ -131,15 +132,16 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||||
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||||
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), payType, payOrderNo,
|
||||||
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
payParam.getAmount(), "", isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||||
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
|
||||||
"会员充值", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.jsPayReq(payOrderNo, "会员充值", payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||||
|
payParam.getPayType(), payParam.getOpenId(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@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()));
|
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, shopInfoService.getMainIdByShopId(payParam.getShopId())).eq(ShopUser::getId, payParam.getShopUserId()));
|
||||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||||
MemberOrder memberOrder = memberOrderService.createMemberOrder(new MemberOrderDTO().setName(payParam.getName())
|
MemberOrder memberOrder = memberOrderService.createMemberOrder(new MemberOrderDTO().setName(payParam.getName())
|
||||||
@@ -155,7 +157,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
.setShopId(payParam.getShopId())
|
.setShopId(payParam.getShopId())
|
||||||
.setRecordId(shopUser.getId())
|
.setRecordId(shopUser.getId())
|
||||||
.setPrice(memberOrder.getAmount())
|
.setPrice(memberOrder.getAmount())
|
||||||
.setIp(clientIP);
|
.setIp(clientIp);
|
||||||
return payService.ltPayOther(payParam1, PayTypeConstants.SourceType.MEMBER_PAY, "会员充值");
|
return payService.ltPayOther(payParam1, PayTypeConstants.SourceType.MEMBER_PAY, "会员充值");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +193,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
boolean isFree = checkPayVip(rechargeDTO);
|
||||||
Long mainShopId = shopInfoService.getMainIdByShopId(rechargeDTO.getShopId());
|
Long mainShopId = shopInfoService.getMainIdByShopId(rechargeDTO.getShopId());
|
||||||
|
|
||||||
@@ -212,7 +214,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
.setShopId(rechargeDTO.getShopId())
|
.setShopId(rechargeDTO.getShopId())
|
||||||
.setRecordId(shopUser.getId())
|
.setRecordId(shopUser.getId())
|
||||||
.setPrice(amount)
|
.setPrice(amount)
|
||||||
.setIp(clientIP);
|
.setIp(clientIp);
|
||||||
return payService.ltPayOther(payParam, payType, "会员充值");
|
return payService.ltPayOther(payParam, payType, "会员充值");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,10 +226,10 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||||
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||||
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), payType, payOrderNo,
|
||||||
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
payParam.getAmount(), "", isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||||
return payService.scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.SCAN_PAY,
|
||||||
"会员充值", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.scanPayReq(payOrderNo, "会员充值", payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -239,10 +241,9 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||||
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||||
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), payType, payOrderNo, payParam.getAmount(), "", isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||||
payParam.getAuthCode(), payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
CzgResult<Map<String, Object>> mapCzgResult = payService.pay(payParam.getShopId(), CzgPayEnum.MICRO_PAY,
|
||||||
CzgResult<Map<String, Object>> mapCzgResult = payService.microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
CzgPayBaseReq.microPay(payOrderNo, "会员充值", payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getAuthCode()));
|
||||||
"会员充值", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
|
|
||||||
mapCzgResult.setData(Map.of("payOrderNo", payOrderNo));
|
mapCzgResult.setData(Map.of("payOrderNo", payOrderNo));
|
||||||
return mapCzgResult;
|
return mapCzgResult;
|
||||||
}
|
}
|
||||||
@@ -309,19 +310,20 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
return CzgResult.failure("退款失败,该充值记录不存在");
|
return CzgResult.failure("退款失败,该充值记录不存在");
|
||||||
}
|
}
|
||||||
String refPayOrderNo = "REFVIP" + IdUtil.getSnowflakeNextId();
|
String refPayOrderNo = "REFVIP" + IdUtil.getSnowflakeNextId();
|
||||||
refPaymentId = payService.initOrderPayment(new OrderPayment(refPayParam.getShopId(), shopUser.getId(),
|
refPaymentId = payService.initPayment(OrderPayment.refund(refPayParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN,
|
||||||
PayTypeConstants.SourceType.MEMBER_IN, PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refPayParam.getRefAmount()));
|
refPayOrderNo, refPayParam.getRefAmount(), inFlow.getId(), payment.getPlatformType()));
|
||||||
CzgResult<CzgRefundResp> refund = payService.refund(refPayParam.getShopId(), new CzgRefundReq(refPayOrderNo, refPayParam.getRemark(),
|
CzgResult<RefundRespDTO> refund = payService.refund(refPayParam.getShopId(), new CzgRefundReq(refPayOrderNo, refPayParam.getRemark(),
|
||||||
refPayParam.getRefAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
refPayParam.getRefAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||||
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
|
payment.getOrderNo(), "", payment.getPlatformType()));
|
||||||
|
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getStatus())) {
|
||||||
throw new CzgException(refund.getMsg());
|
throw new CzgException(refund.getMsg());
|
||||||
} else {
|
} else {
|
||||||
paymentService.updateChain()
|
paymentService.updateChain()
|
||||||
.eq(OrderPayment::getId, refPaymentId)
|
.eq(OrderPayment::getId, refPaymentId)
|
||||||
.set(OrderPayment::getPayTime, refund.getData().getRefundTime())
|
.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::getPayStatus, PayTypeConstants.PayStatus.SUCCESS)
|
||||||
.set(OrderPayment::getRespJson, JSONObject.toJSONString(refund.getData()))
|
.set(OrderPayment::getRespJson, refund.getData().getOriginalData())
|
||||||
.update();
|
.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
<!DOCTYPE mapper
|
<!DOCTYPE mapper
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"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>
|
</mapper>
|
||||||
37
cash-service/pay-service/pom.xml
Normal file
37
cash-service/pay-service/pom.xml
Normal 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>
|
||||||
@@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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
Reference in New Issue
Block a user