Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bfff341d17 | |||
| f85ac0815b | |||
| 80fb367673 | |||
| 574c73d0b5 | |||
| cb18aa5670 | |||
| da3447cd0b | |||
| 9e946443ec | |||
| 71ffdede19 | |||
| 353404dde4 |
@@ -1,18 +1,28 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import cn.hutool.http.server.HttpServerRequest;
|
||||
import cn.hutool.http.server.HttpServerResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.czg.account.dto.SysLoginDTO;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.entity.SysUser;
|
||||
import com.czg.account.service.AuthorizationService;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.SysUserService;
|
||||
import com.czg.account.service.*;
|
||||
import com.czg.account.vo.LoginVO;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.annotation.SaStaffCheckPermission;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -66,6 +76,27 @@ public class AuthorizationController {
|
||||
return CzgResult.success(StpKit.USER.getPermissionList());
|
||||
}
|
||||
|
||||
@Resource
|
||||
RabbitPublisher rabbitPublisher;
|
||||
@Resource
|
||||
ShopTableService shopTableService;
|
||||
|
||||
@GetMapping("test")
|
||||
public CzgResult<?> login(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
// shopTableService.createQrCode(1L, 1, response, request);
|
||||
|
||||
|
||||
// rabbitPublisher.sendOrderPrintMsg("552");
|
||||
// printMqListener.orderPrint("1");
|
||||
// return CzgResult.success(Map.of("token", StpKit.USER.getShopId()));
|
||||
return CzgResult.success(StpKit.USER.getLoginId());
|
||||
}
|
||||
|
||||
@GetMapping("test1")
|
||||
public CzgResult<?> login1() throws IOException {
|
||||
authorizationService.switchTo(86L);
|
||||
return CzgResult.success(StpKit.USER.getLoginId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销获取 信息使用
|
||||
|
||||
@@ -4,18 +4,14 @@ import com.czg.account.dto.menu.MenuAddDTO;
|
||||
import com.czg.account.dto.menu.MenuDelDTO;
|
||||
import com.czg.account.dto.menu.MenuEditDTO;
|
||||
import com.czg.account.entity.CashMenu;
|
||||
import com.czg.account.entity.QuickMenu;
|
||||
import com.czg.account.entity.SysMenu;
|
||||
import com.czg.account.service.QuickMenuService;
|
||||
import com.czg.account.service.SysMenuService;
|
||||
import com.czg.account.vo.MenuVO;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.annotation.SaAdminCheckRole;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -23,7 +19,6 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单管理
|
||||
*
|
||||
* @author zs
|
||||
*/
|
||||
@RestController
|
||||
@@ -32,12 +27,9 @@ public class MenuController {
|
||||
|
||||
@Resource
|
||||
private SysMenuService menuService;
|
||||
@Resource
|
||||
private QuickMenuService quickMenuService;
|
||||
|
||||
/**
|
||||
* 获取当前用户菜单列表
|
||||
*
|
||||
* @return 菜单结构
|
||||
*/
|
||||
@GetMapping
|
||||
@@ -48,7 +40,6 @@ public class MenuController {
|
||||
|
||||
/**
|
||||
* 收银机菜单
|
||||
*
|
||||
* @return 所有菜单
|
||||
*/
|
||||
@GetMapping("/list/cash")
|
||||
@@ -58,7 +49,6 @@ public class MenuController {
|
||||
|
||||
/**
|
||||
* 获取所有菜单
|
||||
*
|
||||
* @return 菜单结构
|
||||
*/
|
||||
@SaAdminCheckPermission(parentName = "菜单管理", value = "menu:list", name = "菜单列表")
|
||||
@@ -72,7 +62,6 @@ public class MenuController {
|
||||
|
||||
/**
|
||||
* 菜单详情
|
||||
*
|
||||
* @return 菜单结构
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@@ -84,7 +73,6 @@ public class MenuController {
|
||||
|
||||
/**
|
||||
* 菜单添加
|
||||
*
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@@ -96,7 +84,6 @@ public class MenuController {
|
||||
|
||||
/**
|
||||
* 菜单修改
|
||||
*
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@@ -108,15 +95,12 @@ public class MenuController {
|
||||
|
||||
/**
|
||||
* 菜单删除
|
||||
*
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@SaAdminCheckPermission(parentName = "菜单管理", value = "menu:del", name = "菜单删除")
|
||||
@DeleteMapping()
|
||||
@Transactional
|
||||
public CzgResult<Boolean> edit(@RequestBody @Validated MenuDelDTO menuDelDTO) {
|
||||
quickMenuService.remove(QueryWrapper.create().eq(QuickMenu::getMenuId, menuDelDTO.getId()));
|
||||
return CzgResult.success(menuService.removeById(menuDelDTO.getId()));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.czg.account.entity.QuickMenu;
|
||||
import com.czg.account.service.QuickMenuService;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 悬浮窗/快捷菜单
|
||||
*
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/quick")
|
||||
@Slf4j
|
||||
public class QuickMenuController {
|
||||
|
||||
@Resource
|
||||
private QuickMenuService quickMenuService;
|
||||
|
||||
@SaAdminCheckPermission(parentName = "悬浮窗", value = "quick:list", name = "悬浮窗-列表")
|
||||
@GetMapping
|
||||
public CzgResult<List<QuickMenu>> getQuickList(@RequestParam(required = false) Integer status,
|
||||
@RequestParam(required = false, defaultValue = "0") Integer isEdit) {
|
||||
List<QuickMenu> list = quickMenuService.list(QueryWrapper.create()
|
||||
.eq(QuickMenu::getShopId, StpKit.USER.getShopId())
|
||||
.eq(QuickMenu::getStatus, status)
|
||||
.orderBy(QuickMenu::getSort, true));
|
||||
if (isEdit.equals(0)) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
list = quickMenuService.list(QueryWrapper.create()
|
||||
.eq(QuickMenu::getShopId, 1)
|
||||
.eq(QuickMenu::getStatus, status)
|
||||
.orderBy(QuickMenu::getSort, true));
|
||||
}
|
||||
}
|
||||
return CzgResult.success(list);
|
||||
}
|
||||
|
||||
@SaAdminCheckPermission(parentName = "悬浮窗", value = "quick:list", name = "悬浮窗-新增")
|
||||
@PostMapping
|
||||
public CzgResult<Boolean> saveQuick(@RequestBody @Validated QuickMenu quickMenu) {
|
||||
quickMenu.setShopId(StpKit.USER.getShopId());
|
||||
return CzgResult.success(quickMenuService.save(quickMenu));
|
||||
}
|
||||
|
||||
@SaAdminCheckPermission(parentName = "悬浮窗", value = "quick:list", name = "悬浮窗-修改")
|
||||
@PutMapping
|
||||
public CzgResult<Boolean> updateQuick(@RequestBody @Validated QuickMenu quickMenu) {
|
||||
return CzgResult.success(quickMenuService.update(quickMenu, QueryWrapper.create()
|
||||
.eq(QuickMenu::getId, quickMenu.getId()).eq(QuickMenu::getShopId, StpKit.USER.getShopId())));
|
||||
}
|
||||
|
||||
@SaAdminCheckPermission(parentName = "悬浮窗", value = "quick:list", name = "悬浮窗-删除")
|
||||
@DeleteMapping
|
||||
public CzgResult<Boolean> deleteQuick(@RequestBody Set<Long> ids) {
|
||||
return CzgResult.success(quickMenuService.remove(QueryWrapper.create().in(QuickMenu::getId, ids).eq(QuickMenu::getShopId, StpKit.USER.getShopId())));
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.dto.merchant.ShopMerchantEditDTO;
|
||||
import com.czg.account.entity.ShopMerchant;
|
||||
import com.czg.account.service.ShopMerchantService;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.annotation.SaAdminCheckRole;
|
||||
import com.czg.order.dto.ShopMerchantDTO;
|
||||
import com.czg.order.entity.ShopDirectMerchant;
|
||||
import com.czg.order.service.ShopMerchantService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 商户信息管理
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@@ -23,36 +24,25 @@ public class ShopMerchantController {
|
||||
/**
|
||||
* 商户支付信息获取
|
||||
* 权限标识: shopMerchant:detail
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @return 支付信息
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:detail", name = "商户支付信息获取")
|
||||
@GetMapping
|
||||
public CzgResult<ShopMerchantDTO> detail(@RequestParam Long shopId) {
|
||||
public CzgResult<ShopMerchant> detail(@RequestParam Integer shopId) {
|
||||
return CzgResult.success(shopMerchantService.detail(shopId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户支付信息修改
|
||||
* 权限标识: shopMerchant:edit
|
||||
*
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:edit", name = "商户支付信息修改")
|
||||
@PutMapping
|
||||
public CzgResult<Boolean> edit(@RequestBody ShopMerchantDTO shopMerchant) {
|
||||
return CzgResult.success(shopMerchantService.editEntry(shopMerchant, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前店铺的主店进件信息
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@GetMapping("getMainMerchant")
|
||||
public CzgResult<ShopDirectMerchant> getMainMerchant(Long shopId) {
|
||||
return CzgResult.success(shopMerchantService.getMainMerchant(shopId));
|
||||
public CzgResult<Boolean> edit(@RequestBody @Validated ShopMerchantEditDTO shopMerchantEditDTO) {
|
||||
return CzgResult.success(shopMerchantService.edit(shopMerchantEditDTO));
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.czg.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.constants.SystemConstants;
|
||||
import com.czg.exception.CzgException;
|
||||
@@ -12,11 +15,13 @@ import com.czg.market.service.MkDistributionUserService;
|
||||
import com.czg.market.service.OrderInfoService;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.service.market.enums.OrderStatusEnums;
|
||||
import com.czg.utils.FunUtils;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.czg.controller.pay;
|
||||
package com.czg.controller;
|
||||
|
||||
import com.czg.annotation.Debounce;
|
||||
import com.czg.order.dto.MkDistributionPayDTO;
|
||||
@@ -35,7 +35,7 @@ public class DistributionPayController {
|
||||
*/
|
||||
@PostMapping("/ltPayOrder")
|
||||
@Debounce(value = "#payParam.userId")
|
||||
public CzgResult<Map<String, Object>> ltPayOrder(HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
public CzgResult<Map<String, Object>> ltPayOrder( HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
return payService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
@@ -46,8 +46,8 @@ public class DistributionPayController {
|
||||
*/
|
||||
@PostMapping("/mchRecharge")
|
||||
@Debounce(value = "#payParam.userId")
|
||||
public CzgResult<Map<String, String>> mchRecharge(@Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
public CzgResult<Map<String, String>> mchRecharge(HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
AssertUtil.isBlank(payParam.getCode(), "微信code不为空");
|
||||
return CzgResult.success(payService.mchRecharge(payParam));
|
||||
return CzgResult.success(payService.mchRecharge(ServletUtil.getClientIP(request), payParam));
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,9 @@ package com.czg.controller;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.PolyPayUtils;
|
||||
import com.czg.constant.PayChannelCst;
|
||||
import com.czg.CzgPayUtils;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.dto.req.WechatNotifyReqDto;
|
||||
import com.czg.dto.req.WechatPayNotifyDataDto;
|
||||
import com.czg.entity.PolyBaseResp;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.entity.CzgBaseRespParams;
|
||||
import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
||||
import com.czg.market.service.MkDistributionUserService;
|
||||
import com.czg.market.service.MkShopConsumeDiscountRecordService;
|
||||
@@ -19,15 +14,16 @@ import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.service.OrderInfoCustomService;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.pay.PayNotifyRespDTO;
|
||||
import com.czg.service.market.service.impl.AppWxServiceImpl;
|
||||
import com.czg.third.wechat.WechatReqUtils;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -63,57 +59,13 @@ public class NotifyController {
|
||||
return "success";
|
||||
}
|
||||
|
||||
/**
|
||||
* 原生支付回调
|
||||
*/
|
||||
@RequestMapping("/native/pay/{platform}")
|
||||
public String pay(@PathVariable String platform, @RequestBody JSONObject json) {
|
||||
if (PayCst.Platform.WECHAT.equalsIgnoreCase(platform)) {
|
||||
// 微信
|
||||
WechatNotifyReqDto reqDto = JSONObject.parseObject(json.toJSONString(), WechatNotifyReqDto.class);
|
||||
log.info("【微信支付回调】收到微信支付回调 data: {}", JSONObject.toJSONString(reqDto));
|
||||
|
||||
String decrypted = WechatReqUtils.decryptRespParam(null, reqDto);
|
||||
log.info("【微信支付回调】解密数据 {}", decrypted);
|
||||
|
||||
WechatPayNotifyDataDto dataDto = JSONObject.parseObject(decrypted, WechatPayNotifyDataDto.class);
|
||||
PayNotifyRespDTO respDTO = dataDto.convertToPayNotifyRespDTO();
|
||||
orderInfoCustomService.payCallBackOrder(respDTO.getMchOrderNo(), respDTO, PayChannelCst.NATIVE, 0);
|
||||
return "success";
|
||||
} else if (PayCst.Platform.ALIPAY.equalsIgnoreCase(platform)) {
|
||||
// 支付宝
|
||||
return "success";
|
||||
}
|
||||
throw new CzgException("不支持的支付平台");
|
||||
}
|
||||
|
||||
/**
|
||||
* 原生退款回调
|
||||
*/
|
||||
@RequestMapping("/native/refund/{platform}")
|
||||
public String refund(@PathVariable String platform, @RequestBody JSONObject json) {
|
||||
if (PayCst.Platform.WECHAT.equalsIgnoreCase(platform)) {
|
||||
// 微信
|
||||
WechatNotifyReqDto reqDto = JSONObject.parseObject(json.toJSONString(), WechatNotifyReqDto.class);
|
||||
log.info("【微信退款回调】收到微信退款回调 data: {}", JSONObject.toJSONString(reqDto));
|
||||
String decrypted = WechatReqUtils.decryptRespParam(null, reqDto);
|
||||
log.info("【微信退款回调】解密数据 {}", decrypted);
|
||||
|
||||
return "success";
|
||||
} else if (PayCst.Platform.ALIPAY.equalsIgnoreCase(platform)) {
|
||||
// 支付宝
|
||||
return "success";
|
||||
}
|
||||
throw new CzgException("不支持的支付平台");
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/payCallBack")
|
||||
public String notifyCallBack(@RequestBody PolyBaseResp respParams) {
|
||||
PayNotifyRespDTO respDTO = PolyPayUtils.getNotifyResp(respParams);
|
||||
AssertUtil.isNull(respDTO, "支付回调数据为空");
|
||||
log.info("支付回调数据为:{}", respDTO);
|
||||
orderInfoCustomService.payCallBackOrder(respDTO.getMchOrderNo(), respDTO, PayChannelCst.POLY, 0);
|
||||
public String notifyCallBack(@RequestBody CzgBaseRespParams respParams) {
|
||||
JSONObject czg = CzgPayUtils.getCzg(respParams);
|
||||
AssertUtil.isNull(czg, "支付回调数据为空");
|
||||
log.info("支付回调数据为:{}", czg);
|
||||
orderInfoCustomService.payCallBackOrder(czg.getString("mchOrderNo"), czg, 0);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -135,15 +87,12 @@ public class NotifyController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 微信原生支付回调
|
||||
*/
|
||||
@RequestMapping("/native/wx/pay/distributionRecharge")
|
||||
public String nativeNotify(HttpServletRequest request) throws IOException {
|
||||
// String timestamp = request.getHeader("Wechatpay-Timestamp");
|
||||
// String nonce = request.getHeader("Wechatpay-Nonce");
|
||||
// String serialNo = request.getHeader("Wechatpay-Serial");
|
||||
// String signature = request.getHeader("Wechatpay-Signature");
|
||||
String timestamp = request.getHeader("Wechatpay-Timestamp");
|
||||
String nonce = request.getHeader("Wechatpay-Nonce");
|
||||
String serialNo = request.getHeader("Wechatpay-Serial");
|
||||
String signature = request.getHeader("Wechatpay-Signature");
|
||||
String result = IoUtil.readUtf8(request.getInputStream());
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
JSONObject resource = jsonObject.getJSONObject("resource");
|
||||
@@ -178,8 +127,8 @@ public class NotifyController {
|
||||
|
||||
|
||||
@RequestMapping("/refundCallBack")
|
||||
public String refundCallBack(@RequestBody PolyBaseResp respParams) {
|
||||
JSONObject czg = PolyPayUtils.getCzg(respParams);
|
||||
public String refundCallBack(@RequestBody CzgBaseRespParams respParams) {
|
||||
JSONObject czg = CzgPayUtils.getCzg(respParams);
|
||||
AssertUtil.isNull(czg, "退款回调数据为空");
|
||||
log.info("退款回调数据为:{}", czg);
|
||||
orderInfoCustomService.refundCallBackOrder(czg.getString("mchOrderNo"), czg);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.czg.controller.pay;
|
||||
package com.czg.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
@@ -10,7 +10,7 @@ import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.service.OrderInfoCustomService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||
import com.czg.service.order.service.OrderPayService;
|
||||
import com.czg.service.order.service.PayService;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.ServletUtil;
|
||||
@@ -35,7 +35,7 @@ import java.util.Map;
|
||||
@RequestMapping("/pay")
|
||||
public class OrderPayController {
|
||||
@Resource
|
||||
private OrderPayService orderPayService;
|
||||
private PayService payService;
|
||||
@Resource
|
||||
private OrderInfoCustomService orderInfoCustomService;
|
||||
@Resource
|
||||
@@ -47,14 +47,14 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Object> creditPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return orderPayService.creditPayOrder(payParam);
|
||||
return payService.creditPayOrder(payParam);
|
||||
}
|
||||
|
||||
@PostMapping("/cashPay")
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Object> cashPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return orderPayService.cashPayOrder(payParam);
|
||||
return payService.cashPayOrder(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> rechargePayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return orderPayService.rechargePayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return payService.rechargePayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ public class OrderPayController {
|
||||
public CzgResult<Object> vipPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付类型不可为空");
|
||||
return orderPayService.vipPayOrder(payParam);
|
||||
return payService.vipPayOrder(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +93,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> h5PayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return orderPayService.h5PayOrder(ServletUtil.getClientIP(request, ""), payParam);
|
||||
return payService.h5PayOrder(ServletUtil.getClientIP(request, ""), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> jsPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return orderPayService.jsPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return payService.jsPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +118,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> ltPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return orderPayService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return payService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> scanPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return orderPayService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return payService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> microPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return orderPayService.microPayOrder(payParam);
|
||||
return payService.microPayOrder(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ public class OrderPayController {
|
||||
@PostMapping("/shopPayApi/js2Pay")
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> js2PayOrder(HttpServletRequest request, @RequestBody OrderPayParamDTO payParam) {
|
||||
return orderPayService.js2PayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return payService.js2PayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1,18 +1,14 @@
|
||||
package com.czg.controller.pay;
|
||||
package com.czg.controller;
|
||||
|
||||
import com.czg.annotation.Debounce;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.pay.QueryOrderRespDTO;
|
||||
import com.czg.entity.resp.CzgBaseResp;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.order.dto.VipMemberPayParamDTO;
|
||||
import com.czg.service.order.dto.VipPayParamDTO;
|
||||
import com.czg.service.order.dto.VipRefundDTO;
|
||||
import com.czg.service.order.service.PayService;
|
||||
import com.czg.service.order.service.ShopUserPayService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.ServletUtil;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -32,11 +28,6 @@ import java.util.Map;
|
||||
public class VipPayController {
|
||||
@Resource
|
||||
private PayService payService;
|
||||
@Resource
|
||||
private ShopUserPayService shopUserPayService;
|
||||
|
||||
@Resource
|
||||
private OrderPaymentService paymentService;
|
||||
|
||||
/**
|
||||
* 现金充值
|
||||
@@ -48,7 +39,7 @@ public class VipPayController {
|
||||
public CzgResult<Object> cashPayVip(@Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return shopUserPayService.cashPayVip(payParam);
|
||||
return payService.cashPayVip(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +52,7 @@ public class VipPayController {
|
||||
public CzgResult<Map<String, Object>> jsPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return shopUserPayService.jsPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
return payService.jsPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,11 +65,14 @@ public class VipPayController {
|
||||
public CzgResult<Map<String, Object>> ltPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return shopUserPayService.ltPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
return payService.ltPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 智慧充值
|
||||
* @param request
|
||||
* @param rechargeDTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/recharge")
|
||||
@Debounce(value = "#rechargeDTO.shopUserId")
|
||||
@@ -87,18 +81,21 @@ public class VipPayController {
|
||||
return CzgResult.failure("充值失败 未指定充值金额");
|
||||
}
|
||||
rechargeDTO.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return shopUserPayService.recharge(ServletUtil.getClientIP(request), rechargeDTO, rechargeDTO.getShopUserId());
|
||||
return payService.recharge(ServletUtil.getClientIP(request), rechargeDTO, rechargeDTO.getShopUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员购买支付
|
||||
* @param request
|
||||
* @param payParam
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/ltPayMember")
|
||||
@Debounce(value = "#payParam.shopUserId")
|
||||
public CzgResult<Map<String, Object>> ltPayMember(HttpServletRequest request, @Validated @RequestBody VipMemberPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "购买失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return shopUserPayService.ltPayMember(ServletUtil.getClientIP(request), payParam);
|
||||
return payService.ltPayMember(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +108,7 @@ public class VipPayController {
|
||||
public CzgResult<Map<String, Object>> scanPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(request, "platformType"));
|
||||
return shopUserPayService.scanPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
return payService.scanPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +121,7 @@ public class VipPayController {
|
||||
public CzgResult<Map<String, Object>> microPayVip(@Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return shopUserPayService.microPayVip(payParam);
|
||||
return payService.microPayVip(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +132,7 @@ public class VipPayController {
|
||||
@PostMapping("/refundVipBefore")
|
||||
@Debounce(value = "#payParam.flowId")
|
||||
public CzgResult<Map<String, BigDecimal>> refundVipBefore(@Validated @RequestBody VipRefundDTO payParam) {
|
||||
return shopUserPayService.refundVipBefore(payParam);
|
||||
return payService.refundVipBefore(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +155,7 @@ public class VipPayController {
|
||||
return CzgResult.failure("退款金额过大");
|
||||
}
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(request, "platformType"));
|
||||
return shopUserPayService.refundVip(payParam);
|
||||
return payService.refundVip(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,16 +165,10 @@ public class VipPayController {
|
||||
public CzgResult<String> queryOrderStatus(Long shopId, String payOrderNo) {
|
||||
AssertUtil.isNull(shopId, "店铺id不能为空");
|
||||
AssertUtil.isBlank(payOrderNo, "支付单号不能为空");
|
||||
|
||||
OrderPayment payment = paymentService.getOne(QueryWrapper.create().eq(OrderPayment::getOrderNo, payOrderNo));
|
||||
if (payment == null) {
|
||||
return CzgResult.failure("支付单号不存在");
|
||||
}
|
||||
|
||||
CzgResult<String> result = CzgResult.success();
|
||||
CzgResult<QueryOrderRespDTO> queryPayOrder = payService.queryPayOrder(shopId, null, payOrderNo, payment.getPlatformType());
|
||||
if (queryPayOrder.isSuccess() && queryPayOrder.getData() != null) {
|
||||
String state = queryPayOrder.getData().getStatus();
|
||||
CzgResult<CzgBaseResp> queryPayOrder = payService.queryPayOrder(shopId, null, payOrderNo);
|
||||
if (queryPayOrder.getCode() == 200 && queryPayOrder.getData() != null) {
|
||||
String state = queryPayOrder.getData().getState();
|
||||
result.setData(state);
|
||||
switch (state) {
|
||||
case "TRADE_AWAIT" -> result.setMsg("等待用户付款");
|
||||
@@ -9,7 +9,7 @@ import com.czg.order.vo.HistoryOrderVo;
|
||||
import com.czg.order.vo.OrderInfoVo;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.order.service.OrderPayService;
|
||||
import com.czg.service.order.service.PayService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.ServletUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
@@ -31,7 +31,7 @@ public class AdminOrderController {
|
||||
@Resource
|
||||
private OrderInfoCustomService orderInfoService;
|
||||
@Resource
|
||||
private OrderPayService orderPayService;
|
||||
private PayService payService;
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
@@ -94,7 +94,7 @@ public class AdminOrderController {
|
||||
@PostMapping("/refundOrder")
|
||||
@Debounce(value = "#refundDTO.orderId")
|
||||
public CzgResult<Object> refundOrder(@Validated @RequestBody OrderInfoRefundDTO refundDTO) {
|
||||
return orderPayService.refundOrderBefore(refundDTO);
|
||||
return payService.refundOrderBefore(refundDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.EntryManager;
|
||||
import com.czg.annotation.Debounce;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.dto.req.AggregateMerchantDto;
|
||||
import com.czg.dto.resp.WechatBankBranchRespDto;
|
||||
import com.czg.order.entity.ShopDirectMerchant;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.order.dto.AggregateMerchantVO;
|
||||
import com.czg.service.order.dto.MerchantQueryDTO;
|
||||
import com.czg.service.order.service.ShopDirectMerchantService;
|
||||
import com.czg.task.EntryManagerTask;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 进件管理
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/admin/data/entryManager")
|
||||
public class EntryManagerController {
|
||||
|
||||
@Resource
|
||||
private ShopDirectMerchantService shopDirectMerchantService;
|
||||
@Resource
|
||||
private EntryManagerTask entryManagerTask;
|
||||
|
||||
@Resource
|
||||
private RabbitPublisher rabbitPublisher;
|
||||
|
||||
/**
|
||||
* ocr识别填充
|
||||
* 阿里 ocr识别图片
|
||||
* 本接口支持:PNG、JPG、JPEG、BMP、GIF、TIFF、WebP、PDF。
|
||||
* 图片长宽需要大于 15 像素,小于 8192 像素。
|
||||
* 长宽比需要小于 50。长宽均大于 500px。
|
||||
* 图片二进制文件不能超过 10MB。
|
||||
* 图片过大会影响接口响应速度,建议使用小于 1.5M 图片进行识别,
|
||||
*
|
||||
* @param url 图片地址
|
||||
* @param type IdCard 身份证
|
||||
* BankCard 银行卡
|
||||
* BusinessLicense 营业执照
|
||||
*/
|
||||
@GetMapping("getInfoByImg")
|
||||
public CzgResult<JSONObject> getInfoByImg(String url, String type) throws Exception {
|
||||
return CzgResult.success(shopDirectMerchantService.getInfoByImg(url, type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询银行支行列表
|
||||
*
|
||||
* @param bankAliceCode 银行别名code bankAliasCode 从 /system/admin/common/bankInfo 获取
|
||||
* @param cityCode 市编码 wxProvinceCode 从 /system/admin/common/region 获取
|
||||
*/
|
||||
@GetMapping("bankBranchList")
|
||||
public CzgResult<WechatBankBranchRespDto> queryBankBranchList(String bankAliceCode, String cityCode) {
|
||||
AssertUtil.isBlank(bankAliceCode, "请选择银行别名");
|
||||
AssertUtil.isBlank(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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取进件列表
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public CzgResult<Page<ShopDirectMerchant>> getEntryList(MerchantQueryDTO queryParam) {
|
||||
return CzgResult.success(shopDirectMerchantService.getEntryList(queryParam));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取进件信息
|
||||
*/
|
||||
@GetMapping
|
||||
public CzgResult<AggregateMerchantVO> getEntry(Long shopId, String licenceNo) {
|
||||
return CzgResult.success(shopDirectMerchantService.getEntry(shopId, licenceNo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 主动查询进件信息状态
|
||||
* 进件状态是INIT 待处理 AUDIT 审核中 SIGN 待签约
|
||||
* 3分钟内只能查一次
|
||||
*/
|
||||
@GetMapping("queryEntry")
|
||||
@Debounce(value = "#shopId", interval = 1000 * 60 * 3)
|
||||
public CzgResult<Boolean> queryEntry(Long shopId, String licenceNo) {
|
||||
entryManagerTask.entryManager(shopId, licenceNo);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请进件
|
||||
*/
|
||||
@Debounce(value = "#reqDto.shopId")
|
||||
@PostMapping
|
||||
public CzgResult<Boolean> entryManager(@RequestBody AggregateMerchantDto reqDto) {
|
||||
return CzgResult.success(shopDirectMerchantService.entryManager(reqDto));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
package com.czg.mq;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.EntryManager;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.config.RabbitConstants;
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.dto.resp.EntryRespDto;
|
||||
import com.czg.order.entity.ShopDirectMerchant;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.service.order.dto.AggregateMerchantVO;
|
||||
import com.czg.service.order.service.ShopDirectMerchantService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.logging.log4j.ThreadContext;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.annotation.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 打印mq消息处理器
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class EntryManagerMqListener {
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
@Resource
|
||||
private ShopDirectMerchantService shopDirectMerchantService;
|
||||
|
||||
String key = RedisCst.SHOP_ENTRY;
|
||||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue(value = "${spring.profiles.active}-" + RabbitConstants.Queue.SHOP_ENTRY_MANAGER,
|
||||
durable = "true", exclusive = "false", autoDelete = "false"),
|
||||
exchange = @Exchange(value = "${spring.profiles.active}-" + RabbitConstants.Exchange.CASH_EXCHANGE),
|
||||
key = "${spring.profiles.active}-" + RabbitConstants.Queue.SHOP_ENTRY_MANAGER
|
||||
),
|
||||
concurrency = "5"
|
||||
)
|
||||
@RabbitHandler
|
||||
public void handle(Message message, Channel channel, String msg) throws IOException {
|
||||
log.info("进件1MQ对接开始 店铺标识:{}", msg);
|
||||
long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||
if (StrUtil.isBlank(msg)) {
|
||||
channel.basicNack(deliveryTag, false, false);
|
||||
return;
|
||||
}
|
||||
String[] split = msg.split(":");
|
||||
if (split.length != 2) {
|
||||
log.error("进件MQ对接参数异常 店铺标识:{}", msg);
|
||||
channel.basicNack(deliveryTag, false, false);
|
||||
return;
|
||||
}
|
||||
Long shopId = Long.valueOf(split[0]);
|
||||
if (shopId == null) {
|
||||
channel.basicNack(deliveryTag, false, false);
|
||||
return;
|
||||
}
|
||||
if (hasMessageId(msg)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// 将唯一标识添加到日志上下文
|
||||
ThreadContext.put("traceId", String.valueOf(shopId));
|
||||
log.info("进件2MQ对接开始shopId:{}", msg);
|
||||
// 安全转换shopId
|
||||
AggregateMerchantVO entry = shopDirectMerchantService.getEntry(shopId, split[1]);
|
||||
log.info("进件3MQ对接开始shopId:{}", msg);
|
||||
if (entry != null) {
|
||||
EntryManager.uploadParamImage(entry);
|
||||
List<String> platform = new ArrayList<>();
|
||||
if (PayCst.EntryStatus.WAIT.equals(entry.getAlipayStatus())) {
|
||||
platform.add(PayCst.Platform.ALIPAY);
|
||||
}
|
||||
if (PayCst.EntryStatus.WAIT.equals(entry.getWechatStatus())) {
|
||||
platform.add(PayCst.Platform.WECHAT);
|
||||
}
|
||||
EntryRespDto resp = EntryManager.entryMerchant(entry, platform.toArray(new String[0]));
|
||||
ShopDirectMerchant merchant = new ShopDirectMerchant();
|
||||
merchant.setMerchantBaseInfo(JSONObject.toJSONString(entry.getMerchantBaseInfo()));
|
||||
merchant.setLegalPersonInfo(JSONObject.toJSONString(entry.getLegalPersonInfo()));
|
||||
merchant.setBusinessLicenceInfo(JSONObject.toJSONString(entry.getBusinessLicenceInfo()));
|
||||
merchant.setStoreInfo(JSONObject.toJSONString(entry.getStoreInfo()));
|
||||
merchant.setSettlementInfo(JSONObject.toJSONString(entry.getSettlementInfo()));
|
||||
|
||||
|
||||
merchant.setWechatApplyId(resp.getWechatApplyId());
|
||||
merchant.setWechatStatus(resp.getWechatStatus());
|
||||
merchant.setWechatErrorMsg(resp.getWechatErrorMsg());
|
||||
merchant.setAlipayOrderId(resp.getAlipayOrderId());
|
||||
merchant.setAlipayStatus(resp.getAlipayStatus());
|
||||
merchant.setAlipayAuthInfo(resp.getAlipayAuthInfo());
|
||||
merchant.setAlipayErrorMsg(resp.getAlipayErrorMsg());
|
||||
shopDirectMerchantService.update(merchant, new QueryWrapper().eq(ShopDirectMerchant::getShopId, shopId).eq(ShopDirectMerchant::getLicenceNo, split[1]));
|
||||
}
|
||||
channel.basicAck(deliveryTag, false);
|
||||
} catch (Exception e) {
|
||||
log.error("进件MQ对接业务异常shopId:{}", msg, e);
|
||||
ShopDirectMerchant merchant = new ShopDirectMerchant();
|
||||
merchant.setWechatStatus(PayCst.EntryStatus.REJECTED);
|
||||
merchant.setAlipayStatus(PayCst.EntryStatus.REJECTED);
|
||||
merchant.setErrorMsg("系统错误,请联系管理员后重试。");
|
||||
shopDirectMerchantService.update(merchant, new QueryWrapper().eq(ShopDirectMerchant::getShopId, shopId).eq(ShopDirectMerchant::getLicenceNo, split[1]));
|
||||
channel.basicNack(deliveryTag, false, false);
|
||||
} finally {
|
||||
delMessageId(msg);
|
||||
// 清除日志上下文信息
|
||||
ThreadContext.remove("messageId");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasMessageId(String messageId) {
|
||||
if (!redisService.hasKey(key)) {
|
||||
if (StrUtil.isNotBlank(messageId)) {
|
||||
redisService.leftPush(key, messageId);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
List<Object> list = redisService.lGet(key, 0, -1);
|
||||
if (!list.contains(messageId)) {
|
||||
redisService.leftPush(key, messageId);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void delMessageId(String messageId) {
|
||||
redisService.lRemove(key, 0, messageId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import com.czg.order.entity.MqLog;
|
||||
import com.czg.order.service.MqLogService;
|
||||
import com.czg.order.service.OrderInfoCustomService;
|
||||
import com.czg.order.service.OrderInfoRpcService;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.service.order.utils.FunUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
@@ -31,7 +31,7 @@ public class OrderMqListener {
|
||||
@Resource
|
||||
private OrderInfoCustomService orderInfoCustomService;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
private FunUtil funUtil;
|
||||
|
||||
/**
|
||||
* 订单上菜
|
||||
@@ -44,10 +44,13 @@ public class OrderMqListener {
|
||||
info = info.replace("UP_ORDER_DETAIL:", "");
|
||||
log.info("接收到修改菜品状态mq, info: {}", info);
|
||||
String finalInfo = info;
|
||||
redisService.debounce("UP_ORDER_DETAIL:" + info, 5, () -> {
|
||||
funUtil.debounce("UP_ORDER_DETAIL:" + info, 5, () -> {
|
||||
orderInfoCustomService.updateOrderDetailStatus(Long.valueOf(finalInfo));
|
||||
|
||||
});
|
||||
info = info.replace("UP_ORDER_DETAIL:", "");
|
||||
System.out.println(info);
|
||||
|
||||
}
|
||||
|
||||
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_STOCK_QUEUE})
|
||||
|
||||
@@ -6,12 +6,13 @@ import com.czg.config.RabbitConstants;
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.order.entity.MqLog;
|
||||
import com.czg.order.service.MqLogService;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.service.order.print.PrinterHandler;
|
||||
import com.czg.service.order.utils.FunUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
@@ -27,15 +28,19 @@ public class PrintMqListener {
|
||||
@Resource
|
||||
private MqLogService mqLogService;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
private FunUtil funUtil;
|
||||
|
||||
// 注入自定义线程池(建议单独配置,避免使用默认线程池)
|
||||
@Resource
|
||||
private ThreadPoolTaskExecutor asyncExecutor;
|
||||
@Lazy
|
||||
@Resource
|
||||
private PrinterHandler printerHandler;
|
||||
|
||||
private <T> void invokeFun(String queue, String type, String plat, T data, Consumer<T> consumer) {
|
||||
private <T> void invokeFun(String type, String plat, T data, Consumer<T> consumer) {
|
||||
long startTime = DateUtil.date().getTime();
|
||||
log.info("接收到{}打印消息:{}", type, data);
|
||||
MqLog mqLog = new MqLog().setQueue(queue).setMsg(data.toString())
|
||||
MqLog mqLog = new MqLog().setQueue(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE).setMsg(data.toString())
|
||||
.setType(type).setPlat(plat).setCreateTime(DateUtil.date().toLocalDateTime());
|
||||
try {
|
||||
consumer.accept(data);
|
||||
@@ -51,18 +56,45 @@ public class PrintMqListener {
|
||||
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE})
|
||||
public void orderPrint(String req) {
|
||||
// 执行核心打印逻辑
|
||||
invokeFun(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, "orderPrint", "java.order", req, (data) -> {
|
||||
invokeFun("orderPrint", "java.order", req, (data) -> {
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
String orderId = jsonObject.getString("orderId");
|
||||
if (orderId == null) {
|
||||
throw new RuntimeException("订单打印失败,未传递orderId");
|
||||
}
|
||||
Boolean printOrder = jsonObject.getBoolean("printOrder");
|
||||
redisService.runFunAndCheckKey(() -> {
|
||||
funUtil.runFunAndCheckKey(() -> {
|
||||
printerHandler.handler(orderId, printOrder != null && !printOrder ? PrinterHandler.PrintTypeEnum.ONE : PrinterHandler.PrintTypeEnum.ONE_AND_ORDER);
|
||||
return null;
|
||||
}, RedisCst.getLockKey("orderPrint", orderId));
|
||||
});
|
||||
// // 使用异步线程池执行延迟任务,不阻塞当前消费者线程
|
||||
// CompletableFuture.runAsync(() -> {
|
||||
// try {
|
||||
// // 延迟3秒处理
|
||||
// TimeUnit.SECONDS.sleep(3);
|
||||
// // 执行核心打印逻辑
|
||||
// invokeFun("orderPrint", "java.order", req, (data) -> {
|
||||
// JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
// String orderId = jsonObject.getString("orderId");
|
||||
// if (orderId == null) {
|
||||
// throw new RuntimeException("订单打印失败,未传递orderId");
|
||||
// }
|
||||
// Boolean printOrder = jsonObject.getBoolean("printOrder");
|
||||
// funUtil.runFunAndCheckKey(() -> {
|
||||
// printerHandler.handler(orderId, printOrder != null && !printOrder ? PrinterHandler.PrintTypeEnum.ONE : PrinterHandler.PrintTypeEnum.ONE_AND_ORDER);
|
||||
// return null;
|
||||
// }, RedisCst.getLockKey("orderPrint", orderId));
|
||||
// });
|
||||
// } catch (InterruptedException e) {
|
||||
// Thread.currentThread().interrupt();
|
||||
// // 记录中断日志
|
||||
// log.warn("打印任务被中断,req:{}", req, e);
|
||||
// } catch (Exception e) {
|
||||
// // 记录业务异常日志
|
||||
// log.error("打印任务处理失败,req:{}", req, e);
|
||||
// }
|
||||
// }, asyncExecutor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,16 +102,14 @@ public class PrintMqListener {
|
||||
*/
|
||||
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE})
|
||||
public void handoverPrint(String id) {
|
||||
invokeFun(RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE, "handoverPrint", "java.order", id, (data) ->
|
||||
printerHandler.handler(data, PrinterHandler.PrintTypeEnum.HANDOVER));
|
||||
invokeFun("handoverPrint", "java.order", id, (data) -> printerHandler.handler(data, PrinterHandler.PrintTypeEnum.HANDOVER));
|
||||
}
|
||||
|
||||
/**
|
||||
* 叫号打印
|
||||
* 交班打印
|
||||
*/
|
||||
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.CALL_TABLE_QUEUE})
|
||||
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.CALL_TABLE_PRINT_QUEUE})
|
||||
public void callTablePrint(String id) {
|
||||
invokeFun(RabbitConstants.Queue.CALL_TABLE_QUEUE, "callTable", "java.order", id, (data) ->
|
||||
printerHandler.handler(data, PrinterHandler.PrintTypeEnum.CALL));
|
||||
invokeFun("handoverPrint", "java.order", id, (data) -> printerHandler.handler(data, PrinterHandler.PrintTypeEnum.CALL));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
package com.czg.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.EntryManager;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.constant.PayChannelCst;
|
||||
import com.czg.dto.resp.QueryStatusResp;
|
||||
import com.czg.order.dto.ShopMerchantDTO;
|
||||
import com.czg.order.entity.ShopDirectMerchant;
|
||||
import com.czg.order.service.ShopMerchantService;
|
||||
import com.czg.pay.AlipayAuthInfoDto;
|
||||
import com.czg.pay.NativeMerchantDTO;
|
||||
import com.czg.service.order.service.ShopDirectMerchantService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 进件查询
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class EntryManagerTask {
|
||||
@Resource
|
||||
private ShopDirectMerchantService shopDirectMerchantService;
|
||||
@Resource
|
||||
private ShopMerchantService shopMerchantService;
|
||||
|
||||
//每10分钟查一次
|
||||
@Scheduled(cron = "0 0/10 * * * ? ")
|
||||
public void run() {
|
||||
log.info("进件查询,定时任务执行");
|
||||
long start = System.currentTimeMillis();
|
||||
entryManager(null, null);
|
||||
log.info("进件查询,定时任务执行完毕,耗时:{}ms", start - System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询状态为待处理、待签约、待审核的进件
|
||||
*/
|
||||
public void entryManager(Long shopId, String licenceNo) {
|
||||
List<ShopDirectMerchant> list = shopDirectMerchantService.list(QueryWrapper.create()
|
||||
.eq(ShopDirectMerchant::getShopId, shopId)
|
||||
.eq(ShopDirectMerchant::getLicenceNo, licenceNo)
|
||||
.in(ShopDirectMerchant::getWechatStatus, PayCst.EntryStatus.NEED_QUERY_LIST)
|
||||
.or(ShopDirectMerchant::getAlipayStatus).in(PayCst.EntryStatus.NEED_QUERY_LIST));
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
for (ShopDirectMerchant shopDirectMerchant : list) {
|
||||
String wechatMerchantId = "";
|
||||
String alipayMerchantId = "";
|
||||
if (PayCst.EntryStatus.NEED_QUERY_LIST.contains(shopDirectMerchant.getWechatStatus()) && StrUtil.isNotBlank(shopDirectMerchant.getWechatApplyId())) {
|
||||
QueryStatusResp wechatStatus = EntryManager.queryWechatEntryStatus(shopDirectMerchant.getWechatApplyId());
|
||||
shopDirectMerchant.setWechatStatus(wechatStatus.getStatus());
|
||||
shopDirectMerchant.setWechatErrorMsg(wechatStatus.getFailReason());
|
||||
shopDirectMerchant.setWechatSignUrl("");
|
||||
shopDirectMerchant.setWechatMerchantId(wechatStatus.getThirdMerchantId());
|
||||
if (PayCst.EntryStatus.FINISH.equals(wechatStatus.getStatus())) {
|
||||
wechatMerchantId = wechatStatus.getThirdMerchantId();
|
||||
}
|
||||
}
|
||||
if (PayCst.EntryStatus.NEED_QUERY_LIST.contains(shopDirectMerchant.getAlipayStatus()) && StrUtil.isNotBlank(shopDirectMerchant.getAlipayOrderId())) {
|
||||
QueryStatusResp alipayStatus = EntryManager.queryAlipayEntryStatus(shopDirectMerchant.getAlipayOrderId());
|
||||
shopDirectMerchant.setAlipayStatus(alipayStatus.getStatus());
|
||||
shopDirectMerchant.setAlipayErrorMsg(alipayStatus.getFailReason());
|
||||
shopDirectMerchant.setAlipaySignUrl("");
|
||||
shopDirectMerchant.setAlipayMerchantId(alipayStatus.getThirdMerchantId());
|
||||
if (PayCst.EntryStatus.FINISH.equals(alipayStatus.getStatus())) {
|
||||
alipayMerchantId = alipayStatus.getThirdMerchantId();
|
||||
}
|
||||
}
|
||||
shopDirectMerchantService.updateById(shopDirectMerchant);
|
||||
if (StrUtil.isNotBlank(wechatMerchantId) || StrUtil.isNotBlank(alipayMerchantId)) {
|
||||
ShopMerchantDTO shopMerchantDTO = new ShopMerchantDTO();
|
||||
shopMerchantDTO.setShopId(shopId);
|
||||
shopMerchantDTO.setChannel(PayChannelCst.NATIVE);
|
||||
shopMerchantDTO.setRelatedLicenceNo(licenceNo);
|
||||
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(licenceNo, nativeMerchantDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单过期处理
|
||||
* 退款失败 补偿
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
|
||||
@@ -25,23 +25,7 @@ spring:
|
||||
port: 5672
|
||||
username: chaozg
|
||||
password: chaozg123
|
||||
# 关键优化:解决MissedHeartbeatException 心跳超时问题
|
||||
connection-timeout: 10000 # 连接超时时间(10秒,避免连接建立过慢)
|
||||
requested-heartbeat: 30 # 心跳间隔调整为30秒(原60秒过长,降低超时概率;过短易误触发)
|
||||
# 自动重连配置(Spring AMQP 自带,关键兜底)
|
||||
publisher-returns: true
|
||||
template:
|
||||
retry:
|
||||
enabled: true # 开启消息发送重试
|
||||
max-attempts: 3 # 最大重试次数
|
||||
initial-interval: 3000 # 首次重试间隔2秒
|
||||
multiplier: 1.5 # 重试间隔倍增因子
|
||||
listener:
|
||||
simple:
|
||||
retry:
|
||||
enabled: true # 开启消费者重试
|
||||
max-attempts: 3 # 消费者最大重试次数
|
||||
acknowledge-mode: auto # 确认模式(可根据业务改为manual)
|
||||
|
||||
dubbo:
|
||||
application:
|
||||
name: order-server
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.BaseQueryParam;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.system.entity.SysBankInfo;
|
||||
import com.czg.system.entity.SysRegion;
|
||||
import com.czg.system.service.SysBankInfoService;
|
||||
import com.czg.system.service.SysCategoryInfoService;
|
||||
import com.czg.system.service.SysRegionService;
|
||||
import com.czg.system.vo.SysCategoryInfoVO;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通用
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/common")
|
||||
public class SysCommonController {
|
||||
@Resource
|
||||
private SysRegionService sysRegionService;
|
||||
@Resource
|
||||
private SysBankInfoService bankInfoService;
|
||||
@Resource
|
||||
private SysCategoryInfoService categoryInfoService;
|
||||
|
||||
/**
|
||||
* 获取所有地域
|
||||
*/
|
||||
@GetMapping("/region")
|
||||
public CzgResult<List<SysRegion>> region() {
|
||||
return CzgResult.success(sysRegionService.regionList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取银行信息
|
||||
*/
|
||||
@GetMapping("/bankInfo")
|
||||
public CzgResult<Page<SysBankInfo>> bankInfo(BaseQueryParam param, @RequestParam String bankName) {
|
||||
return CzgResult.success(bankInfoService.bankInfoList(param, bankName));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 类目信息表
|
||||
*/
|
||||
@GetMapping("/category")
|
||||
public CzgResult<List<SysCategoryInfoVO>> category() {
|
||||
return CzgResult.success(categoryInfoService.categoryList());
|
||||
}
|
||||
}
|
||||
@@ -50,8 +50,9 @@ public class FastJson2Config implements WebMvcConfigurer {
|
||||
// 设置支持的媒体类型
|
||||
List<MediaType> supportedMediaTypes = new ArrayList<>();
|
||||
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
|
||||
supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
|
||||
converter.setSupportedMediaTypes(supportedMediaTypes);
|
||||
// 将转换器添加到 Spring MVC 的消息转换器列表中
|
||||
converters.addFirst(converter);
|
||||
converters.add(0, converter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class FilteredNacosRegistry extends NacosRegistry {
|
||||
public void register(URL url) {
|
||||
// 1. 获取原始注册的方法列表
|
||||
String originalMethods = url.getParameter("methods");
|
||||
// log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), originalMethods);
|
||||
log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), originalMethods);
|
||||
if (originalMethods != null && !originalMethods.isEmpty()) {
|
||||
// 2. 过滤黑名单中的方法名
|
||||
List<String> filteredMethods = Arrays.stream(originalMethods.split(","))
|
||||
@@ -67,12 +67,12 @@ public class FilteredNacosRegistry extends NacosRegistry {
|
||||
// 3. 处理过滤后的结果
|
||||
if (filteredMethods.isEmpty()) {
|
||||
// 若所有方法都被过滤,直接终止注册(可选:根据业务决定是否保留服务注册)
|
||||
// log.info("【过滤提示】服务 {} 所有方法均被过滤,终止注册", url.getServiceInterface());
|
||||
log.info("【过滤提示】服务 {} 所有方法均被过滤,终止注册", url.getServiceInterface());
|
||||
return;
|
||||
} else {
|
||||
// 替换 URL 中的 methods 参数为过滤后的列表
|
||||
url = url.addParameter("methods", String.join(",", filteredMethods));
|
||||
// log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), filteredMethods);
|
||||
log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), filteredMethods);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,24 +21,12 @@ public class RabbitConfig {
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String activeProfile;
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public DirectExchange directExchange() {
|
||||
return new DirectExchange(activeProfile + "-" + RabbitConstants.Exchange.CASH_EXCHANGE);
|
||||
}
|
||||
|
||||
//------------------------------------------------------ 商家入驻
|
||||
@Bean
|
||||
public Queue entryManagerQueue() {
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.SHOP_ENTRY_MANAGER, true, false, false);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding entryManagerExchange(Queue entryManagerQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(entryManagerQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.SHOP_ENTRY_MANAGER);
|
||||
}
|
||||
|
||||
//------------------------------------------------------订单打印队列
|
||||
@Bean
|
||||
public Queue orderPrintQueue() {
|
||||
@@ -48,7 +36,6 @@ public class RabbitConfig {
|
||||
args.put("x-message-ttl", 180000);
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_PRINT_QUEUE, true, false, false, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingOrderPrintExchange(Queue orderPrintQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(orderPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_PRINT_QUEUE);
|
||||
@@ -64,7 +51,6 @@ public class RabbitConfig {
|
||||
// args.put("x-message-ttl", 180000);
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, true, false, false);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingOrderMachinePrintExchange(Queue orderMachinePrintQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(orderMachinePrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE);
|
||||
@@ -75,7 +61,6 @@ public class RabbitConfig {
|
||||
public Queue handoverPrintQueue() {
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE, true, false, false);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingHandoverPrintExchange(Queue handoverPrintQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(handoverPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE);
|
||||
@@ -84,12 +69,11 @@ public class RabbitConfig {
|
||||
//------------------------------------------------------叫号 打票
|
||||
@Bean
|
||||
public Queue callTablePrintQueue() {
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.CALL_TABLE_QUEUE, true, false, false);
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.CALL_TABLE_PRINT_QUEUE, true, false, false);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingCallTablePrintExchange(Queue callTablePrintQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(callTablePrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.CALL_TABLE_QUEUE);
|
||||
return BindingBuilder.bind(callTablePrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.CALL_TABLE_PRINT_QUEUE);
|
||||
}
|
||||
|
||||
//------------------------------------------------------订单取消
|
||||
@@ -97,10 +81,9 @@ public class RabbitConfig {
|
||||
public Queue orderCancelQueue() {
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_CANCEL_QUEUE, true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingOrderCancelExchange(Queue orderCancelQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(orderCancelQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_CANCEL_QUEUE);
|
||||
public Binding bindingOrderCancelExchange(Queue orderPrintQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(orderPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_CANCEL_QUEUE);
|
||||
}
|
||||
|
||||
//------------------------------------------------------ 订单库存更新
|
||||
@@ -108,7 +91,6 @@ public class RabbitConfig {
|
||||
public Queue orderStockQueue() {
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_STOCK_QUEUE, true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingOrderStockExchange(Queue orderStockQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(orderStockQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_STOCK_QUEUE);
|
||||
@@ -120,7 +102,6 @@ public class RabbitConfig {
|
||||
public Queue productInfoChangeQueue() {
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE, true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingProductInfoChange(Queue productInfoChangeQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(productInfoChangeQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE);
|
||||
@@ -131,7 +112,6 @@ public class RabbitConfig {
|
||||
public Queue orderRefundQueue() {
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_REFUND_QUEUE, true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingOrderRefundExchange(Queue orderRefundQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(orderRefundQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_REFUND_QUEUE);
|
||||
@@ -139,7 +119,6 @@ public class RabbitConfig {
|
||||
|
||||
|
||||
//------------------------------------------------------ 申请短信模板队列
|
||||
|
||||
/**
|
||||
* 1,2,applySmsTemp 模版审核
|
||||
* 1,2,sendMarkSms 发送营销短信
|
||||
@@ -150,18 +129,16 @@ public class RabbitConfig {
|
||||
public Queue applySmsTemplateQueue() {
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.APPLY_SMS_TEMPLATE_QUEUE, true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingApplySmsTemplateExchange(Queue applySmsTemplateQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(applySmsTemplateQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.APPLY_SMS_TEMPLATE_QUEUE);
|
||||
}
|
||||
|
||||
//------------------------------------------------------ 生日礼品短信队列
|
||||
//------------------------------------------------------ 生日礼品短信队列
|
||||
@Bean
|
||||
public Queue birthdayGiftSmsQueue() {
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.BIRTHDAY_GIFT_SMS_QUEUE, true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingBirthdayGiftSmsExchange(Queue birthdayGiftSmsQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(birthdayGiftSmsQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.BIRTHDAY_GIFT_SMS_QUEUE);
|
||||
@@ -172,7 +149,6 @@ public class RabbitConfig {
|
||||
public Queue orderProductStatusQueue() {
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_PRODUCT_STATUS_QUEUE, true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingOrderProductStatusExchange(Queue orderProductStatusQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(orderProductStatusQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_PRODUCT_STATUS_QUEUE);
|
||||
@@ -184,7 +160,6 @@ public class RabbitConfig {
|
||||
public Queue orderDetailStatusQueue() {
|
||||
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_DETAIL_STATUS_QUEUE, true);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindingOrderDetailStatusExchange(Queue orderDetailStatusQueue, DirectExchange exchange) {
|
||||
return BindingBuilder.bind(orderDetailStatusQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_DETAIL_STATUS_QUEUE);
|
||||
|
||||
@@ -10,14 +10,13 @@ public interface RabbitConstants {
|
||||
}
|
||||
|
||||
class Queue {
|
||||
public static final String SHOP_ENTRY_MANAGER = "shop.entry.manager";
|
||||
public static final String ORDER_STOCK_QUEUE = "order.stock.queue";
|
||||
public static final String ORDER_REFUND_QUEUE = "order.refund.queue";
|
||||
public static final String ORDER_CANCEL_QUEUE = "order.cancel.queue";
|
||||
public static final String ORDER_PRINT_QUEUE = "order.print.queue";
|
||||
public static final String ORDER_MACHINE_PRINT_QUEUE = "order.machine.print.queue";
|
||||
public static final String ORDER_HANDOVER_PRINT_QUEUE = "order.handover.print.queue";
|
||||
public static final String CALL_TABLE_QUEUE = "call.table.print.queue";
|
||||
public static final String CALL_TABLE_PRINT_QUEUE = "call.table.print.queue";
|
||||
public static final String PRODUCT_INFO_CHANGE_QUEUE = "product.info.change.queue";
|
||||
|
||||
/**
|
||||
|
||||
@@ -130,13 +130,6 @@ public class RabbitPublisher {
|
||||
sendMsg(RabbitConstants.Queue.ORDER_PRODUCT_STATUS_QUEUE, qrContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 进件
|
||||
*/
|
||||
public void sendEntryManagerMsg(String shopId) {
|
||||
sendMsg(RabbitConstants.Queue.SHOP_ENTRY_MANAGER, shopId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 订单商品状态消息
|
||||
|
||||
@@ -33,8 +33,6 @@ public interface RedisCst {
|
||||
public static final String EXPIRED_WECHAT = "expired:wechat:";
|
||||
}
|
||||
|
||||
//商家进件
|
||||
String SHOP_ENTRY = "shop:entry";
|
||||
|
||||
String SMS_CODE = "sms:code:";
|
||||
// 店铺会员动态支付码
|
||||
|
||||
@@ -6,15 +6,14 @@ import jakarta.annotation.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @author GYJoker
|
||||
@@ -651,106 +650,4 @@ public class RedisService {
|
||||
}
|
||||
return JSON.parseArray(jsonStr, type);
|
||||
}
|
||||
|
||||
|
||||
public static int retryCount = 5;
|
||||
|
||||
/**
|
||||
* 执行任务并保证锁唯一
|
||||
*
|
||||
* @param supplier 业务逻辑
|
||||
* @param lockKey Redis锁的Key
|
||||
* @return 业务逻辑返回值
|
||||
*/
|
||||
public <T> T runFunAndCheckKey(Supplier<T> supplier, String lockKey) {
|
||||
String lockValue = String.valueOf(System.nanoTime() + Thread.currentThread().threadId());
|
||||
try {
|
||||
// 尝试获取锁,超时时间 5 秒,防止死锁
|
||||
boolean lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 5, TimeUnit.SECONDS));
|
||||
int count = 0;
|
||||
// 初始等待 10ms
|
||||
int retryDelay = 10;
|
||||
|
||||
while (!lock) {
|
||||
// 最多重试 10 次,大约 10 秒
|
||||
if (count++ > 50) {
|
||||
throw new RuntimeException("系统繁忙, 稍后再试");
|
||||
}
|
||||
Thread.sleep(retryDelay);
|
||||
// 指数退避,最大等待 200ms
|
||||
retryDelay = Math.min(retryDelay * 2, 200);
|
||||
lock = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent(lockKey, lockValue, 5, TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
// 执行任务
|
||||
return supplier.get();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new RuntimeException("线程被中断", e);
|
||||
} catch (Exception e) {
|
||||
log.error("执行出错:{}", e.getMessage(), e);
|
||||
throw e;
|
||||
} finally {
|
||||
// 释放锁(使用 Lua 脚本确保原子性)
|
||||
unlock(lockKey, lockValue);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用 Lua 脚本确保释放锁的原子性
|
||||
*
|
||||
* @param lockKey 锁的 Key
|
||||
* @param lockValue 当前线程的锁值
|
||||
*/
|
||||
private void unlock(String lockKey, String lockValue) {
|
||||
String luaScript =
|
||||
"if redis.call('get', KEYS[1]) == ARGV[1] then " +
|
||||
"return redis.call('del', KEYS[1]) " +
|
||||
"else return 0 end";
|
||||
redisTemplate.execute(new DefaultRedisScript<>(luaScript, Long.class),
|
||||
Collections.singletonList(lockKey), lockValue);
|
||||
}
|
||||
|
||||
public static <T, R> R runFunAndRetry(
|
||||
Supplier<R> function,
|
||||
Function<R, Boolean> check, Consumer<R> errFun) {
|
||||
R result = function.get();
|
||||
boolean flag = check.apply(result);
|
||||
|
||||
while (flag && retryCount-- > 0) {
|
||||
result = function.get();
|
||||
flag = check.apply(result);
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
errFun.accept(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 防抖函数:在指定秒数内相同 Key 的任务只会执行一次
|
||||
*
|
||||
* @param key 防抖使用的 Redis Key
|
||||
* @param seconds 防抖时间(秒)
|
||||
* @param task 要执行的业务逻辑
|
||||
* @return true 执行了任务;false 在防抖期内被拦截
|
||||
*/
|
||||
public boolean debounce(String key, long seconds, Runnable task) {
|
||||
try {
|
||||
Boolean success = redisTemplate.opsForValue().setIfAbsent(
|
||||
key, "1", seconds, TimeUnit.SECONDS
|
||||
);
|
||||
|
||||
if (Boolean.TRUE.equals(success)) {
|
||||
task.run();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
log.error("防抖函数执行失败 key={} err={}", key, e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package com.czg.pay;
|
||||
package com.czg.account.dto.merchant;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 聚合支付参数
|
||||
* @author ww
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
public class PolyMerchantDTO {
|
||||
public class ShopMerchantEditDTO {
|
||||
@NotNull(message = "店铺id不为空")
|
||||
private Long shopId;
|
||||
@NotEmpty(message = "支付系统商户id不为空")
|
||||
private String storeId;
|
||||
@NotEmpty(message = "支付系统商户名称不为空")
|
||||
@@ -18,6 +20,12 @@ public class PolyMerchantDTO {
|
||||
@NotEmpty(message = "商户秘钥不为空")
|
||||
private String appSecret;
|
||||
// 支付密码
|
||||
// @NotEmpty(message = "支付密码不为空")
|
||||
@NotEmpty(message = "支付密码不为空")
|
||||
private String payPassword;
|
||||
// 微信appid
|
||||
@NotEmpty(message = "微信appid")
|
||||
private String wechatSmallAppid;
|
||||
// 支付宝appid
|
||||
@NotEmpty(message = "支付宝appid")
|
||||
private String alipaySmallAppid;
|
||||
}
|
||||
@@ -285,13 +285,4 @@ public class ShopInfoEditDTO {
|
||||
*/
|
||||
private Integer isCountStick;
|
||||
|
||||
/**
|
||||
* 企业id
|
||||
*/
|
||||
private String weworkId;
|
||||
/**
|
||||
* 企业接入链接
|
||||
*/
|
||||
private String weworkUrl;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
package com.czg.account.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 悬浮窗配置 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-12-29
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_quick_menu")
|
||||
public class QuickMenu implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 店铺Id
|
||||
*/
|
||||
private Long shopId;
|
||||
/**
|
||||
* 菜单图标
|
||||
*/
|
||||
private String url;
|
||||
|
||||
|
||||
/**
|
||||
* 菜单Id
|
||||
*/
|
||||
@NotNull(message = "关联菜单不能为空")
|
||||
private Long menuId;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 状态 1-启用 0-禁用
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -135,13 +135,5 @@ public class ShopConfig implements Serializable {
|
||||
|
||||
private String dingAppKey;
|
||||
private String dingAppSecret;
|
||||
/**
|
||||
* 企业id
|
||||
*/
|
||||
private String weworkId;
|
||||
/**
|
||||
* 企业接入链接
|
||||
*/
|
||||
private String weworkUrl;
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public class ShopInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 使用系统用户 sys_user id
|
||||
*/
|
||||
@@ -362,15 +363,4 @@ public class ShopInfo implements Serializable {
|
||||
*/
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 企业id
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private String weworkId;
|
||||
/**
|
||||
* 企业接入链接
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private String weworkUrl;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.czg.order.entity;
|
||||
package com.czg.account.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -19,54 +18,57 @@ import java.time.LocalDateTime;
|
||||
* @since 2025-02-11
|
||||
*/
|
||||
@Data
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_merchant2")
|
||||
@Table("tb_shop_merchant")
|
||||
public class ShopMerchant implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
@Id
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* poly 聚合(支付平台) native 原生(wx/ali 原生)
|
||||
* {@link com.czg.constant.PayChannelCst}
|
||||
* 支付系统商户id
|
||||
*/
|
||||
private String channel;
|
||||
private String storeId;
|
||||
|
||||
private String merchantName;
|
||||
|
||||
/**
|
||||
* 聚合支付商户
|
||||
* native 必填 对应 tb_shop_direct_merchant 的 licence_no 营业执照
|
||||
* 商户应用id
|
||||
*/
|
||||
private String relatedLicenceNo;
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 微信appid
|
||||
* 商户token
|
||||
*/
|
||||
private String wechatAppId;
|
||||
/**
|
||||
* 支付宝appid
|
||||
*/
|
||||
private String alipayAppId;
|
||||
private String appSecret;
|
||||
|
||||
/**
|
||||
* 聚合支付参数
|
||||
* 微信小程序appid
|
||||
*/
|
||||
private String polyPayJson;
|
||||
private String wechatSmallAppid;
|
||||
|
||||
/**
|
||||
* 原生支付参数
|
||||
* 支付宝小程序appid
|
||||
*/
|
||||
private String nativePayJson;
|
||||
private String alipaySmallAppid;
|
||||
|
||||
/**
|
||||
* 支付密码
|
||||
*/
|
||||
private String payPassword;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.czg.account.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.account.entity.QuickMenu;
|
||||
|
||||
/**
|
||||
* 悬浮窗配置 服务层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-12-29
|
||||
*/
|
||||
public interface QuickMenuService extends IService<QuickMenu> {
|
||||
|
||||
}
|
||||
@@ -23,9 +23,8 @@ public interface ShopInfoService extends IService<ShopInfo> {
|
||||
|
||||
/**
|
||||
* 检测开关
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @param switchType ShopInfo的某列 开关 目前只支持Integer类型字段
|
||||
* @param shopId 店铺id
|
||||
* @param switchType ShopInfo的某列 开关 目前只支持Integer类型字段
|
||||
* @return true:开启 false:关闭
|
||||
*/
|
||||
boolean checkSwitch(Long shopId, ShopSwitchTypeEnum switchType) throws ValidateException;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
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,27 +79,7 @@ public interface ParamCodeCst {
|
||||
* 超掌柜支付回调地址
|
||||
* <p>支付宝/微信支付完成后,支付平台回调我方系统的地址</p>
|
||||
*/
|
||||
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";
|
||||
public static String PAY_CZG_NOTIFY_URL = "pay_czg_notify_url";
|
||||
/**
|
||||
* 排队到号通知
|
||||
*/
|
||||
@@ -131,6 +111,11 @@ public interface ParamCodeCst {
|
||||
*/
|
||||
public static String SMS_FEE = "sms_fee";
|
||||
|
||||
/**
|
||||
* 店铺订单支付BaseUrl
|
||||
* <p>店铺订单支付页面的基础域名</p>
|
||||
*/
|
||||
public static String SHOP_ORDER_PAY_BASE_URL = "shop_order_pay_base_url";
|
||||
|
||||
/**
|
||||
* 平台名称
|
||||
@@ -138,12 +123,30 @@ public interface ParamCodeCst {
|
||||
*/
|
||||
public static String PLATE_NAME = "plate_name";
|
||||
|
||||
/**
|
||||
* 超掌柜退款回调地址
|
||||
* <p>支付平台处理退款后,回调我方系统的地址</p>
|
||||
*/
|
||||
public static String PAY_CZG_REFUND_NOTIFY_URL = "pay_czg_refund_notify_url";
|
||||
|
||||
/**
|
||||
* 超掌柜支付域名
|
||||
* <p>超掌柜支付相关接口的根域名</p>
|
||||
*/
|
||||
public static String PAY_CZG_DOMAIN = "pay_czg_domain";
|
||||
|
||||
/**
|
||||
* 叫号页面地址
|
||||
* <p>餐厅叫号系统的前端页面地址</p>
|
||||
*/
|
||||
public static String CALL_PAGE_URL = "call_page_url";
|
||||
|
||||
/**
|
||||
* 微信原生回调地址
|
||||
* <p>微信原生支付接口的回调地址(区别于超掌柜封装的回调)</p>
|
||||
*/
|
||||
public static String NATIVE_NOTIFY_URL = "native_notify_url";
|
||||
|
||||
/**
|
||||
* 公众号关注位置
|
||||
* <p>公众号关注入口的展示位置,可选值:mine-我的页面、order-订单页面、eat-就餐页面</p>
|
||||
|
||||
@@ -43,30 +43,4 @@ public interface SystemConstants {
|
||||
*/
|
||||
public static final String CUSTOM = "custom";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 三方支付类型
|
||||
*/
|
||||
class PayType {
|
||||
/**
|
||||
* 微信支付
|
||||
*/
|
||||
public static final String WECHAT = "wechatPay";
|
||||
|
||||
/**
|
||||
* 支付宝支付
|
||||
*/
|
||||
public static final String ALIPAY = "alipay";
|
||||
|
||||
/**
|
||||
* 微信小程序支付
|
||||
*/
|
||||
public static final String WECHAT_APP_ID = "wxd88fffa983758a30";
|
||||
|
||||
/**
|
||||
* 支付宝小程序支付
|
||||
*/
|
||||
public static final String ALIPAY_APP_ID = "2021004145625815";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.czg.market.service;
|
||||
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MkShopRechargeDTO;
|
||||
import com.czg.market.vo.MkShopRechargeShopListVO;
|
||||
import com.czg.market.vo.MkShopRechargeVO;
|
||||
@@ -21,7 +22,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface MkShopRechargeService extends IService<MkShopRecharge> {
|
||||
|
||||
MkShopRechargeVO detail(Long shopId);
|
||||
MkShopRechargeVO detail(Long shopId) throws CzgException;
|
||||
|
||||
MkShopRechargeVO detailApp(Long shopId);
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.czg.order.dto;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -14,7 +13,6 @@ import java.math.BigDecimal;
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class LtPayOtherDTO {
|
||||
/**
|
||||
* 积分商品id/团购商品id
|
||||
|
||||
@@ -24,10 +24,6 @@ public class MkDistributionPayDTO implements Serializable {
|
||||
private Long shopId;
|
||||
private String platformType = "DIS";
|
||||
private Long userId;
|
||||
/**
|
||||
* 支付类型
|
||||
* {@link com.czg.constants.SystemConstants.PayType}
|
||||
*/
|
||||
private String payType;
|
||||
private String returnUrl;
|
||||
private String buyerRemark;
|
||||
|
||||
@@ -28,7 +28,6 @@ public class OrderInfoAddDTO implements Serializable {
|
||||
* 已出菜 SENT_OUT
|
||||
* 已上菜 DELIVERED
|
||||
* 已超时 EXPIRED
|
||||
* 加急 URGENT
|
||||
*/
|
||||
private String subStatus;
|
||||
//限时折扣部分
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
|
||||
package com.czg.order.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 订单表 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-02-13
|
||||
*/
|
||||
@Data
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OrderInfoDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
* pc 收银机客户端 PC+雪花ID
|
||||
* wechat 微信小程序 WX+雪花ID
|
||||
* alipay 支付宝小程序 ALI+雪花ID
|
||||
* admin-pc PC管理端 WEB+雪花ID
|
||||
* admin-app APP管理端 APP+雪花ID
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 店铺Id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 用户Id user_info表的id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 退单金额
|
||||
*/
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
/**
|
||||
* 订单原金额 不含折扣价格
|
||||
*/
|
||||
private BigDecimal originAmount;
|
||||
/**
|
||||
* 抹零金额 减免多少钱
|
||||
*/
|
||||
private BigDecimal roundAmount;
|
||||
/**
|
||||
* 优惠总金额
|
||||
*/
|
||||
private BigDecimal discountAllAmount;
|
||||
|
||||
/**
|
||||
* 订单金额 (扣除各类折扣)
|
||||
*/
|
||||
private BigDecimal orderAmount;
|
||||
|
||||
/**
|
||||
* 实际支付金额
|
||||
*/
|
||||
private BigDecimal payAmount;
|
||||
|
||||
/**
|
||||
* 积分抵扣金额
|
||||
*/
|
||||
private BigDecimal pointsDiscountAmount;
|
||||
|
||||
/**
|
||||
* 使用的积分数量
|
||||
*/
|
||||
private Integer pointsNum;
|
||||
|
||||
/**
|
||||
* 商品优惠券抵扣金额
|
||||
*/
|
||||
private BigDecimal productCouponDiscountAmount;
|
||||
|
||||
/**
|
||||
* 用户使用的卡券
|
||||
*/
|
||||
private String couponInfoList;
|
||||
|
||||
/**
|
||||
* 满减活动抵扣金额
|
||||
*/
|
||||
private BigDecimal discountActAmount;
|
||||
|
||||
/**
|
||||
* 折扣金额
|
||||
*/
|
||||
private BigDecimal discountAmount;
|
||||
|
||||
// /**
|
||||
// * 折扣比例
|
||||
// */
|
||||
// private BigDecimal discountRatio;
|
||||
|
||||
/**
|
||||
* 打包费
|
||||
*/
|
||||
private BigDecimal packFee;
|
||||
|
||||
/**
|
||||
* 台桌Id
|
||||
*/
|
||||
private String tableCode;
|
||||
|
||||
/**
|
||||
* 台桌名称
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 订单类型-
|
||||
* cash收银(除小程序以外 都属于收银)
|
||||
* miniapp小程序
|
||||
*/
|
||||
private String orderType;
|
||||
|
||||
/**
|
||||
* 平台类型 pc 收银机客户端 wechat 微信小程序 alipay 支付宝小程序 admin-pc PC管理端 admin-app APP管理端
|
||||
*/
|
||||
private String platformType;
|
||||
|
||||
/**
|
||||
* 用餐模式 堂食 dine-in 外带 take-out 外卖 take-away
|
||||
*/
|
||||
private String dineMode;
|
||||
|
||||
/**
|
||||
* 支付模式:
|
||||
* 后付费 after-pay
|
||||
* 先付费 before-pay
|
||||
* 无桌码 no-table
|
||||
*/
|
||||
private String payMode;
|
||||
|
||||
/**
|
||||
* 支付类型
|
||||
* 主扫 main-scan
|
||||
* 被扫 back-scan
|
||||
* 微信小程序 wechat-mini
|
||||
* 支付宝小程序 alipay-mini
|
||||
* 会员支付 vip-pay
|
||||
* 现金支付 cash-pay
|
||||
*/
|
||||
private String payType;
|
||||
|
||||
/**
|
||||
* 状态: unpaid-待支付;in-production 制作中;wait_out 待取餐;;done-订单完成;refunding-申请退单;refund-退单;part_refund 部分退单;cancelled-取消订单
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 折扣信息 json
|
||||
*/
|
||||
private String discountInfo;
|
||||
|
||||
/**
|
||||
* 限时折扣信息 json
|
||||
*/
|
||||
private String limitRate;
|
||||
|
||||
/**
|
||||
* 是否支持退款,1支持退单, 0不支持退单
|
||||
*/
|
||||
private Integer refundAble;
|
||||
|
||||
/**
|
||||
* 支付时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime paidTime;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 支付订单号
|
||||
* tb_order_payment.id
|
||||
* tb_shop_user_flow.id
|
||||
*/
|
||||
private Long payOrderId;
|
||||
|
||||
/**
|
||||
* 交易日期
|
||||
*/
|
||||
private String tradeDay;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 取餐码
|
||||
*/
|
||||
private String takeCode;
|
||||
|
||||
/**
|
||||
* 员工id
|
||||
*/
|
||||
private Long staffId;
|
||||
|
||||
/**
|
||||
* 当前订单下单次数
|
||||
*/
|
||||
private Integer placeNum;
|
||||
|
||||
/**
|
||||
* 用餐人数
|
||||
*/
|
||||
private Integer seatNum;
|
||||
|
||||
/**
|
||||
* 餐位费
|
||||
*/
|
||||
private BigDecimal seatAmount;
|
||||
|
||||
/**
|
||||
* 退款备注
|
||||
*/
|
||||
private String refundRemark;
|
||||
|
||||
/**
|
||||
* 是否使用了霸王餐
|
||||
*/
|
||||
private Integer isFreeDine;
|
||||
|
||||
/**
|
||||
* 是否等叫 0 否 1 等叫
|
||||
*/
|
||||
private Integer isWaitCall;
|
||||
|
||||
/**
|
||||
* 挂账人id
|
||||
*/
|
||||
private Long creditBuyerId;
|
||||
|
||||
/**
|
||||
* 是否回收站 0-否,1回收站
|
||||
*/
|
||||
private Integer isDel;
|
||||
private String failMsg;
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
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 的 licence_no 营业执照
|
||||
*/
|
||||
private String relatedLicenceNo;
|
||||
/**
|
||||
* 原生支付参数
|
||||
*/
|
||||
private NativeMerchantDTO nativeMerchantDTO;
|
||||
/**
|
||||
* 聚合支付参数
|
||||
*/
|
||||
private PolyMerchantDTO polyMerchantDTO;
|
||||
|
||||
/**
|
||||
* 店铺绑定的商户信息
|
||||
*/
|
||||
private ShopDirectMerchant shopDirectMerchant;
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.czg.order.entity;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.order.dto.LimitRateDTO;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
@@ -300,10 +298,8 @@ public class OrderInfo implements Serializable {
|
||||
private Integer isDel;
|
||||
|
||||
private String failMsg;
|
||||
/**
|
||||
* 打印状态 Json格式
|
||||
*/
|
||||
private String printStatus;
|
||||
|
||||
|
||||
|
||||
|
||||
public String getRefundRemark() {
|
||||
@@ -346,41 +342,4 @@ public class OrderInfo implements Serializable {
|
||||
// 如果需要加上抹零金额,可以取消下面这行注释
|
||||
// .add(this.getRoundAmount() != null ? this.getRoundAmount() : BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
private JSONArray getPrintStatusAsArray() {
|
||||
if (StrUtil.isBlank(printStatus)) {
|
||||
return new JSONArray();
|
||||
}
|
||||
try {
|
||||
return JSONArray.parseArray(printStatus.trim());
|
||||
} catch (Exception e) {
|
||||
return new JSONArray();
|
||||
}
|
||||
}
|
||||
|
||||
public void upPrintStatus(JSONObject printJson, boolean isPrintSuccess) {
|
||||
String currentDeviceId = printJson.getString("id");
|
||||
JSONArray oldPrintStatusArray = getPrintStatusAsArray();
|
||||
// 3. 初始化新的打印状态JSON数组(用于存储处理后的结果)
|
||||
JSONArray newPrintStatusArray = new JSONArray();
|
||||
// 场景1:打印成功 - 移除原有数组中与当前设备ID一致的记录,保留其余记录
|
||||
if (oldPrintStatusArray != null && !oldPrintStatusArray.isEmpty()) {
|
||||
for (int i = 0; i < oldPrintStatusArray.size(); i++) {
|
||||
JSONObject deviceObj = oldPrintStatusArray.getJSONObject(i);
|
||||
String deviceId = deviceObj.getString("id");
|
||||
// 仅保留非当前设备ID的记录
|
||||
if (currentDeviceId != null && !currentDeviceId.equals(deviceId)) {
|
||||
newPrintStatusArray.add(deviceObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isPrintSuccess) {
|
||||
newPrintStatusArray.add(printJson);
|
||||
}
|
||||
if (!newPrintStatusArray.isEmpty()) {
|
||||
printStatus = newPrintStatusArray.toJSONString();
|
||||
} else {
|
||||
printStatus = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -41,17 +40,6 @@ public class OrderPayment implements Serializable {
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 支付渠道
|
||||
* {@link com.czg.constant.PayChannelCst}
|
||||
*/
|
||||
private String channel;
|
||||
|
||||
/**
|
||||
* 平台类型
|
||||
* {@link com.czg.PayCst.Platform}
|
||||
*/
|
||||
private String platformType;
|
||||
/**
|
||||
* 来源Id 订单Id或充值id
|
||||
*/
|
||||
@@ -93,7 +81,7 @@ public class OrderPayment implements Serializable {
|
||||
*/
|
||||
private String tradeNumber;
|
||||
|
||||
@Column(onUpdateValue = "now()")
|
||||
// @Column(onUpdateValue = "now()")
|
||||
private LocalDateTime payTime;
|
||||
|
||||
/**
|
||||
@@ -116,67 +104,28 @@ public class OrderPayment implements Serializable {
|
||||
public OrderPayment() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单专用支付
|
||||
*
|
||||
* @param sourceId 订单Id
|
||||
* @param amount 单元 元
|
||||
* @param authCode 扫码支付时必填 扫描码
|
||||
*/
|
||||
public static OrderPayment orderPay(@NonNull Long shopId, @NonNull Long sourceId,
|
||||
@NotBlank String orderNo, @NonNull BigDecimal amount, String authCode) {
|
||||
OrderPayment orderPayment = getInstance(shopId, sourceId, PayTypeConstants.SourceType.ORDER, orderNo, amount, authCode, null);
|
||||
orderPayment.setPayType(PayTypeConstants.PayType.PAY);
|
||||
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
|
||||
return orderPayment;
|
||||
public OrderPayment(@NonNull Long shopId,@NonNull Long sourceId, @NotBlank String sourceType,@NotBlank String payType, @NotBlank String orderNo,
|
||||
String authCode, @NonNull BigDecimal amount) {
|
||||
this.shopId = shopId;
|
||||
this.sourceId = sourceId;
|
||||
this.sourceType = sourceType;
|
||||
this.payType = payType;
|
||||
this.orderNo = orderNo;
|
||||
this.authCode = authCode;
|
||||
this.amount = amount;
|
||||
this.payStatus = PayTypeConstants.PayStatus.INIT;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化支付参数
|
||||
*
|
||||
* @param sourceId 充值时为会员Id shopUserID
|
||||
* 购买时为商品Id
|
||||
* @param sourceType {@link PayTypeConstants.SourceType} 支付来源
|
||||
* @param amount 单元 元
|
||||
* @param authCode 扫码支付时必填 扫描码
|
||||
* @param relatedId 霸王餐充值为 订单id 会员充值为 活动id 充值并支付时 为 MkShopRechargeDetail
|
||||
*/
|
||||
public static OrderPayment pay(@NonNull Long shopId, @NonNull Long sourceId, @NotBlank String sourceType,
|
||||
@NotBlank String orderNo, @NonNull BigDecimal amount,
|
||||
String authCode, Long relatedId) {
|
||||
OrderPayment orderPayment = getInstance(shopId, sourceId, sourceType, orderNo, amount, authCode, relatedId);
|
||||
orderPayment.setPayType(PayTypeConstants.PayType.PAY);
|
||||
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
|
||||
return orderPayment;
|
||||
}
|
||||
|
||||
public static OrderPayment refund(@NonNull Long shopId, @NonNull Long sourceId, @NotBlank String sourceType,
|
||||
@NotBlank String orderNo, @NonNull BigDecimal amount, Long relatedId, String platformType) {
|
||||
OrderPayment orderPayment = getInstance(shopId, sourceId, sourceType, orderNo, amount, null, relatedId);
|
||||
orderPayment.setPayType(PayTypeConstants.PayType.REFUND);
|
||||
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
|
||||
orderPayment.setPlatformType(platformType);
|
||||
return orderPayment;
|
||||
}
|
||||
|
||||
public static OrderPayment refundCompensate(@NonNull Long shopId, @NonNull Long sourceId, @NotBlank String sourceType,
|
||||
@NotBlank String orderNo, @NonNull BigDecimal amount, Long relatedId) {
|
||||
OrderPayment orderPayment = getInstance(shopId, sourceId, sourceType, orderNo, amount, null, relatedId);
|
||||
orderPayment.setPayType(PayTypeConstants.PayType.REFUND_COMPENSATE);
|
||||
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
|
||||
return orderPayment;
|
||||
}
|
||||
|
||||
private static OrderPayment getInstance(Long shopId, Long sourceId, String sourceType,
|
||||
String orderNo, BigDecimal amount, String authCode, Long relatedId) {
|
||||
OrderPayment orderPayment = new OrderPayment();
|
||||
orderPayment.shopId = shopId;
|
||||
orderPayment.sourceId = sourceId;
|
||||
orderPayment.sourceType = sourceType;
|
||||
orderPayment.orderNo = orderNo;
|
||||
orderPayment.authCode = authCode;
|
||||
orderPayment.amount = amount;
|
||||
orderPayment.relatedId = relatedId;
|
||||
return orderPayment;
|
||||
public OrderPayment(@NonNull Long shopId,@NonNull Long sourceId, @NotBlank String sourceType,@NotBlank String payType, @NotBlank String orderNo,
|
||||
String authCode, @NonNull BigDecimal amount, Long relatedId) {
|
||||
this.shopId = shopId;
|
||||
this.sourceId = sourceId;
|
||||
this.sourceType = sourceType;
|
||||
this.payType = payType;
|
||||
this.orderNo = orderNo;
|
||||
this.authCode = authCode;
|
||||
this.amount = amount;
|
||||
this.relatedId = relatedId;
|
||||
this.payStatus = PayTypeConstants.PayStatus.INIT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
package com.czg.order.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 商户进件 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2026-01-07
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_direct_merchant")
|
||||
public class ShopDirectMerchant implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
@Id
|
||||
private Long shopId;
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private String shopName;
|
||||
|
||||
/**
|
||||
* 营业执照编号
|
||||
*/
|
||||
private String licenceNo;
|
||||
/**
|
||||
* 支付宝账号
|
||||
*/
|
||||
private String alipayAccount;
|
||||
/**
|
||||
* 商户编号(在当前系统唯一)
|
||||
*/
|
||||
private String merchantCode;
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户类型
|
||||
* 0: 个体商户;
|
||||
* 1: 企业商户;
|
||||
* 3: 小微商户 暂不支持
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户简称--企业、个体必填
|
||||
*/
|
||||
private String shortName;
|
||||
/**
|
||||
* 商户基础信息
|
||||
*/
|
||||
private String merchantBaseInfo;
|
||||
|
||||
/**
|
||||
* 法人信息
|
||||
*/
|
||||
private String legalPersonInfo;
|
||||
|
||||
/**
|
||||
* 营业执照信息
|
||||
*/
|
||||
private String businessLicenceInfo;
|
||||
|
||||
/**
|
||||
* 门店信息
|
||||
*/
|
||||
private String storeInfo;
|
||||
|
||||
/**
|
||||
* 结算信息
|
||||
*/
|
||||
private String settlementInfo;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
private String errorMsg;
|
||||
|
||||
private String wechatApplyId;
|
||||
/**
|
||||
* 微信状态
|
||||
*/
|
||||
private String wechatStatus;
|
||||
|
||||
/**
|
||||
* 微信进件错误信息
|
||||
*/
|
||||
private String wechatErrorMsg;
|
||||
/**
|
||||
* 微信进件签名地址
|
||||
*/
|
||||
private String wechatSignUrl;
|
||||
|
||||
private String alipayOrderId;
|
||||
|
||||
/**
|
||||
* 支付宝状态
|
||||
*/
|
||||
private String alipayStatus;
|
||||
|
||||
/**
|
||||
* 支付宝进件错误信息
|
||||
*/
|
||||
private String alipayErrorMsg;
|
||||
/**
|
||||
* 支付宝进件签名地址
|
||||
*/
|
||||
private String alipaySignUrl;
|
||||
|
||||
/**
|
||||
* 支付宝授信息
|
||||
*/
|
||||
private String alipayAuthInfo;
|
||||
/**
|
||||
* 微信商户id
|
||||
*/
|
||||
private String wechatMerchantId;
|
||||
/**
|
||||
* 支付宝商户id
|
||||
*/
|
||||
private String alipayMerchantId;
|
||||
|
||||
|
||||
}
|
||||
@@ -12,9 +12,9 @@ import com.czg.order.enums.PayEnums;
|
||||
import com.czg.order.vo.HistoryOrderPrintVo;
|
||||
import com.czg.order.vo.HistoryOrderVo;
|
||||
import com.czg.order.vo.OrderInfoVo;
|
||||
import com.czg.pay.PayNotifyRespDTO;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface OrderInfoCustomService {
|
||||
|
||||
CzgResult<Object> mergeOrder(MergeOrderDTO param);
|
||||
|
||||
void payCallBackOrder(@NotBlank String orderNo, @NotNull PayNotifyRespDTO notifyRespDTO, String channel, int retryCount);
|
||||
void payCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson, int retryCount);
|
||||
|
||||
void refundCallBackOrder(@NotBlank String orderNo, @NotNull JSONObject resultJson);
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@ import com.czg.order.entity.PrintMachineLog;
|
||||
* @since 2025-03-11
|
||||
*/
|
||||
public interface PrintMachineLogService extends IService<PrintMachineLog> {
|
||||
void save(Long orderId, PrintMachine config, String bizType, String printContent, String respJson);
|
||||
|
||||
void save(PrintMachine config, String bizType, String printContent, String respJson);
|
||||
void save(PrintMachine config, String bizType, String printContent, Object respJson);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
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 String relatedLicenceNo, @NotNull NativeMerchantDTO nativeMerchantDTO);
|
||||
|
||||
ShopMerchant getByShopId(Long shopId);
|
||||
|
||||
|
||||
ShopDirectMerchant getMainMerchant(Long shopId);
|
||||
}
|
||||
@@ -42,5 +42,6 @@ public class OrderDetailSmallVO implements Serializable {
|
||||
private LocalDateTime dishOutTime;
|
||||
private LocalDateTime foodServeTime;
|
||||
private Integer isTemporary;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -133,11 +133,6 @@ public class OrderInfoVo implements Serializable {
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 打印状态 Json格式
|
||||
* [{"id":"124","name":"111","time":"2025-12-29 11:05:18"},{"id":"111","name":"标签","time":"2025-12-29 11:05:30"}]
|
||||
*/
|
||||
private String printStatus;
|
||||
|
||||
/**
|
||||
* 是否使用了霸王餐
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.czg.pay;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 支付宝授权信息
|
||||
* @author yjjie
|
||||
* @date 2026/1/9 11:31
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AlipayAuthInfoDto {
|
||||
|
||||
/**
|
||||
* 授权商户的user_id
|
||||
*/
|
||||
@JSONField(name = "user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 授权商户的open_id
|
||||
*/
|
||||
@JSONField(name = "open_id")
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
* 授权商户的appid
|
||||
*/
|
||||
@JSONField(name = "auth_app_id")
|
||||
private String authAppId;
|
||||
|
||||
/**
|
||||
* 应用授权令牌
|
||||
*/
|
||||
@JSONField(name = "app_auth_token")
|
||||
private String appAuthToken;
|
||||
|
||||
/**
|
||||
* 应用授权令牌有效期
|
||||
*/
|
||||
@JSONField(name = "expires_in")
|
||||
private String expiresIn;
|
||||
|
||||
/**
|
||||
* 刷新令牌
|
||||
*/
|
||||
@JSONField(name = "app_refresh_token")
|
||||
private String appRefreshToken;
|
||||
|
||||
/**
|
||||
* 刷新令牌的有效时间
|
||||
*/
|
||||
@JSONField(name = "re_expires_in")
|
||||
private String reExpiresIn;
|
||||
|
||||
/**
|
||||
* 签约单号
|
||||
*/
|
||||
@JSONField(name = "order_no")
|
||||
private String orderNo;
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
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,17 +0,0 @@
|
||||
package com.czg.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 原生支付参数
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class NativeMerchantDTO {
|
||||
private String wechatMerchantId;
|
||||
private String alipayMerchantId;
|
||||
/**
|
||||
* 支付宝 授权信息解析
|
||||
*/
|
||||
private AlipayAuthInfoDto alipayAuthInfo;
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
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,39 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
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;
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package com.czg.system.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 银行账户信息表 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2026-01-06
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("sys_bank_info")
|
||||
public class SysBankInfo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private BigInteger id;
|
||||
|
||||
/**
|
||||
* 银行名称
|
||||
*/
|
||||
private String accountBank;
|
||||
|
||||
/**
|
||||
* 银行数字编码
|
||||
*/
|
||||
private Integer accountBankCode;
|
||||
|
||||
/**
|
||||
* 银行别名
|
||||
*/
|
||||
private String bankAlias;
|
||||
|
||||
/**
|
||||
* 银行别名编码
|
||||
*/
|
||||
private String bankAliasCode;
|
||||
|
||||
/**
|
||||
* 是否需要支行信息
|
||||
*/
|
||||
private Boolean needBankBranch;
|
||||
|
||||
/**
|
||||
* 银行英文编码
|
||||
*/
|
||||
private String bankCode;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package com.czg.system.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 类目信息表 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2026-01-06
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("sys_category_info")
|
||||
public class SysCategoryInfo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private BigInteger id;
|
||||
|
||||
/**
|
||||
* 一级类目code
|
||||
*/
|
||||
private String firstCategoryCode;
|
||||
/**
|
||||
* 一级类目
|
||||
*/
|
||||
private String firstCategory;
|
||||
|
||||
/**
|
||||
* 二级类目code
|
||||
*/
|
||||
private String secondCategoryCode;
|
||||
|
||||
/**
|
||||
* 二级类目
|
||||
*/
|
||||
private String secondCategory;
|
||||
|
||||
/**
|
||||
* 适用商家说明
|
||||
*/
|
||||
private String applicableMerchant;
|
||||
|
||||
/**
|
||||
* 特殊资质(为空则无需提供)
|
||||
*/
|
||||
private String specialQualification;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.czg.system.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 行政区表 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2026-01-06
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("sys_region")
|
||||
public class SysRegion implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 区域编码
|
||||
*/
|
||||
@Id
|
||||
private String regionId;
|
||||
|
||||
/**
|
||||
* 上级区域编码
|
||||
*/
|
||||
private String parentRegionId;
|
||||
|
||||
/**
|
||||
* 区域级别:1=国家,2=省,3=市,4=县
|
||||
*/
|
||||
@Id
|
||||
private Integer regionLevel;
|
||||
|
||||
/**
|
||||
* 区域中文全称
|
||||
*/
|
||||
private String regionName;
|
||||
|
||||
/**
|
||||
* 区域拼音
|
||||
*/
|
||||
private String regionPinyin;
|
||||
|
||||
/**
|
||||
* 全级别名称(如“中国|北京|北京市|东城区)
|
||||
*/
|
||||
private String fullName;
|
||||
/**
|
||||
* 微信区域编码
|
||||
*/
|
||||
private String wxProvinceCode;
|
||||
|
||||
/**
|
||||
* 子级区域
|
||||
*/
|
||||
@Column(ignore = true)
|
||||
private List<SysRegion> children;
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.czg.system.service;
|
||||
|
||||
import com.czg.BaseQueryParam;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.system.entity.SysBankInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 银行账户信息表 服务层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2026-01-06
|
||||
*/
|
||||
public interface SysBankInfoService extends IService<SysBankInfo> {
|
||||
|
||||
Page<SysBankInfo> bankInfoList(BaseQueryParam param, String bankName);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.czg.system.service;
|
||||
|
||||
import com.czg.system.vo.SysCategoryInfoVO;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.system.entity.SysCategoryInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 类目信息表 服务层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2026-01-06
|
||||
*/
|
||||
public interface SysCategoryInfoService extends IService<SysCategoryInfo> {
|
||||
|
||||
|
||||
List<SysCategoryInfoVO> categoryList();
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.czg.system.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.system.entity.SysRegion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 行政区表 服务层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2026-01-06
|
||||
*/
|
||||
public interface SysRegionService extends IService<SysRegion> {
|
||||
|
||||
List<SysRegion> regionList();
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.czg.system.vo;
|
||||
|
||||
import com.czg.system.entity.SysCategoryInfo;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类目信息表 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2026-01-06
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysCategoryInfoVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 一级类目
|
||||
*/
|
||||
private String firstCategory;
|
||||
|
||||
private List<SysCategoryInfo> child;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.czg.constant;
|
||||
|
||||
/**
|
||||
* 支付渠道常量
|
||||
* @author ww
|
||||
*/
|
||||
public interface PayChannelCst {
|
||||
/**
|
||||
* 聚合支付
|
||||
* 对应 类 PolyPay
|
||||
*/
|
||||
String POLY = "poly";
|
||||
/**
|
||||
* 原生支付
|
||||
* 对应 类 NativePay
|
||||
*/
|
||||
String NATIVE = "native";
|
||||
}
|
||||
@@ -59,8 +59,4 @@ public class CzgResult<T> implements Serializable {
|
||||
public static <T> CzgResult<T> failure(CzgRespCode respCode) {
|
||||
return new CzgResult<>(respCode.getCode(), respCode.getMsg(), null);
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return code == 200;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
<pinyin.version>2.5.1</pinyin.version>
|
||||
<IJPay.version>2.9.10</IJPay.version>
|
||||
<netty.version>4.1.128.Final</netty.version>
|
||||
<wechatpay.version>0.2.17</wechatpay.version>
|
||||
<apipay-v3.version>3.1.65.ALL</apipay-v3.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
@@ -270,18 +268,6 @@
|
||||
<artifactId>netty-codec-mqtt</artifactId>
|
||||
<version>${netty.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.wechatpay-apiv3</groupId>
|
||||
<artifactId>wechatpay-java</artifactId>
|
||||
<version>${wechatpay.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java-v3</artifactId>
|
||||
<version>${apipay-v3.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?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-sdk</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>aggregation-pay</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>聚合支付</name>
|
||||
|
||||
|
||||
<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.github.wechatpay-apiv3</groupId>
|
||||
<artifactId>wechatpay-java</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java-v3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ocr_api20210707</artifactId>
|
||||
<version>3.1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,493 +0,0 @@
|
||||
package com.czg;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.dto.req.*;
|
||||
import com.czg.dto.resp.*;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.third.alipay.AlipayEntryManager;
|
||||
import com.czg.third.alipay.AlipayIsvEntryManager;
|
||||
import com.czg.third.wechat.WechatEntryManager;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.AsyncTaskExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 进件管理
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2026/1/6 13:56
|
||||
*/
|
||||
public class EntryManager {
|
||||
|
||||
/**
|
||||
* 查询银行支行列表
|
||||
*
|
||||
* @param province 省份 陕西省
|
||||
* @param city 城市 西安市
|
||||
* @param instId 顶级机构ID CMB
|
||||
*/
|
||||
public static List<BankBranchDto> queryBankBranchList(String province, String city, String instId) {
|
||||
return AlipayEntryManager.queryBankBranchList(null, instId, province, city);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询银行支行列表
|
||||
* 走微信查询
|
||||
*
|
||||
* @param bankAliceCode 银行代码
|
||||
* @param cityCode 城市编码
|
||||
*/
|
||||
public static WechatBankBranchRespDto queryBankBranchList(String bankAliceCode, String cityCode) {
|
||||
return WechatEntryManager.queryBankBranchList(null, bankAliceCode, cityCode, 0, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询微信进件状态
|
||||
*
|
||||
* @param merchantCode 商户编号, 进件时返回的批次号 {@link EntryRespDto#wechatApplyId}
|
||||
* @return 进件状态
|
||||
*/
|
||||
public static QueryStatusResp queryWechatEntryStatus(String merchantCode) {
|
||||
return WechatEntryManager.queryMerchantEntryStatus(null, merchantCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询支付宝进件状态
|
||||
*
|
||||
* @param batchNo 商户编号, 进件时返回的批次号 {@link EntryRespDto#alipayOrderId}
|
||||
* @return 进件状态
|
||||
*/
|
||||
public static QueryStatusResp queryAlipayEntryStatus(String batchNo) {
|
||||
return AlipayIsvEntryManager.queryMerchantBatchStatus(null, batchNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 进件
|
||||
* 请先执行:
|
||||
* 1. {@link com.czg.EntryManager#verifyEntryParam(AggregateMerchantDto)} 验证进件参数
|
||||
* 2. {@link com.czg.EntryManager#uploadParamImage(AggregateMerchantDto)} 上传图片至第三方
|
||||
*
|
||||
* @param reqDto 进件参数
|
||||
* @param platform 平台 {@link com.czg.PayCst.Platform}
|
||||
*/
|
||||
public static EntryRespDto entryMerchant(AggregateMerchantDto reqDto, String... platform) {
|
||||
List<Supplier<EntryThirdRespDto>> tasks = new ArrayList<>();
|
||||
|
||||
if (platform == null || platform.length == 0) {
|
||||
platform = new String[]{PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY};
|
||||
}
|
||||
|
||||
if (ArrayUtil.contains(platform, PayCst.Platform.WECHAT)) {
|
||||
tasks.add(() -> WechatEntryManager.entryMerchant(null, reqDto));
|
||||
}
|
||||
if (ArrayUtil.contains(platform, PayCst.Platform.ALIPAY)) {
|
||||
tasks.add(() -> AlipayIsvEntryManager.entryMerchant(null, reqDto));
|
||||
}
|
||||
|
||||
// 执行所有任务
|
||||
List<AsyncTaskExecutor.TaskResult<EntryThirdRespDto>> results = AsyncTaskExecutor.executeAll(tasks);
|
||||
|
||||
return getEntryRespDto(results);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static EntryRespDto getEntryRespDto(List<AsyncTaskExecutor.TaskResult<EntryThirdRespDto>> results) {
|
||||
EntryRespDto entryRespDto = new EntryRespDto();
|
||||
for (AsyncTaskExecutor.TaskResult<EntryThirdRespDto> result : results) {
|
||||
// 合并两个进件结果
|
||||
EntryThirdRespDto respDto = result.result();
|
||||
if (PayCst.Platform.WECHAT.equals(respDto.getPlatform())) {
|
||||
entryRespDto.setWechatApplyId(respDto.getEntryId());
|
||||
entryRespDto.setWechatStatus(respDto.getStatus());
|
||||
entryRespDto.setWechatErrorMsg(respDto.getErrorMsg());
|
||||
} else if (PayCst.Platform.ALIPAY.equals(respDto.getPlatform())) {
|
||||
entryRespDto.setAlipayOrderId(respDto.getEntryId());
|
||||
entryRespDto.setAlipayStatus(respDto.getStatus());
|
||||
entryRespDto.setAlipayErrorMsg(respDto.getErrorMsg());
|
||||
entryRespDto.setAlipayAuthInfo(respDto.getAlipayAuthInfo());
|
||||
}
|
||||
}
|
||||
return entryRespDto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片至第三方
|
||||
* 请先执行 {@link com.czg.EntryManager#verifyEntryParam(AggregateMerchantDto)} 验证进件参数
|
||||
*
|
||||
* @param reqDto 进件参数
|
||||
*/
|
||||
public static void uploadParamImage(AggregateMerchantDto reqDto) {
|
||||
List<Supplier<Void>> tasks = new ArrayList<>();
|
||||
|
||||
MerchantBaseInfoDto baseInfo = reqDto.getMerchantBaseInfo();
|
||||
// 联系人身份证反面
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(baseInfo.getContactIdCardBackPic());
|
||||
return null;
|
||||
});
|
||||
// 联系人身份证正面
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(baseInfo.getContactIdCardFrontPic());
|
||||
return null;
|
||||
});
|
||||
|
||||
LegalPersonInfoDto legalPersonInfo = reqDto.getLegalPersonInfo();
|
||||
// 法人身份证反面
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(legalPersonInfo.getIdCardBackPic());
|
||||
return null;
|
||||
});
|
||||
// 法人身份证正面
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(legalPersonInfo.getIdCardFrontPic());
|
||||
return null;
|
||||
});
|
||||
// 法人手持身份证
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(legalPersonInfo.getIdCardHandPic());
|
||||
return null;
|
||||
});
|
||||
|
||||
BusinessLicenceInfoDto businessLicenceInfo = reqDto.getBusinessLicenceInfo();
|
||||
// 营业执照
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(businessLicenceInfo.getLicensePic());
|
||||
return null;
|
||||
});
|
||||
|
||||
SettlementInfoDto settlementInfo = reqDto.getSettlementInfo();
|
||||
// 银行卡背面
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(settlementInfo.getBankCardBackPic());
|
||||
return null;
|
||||
});
|
||||
// 银行卡正面
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(settlementInfo.getBankCardFrontPic());
|
||||
return null;
|
||||
});
|
||||
// 开户许可证
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(settlementInfo.getOpenAccountLicencePic());
|
||||
return null;
|
||||
});
|
||||
// 非法人手持授权函
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(settlementInfo.getNoLegalHandSettleAuthPic());
|
||||
return null;
|
||||
});
|
||||
// 非法人授权函
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(settlementInfo.getNoLegalSettleAuthPic());
|
||||
return null;
|
||||
});
|
||||
// 非法人身份证反面
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(settlementInfo.getNoLegalIdCardBackPic());
|
||||
return null;
|
||||
});
|
||||
// 非法人身份证正面
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(settlementInfo.getNoLegalIdCardFrontPic());
|
||||
return null;
|
||||
});
|
||||
|
||||
StoreInfoDto storeInfo = reqDto.getStoreInfo();
|
||||
// 店内图片
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(storeInfo.getInsidePic());
|
||||
return null;
|
||||
});
|
||||
// 门店门头图片
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(storeInfo.getDoorPic());
|
||||
return null;
|
||||
});
|
||||
// 收银台图片
|
||||
tasks.add(() -> {
|
||||
uploadImageToThird(storeInfo.getCashierDeskPic());
|
||||
return null;
|
||||
});
|
||||
|
||||
// 执行所有任务
|
||||
AsyncTaskExecutor.executeAll(tasks);
|
||||
}
|
||||
|
||||
private static void uploadImageToThird(ImageDto dto) {
|
||||
if (dto != null && StrUtil.isNotBlank(dto.getUrl())) {
|
||||
if (StrUtil.isBlank(dto.getWechatId())) {
|
||||
String image = WechatEntryManager.uploadImage(null, dto.getUrl());
|
||||
dto.setWechatId(image);
|
||||
}
|
||||
// if (StrUtil.isBlank(dto.getAlipayId())) {
|
||||
// String image = AlipayEntryManager.uploadImage(null, dto.getUrl());
|
||||
// dto.setAlipayId(image);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证进件参数
|
||||
*
|
||||
* @param reqDto 进件参数
|
||||
*/
|
||||
public static void verifyEntryParam(AggregateMerchantDto reqDto) {
|
||||
AssertUtil.isBlank(reqDto.getMerchantCode(), "商户编号不能为空");
|
||||
|
||||
AssertUtil.isNull(reqDto.getMerchantBaseInfo(), "商户基础信息不能为空");
|
||||
|
||||
MerchantBaseInfoDto baseInfo = reqDto.getMerchantBaseInfo();
|
||||
AssertUtil.isBlank(baseInfo.getUserType(), "商户类型不能为空");
|
||||
AssertUtil.isBlank(baseInfo.getShortName(), "商户简称不能为空");
|
||||
AssertUtil.isBlank(baseInfo.getMccCode(), "商户行业编码不能为空");
|
||||
AssertUtil.isBlank(baseInfo.getAlipayAccount(), "支付宝账号不能为空");
|
||||
AssertUtil.isBlank(baseInfo.getContactPersonType(), "联系人类型不能为空");
|
||||
if (!PayCst.ContactPersonType.SUPER.equals(baseInfo.getContactPersonType()) && !PayCst.ContactPersonType.LEGAL.equals(baseInfo.getContactPersonType())) {
|
||||
throw new CzgException("联系人类型错误");
|
||||
}
|
||||
if (PayCst.ContactPersonType.SUPER.equals(baseInfo.getContactPersonType())) {
|
||||
AssertUtil.isBlank(baseInfo.getCertType(), "证件类型不能为空");
|
||||
if (!"0".equals(baseInfo.getCertType())) {
|
||||
throw new CzgException("证件类型错误");
|
||||
}
|
||||
AssertUtil.isBlank(baseInfo.getContactName(), "联系人姓名不能为空");
|
||||
AssertUtil.isBlank(baseInfo.getContactPersonId(), "联系人身份证号不能为空");
|
||||
AssertUtil.isBlank(baseInfo.getContactPhone(), "联系人电话不能为空");
|
||||
AssertUtil.isBlank(baseInfo.getContactAddr(), "联系人地址不能为空");
|
||||
AssertUtil.isBlank(baseInfo.getContactEmail(), "联系人邮箱不能为空");
|
||||
AssertUtil.isBlank(baseInfo.getContactPersonIdStartDate(), "联系人身份证开始日期不能为空");
|
||||
AssertUtil.isBlank(baseInfo.getContactPersonIdEndDate(), "联系人身份证到期日期不能为空");
|
||||
AssertUtil.isNull(baseInfo.getContactIdCardBackPic(), "联系人身份证反面不能为空");
|
||||
AssertUtil.isBlank(baseInfo.getContactIdCardBackPic().getUrl(), "联系人身份证反面不能为空");
|
||||
AssertUtil.isNull(baseInfo.getContactIdCardFrontPic(), "联系人身份证正面不能为空");
|
||||
AssertUtil.isBlank(baseInfo.getContactIdCardFrontPic().getUrl(), "联系人身份证正面不能为空");
|
||||
}
|
||||
AssertUtil.isBlank(baseInfo.getCompanyChildType(), "商户类型不能为空");
|
||||
if ("0".equals(baseInfo.getUserType())) {
|
||||
// 个体商户, 暂无其他校验
|
||||
} else if ("1".equals(baseInfo.getUserType())) {
|
||||
if (!"1".equals(baseInfo.getCompanyChildType()) && !"2".equals(baseInfo.getCompanyChildType()) && !"3".equals(baseInfo.getCompanyChildType())) {
|
||||
throw new CzgException("商户类型错误");
|
||||
}
|
||||
} else {
|
||||
throw new CzgException("商户类型错误");
|
||||
}
|
||||
|
||||
AssertUtil.isNull(reqDto.getBusinessLicenceInfo(), "营业执照信息不能为空");
|
||||
BusinessLicenceInfoDto businessLicenceInfo = reqDto.getBusinessLicenceInfo();
|
||||
AssertUtil.isBlank(businessLicenceInfo.getLicenceNo(), "营业执照编号不能为空");
|
||||
AssertUtil.isBlank(businessLicenceInfo.getLicenceName(), "营业执照名称不能为空");
|
||||
AssertUtil.isBlank(businessLicenceInfo.getRegisteredAddress(), "营业执照注册地址不能为空");
|
||||
AssertUtil.isBlank(businessLicenceInfo.getLicenceStartDate(), "营业执照开始日期不能为空");
|
||||
AssertUtil.isBlank(businessLicenceInfo.getLicenceEndDate(), "营业执照到期日期不能为空");
|
||||
AssertUtil.isNull(businessLicenceInfo.getLicensePic(), "营业执照名称不能为空");
|
||||
AssertUtil.isBlank(businessLicenceInfo.getLicensePic().getUrl(), "营业执照名称不能为空");
|
||||
|
||||
|
||||
AssertUtil.isNull(reqDto.getLegalPersonInfo(), "法人信息不能为空");
|
||||
LegalPersonInfoDto legalPersonInfo = reqDto.getLegalPersonInfo();
|
||||
AssertUtil.isBlank(legalPersonInfo.getLegalPersonName(), "法人姓名不能为空");
|
||||
AssertUtil.isBlank(legalPersonInfo.getLegalPersonId(), "法人身份证号不能为空");
|
||||
AssertUtil.isBlank(legalPersonInfo.getLegalIdPersonStartDate(), "法人身份证开始日期不能为空");
|
||||
AssertUtil.isBlank(legalPersonInfo.getLegalPersonIdEndDate(), "法人身份证到期日期不能为空");
|
||||
AssertUtil.isBlank(legalPersonInfo.getLegalPersonPhone(), "法人电话不能为空");
|
||||
AssertUtil.isBlank(legalPersonInfo.getLegalPersonEmail(), "法人邮箱不能为空");
|
||||
AssertUtil.isBlank(legalPersonInfo.getLegalGender(), "法人性别不能为空");
|
||||
AssertUtil.isBlank(legalPersonInfo.getLegalAddress(), "法人地址不能为空");
|
||||
AssertUtil.isNull(legalPersonInfo.getIdCardHandPic(), "法人身份证手持不能为空");
|
||||
AssertUtil.isBlank(legalPersonInfo.getIdCardHandPic().getUrl(), "法人身份证手持不能为空");
|
||||
AssertUtil.isNull(legalPersonInfo.getIdCardFrontPic(), "法人身份证正面不能为空");
|
||||
AssertUtil.isBlank(legalPersonInfo.getIdCardFrontPic().getUrl(), "法人身份证正面不能为空");
|
||||
AssertUtil.isNull(legalPersonInfo.getIdCardBackPic(), "法人身份证反面不能为空");
|
||||
AssertUtil.isBlank(legalPersonInfo.getIdCardBackPic().getUrl(), "法人身份证反面不能为空");
|
||||
|
||||
AssertUtil.isNull(reqDto.getStoreInfo(), "门店信息不能为空");
|
||||
StoreInfoDto storeInfo = reqDto.getStoreInfo();
|
||||
AssertUtil.isBlank(storeInfo.getMercProvCode(), "门店省ID不能为空");
|
||||
AssertUtil.isBlank(storeInfo.getMercCityCode(), "门店市ID不能为空");
|
||||
AssertUtil.isBlank(storeInfo.getMercAreaCode(), "门店区ID不能为空");
|
||||
AssertUtil.isBlank(storeInfo.getMercProv(), "门店省不能为空");
|
||||
AssertUtil.isBlank(storeInfo.getMercCity(), "门店市不能为空");
|
||||
AssertUtil.isBlank(storeInfo.getMercArea(), "门店区不能为空");
|
||||
AssertUtil.isBlank(storeInfo.getBusinessAddress(), "门店营业地址不能为空");
|
||||
AssertUtil.isNull(storeInfo.getInsidePic(), "门店营业地址不能为空");
|
||||
AssertUtil.isBlank(storeInfo.getInsidePic().getUrl(), "门店营业地址不能为空");
|
||||
AssertUtil.isNull(storeInfo.getDoorPic(), "门店门头照不能为空");
|
||||
AssertUtil.isBlank(storeInfo.getDoorPic().getUrl(), "门店门头照不能为空");
|
||||
AssertUtil.isNull(storeInfo.getCashierDeskPic(), "门店收银台照不能为空");
|
||||
AssertUtil.isBlank(storeInfo.getCashierDeskPic().getUrl(), "门店收银台照不能为空");
|
||||
|
||||
|
||||
AssertUtil.isNull(reqDto.getSettlementInfo(), "结算信息不能为空");
|
||||
SettlementInfoDto settlementInfo = reqDto.getSettlementInfo();
|
||||
AssertUtil.isBlank(settlementInfo.getSettlementCardNo(), "结算卡号不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getSettlementName(), "结算账户户名不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getBankName(), "结算银行名称不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getBankInstId(), "结算银行缩写不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getBankMobile(), "结算银行预留手机号不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getSettlementCardType(), "结算卡类型不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getOpenAccProvinceId(), "结算开户行省ID不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getOpenAccCityId(), "结算开户行市ID不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getOpenAccAreaId(), "结算开户行区ID不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getOpenAccProvince(), "结算开户行省不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getOpenAccCity(), "结算开户行市不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getOpenAccArea(), "结算开户行区不能为空");
|
||||
if ("11".equals(settlementInfo.getSettlementCardType())) {
|
||||
// 11 对私借记卡(结算卡正面照、结算卡反面照图片必传)
|
||||
AssertUtil.isNull(settlementInfo.getBankCardFrontPic(), "结算卡正面照不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getBankCardFrontPic().getUrl(), "结算卡正面照不能为空");
|
||||
AssertUtil.isNull(settlementInfo.getBankCardBackPic(), "结算卡反面照不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getBankCardBackPic().getUrl(), "结算卡反面照不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getSettlementType(), "结算类型不能为空");
|
||||
if ("0".equals(settlementInfo.getSettlementType())) {
|
||||
// 非法人结算
|
||||
AssertUtil.isBlank(settlementInfo.getNoLegalName(), "非法人姓名不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getNoLegalId(), "非法人身份证号不能为空");
|
||||
AssertUtil.isNull(settlementInfo.getNoLegalIdCardFrontPic(), "非法人身份证正面不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getNoLegalIdCardFrontPic().getUrl(), "非法人身份证正面不能为空");
|
||||
AssertUtil.isNull(settlementInfo.getNoLegalIdCardBackPic(), "非法人身份证反面不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getNoLegalIdCardBackPic().getUrl(), "非法人身份证反面不能为空");
|
||||
AssertUtil.isNull(settlementInfo.getNoLegalSettleAuthPic(), "非法人结算授权书不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getNoLegalSettleAuthPic().getUrl(), "非法人结算授权书不能为空");
|
||||
} else if ("1".equals(settlementInfo.getSettlementType())) {
|
||||
// 法人结算 暂无处理
|
||||
} else {
|
||||
throw new CzgException("结算类型错误");
|
||||
}
|
||||
} else if ("21".equals(settlementInfo.getSettlementCardType())) {
|
||||
// 21 对公借记卡(只须结算卡正面照片)
|
||||
AssertUtil.isNull(settlementInfo.getOpenAccountLicencePic(), "开户许可证不能为空");
|
||||
AssertUtil.isBlank(settlementInfo.getOpenAccountLicencePic().getUrl(), "开户许可证不能为空");
|
||||
} else {
|
||||
throw new CzgException("结算卡类型错误");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// WechatBankBranchRespDto respDto = queryBankBranchList("1000009547", "931");
|
||||
// System.out.println(respDto);
|
||||
|
||||
|
||||
AggregateMerchantDto merchantDto = getTestMerchantEntryData();
|
||||
//
|
||||
verifyEntryParam(merchantDto);
|
||||
uploadParamImage(merchantDto);
|
||||
//
|
||||
// verifyEntryParam(merchantDto);
|
||||
// uploadParamImage(merchantDto);
|
||||
//// System.out.println(merchantDto);
|
||||
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.WECHAT);
|
||||
// entryMerchant(merchantDto, PayCst.Platform.ALIPAY);
|
||||
// entryMerchant(merchantDto, PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY);
|
||||
System.out.println(respDto);
|
||||
}
|
||||
|
||||
private static AggregateMerchantDto getTestMerchantEntryData() {
|
||||
AggregateMerchantDto merchantDto = new AggregateMerchantDto();
|
||||
merchantDto.setMerchantCode("CZG20260112151202011");
|
||||
|
||||
String baseInfo = "{\"alipayAccount\":\"18191655977\",\"certType\":\"0\",\"companyChildType\":\"1\",\"contactAddr\":\"西安市沣东新城石化大道西段106号沣东科技园5号楼1层5-037室\",\"contactEmail\":\"892675422@qq.com\",\"contactIdCardBackPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/ce731859ee644df8a4a46104b49c7696.png\",\"wechatId\":\"V1_S-iU_YpBpSKoSZFhQw3plh53G4PXHmNlhi1s88_VTk7A943tAxrkIcKErRcpFPkxG7vkMzhkT4ecN3IWxv71JwLJOzY9eQhmv6giwKWUAjk\"},\"contactIdCardFrontPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/e0d259f9fbcf4897b7f93f3f7d1b8e9a.png\",\"wechatId\":\"V1_oYXFrsrx4sZqiHXURjDBMB53G4PXHmPB0jH4yl2JSowqJDinBqRYIZmHrRcpFPkxsGFO-6Ci3dGvLAs-X2g2DQLJOzY9eQhmv6giwKWUAjk\"},\"contactName\":\"\",\"contactPersonId\":\"612501199212187875\",\"contactPersonIdEndDate\":\"2039-02-01\",\"contactPersonIdStartDate\":\"2019-02-01\",\"contactPersonType\":\"LEGAL\",\"contactPhone\":\"18191655977\",\"mccCode\":\"A0001_B0001\",\"shortName\":\"菲慕斯博\",\"userType\":\"1\"}";
|
||||
merchantDto.setMerchantBaseInfo(JSONObject.parseObject(baseInfo, MerchantBaseInfoDto.class));
|
||||
|
||||
String legalPersonInfo = "{\"idCardBackPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/bb0f77b0b3404bbd9975a4f8497494df.png\",\"wechatId\":\"V1_Kt7wB6u_YhTp_V97CU_V_x53G4PXHmOeC1YpTSt8JenBIbhCzXjNIZWHrRcpFPkxHwsAu6WQfWU6BYJ3glMBnALJOzY9eQhmv6giwKWUAjk\"},\"idCardFrontPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/196a6f37c5954fc395d621e5b0289cb5.png\",\"wechatId\":\"V1__G9UoJplQHSY_ychzdk7QR53G4PXHmMm845pnkw_19i0CeVtQ34dIbOHrRcpFPkxsIEMvoVq19SdOFHTsw6b3wLJOzY9eQhmv6giwKWUAjk\"},\"idCardHandPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/eaa5e0f9352d4e77bbf5fa133ed54564.jpg\",\"wechatId\":\"V1_mWQpc12PTPL7P7kkdUOR6h53G4PXHmPbBEOZTTwh_KJ8RdecGr9kIZuGrRcpFPkx-jdQCaZuUWIQRmxr8pm-7QLJOzY9eQhmv6giwKWUAjk\"},\"legalAddress\":\"西安市沣东新城石化大道西段106号沣东科技园5号楼1层5-037室\",\"legalGender\":\"0\",\"legalIdPersonStartDate\":\"2019-02-01\",\"legalPersonEmail\":\"892675422@qq.com\",\"legalPersonId\":\"612501199212187875\",\"legalPersonIdEndDate\":\"2039-02-01\",\"legalPersonName\":\"蔺佳佳\",\"legalPersonPhone\":\"18191655977\"}";
|
||||
merchantDto.setLegalPersonInfo(JSONObject.parseObject(legalPersonInfo, LegalPersonInfoDto.class));
|
||||
|
||||
String businessInfo = "{\"licenceEndDate\":\"2099-12-31\",\"licenceName\":\"西安菲慕斯博市场营销策划有限公司\",\"licenceNo\":\"91610131MA6TXACP28\",\"licenceStartDate\":\"2021-02-25\",\"licensePic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/81b60f3a25494c8586159a193389aa2d.jpg\",\"wechatId\":\"V1_-Vbealekn9NZb3mT37ggpB53G4PXHmNEw41rkFGHdR1KJkYqgc5QId-HrRcpFPkxJLlN6u4U4s24lzVyTVoxPgLJOzY9eQhmv6giwKWUAjk\"},\"registeredAddress\":\"陕西省西安市高新区科技路37号海星城市广场B座2002-080室\"}";
|
||||
merchantDto.setBusinessLicenceInfo(JSONObject.parseObject(businessInfo, BusinessLicenceInfoDto.class));
|
||||
|
||||
String storeInfo = "{\"businessAddress\":\"西安市沣东新城石化大道西段106号沣东科技园5号楼1层5-037室\",\"cashierDeskPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/4e52859aac754670aaf9be1c923da827.jpg\",\"wechatId\":\"V1_qFmvcdaX1XSUmknkcwKzMh53G4PXHmNYVJzGUiEs-qE-2ERQMr6XIemErRcpFPkxyCyY2DFU5QIBiaW6WamZmwLJOzY9eQhmv6giwKWUAjk\"},\"doorPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/2c207c6f4a764ad18e501ed10fbfad59.png\",\"wechatId\":\"V1_JPI6iQUmEXiUL2JogtdaJR53G4PXHmO3QpILvqWkLccmvi-vX4OJIdmBrRcpFPkxwNCa-m1w5XissHoA_ynwKQLJOzY9eQhmv6giwKWUAjk\"},\"insidePic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/394b4834698a47e9b75419a5fd7f7de7.jpg\",\"wechatId\":\"V1_djcTvjUKESKADtVCmtLqmR53G4PXHmOLw9uEV3te3o7OebPqjdklIdGBrRcpFPkxy6JbIGyYEZT6XatGXNQ2YQLJOzY9eQhmv6giwKWUAjk\"},\"mercArea\":\"雁塔区\",\"mercAreaCode\":\"610113\",\"mercCity\":\"西安市\",\"mercCityCode\":\"610100\",\"mercProv\":\"陕西省\",\"mercProvCode\":\"610000\"}";
|
||||
merchantDto.setStoreInfo(JSONObject.parseObject(storeInfo, StoreInfoDto.class));
|
||||
|
||||
String settlementInfo = "{\"bankBranchCode\":\"313791000427\",\"bankBranchName\":\"西安银行高新四路支行\",\"bankCardBackPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/3f3bb30f89fd4441985808f4a451c9c7.jpg\",\"wechatId\":\"V1_KAo5J49VNaCiC7twEi6NfB53G4PXHmNqgVl38ZojoETk3a9m_ZLvIaeHrRcpFPkxmQ3bRK2ytADSD8Fe8v-mpALJOzY9eQhmv6giwKWUAjk\"},\"bankCardFrontPic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/413f9170ca1d4f0893e05fd72b5e2b0e.jpg\",\"wechatId\":\"V1_GNhNtE1UYUCeRAuLsxdimR53G4PXHmNn9A4-gDbYgq47MiHxjki-IarByRcpFPkxfqldVa9taQ7W5KtWL35ppwLJOzY9eQhmv6giwKWUAjk\"},\"bankInstId\":\"XAB\",\"bankMobile\":\"18191655977\",\"bankName\":\"其他银行\",\"bankType\":\"\",\"noLegalHandSettleAuthPic\":{\"alipayId\":\"\",\"url\":\"\",\"wechatId\":\"\"},\"noLegalId\":\"\",\"noLegalIdCardBackPic\":{\"alipayId\":\"\",\"url\":\"\",\"wechatId\":\"\"},\"noLegalIdCardFrontPic\":{\"alipayId\":\"\",\"url\":\"\",\"wechatId\":\"\"},\"noLegalName\":\"\",\"noLegalSettleAuthPic\":{\"alipayId\":\"\",\"url\":\"\",\"wechatId\":\"\"},\"openAccArea\":\"雁塔区\",\"openAccAreaId\":\"610113\",\"openAccCity\":\"西安市\",\"openAccCityId\":\"610100\",\"openAccProvince\":\"陕西省\",\"openAccProvinceId\":\"610000\",\"openAccountLicencePic\":{\"alipayId\":\"\",\"url\":\"https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/6e5dca0822f742649ecf1666f91ad1b3.jpg\",\"wechatId\":\"V1_1S62SpAFYecG5T-DC9ewHR53G4PXHmMA49fy0uVVk5j35lE5L5njIfSGrRcpFPkxU9Fm6P6bYLY3t010FYkmAQLJOzY9eQhmv6giwKWUAjk\"},\"settlementCardNo\":\"611011580000054186\",\"settlementCardType\":\"21\",\"settlementName\":\"西安菲慕斯博市场营销策划有限公司\",\"settlementType\":\"1\"}";
|
||||
merchantDto.setSettlementInfo(JSONObject.parseObject(settlementInfo, SettlementInfoDto.class));
|
||||
|
||||
|
||||
// merchantDto.setMerchantCode("20220106000000000001");
|
||||
//
|
||||
// MerchantBaseInfoDto baseInfoDto = new MerchantBaseInfoDto();
|
||||
// baseInfoDto.setUserType("1");
|
||||
// baseInfoDto.setCompanyChildType("1");
|
||||
// baseInfoDto.setShortName("测试商户");
|
||||
// baseInfoDto.setAlipayAccount("1157756119@qq.com");
|
||||
// baseInfoDto.setMccCode("A0001_B0001");
|
||||
// baseInfoDto.setContactPersonType(PayCst.ContactPersonType.SUPER);
|
||||
// baseInfoDto.setContactName("张三");
|
||||
// baseInfoDto.setContactPersonId("110101199001011234");
|
||||
// baseInfoDto.setContactPersonIdStartDate("2021-01-01");
|
||||
// baseInfoDto.setContactPersonIdEndDate("2025-01-01");
|
||||
// baseInfoDto.setContactPhone("13800000000");
|
||||
// baseInfoDto.setContactEmail("1157756119@qq.com");
|
||||
// baseInfoDto.setContactAddr("广东省深圳市南山区");
|
||||
// baseInfoDto.setContactIdCardFrontPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
|
||||
// baseInfoDto.setContactIdCardBackPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
|
||||
// merchantDto.setMerchantBaseInfo(baseInfoDto);
|
||||
//
|
||||
// BusinessLicenceInfoDto businessLicenceInfoDto = new BusinessLicenceInfoDto();
|
||||
// businessLicenceInfoDto.setLicenceName("测试商户");
|
||||
// businessLicenceInfoDto.setLicenceNo("110101199001011234");
|
||||
// businessLicenceInfoDto.setLicenceStartDate("2021-01-01");
|
||||
// businessLicenceInfoDto.setLicenceEndDate("2052-01-01");
|
||||
// businessLicenceInfoDto.setRegisteredAddress("广东省深圳市南山区");
|
||||
// businessLicenceInfoDto.setLicensePic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
|
||||
// merchantDto.setBusinessLicenceInfo(businessLicenceInfoDto);
|
||||
//
|
||||
// LegalPersonInfoDto legalPersonInfoDto = new LegalPersonInfoDto();
|
||||
// legalPersonInfoDto.setLegalPersonName("张三");
|
||||
// legalPersonInfoDto.setLegalPersonId("110101199001011234");
|
||||
// legalPersonInfoDto.setLegalIdPersonStartDate("2021-01-01");
|
||||
// legalPersonInfoDto.setLegalPersonIdEndDate("2055-01-01");
|
||||
// legalPersonInfoDto.setLegalPersonPhone("13800000000");
|
||||
// legalPersonInfoDto.setLegalPersonEmail("1157756119@qq.com");
|
||||
// legalPersonInfoDto.setLegalGender("1");
|
||||
// legalPersonInfoDto.setLegalAddress("广东省深圳市南山区");
|
||||
// legalPersonInfoDto.setIdCardHandPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
|
||||
// legalPersonInfoDto.setIdCardFrontPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
|
||||
// legalPersonInfoDto.setIdCardBackPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
|
||||
// merchantDto.setLegalPersonInfo(legalPersonInfoDto);
|
||||
//
|
||||
// StoreInfoDto storeInfoDto = new StoreInfoDto();
|
||||
// storeInfoDto.setMercProvCode("440000");
|
||||
// storeInfoDto.setMercCityCode("440300");
|
||||
// storeInfoDto.setMercAreaCode("440303");
|
||||
// storeInfoDto.setMercProv("广东省");
|
||||
// storeInfoDto.setMercCity("深圳市");
|
||||
// storeInfoDto.setMercArea("南山区");
|
||||
// storeInfoDto.setBusinessAddress("广东省深圳市南山区");
|
||||
// storeInfoDto.setInsidePic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
|
||||
// storeInfoDto.setDoorPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
|
||||
// storeInfoDto.setCashierDeskPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
|
||||
// merchantDto.setStoreInfo(storeInfoDto);
|
||||
//
|
||||
// SettlementInfoDto settlementInfoDto = new SettlementInfoDto();
|
||||
// settlementInfoDto.setSettlementType("1");
|
||||
// settlementInfoDto.setSettlementCardType("21");
|
||||
// settlementInfoDto.setSettlementName("张三");
|
||||
// settlementInfoDto.setSettlementCardNo("110101199001011234");
|
||||
// settlementInfoDto.setBankMobile("13800000000");
|
||||
// settlementInfoDto.setOpenAccProvinceId("440000");
|
||||
// settlementInfoDto.setOpenAccCityId("440300");
|
||||
// settlementInfoDto.setOpenAccAreaId("440303");
|
||||
// settlementInfoDto.setOpenAccProvince("广东省");
|
||||
// settlementInfoDto.setOpenAccCity("深圳市");
|
||||
// settlementInfoDto.setOpenAccArea("南山区");
|
||||
// settlementInfoDto.setBankName("中国工商银行");
|
||||
// settlementInfoDto.setBankInstId("ICBC");
|
||||
// settlementInfoDto.setBankType("1");
|
||||
// settlementInfoDto.setBankBranchName("广东省深圳市南山区");
|
||||
// settlementInfoDto.setBankBranchCode("440300");
|
||||
// settlementInfoDto.setBankCardFrontPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
|
||||
// settlementInfoDto.setBankCardBackPic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
|
||||
// settlementInfoDto.setOpenAccountLicencePic(new ImageDto("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg"));
|
||||
// merchantDto.setSettlementInfo(settlementInfoDto);
|
||||
|
||||
return merchantDto;
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package com.czg;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.aliyun.ocr_api20210707.models.RecognizeAllTextResponse;
|
||||
import com.aliyun.tea.*;
|
||||
import com.czg.exception.CzgException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
*/
|
||||
@Slf4j
|
||||
public class OcrUtils {
|
||||
/**
|
||||
* 阿里 ocr识别图片
|
||||
* 本接口支持:PNG、JPG、JPEG、BMP、GIF、TIFF、WebP、PDF。
|
||||
* 图片长宽需要大于 15 像素,小于 8192 像素。
|
||||
* 长宽比需要小于 50。长宽均大于 500px。
|
||||
* 图片二进制文件不能超过 10MB。
|
||||
* 图片过大会影响接口响应速度,建议使用小于 1.5M 图片进行识别,
|
||||
*
|
||||
* @param url 图片地址
|
||||
* @param type IdCard 身份证
|
||||
* BankCard 银行卡
|
||||
* BusinessLicense 营业执照
|
||||
* 目前使用的角色为 czg-oss@1413456038175003.onaliyun.com
|
||||
* 需要 AliyunOCRFullAccess 权限
|
||||
* AliyunBSSContractFullAccess 权限
|
||||
* 文档地址 <a href="https://help.aliyun.com/zh/ocr/developer-reference/api-ocr-api-2021-07-07-recognizealltext?spm=a2c4g.11186623.0.0.543669f32I79Gw#api-detail-35">
|
||||
*/
|
||||
public static JSONObject getInfoByImg(String accessKeyId, String accessKeySecret,
|
||||
String url, String type) throws Exception {
|
||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||
.setAccessKeyId(accessKeyId)
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||
.setAccessKeySecret(accessKeySecret);
|
||||
config.endpoint = "ocr-api.cn-hangzhou.aliyuncs.com";
|
||||
|
||||
com.aliyun.ocr_api20210707.Client client = new com.aliyun.ocr_api20210707.Client(config);
|
||||
com.aliyun.ocr_api20210707.models.RecognizeAllTextRequest recognizeAllTextRequest = new com.aliyun.ocr_api20210707.models.RecognizeAllTextRequest()
|
||||
.setUrl(url).setType(type);
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
try {
|
||||
RecognizeAllTextResponse resp = client.recognizeAllTextWithOptions(recognizeAllTextRequest, runtime);
|
||||
return JSONObject.from(resp.body.data);
|
||||
} catch (TeaException error) {
|
||||
// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// // 错误 message
|
||||
// System.out.println(error.getMessage());
|
||||
// // 诊断地址
|
||||
// System.out.println(error.getData().get("Recommend"));
|
||||
// com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
log.error("识别失败, msg: {}", error.getMessage());
|
||||
throw new CzgException(error.getMessage());
|
||||
} catch (Exception error) {
|
||||
// TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// // 错误 message
|
||||
// System.out.println(error.getMessage());
|
||||
// // 诊断地址
|
||||
// System.out.println(error.getData().get("Recommend"));
|
||||
// com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
log.error("识别失败, msg: {}", error.getMessage());
|
||||
throw new CzgException(error.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
package com.czg;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付相关常量
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2026/1/7 09:20
|
||||
*/
|
||||
public interface PayCst {
|
||||
|
||||
/**
|
||||
* 长期有效时间
|
||||
*/
|
||||
String LONG_TERM_DATE = "2099-12-31";
|
||||
|
||||
/**
|
||||
* 支付宝异常信息获取 key
|
||||
*/
|
||||
String ALIPAY_ERROR_MSG_KEY = "message";
|
||||
|
||||
/**
|
||||
* 平台
|
||||
*/
|
||||
class Platform {
|
||||
/**
|
||||
* 微信
|
||||
*/
|
||||
public static final String WECHAT = "WECHAT";
|
||||
/**
|
||||
* 支付宝
|
||||
*/
|
||||
public static final String ALIPAY = "ALIPAY";
|
||||
}
|
||||
|
||||
/**
|
||||
* 进件状态
|
||||
*/
|
||||
class EntryStatus {
|
||||
/**
|
||||
* 待提交
|
||||
*/
|
||||
public static final String WAIT = "WAIT";
|
||||
|
||||
/**
|
||||
* 待处理
|
||||
*/
|
||||
public static final String INIT = "INIT";
|
||||
/**
|
||||
* 审核中
|
||||
*/
|
||||
public static final String AUDIT = "AUDIT";
|
||||
|
||||
/**
|
||||
* 待签约
|
||||
*/
|
||||
public static final String SIGN = "SIGN";
|
||||
|
||||
/**
|
||||
* 已完成
|
||||
*/
|
||||
public static final String FINISH = "FINISH";
|
||||
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
public static final String REJECTED = "REJECTED";
|
||||
|
||||
|
||||
/**
|
||||
* 需要查询的状态列表
|
||||
* 待处理、待签约、待审核的进件
|
||||
*/
|
||||
public static final List<String> NEED_QUERY_LIST = List.of(INIT, AUDIT, SIGN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 联系人类型
|
||||
*/
|
||||
class ContactPersonType {
|
||||
/**
|
||||
* 法人
|
||||
*/
|
||||
public static final String LEGAL = "LEGAL";
|
||||
|
||||
/**
|
||||
* 经办人
|
||||
*/
|
||||
public static final String SUPER = "SUPER";
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package com.czg;
|
||||
|
||||
import com.czg.constants.SystemConstants;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.pay.*;
|
||||
import com.czg.third.alipay.AlipayIsvPayManager;
|
||||
import com.czg.third.wechat.WechatPayManager;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2026/1/9 11:24
|
||||
*/
|
||||
public class PayManager {
|
||||
|
||||
/**
|
||||
* jsapi支付
|
||||
*
|
||||
* @param paramsDto 参数
|
||||
* @return 结果
|
||||
*/
|
||||
public static Map<String, Object> jsapiPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
|
||||
return WechatPayManager.jsapiPay(null, paramsDto, merchantDTO);
|
||||
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
|
||||
return AlipayIsvPayManager.jsapiPay(null, paramsDto, merchantDTO);
|
||||
} else {
|
||||
throw new CzgException("不支持的支付平台");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 条码支付
|
||||
*
|
||||
* @param paramsDto 参数
|
||||
* @return 结果
|
||||
*/
|
||||
public static Map<String, Object> barPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
|
||||
return WechatPayManager.barPay(null, paramsDto, merchantDTO);
|
||||
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
|
||||
return AlipayIsvPayManager.barPay(null, paramsDto, merchantDTO);
|
||||
} else {
|
||||
throw new CzgException("不支持的支付平台");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单状态
|
||||
*/
|
||||
public static QueryOrderRespDTO queryOrderStatus(String platform, String orderNo, NativeMerchantDTO merchantDTO) {
|
||||
if (SystemConstants.PayType.WECHAT.equals(platform)) {
|
||||
return WechatPayManager.queryOrder(null, orderNo, merchantDTO);
|
||||
} else if (SystemConstants.PayType.ALIPAY.equals(platform)) {
|
||||
return AlipayIsvPayManager.queryOrder(null, orderNo, merchantDTO);
|
||||
} else {
|
||||
throw new CzgException("不支持的支付平台");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*/
|
||||
public static RefundRespDTO refund(CzgRefundReq paramsDto, String notifyUrl, NativeMerchantDTO merchantDTO) {
|
||||
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
|
||||
return WechatPayManager.refundOrder(null, paramsDto, notifyUrl, merchantDTO);
|
||||
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
|
||||
return AlipayIsvPayManager.refundOrder(null, paramsDto, notifyUrl, merchantDTO);
|
||||
} else {
|
||||
throw new CzgException("不支持的支付平台");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.czg.dto.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 统一进件
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2026/1/6 10:02
|
||||
*/
|
||||
@Data
|
||||
public class AggregateMerchantDto {
|
||||
/**
|
||||
* 商户Id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 自己生成 CZGyyyy-MM-dd HH:mm:ss.SSS
|
||||
* 商户编号(在当前系统唯一)
|
||||
*/
|
||||
private String merchantCode;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户基础信息
|
||||
*/
|
||||
private MerchantBaseInfoDto merchantBaseInfo;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 法人信息
|
||||
*/
|
||||
private LegalPersonInfoDto legalPersonInfo;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 营业执照信息
|
||||
*/
|
||||
private BusinessLicenceInfoDto businessLicenceInfo;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 门店信息
|
||||
*/
|
||||
private StoreInfoDto storeInfo;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 结算信息
|
||||
*/
|
||||
private SettlementInfoDto settlementInfo;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.czg.dto.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 营业执照信息
|
||||
* @author yjjie
|
||||
* @date 2026/1/6 10:17
|
||||
*/
|
||||
@Data
|
||||
public class BusinessLicenceInfoDto {
|
||||
|
||||
/**
|
||||
* 营业执照全称--非小微必填
|
||||
*/
|
||||
private String licenceName;
|
||||
|
||||
/**
|
||||
* 营业执照号码--非小微必填
|
||||
*/
|
||||
private String licenceNo;
|
||||
|
||||
/**
|
||||
* 营业执照开始日期--非小微必填
|
||||
*/
|
||||
private String licenceStartDate;
|
||||
|
||||
/**
|
||||
* 营业执照结束日期--非小微必填
|
||||
*/
|
||||
private String licenceEndDate;
|
||||
|
||||
/**
|
||||
* 营业执照注册地址--非小微必填
|
||||
*/
|
||||
private String registeredAddress;
|
||||
|
||||
/**
|
||||
* 营业执照
|
||||
*/
|
||||
private ImageDto licensePic;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.czg.dto.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2026/1/6 16:53
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ImageDto {
|
||||
|
||||
/**
|
||||
* 图片 url
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 微信 图片 mediaId
|
||||
*/
|
||||
private String wechatId;
|
||||
|
||||
/**
|
||||
* 支付宝 图片 mediaId
|
||||
*/
|
||||
private String alipayId;
|
||||
|
||||
public ImageDto() {}
|
||||
|
||||
public ImageDto(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.czg.dto.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 法人信息
|
||||
* @author yjjie
|
||||
* @date 2026/1/6 10:13
|
||||
*/
|
||||
@Data
|
||||
public class LegalPersonInfoDto {
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 法人姓名
|
||||
*/
|
||||
private String legalPersonName;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 法人身份证号
|
||||
*/
|
||||
private String legalPersonId;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 法人身份证开始日期
|
||||
*/
|
||||
private String legalIdPersonStartDate;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 法人身份证到期日期
|
||||
*/
|
||||
private String legalPersonIdEndDate;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 法人电话
|
||||
*/
|
||||
private String legalPersonPhone;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 法人邮箱
|
||||
*/
|
||||
private String legalPersonEmail;
|
||||
|
||||
/**
|
||||
* 法人性别(0男 1女)
|
||||
*/
|
||||
private String legalGender;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 法人地址
|
||||
*/
|
||||
private String legalAddress;
|
||||
|
||||
/**
|
||||
* 身份证手持 图片
|
||||
*/
|
||||
private ImageDto idCardHandPic;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 身份证正面
|
||||
*/
|
||||
private ImageDto idCardFrontPic;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 身份证反面
|
||||
*/
|
||||
private ImageDto idCardBackPic;
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
package com.czg.dto.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商户基础信息
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2026/1/6 10:09
|
||||
*/
|
||||
@Data
|
||||
public class MerchantBaseInfoDto {
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户类型
|
||||
* 0: 个体商户;
|
||||
* 1: 企业商户;
|
||||
* 3: 小微商户 暂不支持
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户简称--企业、个体必填
|
||||
*/
|
||||
private String shortName;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 行业编码
|
||||
* 一级类目code_二级类目code
|
||||
* 【示例值】A0001_B0199
|
||||
*/
|
||||
private String mccCode;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 支付宝账号
|
||||
*/
|
||||
private String alipayAccount;
|
||||
|
||||
/**
|
||||
* 联系人类型
|
||||
* LEGAL: 经营者/法定代表人
|
||||
* SUPER: 经办人
|
||||
*/
|
||||
private String contactPersonType = "LEGAL";
|
||||
|
||||
/**
|
||||
* 联系人姓名
|
||||
*/
|
||||
private String contactName;
|
||||
|
||||
/**
|
||||
* 证件类型
|
||||
* 目前只支持身份证 传值:0
|
||||
*/
|
||||
private String certType = "0";
|
||||
|
||||
/**
|
||||
* 联系人身份证号
|
||||
*/
|
||||
private String contactPersonId;
|
||||
|
||||
/**
|
||||
* 联系人身份证开始日期
|
||||
*/
|
||||
private String contactPersonIdStartDate;
|
||||
|
||||
/**
|
||||
* 联系人身份证到期日期
|
||||
*/
|
||||
private String contactPersonIdEndDate;
|
||||
|
||||
/**
|
||||
* 联系人身份证背面
|
||||
*/
|
||||
private ImageDto contactIdCardBackPic;
|
||||
|
||||
/**
|
||||
* 联系人身份证正面
|
||||
*/
|
||||
private ImageDto contactIdCardFrontPic;
|
||||
|
||||
/**
|
||||
* 联系人电话
|
||||
*/
|
||||
private String contactPhone;
|
||||
|
||||
/**
|
||||
* 联系人通讯地址
|
||||
*/
|
||||
private String contactAddr;
|
||||
|
||||
/**
|
||||
* 联系人邮箱
|
||||
*/
|
||||
private String contactEmail;
|
||||
|
||||
/**
|
||||
* 企业类型,1:普通企业,2:事业单位,3:政府机关,4:社会组织
|
||||
*/
|
||||
private String companyChildType = "1";
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
package com.czg.dto.req;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.pay.AlipayAuthInfoDto;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 支付参数
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2026/1/9 11:12
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class PayParamsDto {
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 支付方式
|
||||
* {@link com.czg.PayCst.Platform}
|
||||
*/
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 订单号
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 金额,单位:分
|
||||
*/
|
||||
private Long amount;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 订单标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 回调地址
|
||||
*/
|
||||
private String notifyUrl;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* appId
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 用户唯一标识
|
||||
*/
|
||||
private String openId;
|
||||
|
||||
/**
|
||||
* 【微信必填】
|
||||
* 商户ID
|
||||
*/
|
||||
private String merchantId;
|
||||
|
||||
/**
|
||||
* 【支付宝必填】
|
||||
* 支付参数
|
||||
*/
|
||||
private String payParams;
|
||||
|
||||
/**
|
||||
* 商品描述
|
||||
*/
|
||||
private String body;
|
||||
|
||||
/**
|
||||
* 扩展数据
|
||||
*/
|
||||
private String extData;
|
||||
|
||||
/**
|
||||
* 设备 ip
|
||||
*/
|
||||
private String clientIp;
|
||||
|
||||
/**
|
||||
* 支付条码
|
||||
* 微信:18位纯数字,前缀以10、11、12、13、14、15开头
|
||||
*/
|
||||
private String barCode;
|
||||
|
||||
/**
|
||||
* 支付宝 授权信息解析,不用传
|
||||
*/
|
||||
private AlipayAuthInfoDto alipayAuthInfo;
|
||||
|
||||
public void verifyParams() {
|
||||
AssertUtil.isBlank(platform, "请选择支付方式");
|
||||
AssertUtil.isBlank(orderNo, "订单号不能为空");
|
||||
AssertUtil.isBlank(title, "订单标题不能为空");
|
||||
AssertUtil.isBlank(notifyUrl, "回调地址不能为空");
|
||||
AssertUtil.isBlank(appId, "appId不能为空");
|
||||
AssertUtil.isBlank(openId, "用户唯一标识不能为空");
|
||||
|
||||
if (PayCst.Platform.WECHAT.equals(platform)) {
|
||||
AssertUtil.isBlank(merchantId, "商户ID不能为空");
|
||||
} else if (PayCst.Platform.ALIPAY.equals(platform)) {
|
||||
AssertUtil.isBlank(payParams, "支付参数不能为空");
|
||||
alipayAuthInfo = JSONObject.parseObject(payParams, AlipayAuthInfoDto.class);
|
||||
AssertUtil.isNull(alipayAuthInfo, "支付参数错误");
|
||||
AssertUtil.isBlank(alipayAuthInfo.getAppAuthToken(), "授权信息错误");
|
||||
} else {
|
||||
throw new CzgException("支付平台错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package com.czg.dto.req;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 退款参数
|
||||
* @author yjjie
|
||||
* @date 2026/1/14 11:37
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class RefundParamsDto {
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 平台
|
||||
* {@link com.czg.PayCst.Platform}
|
||||
*/
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 订单号
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 退款单号
|
||||
*/
|
||||
private String refundOrderNo;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 退款金额
|
||||
*/
|
||||
private Long refundAmount;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 订单原金额
|
||||
*/
|
||||
private Long orderAmount;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 退款原因
|
||||
*/
|
||||
private String refundReason;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 退款回调地址
|
||||
*/
|
||||
private String refundNotifyUrl;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 微信商户号
|
||||
*/
|
||||
private String merchantId;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 支付宝授权信息
|
||||
*/
|
||||
private String alipayAuthInfo;
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
package com.czg.dto.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 结算信息
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2026/1/6 10:22
|
||||
*/
|
||||
@Data
|
||||
public class SettlementInfoDto {
|
||||
|
||||
/**
|
||||
* 结算类型 0:非法人结算, 1:法人结算
|
||||
*/
|
||||
private String settlementType;
|
||||
|
||||
/**
|
||||
* 非法人姓名
|
||||
*/
|
||||
private String noLegalName;
|
||||
|
||||
/**
|
||||
* 非法人身份证号码
|
||||
*/
|
||||
private String noLegalId;
|
||||
|
||||
/**
|
||||
* 结算卡类型 必填 11 对私借记卡(结算卡正面照、结算卡反面照图片必传) 21 对公借记卡(只须结算卡正面照片)
|
||||
*/
|
||||
private String settlementCardType;
|
||||
|
||||
/**
|
||||
* 结算账户卡号
|
||||
*/
|
||||
private String settlementCardNo;
|
||||
|
||||
/**
|
||||
* 结算账户户名
|
||||
*/
|
||||
private String settlementName;
|
||||
|
||||
/**
|
||||
* 结算银行预留手机号
|
||||
*/
|
||||
private String bankMobile;
|
||||
|
||||
/**
|
||||
* 开户行省ID
|
||||
*/
|
||||
private String openAccProvinceId;
|
||||
|
||||
/**
|
||||
* 开户行市ID
|
||||
*/
|
||||
private String openAccCityId;
|
||||
|
||||
/**
|
||||
* 开户行区ID
|
||||
*/
|
||||
private String openAccAreaId;
|
||||
|
||||
/**
|
||||
* 开户行省
|
||||
*/
|
||||
private String openAccProvince;
|
||||
|
||||
/**
|
||||
* 开户行市
|
||||
*/
|
||||
private String openAccCity;
|
||||
|
||||
/**
|
||||
* 开户行区
|
||||
*/
|
||||
private String openAccArea;
|
||||
|
||||
/**
|
||||
* 开户行行别名称
|
||||
*/
|
||||
private String bankName;
|
||||
|
||||
/**
|
||||
* 开户行缩写
|
||||
*/
|
||||
private String bankInstId;
|
||||
|
||||
/**
|
||||
* 开户行编号
|
||||
*/
|
||||
private String bankType;
|
||||
|
||||
/**
|
||||
* 支行开户行行别名称
|
||||
*/
|
||||
private String bankBranchName;
|
||||
|
||||
/**
|
||||
* 支行开户行编号
|
||||
*/
|
||||
private String bankBranchCode;
|
||||
|
||||
/**
|
||||
* 银行卡正面
|
||||
*/
|
||||
private ImageDto bankCardFrontPic;
|
||||
|
||||
/**
|
||||
* 银行卡反面
|
||||
*/
|
||||
private ImageDto bankCardBackPic;
|
||||
|
||||
/**
|
||||
* 开户许可证
|
||||
*/
|
||||
private ImageDto openAccountLicencePic;
|
||||
|
||||
/**
|
||||
* 非法人手持结算授权书
|
||||
*/
|
||||
private ImageDto noLegalHandSettleAuthPic;
|
||||
|
||||
/**
|
||||
* 非法人结算授权书
|
||||
*/
|
||||
private ImageDto noLegalSettleAuthPic;
|
||||
|
||||
/**
|
||||
* 非法人身份证正面
|
||||
*/
|
||||
private ImageDto noLegalIdCardFrontPic;
|
||||
|
||||
/**
|
||||
* 非法人身份证反面
|
||||
*/
|
||||
private ImageDto noLegalIdCardBackPic;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package com.czg.dto.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 门店信息
|
||||
* @author yjjie
|
||||
* @date 2026/1/6 10:19
|
||||
*/
|
||||
@Data
|
||||
public class StoreInfoDto {
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户归属省Code
|
||||
*/
|
||||
private String mercProvCode;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户归属市Code
|
||||
*/
|
||||
private String mercCityCode;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户归属区Code
|
||||
*/
|
||||
private String mercAreaCode;
|
||||
|
||||
/**
|
||||
* 商户归属省
|
||||
*/
|
||||
private String mercProv;
|
||||
|
||||
/**
|
||||
* 商户归属市
|
||||
*/
|
||||
private String mercCity;
|
||||
|
||||
/**
|
||||
* 商户归属区
|
||||
*/
|
||||
private String mercArea;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 营业地址
|
||||
*/
|
||||
private String businessAddress;
|
||||
|
||||
/**
|
||||
* 经营场所内设照片
|
||||
*/
|
||||
private ImageDto insidePic;
|
||||
|
||||
/**
|
||||
* 门头照
|
||||
*/
|
||||
private ImageDto doorPic;
|
||||
|
||||
/**
|
||||
* 收银台照片
|
||||
*/
|
||||
private ImageDto cashierDeskPic;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.czg.dto.req;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2025/12/23 21:47
|
||||
*/
|
||||
@Data
|
||||
public class WechatNotifyReqDto {
|
||||
|
||||
private String id;
|
||||
@JSONField(name = "create_time")
|
||||
private String createTime;
|
||||
@JSONField(name = "resource_type")
|
||||
private String resourceType;
|
||||
@JSONField(name = "event_type")
|
||||
private String eventType;
|
||||
private String summary;
|
||||
private Resource resource;
|
||||
|
||||
@Data
|
||||
public static class Resource {
|
||||
@JSONField(name = "resource_type")
|
||||
private String originalType;
|
||||
private String algorithm;
|
||||
private String ciphertext;
|
||||
@JSONField(name = "associated_data")
|
||||
private String associatedData;
|
||||
private String nonce;
|
||||
}
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
package com.czg.dto.req;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.pay.PayNotifyRespDTO;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2025/12/23 22:21
|
||||
*/
|
||||
@Data
|
||||
public class WechatPayNotifyDataDto {
|
||||
|
||||
/**
|
||||
* 公众账号ID
|
||||
*/
|
||||
private String appid;
|
||||
|
||||
/**
|
||||
* 商户号
|
||||
*/
|
||||
private String mchid;
|
||||
|
||||
/**
|
||||
* 商户订单号
|
||||
*/
|
||||
@JSONField(name = "out_trade_no")
|
||||
private String outTradeNo;
|
||||
|
||||
/**
|
||||
* 微信支付订单号
|
||||
*/
|
||||
@JSONField(name = "transaction_id")
|
||||
private String transactionId;
|
||||
|
||||
/**
|
||||
* 交易类型
|
||||
* JSAPI:公众号支付、小程序支付
|
||||
* NATIVE:Native支付
|
||||
* APP:APP支付
|
||||
* MICROPAY:付款码支付
|
||||
* MWEB:H5支付
|
||||
* FACEPAY:刷脸支付
|
||||
*/
|
||||
@JSONField(name = "trade_type")
|
||||
private String tradeType;
|
||||
|
||||
/**
|
||||
* 交易状态
|
||||
* SUCCESS—支付成功
|
||||
* REFUND—转入退款
|
||||
* NOTPAY—未支付
|
||||
* CLOSED—已关闭
|
||||
* REVOKED—已撤销(刷卡支付)
|
||||
* USERPAYING--用户支付中
|
||||
* PAYERROR--支付失败(其他原因,如银行返回失败)
|
||||
*/
|
||||
@JSONField(name = "trade_state")
|
||||
private String tradeState;
|
||||
|
||||
/**
|
||||
* 交易状态描述
|
||||
*/
|
||||
@JSONField(name = "trade_state_desc")
|
||||
private String tradeStateDesc;
|
||||
|
||||
/**
|
||||
* 付款银行
|
||||
*/
|
||||
@JSONField(name = "bank_type")
|
||||
private String bankType;
|
||||
|
||||
/**
|
||||
* 商户数据包
|
||||
*/
|
||||
private String attach;
|
||||
|
||||
/**
|
||||
* 支付完成时间
|
||||
*/
|
||||
@JSONField(name = "success_time")
|
||||
private String successTime;
|
||||
|
||||
/**
|
||||
* 金额
|
||||
*/
|
||||
private Amount amount;
|
||||
|
||||
@Data
|
||||
public static class Amount {
|
||||
/**
|
||||
* 用户支付金额
|
||||
*/
|
||||
@JSONField(name = "payer_total")
|
||||
private Integer payerTotal;
|
||||
|
||||
/**
|
||||
* 货币类型
|
||||
*/
|
||||
private String currency;
|
||||
|
||||
/**
|
||||
* 总金额
|
||||
*/
|
||||
private Integer total;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return "SUCCESS".equals(tradeState);
|
||||
}
|
||||
|
||||
public boolean isClosed() {
|
||||
return "CLOSED".equals(tradeState);
|
||||
}
|
||||
|
||||
public Long getPayAmount() {
|
||||
return Long.valueOf(amount.getTotal());
|
||||
}
|
||||
|
||||
public PayNotifyRespDTO convertToPayNotifyRespDTO() {
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.parse(successTime);
|
||||
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
String time = zonedDateTime.format(outputFormatter);
|
||||
PayNotifyRespDTO respDTO = new PayNotifyRespDTO()
|
||||
.setMchOrderNo(outTradeNo)
|
||||
.setThirdOrderNo(transactionId)
|
||||
.setAmount(getPayAmount())
|
||||
.setPlatform(PayCst.Platform.WECHAT)
|
||||
.setExtData(attach)
|
||||
.setPaySuccessTime(time)
|
||||
.setErrorMsg(tradeStateDesc);
|
||||
|
||||
switch (tradeState) {
|
||||
case "SUCCESS":
|
||||
respDTO.setStatus("TRADE_SUCCESS");
|
||||
break;
|
||||
case "CLOSED":
|
||||
respDTO.setStatus("TRADE_CLOSE");
|
||||
break;
|
||||
case "USERPAYING":
|
||||
respDTO.setStatus("TRADE_AWAIT");
|
||||
break;
|
||||
case "NOTPAY":
|
||||
respDTO.setStatus("TRADE_CANCEL");
|
||||
break;
|
||||
default:
|
||||
respDTO.setStatus("TRADE_FAIL");
|
||||
break;
|
||||
}
|
||||
|
||||
return respDTO;
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package com.czg.dto.resp;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 银行支行信息
|
||||
* @author yjjie
|
||||
* @date 2026/1/6 15:37
|
||||
*/
|
||||
@Data
|
||||
public class BankBranchDto {
|
||||
/**
|
||||
* 机构ID
|
||||
*/
|
||||
private String instId;
|
||||
|
||||
/**
|
||||
* 银行代码
|
||||
*/
|
||||
private String bankCode;
|
||||
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 银行简称
|
||||
*/
|
||||
private String simpleName;
|
||||
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
@JSONField(name = "provice")
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* IBPS代码
|
||||
*/
|
||||
private String ibpsCode;
|
||||
|
||||
/**
|
||||
* 承担机构
|
||||
*/
|
||||
private String undertakeInst;
|
||||
|
||||
/**
|
||||
* 分支机构名称
|
||||
*/
|
||||
private String branchName;
|
||||
|
||||
/**
|
||||
* 机构全称
|
||||
*/
|
||||
private String instName;
|
||||
|
||||
/**
|
||||
* 联行支行边行
|
||||
*/
|
||||
@JSONField(name = "bank_branch_id")
|
||||
private String bankBranchId;
|
||||
|
||||
/**
|
||||
* 联行支行名称
|
||||
*/
|
||||
@JSONField(name = "bank_branch_name")
|
||||
private String bankBranchName;
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.czg.dto.resp;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 进件相应结果
|
||||
* @author yjjie
|
||||
* @date 2026/1/6 18:15
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class EntryRespDto {
|
||||
|
||||
/**
|
||||
* 微信申请 Id
|
||||
*/
|
||||
private String wechatApplyId;
|
||||
|
||||
/**
|
||||
* 微信状态
|
||||
* {@link com.czg.PayCst.EntryStatus}
|
||||
*/
|
||||
private String wechatStatus;
|
||||
|
||||
/**
|
||||
* 微信进件错误信息
|
||||
*/
|
||||
private String wechatErrorMsg;
|
||||
|
||||
/**
|
||||
* 支付宝订单 Id
|
||||
*/
|
||||
private String alipayOrderId;
|
||||
|
||||
/**
|
||||
* 支付宝授信息
|
||||
*/
|
||||
private String alipayAuthInfo;
|
||||
|
||||
/**
|
||||
* 支付宝状态
|
||||
* {@link com.czg.PayCst.EntryStatus}
|
||||
*/
|
||||
private String alipayStatus;
|
||||
|
||||
/**
|
||||
* 支付宝进件错误信息
|
||||
*/
|
||||
private String alipayErrorMsg;
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.czg.dto.resp;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2026/1/7 09:07
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class EntryThirdRespDto {
|
||||
|
||||
/**
|
||||
* 录入id
|
||||
*/
|
||||
private String entryId;
|
||||
|
||||
/**
|
||||
* 支付宝授信息
|
||||
*/
|
||||
private String alipayAuthInfo;
|
||||
|
||||
/**
|
||||
* 平台
|
||||
*/
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* {@link com.czg.PayCst.EntryStatus}
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
private String errorMsg;
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.czg.dto.resp;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 查询进件状态
|
||||
* @author yjjie
|
||||
* @date 2026/1/7 17:12
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class QueryStatusResp {
|
||||
|
||||
/**
|
||||
* 平台
|
||||
* {@link com.czg.PayCst.Platform}
|
||||
*/
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* 商户编号
|
||||
*/
|
||||
private String merchantCode;
|
||||
|
||||
/**
|
||||
* 进件编号
|
||||
*/
|
||||
private String applyId;
|
||||
|
||||
/**
|
||||
* 三方商户id
|
||||
*/
|
||||
private String thirdMerchantId;
|
||||
|
||||
/**
|
||||
* 进件状态
|
||||
* {@link com.czg.PayCst.EntryStatus}
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 签约地址
|
||||
*/
|
||||
private String signUrl;
|
||||
|
||||
/**
|
||||
* 失败原因
|
||||
*/
|
||||
private String failReason;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.czg.dto.resp;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信银行支行列表
|
||||
* @author yjjie
|
||||
* @date 2026/1/12 09:32
|
||||
*/
|
||||
@Data
|
||||
public class WechatBankBranchRespDto {
|
||||
|
||||
/**
|
||||
* 开户银行
|
||||
*/
|
||||
@JSONField(name = "account_bank")
|
||||
private String accountBank;
|
||||
|
||||
/**
|
||||
* 开户银行编码
|
||||
*/
|
||||
@JSONField(name = "account_bank_code")
|
||||
private Integer accountBankCode;
|
||||
|
||||
/**
|
||||
* 银行别名
|
||||
*/
|
||||
@JSONField(name = "bank_alias")
|
||||
private String bankAlias;
|
||||
|
||||
/**
|
||||
* 银行别名编码
|
||||
*/
|
||||
@JSONField(name = "bank_alias_code")
|
||||
private String bankAliasCode;
|
||||
|
||||
/**
|
||||
* 银行支行列表
|
||||
*/
|
||||
@JSONField(name = "data")
|
||||
private List<WechatBankBranchList> data;
|
||||
|
||||
|
||||
@Data
|
||||
public static class WechatBankBranchList {
|
||||
/**
|
||||
* 银行支行名称
|
||||
*/
|
||||
@JSONField(name = "bank_branch_name")
|
||||
private String bankBranchName;
|
||||
|
||||
/**
|
||||
* 银行支行编号
|
||||
*/
|
||||
@JSONField(name = "bank_branch_id")
|
||||
private String bankBranchId;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package com.czg.third.alipay;
|
||||
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayConfig;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.v3.ApiClient;
|
||||
import com.alipay.v3.Configuration;
|
||||
import com.czg.third.alipay.dto.config.AlipayConfigDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2026/1/4 13:48
|
||||
*/
|
||||
@Slf4j
|
||||
public class AlipayClient {
|
||||
|
||||
public static DefaultAlipayClient getDefaultClient(AlipayConfigDto configDto) {
|
||||
try {
|
||||
return new DefaultAlipayClient(getAlipayConfig(configDto));
|
||||
} catch (AlipayApiException e) {
|
||||
log.error("创建支付宝客户端失败", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setApiClient(AlipayConfigDto configDto) {
|
||||
if (configDto == null) {
|
||||
configDto = AlipayConfigDto.getDefaultConfig();
|
||||
}
|
||||
try {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
// 初始化alipay参数(全局设置一次)
|
||||
com.alipay.v3.util.model.AlipayConfig alipayConfig = new com.alipay.v3.util.model.AlipayConfig();
|
||||
alipayConfig.setServerUrl(configDto.getDomain());
|
||||
alipayConfig.setAppId(configDto.getAppId());
|
||||
alipayConfig.setAlipayPublicKey(configDto.getAlipayPublicKey());
|
||||
alipayConfig.setPrivateKey(configDto.getPrivateKey());
|
||||
defaultClient.setAlipayConfig(alipayConfig);
|
||||
} catch (Exception e) {
|
||||
log.error("创建支付宝客户端失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static AlipayConfig getAlipayConfig(AlipayConfigDto configDto) {
|
||||
if (configDto == null) {
|
||||
configDto = AlipayConfigDto.getDefaultConfig();
|
||||
}
|
||||
|
||||
AlipayConfig alipayConfig = new AlipayConfig();
|
||||
alipayConfig.setServerUrl(configDto.getDomain());
|
||||
alipayConfig.setAppId(configDto.getAppId());
|
||||
alipayConfig.setPrivateKey(configDto.getPrivateKey());
|
||||
alipayConfig.setFormat("json");
|
||||
alipayConfig.setAlipayPublicKey(configDto.getAlipayPublicKey());
|
||||
alipayConfig.setCharset("UTF-8");
|
||||
alipayConfig.setSignType("RSA2");
|
||||
|
||||
return alipayConfig;
|
||||
}
|
||||
}
|
||||
@@ -1,385 +0,0 @@
|
||||
package com.czg.third.alipay;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.FileItem;
|
||||
import com.alipay.api.domain.*;
|
||||
import com.alipay.api.request.AlipayFinancialnetAuthPbcnameQueryRequest;
|
||||
import com.alipay.api.request.AntMerchantExpandIndirectImageUploadRequest;
|
||||
import com.alipay.api.request.AntMerchantExpandIndirectZftCreateRequest;
|
||||
import com.alipay.api.request.AntMerchantExpandIndirectZftorderQueryRequest;
|
||||
import com.alipay.api.response.AlipayFinancialnetAuthPbcnameQueryResponse;
|
||||
import com.alipay.api.response.AntMerchantExpandIndirectImageUploadResponse;
|
||||
import com.alipay.api.response.AntMerchantExpandIndirectZftCreateResponse;
|
||||
import com.alipay.api.response.AntMerchantExpandIndirectZftorderQueryResponse;
|
||||
import com.alipay.v3.ApiClient;
|
||||
import com.alipay.v3.ApiException;
|
||||
import com.alipay.v3.Configuration;
|
||||
import com.alipay.v3.api.AlipayOpenAgentApi;
|
||||
import com.alipay.v3.model.AlipayOpenAgentCreateDefaultResponse;
|
||||
import com.alipay.v3.model.AlipayOpenAgentCreateModel;
|
||||
import com.alipay.v3.model.AlipayOpenAgentCreateResponseModel;
|
||||
import com.alipay.v3.model.ContactModel;
|
||||
import com.alipay.v3.util.model.AlipayConfig;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.dto.req.*;
|
||||
import com.czg.dto.resp.BankBranchDto;
|
||||
import com.czg.dto.resp.EntryThirdRespDto;
|
||||
import com.czg.dto.resp.QueryStatusResp;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.third.alipay.dto.config.AlipayConfigDto;
|
||||
import com.czg.third.wechat.dto.resp.WechatQueryStateResp;
|
||||
import com.czg.utils.UploadFileUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付宝进件管理
|
||||
* <a href="https://opendocs.alipay.com/solution/9434dd99_ant.merchant.expand.indirect.zft.simplecreate?scene=bf5951260023430e944c2e9afdf7f9e2&pathHash=d3136936">...</a>
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2025/12/29 14:11
|
||||
*/
|
||||
@Slf4j
|
||||
public class AlipayEntryManager {
|
||||
|
||||
/**
|
||||
* 查询商户进件状态
|
||||
*
|
||||
* @param configDto 配置信息
|
||||
* @param merchantCode 自系统的商户编号
|
||||
* @return 进件状态
|
||||
*/
|
||||
public static QueryStatusResp queryMerchantEntryStatus(AlipayConfigDto configDto, String merchantCode) {
|
||||
QueryStatusResp queryStatusResp = new QueryStatusResp();
|
||||
queryStatusResp.setPlatform(PayCst.Platform.ALIPAY);
|
||||
queryStatusResp.setMerchantCode(merchantCode);
|
||||
|
||||
AntMerchantExpandIndirectZftorderQueryRequest request = new AntMerchantExpandIndirectZftorderQueryRequest();
|
||||
|
||||
AntMerchantExpandIndirectZftorderQueryModel model = new AntMerchantExpandIndirectZftorderQueryModel();
|
||||
model.setExternalId(merchantCode);
|
||||
|
||||
request.setBizModel(model);
|
||||
|
||||
try {
|
||||
DefaultAlipayClient defaultAlipayClient = AlipayClient.getDefaultClient(configDto);
|
||||
AntMerchantExpandIndirectZftorderQueryResponse response = defaultAlipayClient.execute(request);
|
||||
log.info("支付宝查询进件状态结果:{}", response.getBody());
|
||||
|
||||
if (response.isSuccess()) {
|
||||
List<ZftSubMerchantOrder> orders = response.getOrders();
|
||||
if (orders != null && !orders.isEmpty()) {
|
||||
ZftSubMerchantOrder first = orders.getFirst();
|
||||
queryStatusResp.setApplyId(first.getExternalId());
|
||||
|
||||
if ("99".equals(first.getStatus())) {
|
||||
// 已完成
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.FINISH);
|
||||
queryStatusResp.setThirdMerchantId(first.getSmid());
|
||||
queryStatusResp.setFailReason("");
|
||||
return queryStatusResp;
|
||||
}
|
||||
if ("-1".equals(first.getStatus())) {
|
||||
// 拒绝
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
queryStatusResp.setFailReason(first.getReason());
|
||||
return queryStatusResp;
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(first.getFkAudit())) {
|
||||
if ("REJECT".equals(first.getFkAudit())) {
|
||||
// 风控拒绝
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
queryStatusResp.setFailReason(first.getFkAuditMemo());
|
||||
return queryStatusResp;
|
||||
}
|
||||
|
||||
if ("CREATE".equals(first.getFkAudit())) {
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.AUDIT);
|
||||
queryStatusResp.setFailReason(first.getFkAuditMemo());
|
||||
return queryStatusResp;
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(first.getKzAudit())) {
|
||||
if ("REJECT".equals(first.getKzAudit())) {
|
||||
// 风控拒绝
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
queryStatusResp.setFailReason(first.getKzAuditMemo());
|
||||
return queryStatusResp;
|
||||
}
|
||||
|
||||
if ("CREATE".equals(first.getKzAudit())) {
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.AUDIT);
|
||||
queryStatusResp.setFailReason(first.getKzAuditMemo());
|
||||
return queryStatusResp;
|
||||
}
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(first.getSubConfirm()) && "FAIL".equals(first.getSubConfirm())) {
|
||||
// 签约失败
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
queryStatusResp.setFailReason("签约失败");
|
||||
return queryStatusResp;
|
||||
}
|
||||
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.SIGN);
|
||||
queryStatusResp.setSignUrl(first.getSubSignQrCodeUrl());
|
||||
return queryStatusResp;
|
||||
}
|
||||
} else {
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
queryStatusResp.setFailReason(response.getSubMsg());
|
||||
}
|
||||
} catch (AlipayApiException e) {
|
||||
log.error("支付宝查询进件状态报错:{}", e.getMessage(), e);
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.INIT);
|
||||
}
|
||||
|
||||
|
||||
return queryStatusResp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 进件商户
|
||||
*
|
||||
* @param configDto 配置信息
|
||||
* @param reqDto 请求信息
|
||||
*/
|
||||
public static EntryThirdRespDto entryMerchant(AlipayConfigDto configDto, AggregateMerchantDto reqDto) {
|
||||
AntMerchantExpandIndirectZftCreateModel entryReqDto = buildEntryParams(reqDto);
|
||||
EntryThirdRespDto respDto = new EntryThirdRespDto()
|
||||
.setPlatform(PayCst.Platform.ALIPAY);
|
||||
|
||||
try {
|
||||
AntMerchantExpandIndirectZftCreateRequest request = new AntMerchantExpandIndirectZftCreateRequest();
|
||||
DefaultAlipayClient defaultAlipayClient = AlipayClient.getDefaultClient(configDto);
|
||||
request.setBizModel(entryReqDto);
|
||||
AntMerchantExpandIndirectZftCreateResponse response = defaultAlipayClient.execute(request);
|
||||
log.info("支付宝进件结果:{}", response.getBody());
|
||||
if (response.isSuccess()) {
|
||||
respDto.setStatus(PayCst.EntryStatus.INIT);
|
||||
respDto.setEntryId(response.getOrderId());
|
||||
respDto.setErrorMsg("");
|
||||
} else {
|
||||
respDto.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
respDto.setEntryId("");
|
||||
respDto.setErrorMsg(response.getSubMsg());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("支付宝进件报错:{}", e.getMessage(), e);
|
||||
respDto.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
respDto.setEntryId("");
|
||||
respDto.setErrorMsg(e.getMessage());
|
||||
}
|
||||
|
||||
return respDto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @param configDto 配置信息
|
||||
* @param url 图片地址
|
||||
* @return 图片ID
|
||||
*/
|
||||
public static String uploadImage(AlipayConfigDto configDto, String url) {
|
||||
try {
|
||||
byte[] bytes = UploadFileUtil.downloadImage(url);
|
||||
|
||||
Path tempFile = Files.createTempFile("image_", ".png");
|
||||
|
||||
// 写入数据
|
||||
Files.write(tempFile, bytes);
|
||||
|
||||
File file = tempFile.toFile();
|
||||
|
||||
AntMerchantExpandIndirectImageUploadRequest request = new AntMerchantExpandIndirectImageUploadRequest();
|
||||
request.setImageType(UploadFileUtil.extractImageExtension(url));
|
||||
|
||||
// 设置图片内容
|
||||
FileItem imageContent = new FileItem(file);
|
||||
request.setImageContent(imageContent);
|
||||
|
||||
DefaultAlipayClient defaultAlipayClient = AlipayClient.getDefaultClient(configDto);
|
||||
AntMerchantExpandIndirectImageUploadResponse response = defaultAlipayClient.execute(request);
|
||||
|
||||
return response.getImageId();
|
||||
} catch (Exception e) {
|
||||
log.error("支付宝上传图片报错,URL:{},错误信息:{}", "url", e.getMessage(), e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询支行
|
||||
*
|
||||
* @param instId 顶级机构ID CMB
|
||||
* @param province 省份 陕西省
|
||||
* @param city 城市 西安市
|
||||
*/
|
||||
public static List<BankBranchDto> queryBankBranchList(AlipayConfigDto configDto, String instId, String province, String city) {
|
||||
try {
|
||||
AlipayFinancialnetAuthPbcnameQueryRequest request = new AlipayFinancialnetAuthPbcnameQueryRequest();
|
||||
|
||||
AlipayFinancialnetAuthPbcnameQueryModel model = new AlipayFinancialnetAuthPbcnameQueryModel();
|
||||
model.setInstId(instId);
|
||||
model.setProvice(province);
|
||||
model.setCity(city);
|
||||
|
||||
request.setBizModel(model);
|
||||
DefaultAlipayClient defaultAlipayClient = AlipayClient.getDefaultClient(configDto);
|
||||
AlipayFinancialnetAuthPbcnameQueryResponse response = defaultAlipayClient.execute(request);
|
||||
|
||||
String data = response.getPbcQueryResult();
|
||||
return JSONArray.parseArray(data, BankBranchDto.class);
|
||||
} catch (Exception e) {
|
||||
log.error("支付宝查询支行报错,错误信息:{}", e.getMessage(), e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建进件参数
|
||||
*
|
||||
* @param reqDto 请求参数
|
||||
* @return 进件参数
|
||||
*/
|
||||
private static AntMerchantExpandIndirectZftCreateModel buildEntryParams(AggregateMerchantDto reqDto) {
|
||||
AntMerchantExpandIndirectZftCreateModel entryParams = new AntMerchantExpandIndirectZftCreateModel();
|
||||
|
||||
MerchantBaseInfoDto baseInfo = reqDto.getMerchantBaseInfo();
|
||||
LegalPersonInfoDto legalPersonInfo = reqDto.getLegalPersonInfo();
|
||||
BusinessLicenceInfoDto businessLicenceInfo = reqDto.getBusinessLicenceInfo();
|
||||
StoreInfoDto storeInfo = reqDto.getStoreInfo();
|
||||
SettlementInfoDto settlementInfo = reqDto.getSettlementInfo();
|
||||
|
||||
entryParams.setExternalId(reqDto.getMerchantCode());
|
||||
if ("0".equals(baseInfo.getUserType())) {
|
||||
entryParams.setMerchantType("07");
|
||||
} else if ("1".equals(baseInfo.getUserType())) {
|
||||
switch (baseInfo.getCompanyChildType()) {
|
||||
case "1" -> entryParams.setMerchantType("01");
|
||||
case "2" -> entryParams.setMerchantType("02");
|
||||
case "3" -> entryParams.setMerchantType("05");
|
||||
case "4" -> entryParams.setMerchantType("04");
|
||||
default -> throw new CzgException("主体类型错误");
|
||||
}
|
||||
} else {
|
||||
throw new CzgException("用户类型错误");
|
||||
}
|
||||
entryParams.setName(businessLicenceInfo.getLicenceName());
|
||||
entryParams.setAliasName(baseInfo.getShortName());
|
||||
entryParams.setMcc(baseInfo.getMccCode());
|
||||
entryParams.setService(List.of("当面付", "jsapi支付", "小程序支付"));
|
||||
entryParams.setInDoorImages(List.of(storeInfo.getInsidePic().getAlipayId(), storeInfo.getCashierDeskPic().getAlipayId()));
|
||||
entryParams.setOutDoorImages(List.of(storeInfo.getDoorPic().getAlipayId()));
|
||||
|
||||
// 证件类型(目前只支持个体和企业,所以都是营业执照)
|
||||
entryParams.setCertType("201");
|
||||
entryParams.setCertImage(businessLicenceInfo.getLicensePic().getAlipayId());
|
||||
entryParams.setCertNo(businessLicenceInfo.getLicenceNo());
|
||||
|
||||
entryParams.setLegalName(legalPersonInfo.getLegalPersonName());
|
||||
entryParams.setLegalCertNo(legalPersonInfo.getLegalPersonId());
|
||||
entryParams.setLegalCertFrontImage(legalPersonInfo.getIdCardFrontPic().getAlipayId());
|
||||
entryParams.setLegalCertBackImage(legalPersonInfo.getIdCardBackPic().getAlipayId());
|
||||
|
||||
entryParams.setServicePhone(PayCst.ContactPersonType.LEGAL.equals(baseInfo.getContactPersonType()) ? legalPersonInfo.getLegalPersonPhone() : baseInfo.getContactPhone());
|
||||
|
||||
com.alipay.api.domain.AddressInfo addressInfo = new com.alipay.api.domain.AddressInfo();
|
||||
addressInfo.setCityCode(storeInfo.getMercCityCode());
|
||||
addressInfo.setDistrictCode(storeInfo.getMercAreaCode());
|
||||
addressInfo.setProvinceCode(storeInfo.getMercProvCode());
|
||||
addressInfo.setAddress(storeInfo.getBusinessAddress());
|
||||
entryParams.setBusinessAddress(addressInfo);
|
||||
|
||||
com.alipay.api.domain.SettleCardInfo settleCardInfo = new com.alipay.api.domain.SettleCardInfo();
|
||||
settleCardInfo.setAccountHolderName(settlementInfo.getSettlementName());
|
||||
settleCardInfo.setAccountNo(settlementInfo.getSettlementCardNo());
|
||||
settleCardInfo.setAccountInstProvince(settlementInfo.getOpenAccProvince());
|
||||
settleCardInfo.setAccountInstCity(settlementInfo.getOpenAccCity());
|
||||
settlementInfo.setBankBranchName(settlementInfo.getBankBranchName());
|
||||
settleCardInfo.setUsageType("21".equals(settlementInfo.getSettlementCardType()) ? "01" : "02");
|
||||
settleCardInfo.setAccountType("DC");
|
||||
settleCardInfo.setAccountInstName(settlementInfo.getBankName());
|
||||
settleCardInfo.setAccountInstId(settlementInfo.getBankInstId());
|
||||
settleCardInfo.setBankCode(settlementInfo.getBankBranchCode());
|
||||
entryParams.setBizCards(List.of(settleCardInfo));
|
||||
|
||||
com.alipay.api.domain.ContactInfo contactInfo = new com.alipay.api.domain.ContactInfo();
|
||||
if (PayCst.ContactPersonType.SUPER.equals(baseInfo.getContactPersonType())) {
|
||||
contactInfo.setName(baseInfo.getContactName());
|
||||
contactInfo.setMobile(baseInfo.getContactPhone());
|
||||
contactInfo.setEmail(baseInfo.getContactEmail());
|
||||
contactInfo.setIdCardNo(baseInfo.getContactPersonId());
|
||||
} else if (PayCst.ContactPersonType.LEGAL.equals(baseInfo.getContactPersonType())) {
|
||||
contactInfo.setName(legalPersonInfo.getLegalPersonName());
|
||||
contactInfo.setMobile(legalPersonInfo.getLegalPersonPhone());
|
||||
contactInfo.setEmail(legalPersonInfo.getLegalPersonEmail());
|
||||
contactInfo.setIdCardNo(legalPersonInfo.getLegalPersonId());
|
||||
} else {
|
||||
throw new CzgException("联系人类型错误");
|
||||
}
|
||||
entryParams.setContactInfos(List.of(contactInfo));
|
||||
|
||||
entryParams.setLicenseAuthLetterImage(businessLicenceInfo.getLicensePic().getAlipayId());
|
||||
|
||||
// 小程序
|
||||
SiteInfo miniAppInfo = new SiteInfo();
|
||||
miniAppInfo.setSiteType("06");
|
||||
miniAppInfo.setSiteUrl("https://sxczgkj.cn");
|
||||
miniAppInfo.setSiteName("银收客");
|
||||
miniAppInfo.setTinyAppId("2021004145625815");
|
||||
entryParams.setSites(List.of(miniAppInfo));
|
||||
|
||||
return entryParams;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ApiException {
|
||||
|
||||
queryBankBranchList(null, "CMB", "陕西省", "西安市");
|
||||
// uploadImage(null, "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240312/31476c871c224389aea0ac4e17c964a3.jpg");
|
||||
|
||||
// test();
|
||||
}
|
||||
|
||||
// https://opendocs.alipay.com/solution/0dec7x?pathHash=caec4753 直付通
|
||||
public static void test() throws ApiException {
|
||||
ApiClient defaultClient = Configuration.getDefaultApiClient();
|
||||
// 初始化alipay参数(全局设置一次)
|
||||
AlipayConfig alipayConfig = new AlipayConfig();
|
||||
alipayConfig.setServerUrl("https://openapi.alipay.com");
|
||||
alipayConfig.setAppId("2021006121646825");
|
||||
alipayConfig.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQkrz+emAuS1mB3KKDOMmAZRd/BlPbh7fAIHAqAj1+QCZNcV3o2BTLIIqnuKpSlFXDG3uDzp2VsBxcizXuBbFyPGylnD9CgCj5abyh3+FIHPAZ2IM3TtpqImZ0TSPGXrMli4Nir7MvZktgccCqQKCC4o6iaDGz+UwWwJUIPna8fm2tiTZ+KH150CZbKVj4ZGNpBh5XSV/1dRgyQIV9D/EwSbkZ0n6VgKQLJBi0C2UE3QB17aL1Ir6+gDXIDbknN8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB");
|
||||
alipayConfig.setPrivateKey("MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCz3FkdffxZibdwis9W7eOW1dEjGAbSvRDL2ikfeCIW5KZNoIjUqxI0mIoUlLRRKO71QLHZS1Vb2aJp8jeOAqIPa8e76HTneQEzk3FGA8gpraSGvbadHWzvxnmYKsts1TBiEZQL82ySJXhQTJvZ6jyDM7s6wHHUnrH+Qi29QpppQ1sxsoJeCtajUgRg3btD6XbBcyFAX3pzM56Kw9eaIjZoD8WToZOM/Y3sqNL2uo8lLqcIpTrI7Pq5ZOspmBQ+t8v3rS9IdDZZMvd0trzS67AXwHz8rKPBT/lL1A4iHnXCHUvktusX1fPs3/RGY/a7PIddaBLnfY0GcueE16K7QcrXAgMBAAECggEAbSdT2eckp75BWoaTcGEs1tRqeM7TDT/6moyKmnOQ1K3tE31SrSYpBUxxuC3LBNo/sw2RIZtrcTOyMnPyLTgB3DP/4lUf5X51MTTQ8LnI1ypvh+pIki9Sdm3QS33lOOZk149tdpdDk6ozyx/DEcvq74EMpoo2SuAIi5LkKVDrXuehvGA/WeXtpmuPgqRFdIA+JBlA3knHk5XEQY/k2Y31gq5oCwNL9iT9OAZqVkukE6EnvCXE9t2rAV4/snYilaf/UaO+ktgEwSbPBQ8YKlovDAarMBbGtgr6E174A9djlPyR+W/fgx8rlTwSWtieb9MkO8LN3KSxgVs0kY5U8OHg8QKBgQDljJq9kTFHare+W/fAXdUy3tJprfNQCAii6s+GuDfTQiviVQDtWmdtHAN+xU3to7MepvVhwHsqtQnZXKTtZuwwxn82FNl7A5RYD3GVFW+wG6AsGLIdESrWxySoL6Kx8QmNpMEVg8acT/ywzW/RnUXS5vU7GIi8GA0vtyBo24R9KQKBgQDIlf/R9+iNk9oXlbB/k4um9eVvBBS7l5cx4E5Id5Dpp4kGZfPZEa7oDsEUstZZM9mgQLJK/noNWbcf0+BohCR5ux7SC12qIoxwN3k4BzTDqrS8BzFuVVp5PELUsf/uCbRn05iMzpiDUhj3Vde04wvjHYIobfKlZO2HeSWXCpUH/wKBgQC8wSuU6ck90pEY5QMKmZ3wYK1g3PsQOirv3Gmde+nbu7PePsuuYQJfBAQTwCZeXJezgtKP+PjOm2Nn6vhrhpB9YxvD2s0ijET1TG23i5L1myHQYNZFdJJnXgXUjqcX7v5ODMYA7QTqEBPXRnbGRK7fx66rU3dMQ/LD46+wyaFeUQKBgA4QTk53dkuu6SSsLyLSwoDjTsHY5Gc+urAZjQORtoxbXcUgEtfOYJgOqMT9wP+iHgkZYCbX7tDO0IMfxOUvFqueTgvmFhwergAUM6CVCMMLTf689l9JBr3nVrw4+rvC3G5HLLP6rEDQ2cVFtIkPPj8fS4fwJYopKGpOOS9843QbAoGBAMoHH8LqoZ50FLsospx/hJe24Cd8wCgQTXSa/hMqNZ1999JDhftMt7R0ZdB1he2LReACe0K9ntBU4H4u225zZ3wZlyOfoyerAHuLK/ysNlgIIzblZlOxbBJ64Kul8leXzlYy3tOZuZ997KqBcWPCE3LUBBNvM6E3blJUnlmJAVoi");
|
||||
defaultClient.setAlipayConfig(alipayConfig);
|
||||
log.info("dd: {}", JSONObject.toJSONString(alipayConfig));
|
||||
AlipayOpenAgentApi api = new AlipayOpenAgentApi();
|
||||
AlipayOpenAgentCreateModel data = new AlipayOpenAgentCreateModel();
|
||||
ContactModel contactInfo = new ContactModel();
|
||||
contactInfo.setContactEmail("zhangsan@alipy.com");
|
||||
contactInfo.setContactName("张三");
|
||||
contactInfo.setContactMobile("18866668888");
|
||||
data.setContactInfo(contactInfo);
|
||||
// data.setOrderTicket("00ee2d475f374ad097ee0f1ac223fX00");
|
||||
data.setAccount("1157756119@qq.com");
|
||||
try {
|
||||
AlipayOpenAgentCreateResponseModel response = api.create(data);
|
||||
System.out.println(response);
|
||||
} catch (ApiException e) {
|
||||
AlipayOpenAgentCreateDefaultResponse errorObject = (AlipayOpenAgentCreateDefaultResponse) e.getErrorObject();
|
||||
System.out.println("调用失败:" + errorObject);
|
||||
System.out.println("调用失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,263 +0,0 @@
|
||||
package com.czg.third.alipay;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alipay.v3.ApiException;
|
||||
import com.alipay.v3.api.*;
|
||||
import com.alipay.v3.model.*;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.dto.req.*;
|
||||
import com.czg.dto.resp.EntryThirdRespDto;
|
||||
import com.czg.dto.resp.QueryStatusResp;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.pay.AlipayAuthInfoDto;
|
||||
import com.czg.third.alipay.dto.config.AlipayConfigDto;
|
||||
import com.czg.utils.UploadFileUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* 支付宝服务商进件管理
|
||||
* <a href="https://opendocs.alipay.com/open-v3/b4c46445_alipay.open.agent.create?scene=common&pathHash=d7084b4b">...</a>
|
||||
* @author yjjie
|
||||
* @date 2026/1/8 13:34
|
||||
*/
|
||||
@Slf4j
|
||||
public class AlipayIsvEntryManager {
|
||||
|
||||
public static QueryStatusResp queryMerchantBatchStatus(AlipayConfigDto configDto, String batchNo) {
|
||||
if (configDto == null) {
|
||||
configDto = AlipayConfigDto.getThirdDefaultConfig();
|
||||
}
|
||||
QueryStatusResp respDto = new QueryStatusResp()
|
||||
.setPlatform(PayCst.Platform.ALIPAY);
|
||||
AlipayClient.setApiClient(configDto);
|
||||
|
||||
try {
|
||||
AlipayOpenAgentOrderApi api = new AlipayOpenAgentOrderApi();
|
||||
AlipayOpenAgentOrderQueryResponseModel response = api.query(batchNo);
|
||||
|
||||
log.info("支付宝查询进件状态: 响应={}", response);
|
||||
respDto.setApplyId(batchNo);
|
||||
|
||||
switch (response.getOrderStatus()) {
|
||||
case "MERCHANT_INFO_HOLD" -> {
|
||||
respDto.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
respDto.setFailReason("三方异常,请重新提交");
|
||||
return respDto;
|
||||
}
|
||||
case "MERCHANT_CONFIRM_TIME_OUT" -> {
|
||||
respDto.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
respDto.setFailReason("商户确认超时,请重新提交");
|
||||
return respDto;
|
||||
}
|
||||
case "MERCHANT_AUDITING" -> {
|
||||
respDto.setStatus(PayCst.EntryStatus.AUDIT);
|
||||
respDto.setFailReason("");
|
||||
return respDto;
|
||||
}
|
||||
case "MERCHANT_CONFIRM" -> {
|
||||
respDto.setStatus(PayCst.EntryStatus.SIGN);
|
||||
respDto.setFailReason("");
|
||||
respDto.setSignUrl(response.getConfirmUrl());
|
||||
return respDto;
|
||||
}
|
||||
case "MERCHANT_APPLY_ORDER_CANCELED" -> {
|
||||
respDto.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
respDto.setFailReason(response.getRejectReason());
|
||||
return respDto;
|
||||
}
|
||||
case "MERCHANT_CONFIRM_SUCCESS" -> {
|
||||
respDto.setStatus(PayCst.EntryStatus.FINISH);
|
||||
respDto.setFailReason("");
|
||||
respDto.setThirdMerchantId(response.getMerchantPid());
|
||||
return respDto;
|
||||
}
|
||||
case null -> {
|
||||
respDto.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
respDto.setFailReason("查询失败");
|
||||
return respDto;
|
||||
}
|
||||
default -> {
|
||||
return respDto;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (ApiException e) {
|
||||
String body = e.getResponseBody();
|
||||
log.error("支付宝查询进件状态异常: {}", body);
|
||||
JSONObject object = JSONObject.parseObject(body);
|
||||
respDto.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
respDto.setFailReason(object.getString(PayCst.ALIPAY_ERROR_MSG_KEY));
|
||||
return respDto;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商户
|
||||
* @param configDto 配置信息
|
||||
* @param reqDto 请求信息
|
||||
*/
|
||||
public static EntryThirdRespDto entryMerchant(AlipayConfigDto configDto, AggregateMerchantDto reqDto) {
|
||||
if (configDto == null) {
|
||||
configDto = AlipayConfigDto.getThirdDefaultConfig();
|
||||
}
|
||||
AlipayClient.setApiClient(configDto);
|
||||
EntryThirdRespDto respDto = new EntryThirdRespDto()
|
||||
.setPlatform(PayCst.Platform.ALIPAY);
|
||||
try {
|
||||
String batchNo = createRequest(configDto, reqDto);
|
||||
respDto.setEntryId(batchNo);
|
||||
|
||||
AlipayOpenAgentFacetofaceSignModel signModel = buildFaceToFaceModel(reqDto, batchNo);
|
||||
File businessLicensePic = UploadFileUtil.getFileByUrl(reqDto.getBusinessLicenceInfo().getLicensePic().getUrl());
|
||||
File shopScenePic = UploadFileUtil.getFileByUrl(reqDto.getStoreInfo().getInsidePic().getUrl());
|
||||
File shopSignBoardPic = UploadFileUtil.getFileByUrl(reqDto.getStoreInfo().getDoorPic().getUrl());
|
||||
|
||||
log.info("支付宝开启代商户签约: 请求={}", JSONObject.toJSONString(signModel));
|
||||
|
||||
// 构造请求参数以调用接口
|
||||
AlipayOpenAgentFacetofaceApi api = new AlipayOpenAgentFacetofaceApi();
|
||||
Object response = api.sign(null, businessLicensePic, signModel, shopScenePic, shopSignBoardPic, null);
|
||||
log.info("支付宝开启代商户签约: 响应={}", JSONObject.toJSONString(response));
|
||||
|
||||
try {
|
||||
String authInfo = confirmRequest(configDto, batchNo);
|
||||
respDto.setAlipayAuthInfo(authInfo);
|
||||
respDto.setStatus(PayCst.EntryStatus.INIT);
|
||||
respDto.setErrorMsg("");
|
||||
return respDto;
|
||||
} catch (CzgException e) {
|
||||
respDto.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
respDto.setErrorMsg(e.getMessage());
|
||||
return respDto;
|
||||
}
|
||||
} catch (ApiException e) {
|
||||
String body = e.getResponseBody();
|
||||
log.error("支付宝开启代商户签约,创建应用事务异常: {}", body);
|
||||
JSONObject object = JSONObject.parseObject(body);
|
||||
respDto.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
respDto.setErrorMsg(object.getString(PayCst.ALIPAY_ERROR_MSG_KEY));
|
||||
return respDto;
|
||||
} catch (Exception e) {
|
||||
log.error("支付宝开启代商户签约,创建应用事务异常2", e);
|
||||
respDto.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
respDto.setErrorMsg(e.getMessage());
|
||||
return respDto;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启代商户签约、创建应用事务
|
||||
* @param reqDto 请求信息
|
||||
* @return 请求ID
|
||||
*/
|
||||
public static String createRequest(AlipayConfigDto configDto, AggregateMerchantDto reqDto) {
|
||||
if (configDto == null) {
|
||||
configDto = AlipayConfigDto.getThirdDefaultConfig();
|
||||
}
|
||||
AlipayClient.setApiClient(configDto);
|
||||
AlipayOpenAgentApi api = new AlipayOpenAgentApi();
|
||||
AlipayOpenAgentCreateModel openModel = new AlipayOpenAgentCreateModel();
|
||||
|
||||
MerchantBaseInfoDto info = reqDto.getMerchantBaseInfo();
|
||||
LegalPersonInfoDto legalPersonInfo = reqDto.getLegalPersonInfo();
|
||||
String contactPersonType = info.getContactPersonType();
|
||||
boolean isSuper = PayCst.ContactPersonType.SUPER.equals(contactPersonType);
|
||||
|
||||
ContactModel contactModel = new ContactModel();
|
||||
// 联系人名称
|
||||
contactModel.setContactName(isSuper ? info.getContactName() : legalPersonInfo.getLegalPersonName());
|
||||
// 联系人手机号码
|
||||
contactModel.setContactMobile(isSuper ? info.getContactPhone() : legalPersonInfo.getLegalPersonPhone());
|
||||
// 联系人邮箱
|
||||
contactModel.setContactEmail(isSuper ? info.getContactEmail() : legalPersonInfo.getLegalPersonEmail());
|
||||
openModel.setContactInfo(contactModel);
|
||||
|
||||
openModel.setAccount(reqDto.getMerchantBaseInfo().getAlipayAccount());
|
||||
|
||||
try {
|
||||
AlipayOpenAgentCreateResponseModel responseModel = api.create(openModel);
|
||||
log.info("支付宝开启代商户签约,开启事务: 结果={}, batchNo={}", responseModel.getBatchStatus(), responseModel.getBatchNo());
|
||||
return responseModel.getBatchNo();
|
||||
} catch (ApiException e) {
|
||||
String body = e.getResponseBody();
|
||||
log.error("支付宝开启代商户签约,开启事务异常: {}", body);
|
||||
JSONObject object = JSONObject.parseObject(body);
|
||||
throw new CzgException("支付宝开启代商户签约,开启事务异常: " + object.getString(PayCst.ALIPAY_ERROR_MSG_KEY));
|
||||
}
|
||||
}
|
||||
|
||||
public static String confirmRequest(AlipayConfigDto configDto, String batchNo) {
|
||||
if (configDto == null) {
|
||||
configDto = AlipayConfigDto.getThirdDefaultConfig();
|
||||
}
|
||||
AlipayClient.setApiClient(configDto);
|
||||
// 构造请求参数以调用接口
|
||||
AlipayOpenAgentApi api = new AlipayOpenAgentApi();
|
||||
AlipayOpenAgentConfirmModel data = new AlipayOpenAgentConfirmModel();
|
||||
|
||||
// 设置ISV 代商户操作事务编号
|
||||
data.setBatchNo(batchNo);
|
||||
try {
|
||||
AlipayOpenAgentConfirmResponseModel response = api.confirm(data);
|
||||
log.info("支付宝开启代商户签约,确认事务: 响应={}", response);
|
||||
|
||||
AlipayAuthInfoDto authInfoDto = new AlipayAuthInfoDto()
|
||||
.setUserId(response.getUserId())
|
||||
.setOpenId(response.getOpenId())
|
||||
.setAuthAppId(response.getAuthAppId())
|
||||
.setAppAuthToken(response.getAppAuthToken())
|
||||
.setExpiresIn(response.getExpiresIn())
|
||||
.setAppRefreshToken(response.getAppRefreshToken())
|
||||
.setReExpiresIn(response.getReExpiresIn())
|
||||
.setOrderNo(response.getOrderNo());
|
||||
return JSONObject.toJSONString(authInfoDto);
|
||||
} catch (ApiException e) {
|
||||
String body = e.getResponseBody();
|
||||
log.error("支付宝开启代商户签约,确认事务异常: {}", body);
|
||||
JSONObject object = JSONObject.parseObject(body);
|
||||
throw new CzgException(object.getString(PayCst.ALIPAY_ERROR_MSG_KEY));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建 当面付参数
|
||||
*/
|
||||
public static AlipayOpenAgentFacetofaceSignModel buildFaceToFaceModel(AggregateMerchantDto reqDto, String batchNo) {
|
||||
AlipayOpenAgentFacetofaceSignModel signModel = new AlipayOpenAgentFacetofaceSignModel();
|
||||
signModel.setBatchNo(batchNo);
|
||||
|
||||
MerchantBaseInfoDto baseInfo = reqDto.getMerchantBaseInfo();
|
||||
LegalPersonInfoDto legalPersonInfo = reqDto.getLegalPersonInfo();
|
||||
BusinessLicenceInfoDto licenceInfo = reqDto.getBusinessLicenceInfo();
|
||||
StoreInfoDto storeInfo = reqDto.getStoreInfo();
|
||||
|
||||
signModel.setMccCode(baseInfo.getMccCode());
|
||||
signModel.setRate("0.38");
|
||||
signModel.setSignAndAuth(true);
|
||||
|
||||
signModel.setBusinessLicenseNo(licenceInfo.getLicenceNo());
|
||||
signModel.setBusinessLicenseMobile(legalPersonInfo.getLegalPersonPhone());
|
||||
signModel.setLongTerm(PayCst.LONG_TERM_DATE.equals(licenceInfo.getLicenceEndDate()));
|
||||
signModel.setDateLimitation(licenceInfo.getLicenceStartDate());
|
||||
|
||||
signModel.setShopName(baseInfo.getShortName());
|
||||
|
||||
// 设置店铺地址
|
||||
SignAddressInfo shopAddress = new SignAddressInfo();
|
||||
shopAddress.setCountryCode("156");
|
||||
shopAddress.setDistrictCode(storeInfo.getMercAreaCode());
|
||||
shopAddress.setDetailAddress(storeInfo.getBusinessAddress());
|
||||
shopAddress.setProvinceCode(storeInfo.getMercProvCode());
|
||||
shopAddress.setCityCode(storeInfo.getMercCityCode());
|
||||
signModel.setShopAddress(shopAddress);
|
||||
|
||||
return signModel;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// confirmRequest("2026010815384505500018243");
|
||||
queryMerchantBatchStatus(null, "2026010815384505500018243");
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
package com.czg.third.alipay;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alipay.v3.ApiException;
|
||||
import com.alipay.v3.api.AlipayTradeApi;
|
||||
import com.alipay.v3.model.AlipayTradeCreateModel;
|
||||
import com.alipay.v3.model.AlipayTradeCreateResponseModel;
|
||||
import com.alipay.v3.model.AlipayTradePayModel;
|
||||
import com.alipay.v3.model.ExtendParams;
|
||||
import com.alipay.v3.util.model.CustomizedParams;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.pay.*;
|
||||
import com.czg.third.alipay.dto.config.AlipayConfigDto;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2026/1/9 09:30
|
||||
*/
|
||||
@Slf4j
|
||||
public class AlipayIsvPayManager {
|
||||
|
||||
/**
|
||||
* H5支付
|
||||
*
|
||||
* @param configDto 配置
|
||||
* @param paramsDto 参数
|
||||
*/
|
||||
public static Map<String, Object> jsapiPay(AlipayConfigDto configDto, CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||
try {
|
||||
AlipayClient.setApiClient(configDto);
|
||||
AlipayTradeApi api = new AlipayTradeApi();
|
||||
AlipayTradeCreateModel model = new AlipayTradeCreateModel();
|
||||
model.setOutTradeNo(paramsDto.getMchOrderNo());
|
||||
model.setProductCode("JSAPI_PAY");
|
||||
model.setOpAppId(merchantDTO.getAlipayMerchantId());
|
||||
model.setOpBuyerOpenId(paramsDto.getUserId());
|
||||
model.setTotalAmount(getYuanAmountByFen(paramsDto.getAmount()));
|
||||
model.setSubject(paramsDto.getSubject());
|
||||
model.setBody(paramsDto.getBody());
|
||||
model.setNotifyUrl(paramsDto.getNotifyUrl() + "/" + PayCst.Platform.ALIPAY);
|
||||
|
||||
model.setExtendParams(new ExtendParams());
|
||||
CustomizedParams customizedParams = new CustomizedParams();
|
||||
customizedParams.setAppAuthToken(merchantDTO.getAlipayAuthInfo().getAppAuthToken());
|
||||
|
||||
AlipayTradeCreateResponseModel responseModel = api.create(model, customizedParams);
|
||||
log.info("支付宝 jsapi 支付结果: {}", responseModel);
|
||||
return new HashMap<>();
|
||||
} catch (ApiException e) {
|
||||
String body = e.getResponseBody();
|
||||
log.error("支付宝 H5 api 支付异常: {}", body);
|
||||
JSONObject object = JSONObject.parseObject(body);
|
||||
throw new CzgException(object.getString(PayCst.ALIPAY_ERROR_MSG_KEY));
|
||||
} catch (Exception e) {
|
||||
log.error("支付宝 H5支付异常: {}", e.getMessage());
|
||||
throw new CzgException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 条码支付
|
||||
*
|
||||
* @param configDto 配置
|
||||
* @param paramsDto 参数
|
||||
*/
|
||||
public static Map<String, Object> barPay(AlipayConfigDto configDto, CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||
try {
|
||||
AlipayClient.setApiClient(configDto);
|
||||
|
||||
// 构造请求参数以调用接口
|
||||
AlipayTradeApi api = new AlipayTradeApi();
|
||||
AlipayTradePayModel data = new AlipayTradePayModel();
|
||||
|
||||
data.setOutTradeNo(paramsDto.getMchOrderNo());
|
||||
data.setTotalAmount(getYuanAmountByFen(paramsDto.getAmount()));
|
||||
data.setSubject(paramsDto.getSubject());
|
||||
// 设置支付授权码
|
||||
data.setAuthCode(merchantDTO.getAlipayAuthInfo().getAppAuthToken());
|
||||
// 设置支付场景
|
||||
data.setScene("bar_code");
|
||||
// 设置产品码
|
||||
data.setProductCode("FACE_TO_FACE_PAYMENT");
|
||||
data.setAuthCode(paramsDto.getAuthCode());
|
||||
// AlipayTradeCreateResponseModel responseModel = api.create(data);
|
||||
|
||||
return new JSONObject();
|
||||
// } catch (ApiException e) {
|
||||
// String body = e.getResponseBody();
|
||||
// log.error("支付宝 条码支付异常: {}", body);
|
||||
// JSONObject object = JSONObject.parseObject(body);
|
||||
// throw new CzgException(object.getString(PayCst.ALIPAY_ERROR_MSG_KEY));
|
||||
} catch (Exception e) {
|
||||
log.error("支付宝 条码支付异常: {}", e.getMessage());
|
||||
throw new CzgException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static QueryOrderRespDTO queryOrder(AlipayConfigDto configDto, String orderNo, NativeMerchantDTO merchantDTO) {
|
||||
return new QueryOrderRespDTO();
|
||||
}
|
||||
|
||||
public static RefundRespDTO refundOrder(AlipayConfigDto configDto, CzgRefundReq paramsDto, String notifyUrl, NativeMerchantDTO merchantDTO) {
|
||||
return new RefundRespDTO();
|
||||
}
|
||||
|
||||
/**
|
||||
* 金额转换
|
||||
*/
|
||||
private static String getYuanAmountByFen(Long amount) {
|
||||
BigDecimal yuanAmount = new BigDecimal(amount).divide(new BigDecimal(100));
|
||||
return yuanAmount.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.czg.third.alipay.dto.config;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2026/1/4 13:49
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AlipayConfigDto {
|
||||
|
||||
/**
|
||||
* 支付宝 AppId
|
||||
*/
|
||||
private String appId;
|
||||
|
||||
/**
|
||||
* 商户私钥
|
||||
*/
|
||||
private String privateKey;
|
||||
|
||||
/**
|
||||
* 支付宝公钥
|
||||
*/
|
||||
private String alipayPublicKey;
|
||||
|
||||
/**
|
||||
* 支付宝支付域名
|
||||
* <a href="https://openapi.alipay.com/gateway.do"></a>
|
||||
*/
|
||||
private String domain;
|
||||
|
||||
/**
|
||||
* 第三方应用 签约当面付
|
||||
*/
|
||||
public static AlipayConfigDto getThirdDefaultConfig() {
|
||||
return new AlipayConfigDto()
|
||||
.setAppId("2021006121646825")
|
||||
.setPrivateKey("MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCz3FkdffxZibdwis9W7eOW1dEjGAbSvRDL2ikfeCIW5KZNoIjUqxI0mIoUlLRRKO71QLHZS1Vb2aJp8jeOAqIPa8e76HTneQEzk3FGA8gpraSGvbadHWzvxnmYKsts1TBiEZQL82ySJXhQTJvZ6jyDM7s6wHHUnrH+Qi29QpppQ1sxsoJeCtajUgRg3btD6XbBcyFAX3pzM56Kw9eaIjZoD8WToZOM/Y3sqNL2uo8lLqcIpTrI7Pq5ZOspmBQ+t8v3rS9IdDZZMvd0trzS67AXwHz8rKPBT/lL1A4iHnXCHUvktusX1fPs3/RGY/a7PIddaBLnfY0GcueE16K7QcrXAgMBAAECggEAbSdT2eckp75BWoaTcGEs1tRqeM7TDT/6moyKmnOQ1K3tE31SrSYpBUxxuC3LBNo/sw2RIZtrcTOyMnPyLTgB3DP/4lUf5X51MTTQ8LnI1ypvh+pIki9Sdm3QS33lOOZk149tdpdDk6ozyx/DEcvq74EMpoo2SuAIi5LkKVDrXuehvGA/WeXtpmuPgqRFdIA+JBlA3knHk5XEQY/k2Y31gq5oCwNL9iT9OAZqVkukE6EnvCXE9t2rAV4/snYilaf/UaO+ktgEwSbPBQ8YKlovDAarMBbGtgr6E174A9djlPyR+W/fgx8rlTwSWtieb9MkO8LN3KSxgVs0kY5U8OHg8QKBgQDljJq9kTFHare+W/fAXdUy3tJprfNQCAii6s+GuDfTQiviVQDtWmdtHAN+xU3to7MepvVhwHsqtQnZXKTtZuwwxn82FNl7A5RYD3GVFW+wG6AsGLIdESrWxySoL6Kx8QmNpMEVg8acT/ywzW/RnUXS5vU7GIi8GA0vtyBo24R9KQKBgQDIlf/R9+iNk9oXlbB/k4um9eVvBBS7l5cx4E5Id5Dpp4kGZfPZEa7oDsEUstZZM9mgQLJK/noNWbcf0+BohCR5ux7SC12qIoxwN3k4BzTDqrS8BzFuVVp5PELUsf/uCbRn05iMzpiDUhj3Vde04wvjHYIobfKlZO2HeSWXCpUH/wKBgQC8wSuU6ck90pEY5QMKmZ3wYK1g3PsQOirv3Gmde+nbu7PePsuuYQJfBAQTwCZeXJezgtKP+PjOm2Nn6vhrhpB9YxvD2s0ijET1TG23i5L1myHQYNZFdJJnXgXUjqcX7v5ODMYA7QTqEBPXRnbGRK7fx66rU3dMQ/LD46+wyaFeUQKBgA4QTk53dkuu6SSsLyLSwoDjTsHY5Gc+urAZjQORtoxbXcUgEtfOYJgOqMT9wP+iHgkZYCbX7tDO0IMfxOUvFqueTgvmFhwergAUM6CVCMMLTf689l9JBr3nVrw4+rvC3G5HLLP6rEDQ2cVFtIkPPj8fS4fwJYopKGpOOS9843QbAoGBAMoHH8LqoZ50FLsospx/hJe24Cd8wCgQTXSa/hMqNZ1999JDhftMt7R0ZdB1he2LReACe0K9ntBU4H4u225zZ3wZlyOfoyerAHuLK/ysNlgIIzblZlOxbBJ64Kul8leXzlYy3tOZuZ997KqBcWPCE3LUBBNvM6E3blJUnlmJAVoi")
|
||||
.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQkrz+emAuS1mB3KKDOMmAZRd/BlPbh7fAIHAqAj1+QCZNcV3o2BTLIIqnuKpSlFXDG3uDzp2VsBxcizXuBbFyPGylnD9CgCj5abyh3+FIHPAZ2IM3TtpqImZ0TSPGXrMli4Nir7MvZktgccCqQKCC4o6iaDGz+UwWwJUIPna8fm2tiTZ+KH150CZbKVj4ZGNpBh5XSV/1dRgyQIV9D/EwSbkZ0n6VgKQLJBi0C2UE3QB17aL1Ir6+gDXIDbknN8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB")
|
||||
.setDomain("https://openapi.alipay.com");
|
||||
// return new AlipayConfigDto()
|
||||
// .setAppId("2021004174605036")
|
||||
// .setPrivateKey("MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQD48HaUoV7OH7os+9L01kHgxzwIhJick4OkFq4aHsntsXEJ J3gedhuEZtV8oHKZ30DPW12IJ4S8NXtpr8OWaqrAPFonf4wVaRY1d0yIAea57kfLEn9oOEEy4FzARgMNDkyxC+/3OUdGbLHpTjfVX3gusXsEhUDy1/WewihAkoNYF37+W3W/uVLzeWoPq0EcUbRv/G/t/p6gL69ltsMAiVFG4Q/Yk24YAN6lYgBPNLXUEwQ1Q+T+1omjfavHgvarKOp33z3JOUH+aGOmDsJ5Y9gyGtJzOCipAd8Zcv+T1ygsEzZYO1/gzcbPnfO1ShqStCHzssuw8FBVx2JdfQKXKMMNAgMBAAECggEAVTrO/pg5Q00titU1Jspsh67u6OOs9H605Ws2dI7yB8VmtAGlaJh7V1t14FN2qSP8poHbhhAxq9aLyGV7C3a9u09udnN+3J28EtYjh7VO732bavWMVXxdJjQWzWWrCb9JlpxFrlkYBA6W4w/6ob0sAqCVQ7jzwbEa0R4cde8ztOa5nysKSfr4YTSs0gqvoiC6fmg8eiRJraEQBoYz9VkKFtOhhh/4w5FhVcYQ2gQvZ3kK3QVuD1eJIQKlCtz8qaox9lXKDiZT4SCmnKshdUL0u5TYIcYeBjZmhJz0Q50KHcpZrCs5y7I0+vRBH3hU+TKSQt7ureymwhbwWMHScLV2gQKBgQD+58SHXhr5M8NGagAmTdsgmCnNv2kOYMd4STyPMY10SVwCv1Bk808ZuP+7e558J1b5/OuDLI5dLq6xrZ/1wLv1G++XqxI00hlFuWS5mUGJVcXotT1mw20rVeUILc7Qe3mLvbMGgfyKf4A7Qa5SSZ4bDeDTJYaFxyiQ281hMzDuPQKBgQD6AiL/Na2/uPH4CG6juwpjYvYVUcjK+7gbRwf3wWsWMpk90Z4ju2iUiP5c1J/oK9P+1T3PIr6M4Xjza8JJj+r9KC/PVB0gBv6vVM96cDpKUEy/UMpcn/T81vqj/Z+WEOODU8Ms6NiTTm+u9ldvpCjbu0u8M+9c0JeIyadJvSTFEQKBgQCsxmFyM3nq8YfpgU2qqNjfBeRH3faSVUy+nj1a/YZYjKS+A/i1BCnYUImeBVNN6chNV342ggvY4xxruDiU9Vcw8wd58O09Oi8BEIFSP6upL6cebUI6Fjo3xlegLJRiwV6INkNTJOYM5hD/mSxUACwXQFfkJipBINXBIgraWD1RLQKBgQCj49axWq0F6+WjZVOyPaD3uh37p9trRUxRhWTxw3fB23WdktaKMgbCqHOmwzP4bRLSEVQtf2dOz1gMqu14b8HqJvgAf/F/11YJ9hz09LEhmjZVjE68HZfqT7uK2W5OX8/lfXmK7TFcj6SjG5YB96lZMhTZ0WnufEd6QkdKDZYXIQKBgQD9GDTcIMbFwbEaKHnfZaTD3f876EGRgsgrCxwdEk7LBCRPwWo7yI929M4psIlpNwNeiyjBkBunWIVkpznp6qPtJqagIPUYesU4f5v6/okq5wcpaNKSkWbIvWVLaLGOiA1aeGJtbpMpyClbSr52puHpRRdvAiIEQ74yYh0JX8q96g==")
|
||||
// .setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQkrz+emAuS1mB3KKDOMmAZRd/BlPbh7fAIHAqAj1+QCZNcV3o2BTLIIqnuKpSlFXDG3uDzp2VsBxcizXuBbFyPGylnD9CgCj5abyh3+FIHPAZ2IM3TtpqImZ0TSPGXrMli4Nir7MvZktgccCqQKCC4o6iaDGz+UwWwJUIPna8fm2tiTZ+KH150CZbKVj4ZGNpBh5XSV/1dRgyQIV9D/EwSbkZ0n6VgKQLJBi0C2UE3QB17aL1Ir6+gDXIDbknN8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB")
|
||||
// .setDomain("https://openapi.alipay.com/gateway.do");
|
||||
// return new AlipayConfigDto()
|
||||
// .setAppId("2021004145625815")
|
||||
// .setPrivateKey("MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCAjDBuS8K/IJb9ui+KuNm/sTUdEiaji4BNpZ92avO1N5JpNlGmac6ec4p3tNFT950sBLcQkClcUpQxUHQzAT6DYNNXOKyvfI/EmcqwCw6PaMNLs/8cV//J2WWZBUhLaOsjKurpm9/3W5MnTh4BGxIfBoeBMA8f8K3BgKdmyKtvIEV2h2cyjsMskdn+g6oNZcmWcms0pvpPHyH46mRaGFhpp0v19wX3WsamGldh1L2VntmaDN3C2XbSrXv90XYp5bEUqwTbLwXpMAlzTibF56d/iqv9oYi8cpAKougUFLOymnbutLNs2tLrEDSFwHcmG2/wbZHybZyYcIgFgv4arf+tAgMBAAECggEAf7hKKlw1y6Z6vvAtalxNZUuRZSfyog3p1bwYWxTavZPQcZ7Zs0lvVDmiO1u5m/7q96BbryY9IhCeUv0H5uF2lhwu/3s9AEL3qTPQkeb6eXxyhhX6A9RfPdM1Qbtg4CQHdHKg4qjP9znSVHwmDZ0y/QaEvdPdQzPjv92u9c2tn4N4x6XyBYcU5gzxiJNnIugCmBgcJo/3H2fgV+XXEhORPvy5of9b4oATHEaLS/8dAS2wuOjhzaGS4MXp3VkXn3XaYjwSzaL03qYWA+xm+aO5sJv8bmqZW7sNVck5o3sPo7cQ4VkBFVzyrRdmJcxcSRJ9MsB9JsrhoKI8pgaXrVie4QKBgQDU2vai0lpBIK/0jzRpPNoqdT8lnafnnWni8nU4kfAh+gCLi+HBPhQRT0kv4unQc2q2/gALE7sgZVO00JGY5a3R0orsojPoUSZlpypGW7GGqKy576NHn0nw4o/PdfysT92VWgt1hlfTf6qfCDhfE9APU+RGvlSWXcT8nxVel3iUaQKBgQCamoJN6+4v+chJvL2nqV8NVVRLp0vDIHxs1QOtKwUodx8Qp1D6CJYtavCXn8aNUFVNQJPJ7TQPpJjXP2rI4SN01weDwx+I+wh8PBGHV6/234R+6TvFgY1PrYgCdfNP4i/E7B4uyEhAxdU73PB8qkqRAeJGok05p7oG71KCOBiYpQKBgEZfGflcuDAeAW5GRhqg3rP4zWa/R7qgZVh9tll8jjp9b96y4XFE99d9MgId8BVVgyt6sEL5Q/2C4ni+F9TH4n6jMADp42VkJuCmsqhOOlP9whU67+2G8Sgtj0QUivPg964f9ffl8XVgGOW5DwIIB9p5btggptCLscufQK5kP545AoGADBvf6tR4wl8w9b2HqTMV08iEIqzGvVC1Dh0c/Zop/EJgN4CzUfIMOSBwGaAVAApzs+pD6QPgGP2OTwWTioo/qa4R05sbxDHNN1XJFa2jhZV6HiqMWOrNs5jm1zJ/zRjtHuJTdtyO9CvKiLbESy9XScY4/8lEfSiK5HIoJzTXkFUCgYAkYkvkW6psJpWj05XWq44UN0n6QOU/Igl35Um/iuOMVhsTmIt09STQVTuzJzfH82+sCqoRsD1blE5unKNUC1DK77aNKTv3Z0dxN9R7FAyfZRiYQXTrbBPBqWjay6FCNxn8e8UsJN4Z6FIV2LGlQI114krSap1MALKLVvnld0NaUQ==")
|
||||
// .setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQkrz+emAuS1mB3KKDOMmAZRd/BlPbh7fAIHAqAj1+QCZNcV3o2BTLIIqnuKpSlFXDG3uDzp2VsBxcizXuBbFyPGylnD9CgCj5abyh3+FIHPAZ2IM3TtpqImZ0TSPGXrMli4Nir7MvZktgccCqQKCC4o6iaDGz+UwWwJUIPna8fm2tiTZ+KH150CZbKVj4ZGNpBh5XSV/1dRgyQIV9D/EwSbkZ0n6VgKQLJBi0C2UE3QB17aL1Ir6+gDXIDbknN8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB")
|
||||
// .setDomain("https://openapi.alipay.com/gateway.do");
|
||||
}
|
||||
|
||||
/**
|
||||
* 直付通商户配置
|
||||
*/
|
||||
public static AlipayConfigDto getDefaultConfig() {
|
||||
// return new AlipayConfigDto()
|
||||
// .setAppId("2021006121646825")
|
||||
// .setPrivateKey("MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCz3FkdffxZibdwis9W7eOW1dEjGAbSvRDL2ikfeCIW5KZNoIjUqxI0mIoUlLRRKO71QLHZS1Vb2aJp8jeOAqIPa8e76HTneQEzk3FGA8gpraSGvbadHWzvxnmYKsts1TBiEZQL82ySJXhQTJvZ6jyDM7s6wHHUnrH+Qi29QpppQ1sxsoJeCtajUgRg3btD6XbBcyFAX3pzM56Kw9eaIjZoD8WToZOM/Y3sqNL2uo8lLqcIpTrI7Pq5ZOspmBQ+t8v3rS9IdDZZMvd0trzS67AXwHz8rKPBT/lL1A4iHnXCHUvktusX1fPs3/RGY/a7PIddaBLnfY0GcueE16K7QcrXAgMBAAECggEAbSdT2eckp75BWoaTcGEs1tRqeM7TDT/6moyKmnOQ1K3tE31SrSYpBUxxuC3LBNo/sw2RIZtrcTOyMnPyLTgB3DP/4lUf5X51MTTQ8LnI1ypvh+pIki9Sdm3QS33lOOZk149tdpdDk6ozyx/DEcvq74EMpoo2SuAIi5LkKVDrXuehvGA/WeXtpmuPgqRFdIA+JBlA3knHk5XEQY/k2Y31gq5oCwNL9iT9OAZqVkukE6EnvCXE9t2rAV4/snYilaf/UaO+ktgEwSbPBQ8YKlovDAarMBbGtgr6E174A9djlPyR+W/fgx8rlTwSWtieb9MkO8LN3KSxgVs0kY5U8OHg8QKBgQDljJq9kTFHare+W/fAXdUy3tJprfNQCAii6s+GuDfTQiviVQDtWmdtHAN+xU3to7MepvVhwHsqtQnZXKTtZuwwxn82FNl7A5RYD3GVFW+wG6AsGLIdESrWxySoL6Kx8QmNpMEVg8acT/ywzW/RnUXS5vU7GIi8GA0vtyBo24R9KQKBgQDIlf/R9+iNk9oXlbB/k4um9eVvBBS7l5cx4E5Id5Dpp4kGZfPZEa7oDsEUstZZM9mgQLJK/noNWbcf0+BohCR5ux7SC12qIoxwN3k4BzTDqrS8BzFuVVp5PELUsf/uCbRn05iMzpiDUhj3Vde04wvjHYIobfKlZO2HeSWXCpUH/wKBgQC8wSuU6ck90pEY5QMKmZ3wYK1g3PsQOirv3Gmde+nbu7PePsuuYQJfBAQTwCZeXJezgtKP+PjOm2Nn6vhrhpB9YxvD2s0ijET1TG23i5L1myHQYNZFdJJnXgXUjqcX7v5ODMYA7QTqEBPXRnbGRK7fx66rU3dMQ/LD46+wyaFeUQKBgA4QTk53dkuu6SSsLyLSwoDjTsHY5Gc+urAZjQORtoxbXcUgEtfOYJgOqMT9wP+iHgkZYCbX7tDO0IMfxOUvFqueTgvmFhwergAUM6CVCMMLTf689l9JBr3nVrw4+rvC3G5HLLP6rEDQ2cVFtIkPPj8fS4fwJYopKGpOOS9843QbAoGBAMoHH8LqoZ50FLsospx/hJe24Cd8wCgQTXSa/hMqNZ1999JDhftMt7R0ZdB1he2LReACe0K9ntBU4H4u225zZ3wZlyOfoyerAHuLK/ysNlgIIzblZlOxbBJ64Kul8leXzlYy3tOZuZ997KqBcWPCE3LUBBNvM6E3blJUnlmJAVoi")
|
||||
// .setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQkrz+emAuS1mB3KKDOMmAZRd/BlPbh7fAIHAqAj1+QCZNcV3o2BTLIIqnuKpSlFXDG3uDzp2VsBxcizXuBbFyPGylnD9CgCj5abyh3+FIHPAZ2IM3TtpqImZ0TSPGXrMli4Nir7MvZktgccCqQKCC4o6iaDGz+UwWwJUIPna8fm2tiTZ+KH150CZbKVj4ZGNpBh5XSV/1dRgyQIV9D/EwSbkZ0n6VgKQLJBi0C2UE3QB17aL1Ir6+gDXIDbknN8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB")
|
||||
// .setDomain("https://openapi.alipay.com");
|
||||
return new AlipayConfigDto()
|
||||
.setAppId("2021004174605036")
|
||||
.setPrivateKey("MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQD48HaUoV7OH7os+9L01kHgxzwIhJick4OkFq4aHsntsXEJ J3gedhuEZtV8oHKZ30DPW12IJ4S8NXtpr8OWaqrAPFonf4wVaRY1d0yIAea57kfLEn9oOEEy4FzARgMNDkyxC+/3OUdGbLHpTjfVX3gusXsEhUDy1/WewihAkoNYF37+W3W/uVLzeWoPq0EcUbRv/G/t/p6gL69ltsMAiVFG4Q/Yk24YAN6lYgBPNLXUEwQ1Q+T+1omjfavHgvarKOp33z3JOUH+aGOmDsJ5Y9gyGtJzOCipAd8Zcv+T1ygsEzZYO1/gzcbPnfO1ShqStCHzssuw8FBVx2JdfQKXKMMNAgMBAAECggEAVTrO/pg5Q00titU1Jspsh67u6OOs9H605Ws2dI7yB8VmtAGlaJh7V1t14FN2qSP8poHbhhAxq9aLyGV7C3a9u09udnN+3J28EtYjh7VO732bavWMVXxdJjQWzWWrCb9JlpxFrlkYBA6W4w/6ob0sAqCVQ7jzwbEa0R4cde8ztOa5nysKSfr4YTSs0gqvoiC6fmg8eiRJraEQBoYz9VkKFtOhhh/4w5FhVcYQ2gQvZ3kK3QVuD1eJIQKlCtz8qaox9lXKDiZT4SCmnKshdUL0u5TYIcYeBjZmhJz0Q50KHcpZrCs5y7I0+vRBH3hU+TKSQt7ureymwhbwWMHScLV2gQKBgQD+58SHXhr5M8NGagAmTdsgmCnNv2kOYMd4STyPMY10SVwCv1Bk808ZuP+7e558J1b5/OuDLI5dLq6xrZ/1wLv1G++XqxI00hlFuWS5mUGJVcXotT1mw20rVeUILc7Qe3mLvbMGgfyKf4A7Qa5SSZ4bDeDTJYaFxyiQ281hMzDuPQKBgQD6AiL/Na2/uPH4CG6juwpjYvYVUcjK+7gbRwf3wWsWMpk90Z4ju2iUiP5c1J/oK9P+1T3PIr6M4Xjza8JJj+r9KC/PVB0gBv6vVM96cDpKUEy/UMpcn/T81vqj/Z+WEOODU8Ms6NiTTm+u9ldvpCjbu0u8M+9c0JeIyadJvSTFEQKBgQCsxmFyM3nq8YfpgU2qqNjfBeRH3faSVUy+nj1a/YZYjKS+A/i1BCnYUImeBVNN6chNV342ggvY4xxruDiU9Vcw8wd58O09Oi8BEIFSP6upL6cebUI6Fjo3xlegLJRiwV6INkNTJOYM5hD/mSxUACwXQFfkJipBINXBIgraWD1RLQKBgQCj49axWq0F6+WjZVOyPaD3uh37p9trRUxRhWTxw3fB23WdktaKMgbCqHOmwzP4bRLSEVQtf2dOz1gMqu14b8HqJvgAf/F/11YJ9hz09LEhmjZVjE68HZfqT7uK2W5OX8/lfXmK7TFcj6SjG5YB96lZMhTZ0WnufEd6QkdKDZYXIQKBgQD9GDTcIMbFwbEaKHnfZaTD3f876EGRgsgrCxwdEk7LBCRPwWo7yI929M4psIlpNwNeiyjBkBunWIVkpznp6qPtJqagIPUYesU4f5v6/okq5wcpaNKSkWbIvWVLaLGOiA1aeGJtbpMpyClbSr52puHpRRdvAiIEQ74yYh0JX8q96g==")
|
||||
.setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQkrz+emAuS1mB3KKDOMmAZRd/BlPbh7fAIHAqAj1+QCZNcV3o2BTLIIqnuKpSlFXDG3uDzp2VsBxcizXuBbFyPGylnD9CgCj5abyh3+FIHPAZ2IM3TtpqImZ0TSPGXrMli4Nir7MvZktgccCqQKCC4o6iaDGz+UwWwJUIPna8fm2tiTZ+KH150CZbKVj4ZGNpBh5XSV/1dRgyQIV9D/EwSbkZ0n6VgKQLJBi0C2UE3QB17aL1Ir6+gDXIDbknN8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB")
|
||||
.setDomain("https://openapi.alipay.com/gateway.do");
|
||||
// return new AlipayConfigDto()
|
||||
// .setAppId("2021004145625815")
|
||||
// .setPrivateKey("MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCAjDBuS8K/IJb9ui+KuNm/sTUdEiaji4BNpZ92avO1N5JpNlGmac6ec4p3tNFT950sBLcQkClcUpQxUHQzAT6DYNNXOKyvfI/EmcqwCw6PaMNLs/8cV//J2WWZBUhLaOsjKurpm9/3W5MnTh4BGxIfBoeBMA8f8K3BgKdmyKtvIEV2h2cyjsMskdn+g6oNZcmWcms0pvpPHyH46mRaGFhpp0v19wX3WsamGldh1L2VntmaDN3C2XbSrXv90XYp5bEUqwTbLwXpMAlzTibF56d/iqv9oYi8cpAKougUFLOymnbutLNs2tLrEDSFwHcmG2/wbZHybZyYcIgFgv4arf+tAgMBAAECggEAf7hKKlw1y6Z6vvAtalxNZUuRZSfyog3p1bwYWxTavZPQcZ7Zs0lvVDmiO1u5m/7q96BbryY9IhCeUv0H5uF2lhwu/3s9AEL3qTPQkeb6eXxyhhX6A9RfPdM1Qbtg4CQHdHKg4qjP9znSVHwmDZ0y/QaEvdPdQzPjv92u9c2tn4N4x6XyBYcU5gzxiJNnIugCmBgcJo/3H2fgV+XXEhORPvy5of9b4oATHEaLS/8dAS2wuOjhzaGS4MXp3VkXn3XaYjwSzaL03qYWA+xm+aO5sJv8bmqZW7sNVck5o3sPo7cQ4VkBFVzyrRdmJcxcSRJ9MsB9JsrhoKI8pgaXrVie4QKBgQDU2vai0lpBIK/0jzRpPNoqdT8lnafnnWni8nU4kfAh+gCLi+HBPhQRT0kv4unQc2q2/gALE7sgZVO00JGY5a3R0orsojPoUSZlpypGW7GGqKy576NHn0nw4o/PdfysT92VWgt1hlfTf6qfCDhfE9APU+RGvlSWXcT8nxVel3iUaQKBgQCamoJN6+4v+chJvL2nqV8NVVRLp0vDIHxs1QOtKwUodx8Qp1D6CJYtavCXn8aNUFVNQJPJ7TQPpJjXP2rI4SN01weDwx+I+wh8PBGHV6/234R+6TvFgY1PrYgCdfNP4i/E7B4uyEhAxdU73PB8qkqRAeJGok05p7oG71KCOBiYpQKBgEZfGflcuDAeAW5GRhqg3rP4zWa/R7qgZVh9tll8jjp9b96y4XFE99d9MgId8BVVgyt6sEL5Q/2C4ni+F9TH4n6jMADp42VkJuCmsqhOOlP9whU67+2G8Sgtj0QUivPg964f9ffl8XVgGOW5DwIIB9p5btggptCLscufQK5kP545AoGADBvf6tR4wl8w9b2HqTMV08iEIqzGvVC1Dh0c/Zop/EJgN4CzUfIMOSBwGaAVAApzs+pD6QPgGP2OTwWTioo/qa4R05sbxDHNN1XJFa2jhZV6HiqMWOrNs5jm1zJ/zRjtHuJTdtyO9CvKiLbESy9XScY4/8lEfSiK5HIoJzTXkFUCgYAkYkvkW6psJpWj05XWq44UN0n6QOU/Igl35Um/iuOMVhsTmIt09STQVTuzJzfH82+sCqoRsD1blE5unKNUC1DK77aNKTv3Z0dxN9R7FAyfZRiYQXTrbBPBqWjay6FCNxn8e8UsJN4Z6FIV2LGlQI114krSap1MALKLVvnld0NaUQ==")
|
||||
// .setAlipayPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiQkrz+emAuS1mB3KKDOMmAZRd/BlPbh7fAIHAqAj1+QCZNcV3o2BTLIIqnuKpSlFXDG3uDzp2VsBxcizXuBbFyPGylnD9CgCj5abyh3+FIHPAZ2IM3TtpqImZ0TSPGXrMli4Nir7MvZktgccCqQKCC4o6iaDGz+UwWwJUIPna8fm2tiTZ+KH150CZbKVj4ZGNpBh5XSV/1dRgyQIV9D/EwSbkZ0n6VgKQLJBi0C2UE3QB17aL1Ir6+gDXIDbknN8O7GUD3aMGdThYdSRUb5wp9CZ5qfV7vCS/CgaRo38nhH3NOzkTL+7v0m1ZDHPmqEkn9VzZN6sCQdL7PoAOjHOCwIDAQAB")
|
||||
// .setDomain("https://openapi.alipay.com/gateway.do");
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.czg.third.wechat;
|
||||
|
||||
import javax.crypto.AEADBadTagException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import javax.crypto.spec.GCMParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* 微信参数 AES 解密
|
||||
* @author GYJoker
|
||||
*/
|
||||
public class WechatAesUtil {
|
||||
static final int KEY_LENGTH_BYTE = 32;
|
||||
static final int TAG_LENGTH_BIT = 128;
|
||||
private final byte[] aesKey;
|
||||
public WechatAesUtil(byte[] key) {
|
||||
if (key.length != KEY_LENGTH_BYTE) {
|
||||
throw new IllegalArgumentException("无效的ApiV3Key,长度必须为32个字节");
|
||||
}
|
||||
this.aesKey = key;
|
||||
}
|
||||
public String decryptToString(byte[] associatedData, byte[] nonce, String ciphertext)
|
||||
throws GeneralSecurityException {
|
||||
try {
|
||||
|
||||
// 调试信息:打印参数信息
|
||||
System.out.println("associatedData长度: " + (associatedData != null ? associatedData.length : 0));
|
||||
System.out.println("nonce长度: " + (nonce != null ? nonce.length : 0));
|
||||
System.out.println("ciphertext长度: " + ciphertext.length());
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
||||
SecretKeySpec key = new SecretKeySpec(aesKey, "AES");
|
||||
GCMParameterSpec spec = new GCMParameterSpec(TAG_LENGTH_BIT, nonce);
|
||||
cipher.init(Cipher.DECRYPT_MODE, key, spec);
|
||||
|
||||
// 处理 associatedData,确保使用空数组而非 null
|
||||
cipher.updateAAD(associatedData != null ? associatedData : new byte[0]);
|
||||
|
||||
byte[] decodedCiphertext = Base64.getDecoder().decode(ciphertext);
|
||||
System.out.println("解码后密文长度: " + decodedCiphertext.length);
|
||||
|
||||
byte[] plaintext = cipher.doFinal(decodedCiphertext);
|
||||
return new String(plaintext, StandardCharsets.UTF_8);
|
||||
} catch (AEADBadTagException e) {
|
||||
// 捕获标签不匹配异常,提供更详细的错误信息
|
||||
throw new GeneralSecurityException("解密失败: 标签不匹配,可能是密钥错误、数据被篡改或参数不匹配", e);
|
||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
|
||||
throw new IllegalStateException(e);
|
||||
} catch (InvalidKeyException | InvalidAlgorithmParameterException e) {
|
||||
throw new IllegalArgumentException("无效的密钥或参数", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package com.czg.third.wechat;
|
||||
|
||||
import com.czg.third.wechat.dto.config.WechatPayConfigDto;
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.RSAPublicKeyConfig;
|
||||
import com.wechat.pay.java.service.file.FileUploadService;
|
||||
|
||||
/**
|
||||
* 微信支付 配置
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2025/12/26 09:33
|
||||
*/
|
||||
public class WechatConfig {
|
||||
|
||||
/**
|
||||
* 获取微信支付配置
|
||||
* @param dto 微信支付配置
|
||||
* @return 微信支付配置
|
||||
*/
|
||||
public static Config getRsaConfig(WechatPayConfigDto dto) {
|
||||
if (dto == null) {
|
||||
dto = WechatPayConfigDto.getDefaultConfig();
|
||||
}
|
||||
return new RSAPublicKeyConfig.Builder()
|
||||
.merchantId(dto.getMerchantId())
|
||||
.privateKey(dto.getPrivateKey())
|
||||
.publicKey(dto.getPublicKey())
|
||||
.publicKeyId(dto.getPublicKeyId())
|
||||
.merchantSerialNumber(dto.getSerialNumber())
|
||||
.apiV3Key(dto.getApiV3Key())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static FileUploadService getFileUploadServiceByConfig(Config config) {
|
||||
return new FileUploadService.Builder()
|
||||
.config(config)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件上传服务
|
||||
* @param dto 微信支付配置
|
||||
* @return 文件上传服务
|
||||
*/
|
||||
public static FileUploadService getFileUploadService(WechatPayConfigDto dto) {
|
||||
return getFileUploadServiceByConfig(getRsaConfig(dto));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package com.czg.third.wechat;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.PublicKey;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* 微信支付加解密
|
||||
* @author yjjie
|
||||
* @date 2025/12/26 10:58
|
||||
*/
|
||||
@Slf4j
|
||||
public class WechatEncrypt {
|
||||
|
||||
public static String rsaEncryptOaep(String message, PublicKey publicKey) {
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||
byte[] data = message.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] cipherData = cipher.doFinal(data);
|
||||
return Base64.getEncoder().encodeToString(cipherData);
|
||||
} catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
|
||||
log.error("当前Java环境不支持RSA v1.5/OAEP");
|
||||
} catch (InvalidKeyException e) {
|
||||
log.error("无效的证书");
|
||||
} catch (IllegalBlockSizeException | BadPaddingException e) {
|
||||
log.error("加密原串的长度不能超过214字节");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getFileBytesSha256(byte[] input) throws NoSuchAlgorithmException {
|
||||
return bytesToHex(calculateSha256(input));
|
||||
}
|
||||
|
||||
/**
|
||||
* 核心方法:计算字节数组的 SHA-256 哈希值
|
||||
* @param input 待计算的字节数组
|
||||
* @return SHA-256 哈希值(32 字节的字节数组)
|
||||
*/
|
||||
private static byte[] calculateSha256(byte[] input) throws NoSuchAlgorithmException {
|
||||
// 获取 SHA-256 消息摘要实例(Java 21 完全兼容)
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
// 计算哈希值
|
||||
return digest.digest(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* 辅助方法:将字节数组转换为十六进制字符串(SHA-256 结果常用格式)
|
||||
* @param bytes 待转换的字节数组
|
||||
* @return 十六进制字符串(SHA-256 对应 64 位字符串)
|
||||
*/
|
||||
private static String bytesToHex(byte[] bytes) {
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
// Java 21 可使用 var 简化声明
|
||||
for (var b : bytes) {
|
||||
// 将字节转换为两位十六进制数,不足补 0
|
||||
String hex = Integer.toHexString(0xff & b);
|
||||
if (hex.length() == 1) {
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
return hexString.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,444 +0,0 @@
|
||||
package com.czg.third.wechat;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONWriter;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.dto.req.*;
|
||||
import com.czg.dto.resp.EntryThirdRespDto;
|
||||
import com.czg.dto.resp.QueryStatusResp;
|
||||
import com.czg.dto.resp.WechatBankBranchRespDto;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.third.wechat.dto.config.WechatPayConfigDto;
|
||||
import com.czg.third.wechat.dto.req.entry.*;
|
||||
import com.czg.third.wechat.dto.req.entry.business.WechatEntryBusinessReqDto;
|
||||
import com.czg.third.wechat.dto.req.entry.business.WechatEntryIdentityReqDto;
|
||||
import com.czg.third.wechat.dto.req.entry.business.WechatEntryLicenseReqDto;
|
||||
import com.czg.third.wechat.dto.req.entry.business.sales.*;
|
||||
import com.czg.third.wechat.dto.req.entry.id.WechatEntryIdCardReqDto;
|
||||
import com.czg.third.wechat.dto.resp.WechatAuditDetail;
|
||||
import com.czg.third.wechat.dto.resp.WechatQueryStateResp;
|
||||
import com.czg.utils.UploadFileUtil;
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.cipher.PrivacyEncryptor;
|
||||
import com.wechat.pay.java.core.exception.MalformedMessageException;
|
||||
import com.wechat.pay.java.service.file.FileUploadService;
|
||||
import com.wechat.pay.java.service.file.model.FileUploadResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 微信支付进件 管理
|
||||
* 参考地址 <a href="https://pay.weixin.qq.com/doc/v3/partner/4012719997">...</a>
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2025/12/26 10:57
|
||||
*/
|
||||
@Slf4j
|
||||
public class WechatEntryManager {
|
||||
|
||||
/**
|
||||
* 查询商户进件状态
|
||||
*
|
||||
* @param configDto 配置信息
|
||||
* @param applyId 自系统的商户编号
|
||||
* @return 进件状态
|
||||
*/
|
||||
public static QueryStatusResp queryMerchantEntryStatus(WechatPayConfigDto configDto, String applyId) {
|
||||
QueryStatusResp queryStatusResp = new QueryStatusResp();
|
||||
queryStatusResp.setPlatform(PayCst.Platform.WECHAT);
|
||||
queryStatusResp.setMerchantCode(applyId);
|
||||
|
||||
String resp = WechatReqUtils.getReq(configDto, "/v3/applyment4sub/applyment/applyment_id/" + applyId, Map.of());
|
||||
JSONObject object = JSONObject.parseObject(resp);
|
||||
if (resp.contains("message")) {
|
||||
log.error("微信查询进件状态失败:{}", resp);
|
||||
queryStatusResp.setFailReason(object.getString("message"));
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
return queryStatusResp;
|
||||
}
|
||||
log.info("微信查询进件状态:{}", resp);
|
||||
WechatQueryStateResp stateResp = JSONObject.parseObject(resp, WechatQueryStateResp.class);
|
||||
|
||||
queryStatusResp.setApplyId(stateResp.getApplyId());
|
||||
switch (stateResp.getApplyState()) {
|
||||
case "APPLYMENT_STATE_EDITTING" -> {
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.WAIT);
|
||||
queryStatusResp.setFailReason("");
|
||||
}
|
||||
case "APPLYMENT_STATE_AUDITING" -> {
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.AUDIT);
|
||||
queryStatusResp.setFailReason("");
|
||||
queryStatusResp.setSignUrl(stateResp.getSignUrl());
|
||||
if (StrUtil.isNotBlank(queryStatusResp.getSignUrl())) {
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.SIGN);
|
||||
}
|
||||
}
|
||||
case "APPLYMENT_STATE_REJECTED" -> {
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for (WechatAuditDetail auditDetail : stateResp.getAuditDetail()) {
|
||||
msg.append(auditDetail.getRejectReason()).append(",");
|
||||
}
|
||||
queryStatusResp.setFailReason(msg.toString());
|
||||
}
|
||||
case "APPLYMENT_STATE_TO_BE_CONFIRMED", "APPLYMENT_STATE_TO_BE_SIGNED" -> {
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.SIGN);
|
||||
queryStatusResp.setFailReason("");
|
||||
queryStatusResp.setSignUrl(stateResp.getSignUrl());
|
||||
}
|
||||
case "APPLYMENT_STATE_SIGNING", "APPLYMENT_STATE_FINISHED" -> {
|
||||
queryStatusResp.setStatus(PayCst.EntryStatus.FINISH);
|
||||
queryStatusResp.setFailReason("");
|
||||
queryStatusResp.setThirdMerchantId(stateResp.getSubMchId());
|
||||
}
|
||||
}
|
||||
|
||||
return queryStatusResp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 进件商户
|
||||
*
|
||||
* @param configDto 配置信息
|
||||
* @param reqDto 请求信息
|
||||
*/
|
||||
public static EntryThirdRespDto entryMerchant(WechatPayConfigDto configDto, AggregateMerchantDto reqDto) {
|
||||
EntryThirdRespDto respDto = new EntryThirdRespDto()
|
||||
.setPlatform(PayCst.Platform.WECHAT);
|
||||
try {
|
||||
WechatEntryReqDto entryReqDto = buildEntryParams(configDto, reqDto);
|
||||
log.info("微信进件参数:{}", JSONObject.toJSONString(entryReqDto));
|
||||
|
||||
String params = JSONObject.toJSONString(entryReqDto, JSONWriter.Feature.IgnoreEmpty);
|
||||
String respBody = WechatReqUtils.postReq(configDto, "/v3/applyment4sub/applyment/", params);
|
||||
JSONObject object = JSONObject.parseObject(respBody);
|
||||
log.info("微信进件结果:{}", respBody);
|
||||
if (respBody.contains("applyment_id")) {
|
||||
respDto.setStatus(PayCst.EntryStatus.INIT);
|
||||
respDto.setEntryId(object.getString("applyment_id"));
|
||||
respDto.setErrorMsg("");
|
||||
} else {
|
||||
respDto.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
respDto.setEntryId("");
|
||||
respDto.setErrorMsg(object.getString("message"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("微信进件报错:{}", e.getMessage());
|
||||
respDto.setStatus(PayCst.EntryStatus.REJECTED);
|
||||
respDto.setEntryId("");
|
||||
respDto.setErrorMsg(e.getMessage());
|
||||
}
|
||||
|
||||
return respDto;
|
||||
}
|
||||
|
||||
public static JSONObject queryBankList(WechatPayConfigDto configDto, Integer offset, Integer limit) {
|
||||
String resp = WechatReqUtils.getReq(configDto, "/v3/capital/capitallhh/banks/corporate-banking", Map.of("offset", offset, "limit", limit));
|
||||
log.info("微信查询银行列表:{}", resp);
|
||||
return JSONObject.parseObject(resp);
|
||||
}
|
||||
|
||||
public static WechatBankBranchRespDto queryBankBranchList(WechatPayConfigDto configDto, String bankAliceCode, String cityCode, Integer offset, Integer limit) {
|
||||
String resp = WechatReqUtils.getReq(configDto, "/v3/capital/capitallhh/banks/" + bankAliceCode + "/branches", Map.of("city_code", cityCode, "offset", offset, "limit", limit));
|
||||
log.info("微信查询银行支行列表:{}", resp);
|
||||
return JSONObject.parseObject(resp, WechatBankBranchRespDto.class);
|
||||
}
|
||||
|
||||
public static JSONObject queryProvinceList(WechatPayConfigDto configDto) {
|
||||
String resp = WechatReqUtils.getReq(configDto, "/v3/capital/capitallhh/areas/provinces", Map.of());
|
||||
log.info("微信查询省份列表:{}", resp);
|
||||
return JSONObject.parseObject(resp);
|
||||
}
|
||||
|
||||
public static JSONObject queryCityList(WechatPayConfigDto configDto, String provinceCode) {
|
||||
String resp = WechatReqUtils.getReq(configDto, "/v3/capital/capitallhh/areas/provinces/" + provinceCode + "/cities", Map.of());
|
||||
log.info("微信查询城市列表:{}", resp);
|
||||
return JSONObject.parseObject(resp);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传图片
|
||||
*
|
||||
* @param url 图片URL
|
||||
* @return 图片ID
|
||||
*/
|
||||
public static String uploadImage(WechatPayConfigDto configDto, String url) {
|
||||
if (configDto == null) {
|
||||
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||
}
|
||||
// 校验入参
|
||||
if (url == null || url.trim().isEmpty()) {
|
||||
log.error("上传图片失败:URL参数为空");
|
||||
return "";
|
||||
}
|
||||
|
||||
FileUploadService service = WechatConfig.getFileUploadService(configDto);
|
||||
|
||||
try {
|
||||
// 获取图片字节数组
|
||||
byte[] bytes = UploadFileUtil.downloadImage(url);
|
||||
if (bytes.length == 0) {
|
||||
log.error("下载的图片内容为空,URL:{}", url);
|
||||
return "";
|
||||
}
|
||||
|
||||
// 2. 计算SHA256
|
||||
String sha256Hex = WechatEncrypt.getFileBytesSha256(bytes);
|
||||
|
||||
// 3. 构造元数据(从URL提取文件名,或自定义)
|
||||
JSONObject meta = new JSONObject();
|
||||
meta.put("sha256", sha256Hex);
|
||||
// 从URL提取文件名,若提取失败则使用默认名
|
||||
String fileName = UploadFileUtil.extractFileNameFromUrl(url);
|
||||
meta.put("filename", fileName);
|
||||
|
||||
// 4. 上传图片到微信接口
|
||||
FileUploadResponse uploadResponse = service.uploadImage(
|
||||
configDto.getDomain() + "/v3/merchant/media/upload",
|
||||
meta.toJSONString(),
|
||||
fileName,
|
||||
bytes
|
||||
);
|
||||
|
||||
return uploadResponse.getMediaId();
|
||||
} catch (MalformedMessageException e) {
|
||||
log.error("微信上传图片报错1,URL:{}", url);
|
||||
} catch (Exception e) {
|
||||
log.error("微信上传图片报错2,URL:{}", url);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建进件参数
|
||||
*
|
||||
* @param reqDto 请求参数
|
||||
* @return 进件参数
|
||||
*/
|
||||
private static WechatEntryReqDto buildEntryParams(WechatPayConfigDto configDto, AggregateMerchantDto reqDto) {
|
||||
WechatEntryReqDto entryParams = new WechatEntryReqDto();
|
||||
|
||||
Config config = WechatConfig.getRsaConfig(configDto);
|
||||
PrivacyEncryptor encryptor = config.createEncryptor();
|
||||
|
||||
entryParams.setBusinessCode(reqDto.getMerchantCode());
|
||||
|
||||
MerchantBaseInfoDto baseInfo = reqDto.getMerchantBaseInfo();
|
||||
LegalPersonInfoDto legalPersonInfo = reqDto.getLegalPersonInfo();
|
||||
BusinessLicenceInfoDto businessLicenceInfo = reqDto.getBusinessLicenceInfo();
|
||||
StoreInfoDto storeInfo = reqDto.getStoreInfo();
|
||||
SettlementInfoDto settlementInfo = reqDto.getSettlementInfo();
|
||||
|
||||
WechatEntryContactReqDto contactInfo = new WechatEntryContactReqDto();
|
||||
contactInfo.setContactType(baseInfo.getContactPersonType());
|
||||
// 默认都使用身份证 暂不支持其他证件
|
||||
contactInfo.setContactIdDocCopy("IDENTIFICATION_TYPE_IDCARD");
|
||||
if (PayCst.ContactPersonType.SUPER.equals(baseInfo.getContactPersonType())) {
|
||||
contactInfo.setContactName(encryptor.encrypt(baseInfo.getContactName()));
|
||||
contactInfo.setContactIdNumber(encryptor.encrypt(baseInfo.getContactPersonId()));
|
||||
contactInfo.setContactIdDocCopy(baseInfo.getContactIdCardFrontPic().getWechatId());
|
||||
contactInfo.setContactIdDocCopyBack(baseInfo.getContactIdCardBackPic().getWechatId());
|
||||
contactInfo.setContactPeriodBegin(baseInfo.getContactPersonIdStartDate());
|
||||
contactInfo.setContactPeriodEnd(PayCst.LONG_TERM_DATE.equals(baseInfo.getContactPersonIdEndDate()) ? "长期" : baseInfo.getContactPersonIdEndDate());
|
||||
contactInfo.setMobilePhone(encryptor.encrypt(baseInfo.getContactPhone()));
|
||||
contactInfo.setContactEmail(encryptor.encrypt(baseInfo.getContactEmail()));
|
||||
} else if (PayCst.ContactPersonType.LEGAL.equals(baseInfo.getContactPersonType())) {
|
||||
contactInfo.setContactName(encryptor.encrypt(legalPersonInfo.getLegalPersonName()));
|
||||
contactInfo.setContactIdNumber(encryptor.encrypt(legalPersonInfo.getLegalPersonId()));
|
||||
contactInfo.setContactIdDocCopy(legalPersonInfo.getIdCardFrontPic().getWechatId());
|
||||
contactInfo.setContactIdDocCopyBack(legalPersonInfo.getIdCardBackPic().getWechatId());
|
||||
contactInfo.setContactPeriodBegin(legalPersonInfo.getLegalIdPersonStartDate());
|
||||
contactInfo.setContactPeriodEnd(PayCst.LONG_TERM_DATE.equals(legalPersonInfo.getLegalPersonIdEndDate()) ? "长期" : legalPersonInfo.getLegalPersonIdEndDate());
|
||||
contactInfo.setMobilePhone(encryptor.encrypt(legalPersonInfo.getLegalPersonPhone()));
|
||||
contactInfo.setContactEmail(encryptor.encrypt(legalPersonInfo.getLegalPersonEmail()));
|
||||
} else {
|
||||
throw new CzgException("联系人类型错误");
|
||||
}
|
||||
entryParams.setContactInfo(contactInfo);
|
||||
|
||||
WechatEntrySubjectReqDto subjectInfo = new WechatEntrySubjectReqDto();
|
||||
if ("0".equals(baseInfo.getUserType())) {
|
||||
subjectInfo.setSubjectType("SUBJECT_TYPE_INDIVIDUAL");
|
||||
} else if ("1".equals(baseInfo.getUserType())) {
|
||||
switch (baseInfo.getCompanyChildType()) {
|
||||
case "1" -> subjectInfo.setSubjectType("SUBJECT_TYPE_ENTERPRISE");
|
||||
case "2" -> subjectInfo.setSubjectType("SUBJECT_TYPE_INSTITUTIONS");
|
||||
case "3" -> subjectInfo.setSubjectType("SUBJECT_TYPE_GOVERNMENT");
|
||||
case "4" -> subjectInfo.setSubjectType("SUBJECT_TYPE_OTHERS");
|
||||
default -> throw new CzgException("主体类型错误");
|
||||
}
|
||||
} else {
|
||||
throw new CzgException("用户类型错误");
|
||||
}
|
||||
subjectInfo.setFinanceInstitution(false);
|
||||
|
||||
WechatEntryLicenseReqDto licenseReqDto = new WechatEntryLicenseReqDto();
|
||||
licenseReqDto.setLicenseCopy(businessLicenceInfo.getLicensePic().getWechatId());
|
||||
licenseReqDto.setLicenseNumber(businessLicenceInfo.getLicenceNo());
|
||||
licenseReqDto.setMerchantName(businessLicenceInfo.getLicenceName());
|
||||
licenseReqDto.setLegalPerson(legalPersonInfo.getLegalPersonName());
|
||||
licenseReqDto.setLicenseAddress(businessLicenceInfo.getRegisteredAddress());
|
||||
licenseReqDto.setPeriodBegin(businessLicenceInfo.getLicenceStartDate());
|
||||
licenseReqDto.setPeriodEnd(PayCst.LONG_TERM_DATE.equals(businessLicenceInfo.getLicenceEndDate()) ? "长期" : businessLicenceInfo.getLicenceEndDate());
|
||||
subjectInfo.setBusinessLicenseInfo(licenseReqDto);
|
||||
WechatEntryIdentityReqDto identityInfo = new WechatEntryIdentityReqDto();
|
||||
identityInfo.setIdHolderType(PayCst.ContactPersonType.LEGAL);
|
||||
identityInfo.setIdDocType("IDENTIFICATION_TYPE_IDCARD");
|
||||
WechatEntryIdCardReqDto idCardInfo = new WechatEntryIdCardReqDto();
|
||||
idCardInfo.setIdCardCopy(legalPersonInfo.getIdCardFrontPic().getWechatId());
|
||||
idCardInfo.setIdCardNational(legalPersonInfo.getIdCardFrontPic().getWechatId());
|
||||
idCardInfo.setIdCardName(encryptor.encrypt(legalPersonInfo.getLegalPersonName()));
|
||||
idCardInfo.setIdCardNumber(encryptor.encrypt(legalPersonInfo.getLegalPersonId()));
|
||||
idCardInfo.setIdCardAddress(encryptor.encrypt(legalPersonInfo.getLegalAddress()));
|
||||
idCardInfo.setCardPeriodBegin(legalPersonInfo.getLegalIdPersonStartDate());
|
||||
idCardInfo.setCardPeriodEnd(legalPersonInfo.getLegalPersonIdEndDate());
|
||||
identityInfo.setIdCardInfo(idCardInfo);
|
||||
subjectInfo.setIdentityInfo(identityInfo);
|
||||
entryParams.setSubjectInfo(subjectInfo);
|
||||
|
||||
WechatEntryBusinessReqDto businessReqInfo = new WechatEntryBusinessReqDto();
|
||||
businessReqInfo.setMerchantShortname(baseInfo.getShortName());
|
||||
businessReqInfo.setServicePhone(PayCst.ContactPersonType.LEGAL.equals(baseInfo.getContactPersonType()) ? legalPersonInfo.getLegalPersonPhone() : baseInfo.getContactPhone());
|
||||
WechatEntrySalesInfoReqDto salesInfo = new WechatEntrySalesInfoReqDto();
|
||||
salesInfo.setSalesScenesType(List.of("SALES_SCENES_STORE", "SALES_SCENES_MINI_PROGRAM"));
|
||||
WechatEntryStoreInfoReqDto bizStoreInfo = new WechatEntryStoreInfoReqDto();
|
||||
bizStoreInfo.setBizStoreName(baseInfo.getShortName());
|
||||
bizStoreInfo.setBizAddressCode(storeInfo.getMercAreaCode());
|
||||
bizStoreInfo.setBizStoreAddress(storeInfo.getBusinessAddress());
|
||||
bizStoreInfo.setStoreEntrancePic(storeInfo.getDoorPic().getWechatId());
|
||||
bizStoreInfo.setIndoorPic(storeInfo.getInsidePic().getWechatId());
|
||||
salesInfo.setBizStoreInfo(bizStoreInfo);
|
||||
WechatEntryMiniProgramReqDto miniProgramInfo = new WechatEntryMiniProgramReqDto();
|
||||
miniProgramInfo.setMiniProgramAppid("wxd88fffa983758a30");
|
||||
salesInfo.setMiniProgramInfo(miniProgramInfo);
|
||||
WechatEntryWebInfoReqDto webInfo = new WechatEntryWebInfoReqDto();
|
||||
webInfo.setDomain("https://invoice.sxczgkj.cn/pay/");
|
||||
salesInfo.setWebInfo(webInfo);
|
||||
businessReqInfo.setSalesInfo(salesInfo);
|
||||
entryParams.setBusinessInfo(businessReqInfo);
|
||||
|
||||
WechatEntrySettleReqDto settlementReqInfo = new WechatEntrySettleReqDto();
|
||||
settlementReqInfo.setSettlementId("0".equals(baseInfo.getUserType()) ? "719" : "716");
|
||||
settlementReqInfo.setQualificationType("餐饮");
|
||||
settlementReqInfo.setActivitiesId("20191030111cff5b5e");
|
||||
settlementReqInfo.setActivitiesRate("0.38");
|
||||
entryParams.setSettlementInfo(settlementReqInfo);
|
||||
|
||||
WechatEntryBankAccountReqDto bankAccountReqInfo = new WechatEntryBankAccountReqDto();
|
||||
bankAccountReqInfo.setBankAccountType("21".equals(settlementInfo.getSettlementCardType()) ? "BANK_ACCOUNT_TYPE_CORPORATE" : "BANK_ACCOUNT_TYPE_PERSONAL");
|
||||
bankAccountReqInfo.setAccountName(encryptor.encrypt(settlementInfo.getSettlementName()));
|
||||
bankAccountReqInfo.setBankAddressCode(settlementInfo.getOpenAccCityId());
|
||||
bankAccountReqInfo.setAccountBank(settlementInfo.getBankName());
|
||||
bankAccountReqInfo.setBankBranchId(settlementInfo.getBankBranchCode());
|
||||
bankAccountReqInfo.setBankName(settlementInfo.getBankBranchName());
|
||||
bankAccountReqInfo.setAccountNumber(encryptor.encrypt(settlementInfo.getSettlementCardNo()));
|
||||
entryParams.setBankAccountInfo(bankAccountReqInfo);
|
||||
|
||||
return entryParams;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
|
||||
// queryMerchantEntryStatus(null, "20220106000000000001");
|
||||
|
||||
int offset = 0;
|
||||
Integer limit = 100;
|
||||
// JSONObject resp = queryBankList(null, offset, limit);
|
||||
|
||||
// queryProvinceList(null);
|
||||
// queryCityList(null, "28");
|
||||
// queryBankBranchList(null, "1000009547", "931", offset, limit);
|
||||
// queryBankBranchList(null, "1000009561", "29", offset, limit);
|
||||
queryBankBranchList(null, "1000005241", "29", offset, limit);
|
||||
|
||||
// uploadImage(null, "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/5/ec5bafd00f96466fb3efe545a058f08b.png");
|
||||
|
||||
// queryProvinceList(dto);
|
||||
// queryCityList(dto, "28");
|
||||
|
||||
|
||||
// String string = uploadImage(dto, "https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png");
|
||||
// log.info("图片上传成功:{}", string);
|
||||
|
||||
// Config config = WechatConfig.getRsaConfig(dto);
|
||||
// PrivacyEncryptor encryptor = config.createEncryptor();
|
||||
//
|
||||
// WechatEntryReqDto reqDto = new WechatEntryReqDto()
|
||||
// .setBusinessCode("MER_20231025110010000010000000000001");
|
||||
//
|
||||
// WechatEntryContactReqDto contactInfo = new WechatEntryContactReqDto()
|
||||
// .setContactType("LEGAL")
|
||||
// .setContactName(encryptor.encrypt("张三"))
|
||||
// .setContactIdType("IDCARD")
|
||||
// .setContactIdNumber(encryptor.encrypt("110101199001011234"))
|
||||
// .setContactIdDocCopy("https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png")
|
||||
// .setContactIdDocCopyBack("https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png")
|
||||
// .setContactPeriodBegin("2023-10-25")
|
||||
// .setContactPeriodEnd("2024-10-25")
|
||||
// .setMobilePhone(encryptor.encrypt("13888888888"))
|
||||
// .setContactEmail(encryptor.encrypt("123456@qq.com"));
|
||||
//
|
||||
// reqDto.setContactInfo(contactInfo);
|
||||
//
|
||||
// WechatEntrySubjectReqDto subjectInfo = new WechatEntrySubjectReqDto()
|
||||
// .setSubjectType("SUBJECT_TYPE_INDIVIDUAL");
|
||||
//
|
||||
// WechatEntryLicenseReqDto licenseInfo = new WechatEntryLicenseReqDto()
|
||||
// .setLicenseCopy("https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png")
|
||||
// .setLicenseNumber("110101199001011234")
|
||||
// .setMerchantName("张三商行")
|
||||
// .setLegalPerson(encryptor.encrypt("张三"))
|
||||
// .setLicenseAddress("北京")
|
||||
// .setPeriodBegin("2023-10-25")
|
||||
// .setPeriodEnd("2024-10-25");
|
||||
// subjectInfo.setBusinessLicenseInfo(licenseInfo);
|
||||
//
|
||||
// WechatEntryIdentityReqDto identityInfo = new WechatEntryIdentityReqDto()
|
||||
// .setIdHolderType("LEGAL");
|
||||
// subjectInfo.setIdentityInfo(identityInfo);
|
||||
//
|
||||
// reqDto.setSubjectInfo(subjectInfo);
|
||||
//
|
||||
// WechatEntryBusinessReqDto businessInfo = new WechatEntryBusinessReqDto()
|
||||
// .setMerchantShortname("张三商行")
|
||||
// .setServicePhone("13888888888");
|
||||
// WechatEntrySalesInfoReqDto salesInfo = new WechatEntrySalesInfoReqDto()
|
||||
// .setSalesScenesType(List.of("SALES_SCENES_STORE"));
|
||||
// WechatEntryStoreInfoReqDto storeInfo = new WechatEntryStoreInfoReqDto()
|
||||
// .setBizStoreName("张三商行")
|
||||
// .setBizAddressCode("110101")
|
||||
// .setBizStoreAddress("北京")
|
||||
// .setStoreEntrancePic(List.of("https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png"))
|
||||
// .setIndoorPic(List.of("https://czg-qr-order.oss-cn-beijing.aliyuncs.com/indexs/shuangbackground.png"));
|
||||
// salesInfo.setBizStoreInfo(storeInfo);
|
||||
// businessInfo.setSalesInfo(salesInfo);
|
||||
//
|
||||
// reqDto.setBusinessInfo(businessInfo);
|
||||
//
|
||||
// WechatEntrySettleReqDto settleInfo = new WechatEntrySettleReqDto()
|
||||
// .setSettlementId("719")
|
||||
// .setQualificationType("IDCARD")
|
||||
// .setQualifications(List.of("110101199001011234"))
|
||||
// .setActivitiesId("20191030111cff5b5e");
|
||||
//
|
||||
// reqDto.setSettlementInfo(settleInfo);
|
||||
//
|
||||
// WechatEntryBankAccountReqDto bankAccountInfo = new WechatEntryBankAccountReqDto()
|
||||
// .setBankAccountType("BANK_ACCOUNT_TYPE_CORPORATE")
|
||||
// .setAccountBank("ICBC")
|
||||
// .setBankName("中国工商银行")
|
||||
// .setAccountName(encryptor.encrypt("张三"))
|
||||
// .setAccountNumber(encryptor.encrypt("110101199001011234"));
|
||||
//
|
||||
// reqDto.setBankAccountInfo(bankAccountInfo);
|
||||
|
||||
// entryMerchant(dto, reqDto);
|
||||
}
|
||||
}
|
||||
@@ -1,385 +0,0 @@
|
||||
package com.czg.third.wechat;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.pay.*;
|
||||
import com.czg.third.wechat.dto.config.WechatPayConfigDto;
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.cipher.Signer;
|
||||
import com.wechat.pay.java.core.util.NonceUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2025/12/26 09:15
|
||||
*/
|
||||
@Slf4j
|
||||
public class WechatPayManager {
|
||||
|
||||
private static final String PAY_SUCCESS = "SUCCESS";
|
||||
private static final String BAR_PAY_URL = "https://api.mch.weixin.qq.com/pay/micropay";
|
||||
|
||||
/**
|
||||
* jsapi 小程序支付
|
||||
*
|
||||
* @param configDto 配置
|
||||
* @param paramsDto 参数
|
||||
*/
|
||||
public static Map<String, Object> jsapiPay(WechatPayConfigDto configDto, CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||
if (configDto == null) {
|
||||
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject reqData = new JSONObject();
|
||||
reqData.put("sp_appid", paramsDto.getSubAppid());
|
||||
reqData.put("sp_mchid", configDto.getMerchantId());
|
||||
reqData.put("sub_mchid", merchantDTO.getWechatMerchantId());
|
||||
reqData.put("description", paramsDto.getSubject());
|
||||
reqData.put("out_trade_no", paramsDto.getMchOrderNo());
|
||||
reqData.put("notify_url", paramsDto.getNotifyUrl() + "/" + PayCst.Platform.WECHAT);
|
||||
reqData.put("attach", paramsDto.getExtParam());
|
||||
|
||||
JSONObject amount = new JSONObject();
|
||||
amount.put("total", paramsDto.getAmount());
|
||||
reqData.put("amount", amount);
|
||||
|
||||
JSONObject payer = new JSONObject();
|
||||
payer.put("sp_openid", paramsDto.getUserId());
|
||||
reqData.put("payer", payer);
|
||||
|
||||
String string = WechatReqUtils.postReq(configDto, "/v3/pay/partner/transactions/jsapi", reqData.toJSONString());
|
||||
log.info("微信支付请求结果: orderNo = {}, res = {}", paramsDto.getMchOrderNo(), string);
|
||||
|
||||
JSONObject object = JSONObject.parseObject(string);
|
||||
|
||||
long timestamp = Instant.now().getEpochSecond();
|
||||
String nonceStr = NonceUtil.createNonce(32);
|
||||
String packageVal = "prepay_id=" + object.getString("prepay_id");
|
||||
String message =
|
||||
paramsDto.getSubAppid() + "\n" + timestamp + "\n" + nonceStr + "\n" + packageVal + "\n";
|
||||
|
||||
Config config = WechatConfig.getRsaConfig(configDto);
|
||||
Signer signer = config.createSigner();
|
||||
String sign = signer.sign(message).getSign();
|
||||
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("appId", paramsDto.getSubAppid());
|
||||
res.put("timeStamp", String.valueOf(timestamp));
|
||||
res.put("nonceStr", nonceStr);
|
||||
res.put("package", packageVal);
|
||||
res.put("signType", "RSA");
|
||||
res.put("paySign", sign);
|
||||
log.info("微信支付签名结果: orderNo = {}, res = {}", paramsDto.getMchOrderNo(), res);
|
||||
return res;
|
||||
} catch (Exception e) {
|
||||
log.error("微信支付异常: orderNo = {}, e = {}", paramsDto.getMchOrderNo(), e.getMessage());
|
||||
throw new CzgException("微信支付异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 条码支付
|
||||
* 用户付款码规则:18位纯数字,前缀以10、11、12、13、14、15开头
|
||||
*
|
||||
* @param configDto 配置
|
||||
* @param paramsDto 参数
|
||||
*/
|
||||
public static Map<String, Object> barPay(WechatPayConfigDto configDto, CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||
try {
|
||||
if (configDto == null) {
|
||||
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||
}
|
||||
|
||||
String nonceStr = NonceUtil.createNonce(32);
|
||||
|
||||
Map<String, Object> payMap = new HashMap<>();
|
||||
Document document = DocumentHelper.createDocument();
|
||||
|
||||
// 添加根元素
|
||||
Element xml = document.addElement("xml");
|
||||
|
||||
addElementIfNotEmpty(xml, "appid", paramsDto.getSubAppid());
|
||||
payMap.put("appid", paramsDto.getSubAppid());
|
||||
addElementIfNotEmpty(xml, "mch_id", configDto.getMerchantId());
|
||||
payMap.put("mch_id", configDto.getMerchantId());
|
||||
addElementIfNotEmpty(xml, "sub_mch_id", merchantDTO.getWechatMerchantId());
|
||||
payMap.put("sub_mch_id", merchantDTO.getWechatMerchantId());
|
||||
addElementIfNotEmpty(xml, "nonce_str", nonceStr);
|
||||
payMap.put("nonce_str", nonceStr);
|
||||
addElementIfNotEmpty(xml, "body", paramsDto.getSubject());
|
||||
payMap.put("body", paramsDto.getSubject());
|
||||
addElementIfNotEmpty(xml, "out_trade_no", paramsDto.getMchOrderNo());
|
||||
payMap.put("out_trade_no", paramsDto.getMchOrderNo());
|
||||
addElementIfNotEmpty(xml, "total_fee", paramsDto.getAmount());
|
||||
payMap.put("total_fee", paramsDto.getAmount());
|
||||
addElementIfNotEmpty(xml, "spbill_create_ip", paramsDto.getClientIp());
|
||||
payMap.put("spbill_create_ip", paramsDto.getClientIp());
|
||||
addElementIfNotEmpty(xml, "auth_code", paramsDto.getAuthCode());
|
||||
payMap.put("auth_code", paramsDto.getAuthCode());
|
||||
|
||||
if (StrUtil.isNotBlank(paramsDto.getExtParam())) {
|
||||
addElementIfNotEmpty(xml, "attach", paramsDto.getExtParam());
|
||||
payMap.put("attach", paramsDto.getExtParam());
|
||||
}
|
||||
|
||||
String sign = signBarPayParam(configDto, payMap);
|
||||
addElementIfNotEmpty(xml, "sign", sign);
|
||||
|
||||
OutputFormat format = OutputFormat.createPrettyPrint();
|
||||
XMLWriter writer = new XMLWriter(System.out, format);
|
||||
writer.write(document);
|
||||
|
||||
String xmlStr = document.asXML();
|
||||
log.info("微信条码支付参数:{}", xmlStr);
|
||||
|
||||
String post = HttpUtil.post(BAR_PAY_URL, xmlStr);
|
||||
log.info("微信条码支付请求结果: orderNo = {}, res = {}", paramsDto.getMchOrderNo(), post);
|
||||
|
||||
JSONObject res = new JSONObject();
|
||||
res.put("orderNo", paramsDto.getMchOrderNo());
|
||||
|
||||
SAXReader saxReader = new SAXReader();
|
||||
Document read = saxReader.read(stringToInputStream(post));
|
||||
Element rootElement = read.getRootElement();
|
||||
String returnCode = rootElement.elementText("return_code");
|
||||
|
||||
String errCode = rootElement.elementText("err_code");
|
||||
String errCodeDes = rootElement.elementText("err_code_des");
|
||||
res.put("message", errCodeDes);
|
||||
|
||||
if (StrUtil.isNotBlank(errCode)) {
|
||||
if ("SYSTEMERROR".equals(errCode) || "BANKERROR".equals(errCode) || "USERPAYING".equals(errCode)) {
|
||||
// 等待结果
|
||||
log.info("微信条码支付等待结果: orderNo = {}, err {}", paramsDto.getMchOrderNo(), errCodeDes);
|
||||
res.put("status", "TRADE_AWAIT");
|
||||
return res;
|
||||
}
|
||||
|
||||
res.put("status", "TRADE_FAIL");
|
||||
return res;
|
||||
}
|
||||
|
||||
if (!PAY_SUCCESS.equals(returnCode)) {
|
||||
log.error("微信条码支付失败: orderNo = {}, msg = {}", paramsDto.getMchOrderNo(), rootElement.elementText("return_msg"));
|
||||
res.put("status", "TRADE_FAIL");
|
||||
return res;
|
||||
}
|
||||
|
||||
// 支付成功
|
||||
log.info("微信条码支付成功: orderNo = {}, msg = {}", paramsDto.getMchOrderNo(), rootElement.elementText("return_msg"));
|
||||
res.put("status", "TRADE_SUCCESS");
|
||||
return res;
|
||||
} catch (CzgException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.error("微信条码支付异常: orderNo = {}, e = {}", paramsDto.getMchOrderNo(), e.getMessage());
|
||||
throw new CzgException("微信支付异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询订单
|
||||
*
|
||||
* @param configDto 配置
|
||||
* @param orderNo 订单号
|
||||
* @param merchantDTO 支付商户信息
|
||||
* SUCCESS:支付成功
|
||||
* REFUND:转入退款
|
||||
* NOTPAY:未支付
|
||||
* CLOSED:已关闭
|
||||
* REVOKED:已撤销(仅付款码支付会返回)
|
||||
* USERPAYING:用户支付中(仅付款码支付会返回)
|
||||
* PAYERROR:支付失败(仅付款码支付会返回)
|
||||
*/
|
||||
public static QueryOrderRespDTO queryOrder(WechatPayConfigDto configDto, String orderNo, NativeMerchantDTO merchantDTO) {
|
||||
try {
|
||||
if (configDto == null) {
|
||||
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||
}
|
||||
|
||||
String resp = WechatReqUtils.getReq(configDto, "/v3/pay/partner/transactions/out-trade-no/" + orderNo,
|
||||
Map.of("sp_mchid", configDto.getMerchantId(), "sub_mchid", merchantDTO.getWechatMerchantId()));
|
||||
log.info("微信查询订单,订单号:{}, 响应:{}", orderNo, resp);
|
||||
|
||||
QueryOrderRespDTO queryOrderRespDTO = new QueryOrderRespDTO()
|
||||
.setOrderNo(orderNo)
|
||||
.setOriginResp(resp);
|
||||
|
||||
JSONObject object = JSONObject.parseObject(resp);
|
||||
String tradeState = object.getString("trade_state");
|
||||
queryOrderRespDTO.setErrorMsg(object.getString("trade_state_desc"));
|
||||
if (PAY_SUCCESS.equals(tradeState)) {
|
||||
queryOrderRespDTO.setStatus("TRADE_SUCCESS");
|
||||
return queryOrderRespDTO;
|
||||
}
|
||||
|
||||
if ("USERPAYING".equals(tradeState)) {
|
||||
queryOrderRespDTO.setStatus("TRADE_AWAIT");
|
||||
return queryOrderRespDTO;
|
||||
}
|
||||
|
||||
queryOrderRespDTO.setStatus("TRADE_FAIL");
|
||||
return queryOrderRespDTO;
|
||||
} catch (Exception e) {
|
||||
log.error("微信查询订单异常: orderNo = {}, e = {}", orderNo, e.getMessage());
|
||||
throw new CzgException("微信查询订单异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*
|
||||
* @param configDto 配置
|
||||
* @param paramsDto 参数
|
||||
* SUCCESS: 退款成功
|
||||
* CLOSED: 退款关闭
|
||||
* PROCESSING: 退款处理中
|
||||
* ABNORMAL: 退款异常,退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往服务商平台-交易中心,手动处理此笔退款
|
||||
*/
|
||||
public static RefundRespDTO refundOrder(WechatPayConfigDto configDto, CzgRefundReq paramsDto, String notifyUrl, NativeMerchantDTO merchantDTO) {
|
||||
try {
|
||||
if (configDto == null) {
|
||||
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||
}
|
||||
|
||||
JSONObject refundParam = new JSONObject();
|
||||
refundParam.put("sub_mchid", merchantDTO.getWechatMerchantId());
|
||||
refundParam.put("out_trade_no", paramsDto.getMchOrderNo());
|
||||
refundParam.put("out_refund_no", paramsDto.getMchRefundNo());
|
||||
refundParam.put("reason", paramsDto.getRefundReason());
|
||||
refundParam.put("notify_url", notifyUrl + "/" + PayCst.Platform.WECHAT);
|
||||
|
||||
JSONObject amount = new JSONObject();
|
||||
amount.put("total", paramsDto.getOrderTotalAmount());
|
||||
amount.put("refund", paramsDto.getRefundAmount());
|
||||
amount.put("currency", "CNY");
|
||||
refundParam.put("amount", amount);
|
||||
|
||||
String resp = WechatReqUtils.postReq(configDto, "/v3/refund/domestic/refunds", refundParam.toJSONString());
|
||||
log.info("微信退款,订单号:{}, 响应:{}", paramsDto.getMchOrderNo(), resp);
|
||||
|
||||
JSONObject object = JSONObject.parseObject(resp);
|
||||
|
||||
String code = object.getString("code");
|
||||
String status = object.getString("status");
|
||||
if ("INVALID_REQUEST".equalsIgnoreCase(code) || StrUtil.isNotBlank(status)) {
|
||||
throw new CzgException("微信退款失败:" + object.getString("message"));
|
||||
}
|
||||
|
||||
RefundRespDTO respDTO = new RefundRespDTO()
|
||||
.setMerchantRefundNo(object.getString("out_refund_no"))
|
||||
.setThirdRefundNo(object.getString("refund_id"))
|
||||
.setRefundTime(object.getString("success_time"))
|
||||
.setOriginalData(resp)
|
||||
.setPlatform(PayCst.Platform.WECHAT);
|
||||
|
||||
JSONObject resAmount = object.getJSONObject("amount");
|
||||
if (resAmount != null) {
|
||||
respDTO.setRefundAmount(resAmount.getLong("refund"));
|
||||
}
|
||||
|
||||
switch (status) {
|
||||
case "SUCCESS":
|
||||
case "PROCESSING":
|
||||
respDTO.setStatus("SUCCESS");
|
||||
break;
|
||||
case "CLOSED":
|
||||
respDTO.setStatus("CLOSED");
|
||||
break;
|
||||
case "ABNORMAL":
|
||||
respDTO.setStatus("INIT");
|
||||
break;
|
||||
default:
|
||||
respDTO.setStatus("FAIL");
|
||||
break;
|
||||
}
|
||||
|
||||
return respDTO;
|
||||
} catch (CzgException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.error("微信退款异常: orderNo = {} ", paramsDto.getMchOrderNo(), e);
|
||||
throw new CzgException("微信退款异常");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将String转换为InputStream
|
||||
*
|
||||
* @param str 待转换的字符串
|
||||
* @return 转换后的InputStream
|
||||
*/
|
||||
private static InputStream stringToInputStream(String str) {
|
||||
if (str == null || str.isEmpty()) {
|
||||
return new ByteArrayInputStream(new byte[0]);
|
||||
}
|
||||
// 核心:先转字节数组,再封装为ByteArrayInputStream
|
||||
byte[] byteArray = str.getBytes(StandardCharsets.UTF_8);
|
||||
return new ByteArrayInputStream(byteArray);
|
||||
}
|
||||
|
||||
private static String signBarPayParam(WechatPayConfigDto configDto, Map<String, Object> params) {
|
||||
TreeMap<String, Object> sortedParams = new TreeMap<>(params);
|
||||
String sortParam = sortedParams.entrySet().stream()
|
||||
// 将每个键值对转换为 "key=value" 格式的字符串
|
||||
.map(entry -> entry.getKey() + "=" + (entry.getValue() == null ? "" : entry.getValue()))
|
||||
// 使用 "&" 连接所有转换后的字符串
|
||||
.collect(Collectors.joining("&"));
|
||||
log.info("微信条码支付 加密前参数: {}", sortParam);
|
||||
|
||||
String signStr = sortParam + "&key=" + configDto.getApiV2Key();
|
||||
return SecureUtil.md5(signStr).toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加元素,包括空值
|
||||
*/
|
||||
private static void addElementIfNotEmpty(Element parent, String name, Object value) {
|
||||
Element element = parent.addElement(name);
|
||||
element.addText(value == null ? "" : String.valueOf(value));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// barPay(null, new PayParamsDto()
|
||||
// .setMerchantId("1738216504")
|
||||
// .setOrderNo("sa101293120sss1")
|
||||
// .setTitle("1213")
|
||||
// .setBody("1213")
|
||||
// .setAmount(1L)
|
||||
// .setAppId("wxd88fffa983758a30")
|
||||
// .setClientIp("127.0.0.1")
|
||||
// .setBarCode("130013153082460022"));
|
||||
|
||||
// Map<String, Object> sss1 = queryOrder(null, "sa101293120sss1", "1738216504");
|
||||
// System.out.println(sss1);
|
||||
|
||||
// refundOrder(null, new RefundParamsDto()
|
||||
// .setMerchantId("1738216504")
|
||||
// .setOrderNo("sa101293120sss1")
|
||||
// .setRefundOrderNo("sa101293120sss1")
|
||||
// .setOrderAmount(1L)
|
||||
// .setRefundAmount(1L)
|
||||
// .setRefundReason("测试")
|
||||
// .setRefundNotifyUrl("https://www.baidu.com"));
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
package com.czg.third.wechat;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.czg.dto.req.WechatNotifyReqDto;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.third.wechat.dto.config.WechatPayConfigDto;
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.cipher.Signer;
|
||||
import com.wechat.pay.java.core.util.NonceUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 微信请求工具类
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2025/12/29 10:02
|
||||
*/
|
||||
@Slf4j
|
||||
public class WechatReqUtils {
|
||||
|
||||
public static String postReq(WechatPayConfigDto configDto, String url, String body) {
|
||||
return req(configDto, url, "POST", body);
|
||||
}
|
||||
|
||||
public static String getReq(WechatPayConfigDto configDto, String url, Map<String, Object> params) {
|
||||
url = Arrays.stream(params.entrySet().toArray(new Map.Entry[0]))
|
||||
.map(entry -> entry.getKey() + "=" + URLEncoder.encode(entry.getValue().toString(), StandardCharsets.UTF_8))
|
||||
.collect(Collectors.joining("&", url + "?", ""));
|
||||
|
||||
// 如果最后没有参数,则去掉多余的 "?"
|
||||
url = url.endsWith("?") ? url.substring(0, url.length() - 1) : url;
|
||||
|
||||
return req(configDto, url, "GET", "");
|
||||
}
|
||||
|
||||
private static String req(WechatPayConfigDto configDto, String url, String method, String body) {
|
||||
if (configDto == null) {
|
||||
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||
}
|
||||
long timestamp = getTimestamp();
|
||||
String nonce = getNonceStr();
|
||||
String signature = encryptReqParam(configDto, method, url, body, timestamp, nonce);
|
||||
String authorization = String.format("WECHATPAY2-SHA256-RSA2048 mchid=\"%s\",nonce_str=\"%s\",signature=\"%s\",timestamp=\"%d\",serial_no=\"%s\"",
|
||||
configDto.getMerchantId(), nonce, signature, timestamp, configDto.getSerialNumber());
|
||||
|
||||
HttpRequest request = switch (method) {
|
||||
case "POST" -> HttpUtil.createPost(configDto.getDomain() + url)
|
||||
.header("Authorization", authorization)
|
||||
.header("Wechatpay-Serial", configDto.getPublicKeyId())
|
||||
.charset(StandardCharsets.UTF_8)
|
||||
.contentType("application/json")
|
||||
.body(body);
|
||||
|
||||
case "GET" -> HttpUtil.createGet(configDto.getDomain() + url)
|
||||
.header("Authorization", authorization)
|
||||
.header("Wechatpay-Serial", configDto.getPublicKeyId())
|
||||
.charset(StandardCharsets.UTF_8)
|
||||
.contentType("application/json");
|
||||
default -> throw new CzgException("不支持的请求方法");
|
||||
};
|
||||
log.info("微信支付请求:url = {} \nauthorization: {}", request.getUrl(), authorization);
|
||||
HttpResponse response = request.execute();
|
||||
String s = response.body();
|
||||
log.info("微信支付请求:\n\turl = {}\n\tmethod: {}\n\tbody: {}\n\tresp: {}", url, method, body, s);
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密请求参数
|
||||
*
|
||||
* @param configDto 配置
|
||||
* @param method 请求方法
|
||||
* @param url 请求地址
|
||||
* @param body 请求报文主体
|
||||
* @return 加密后的报文
|
||||
* <p>
|
||||
* 签名方法
|
||||
* HTTP请求方法\n
|
||||
* URL\n
|
||||
* 请求时间戳\n
|
||||
* 请求随机串\n
|
||||
* 请求报文主体\n
|
||||
*/
|
||||
public static String encryptReqParam(WechatPayConfigDto configDto, String method, String url, String body, long timestamp, String nonce) {
|
||||
String encryptStr = String.format("%s\n%s\n%d\n%s\n%s\n",
|
||||
method, url, timestamp, nonce, body);
|
||||
|
||||
Config config = WechatConfig.getRsaConfig(configDto);
|
||||
Signer signer = config.createSigner();
|
||||
String signature = signer.sign(encryptStr).getSign();
|
||||
log.info("微信签名 encryptStr = \n{} \nsignature:{}", encryptStr, signature);
|
||||
return signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密微信回调报文
|
||||
*
|
||||
* @param configDto 配置
|
||||
* @param reqDto 请求报文
|
||||
* @return 解密后的报文
|
||||
*/
|
||||
public static String decryptRespParam(WechatPayConfigDto configDto, WechatNotifyReqDto reqDto) {
|
||||
if (configDto == null) {
|
||||
configDto = WechatPayConfigDto.getDefaultConfig();
|
||||
}
|
||||
WechatAesUtil aesUtil = new WechatAesUtil(configDto.getApiV3Key().getBytes(StandardCharsets.UTF_8));
|
||||
try {
|
||||
return aesUtil.decryptToString(
|
||||
reqDto.getResource().getAssociatedData() == null ? new byte[0] : reqDto.getResource().getAssociatedData().getBytes(StandardCharsets.UTF_8),
|
||||
reqDto.getResource().getNonce().getBytes(StandardCharsets.UTF_8), reqDto.getResource().getCiphertext());
|
||||
} catch (Exception e) {
|
||||
log.error("【微信支付回调】解密失败 {}", reqDto);
|
||||
throw new CzgException("解密失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取随机串
|
||||
*/
|
||||
private static String getNonceStr() {
|
||||
return NonceUtil.createNonce(32);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取时间戳
|
||||
*/
|
||||
private static long getTimestamp() {
|
||||
return System.currentTimeMillis() / 1000;
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
package com.czg.third.wechat.dto.config;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2025/12/26 09:21
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class WechatPayConfigDto {
|
||||
|
||||
/**
|
||||
* 商户号
|
||||
*/
|
||||
private String merchantId;
|
||||
|
||||
/**
|
||||
* Api V3密钥
|
||||
*/
|
||||
private String apiV3Key;
|
||||
|
||||
/**
|
||||
* Api V2 密钥
|
||||
*/
|
||||
private String apiV2Key;
|
||||
|
||||
/**
|
||||
* 商户证书序列号
|
||||
*/
|
||||
private String serialNumber;
|
||||
|
||||
/**
|
||||
* 商户私钥
|
||||
*/
|
||||
private String privateKey;
|
||||
|
||||
/**
|
||||
* 商户公钥
|
||||
*/
|
||||
private String publicKey;
|
||||
|
||||
/**
|
||||
* 商户公钥 ID
|
||||
*/
|
||||
private String publicKeyId;
|
||||
|
||||
/**
|
||||
* 微信支付域名
|
||||
* <a href="https://api.mch.weixin.qq.com"></a>
|
||||
*/
|
||||
private String domain;
|
||||
|
||||
public static WechatPayConfigDto getDefaultConfig() {
|
||||
return new WechatPayConfigDto()
|
||||
.setMerchantId("1643779408")
|
||||
.setApiV3Key("a92baac5eb7a36ed8ec198113e769a03")
|
||||
.setSerialNumber("4DE9BAC2EA584C3F274F694C9753CA814C4E9BF4")
|
||||
.setPublicKey("""
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtbeWXEEjBaYtw2OyM+SC
|
||||
aCEMbryRXi4duKxx3vYG4rUVix+d5/Jz7Khev4Upml9zC+Xxvv/G9bHWAUyolzqD
|
||||
wefahGurIxr43r4GJVnQ4i5G6BbBVw5d4Vuz0y/9Zd14zmc/EmBpT0Ml26H7tOZl
|
||||
n1LSbQ4xNFkrRKrNEcExBLxkCd+K5K2TREZznywIi0izbHImvuzM8IneuR51FiqK
|
||||
pdFnAjTwb126EIj6ECkL6KLCl8RWqpfiX8SFiolSQLs1/w79O0sIUk96X2zWpnoW
|
||||
rTDFatPif/VEKl3y2dTlxxDxoZtVi48yTDW00OMzVl5D67oX3FVK0KsjHJSCfGlZ
|
||||
6wIDAQAB
|
||||
-----END PUBLIC KEY-----""")
|
||||
.setPrivateKey("""
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQDqnAZhTxT572fo
|
||||
6wvSr8Rt0vRXg+EFKC6UvUiNE24oocQU5fjedX9KL/+fmoqay/xqIxvxvCNFTs4J
|
||||
zlMqavSl6bMWCpjvf/Ry82JmN1v2kJEO4lgP8BsEiqlUpObCH8BMAVUOn1j+9q4Q
|
||||
uZJJcbtRvec2fNweDM8EJp4B7RlUdDbHm86lfcDVp8iini7VjDp6D7aHT+C8A8OT
|
||||
ugxQIquDec778wVd9r2Sv3+t6rAzFs+n+Zu++2xtFEPhO5N0wjrLHaukl+9crU+1
|
||||
lktjDzcPd07SwGZ+A+3BTmW3UCramI3506e/3MWBECB7ge+gM4URAV0nJJCLH/Im
|
||||
WgEvPMr5AgMBAAECggEBAKv+wraoMWqiVv1tA/froAgbtcJLDranJK8qrXuvmPz0
|
||||
yzm+91qvrSgIVFEADUk67swo/R2Vng37nhWWS2Y3jy/rSr2H+2Lp3Z5ATA0/3I3A
|
||||
onfU/FaC4mvL9CP32KzMdj/CYkccDzSsSCQ+x75MQNXGcTGDDCSDo2kZnpEu73j3
|
||||
aqvO1jbqTGWigRfjOIaIhStjQIT8nEm/3mJ4f5dM9M6FMz33mhax8EahSgvdahYB
|
||||
t45iaGOWw81OJhmry47EvpwjXBl7jtO2HX3LiLbq5Ebcwu1zqDz5NM7ttnnGAqWC
|
||||
6y7JN5Vt4wPYrCydiUDe7dj0looffr2yw6MkNfYjLGECgYEA+FAvbEInQEi9YguS
|
||||
CQtLHngqvYeai66tvyykog9o38KHnPGx2Myf+rn/Hcp7KNRfjd5G34CCNg7KLnrx
|
||||
YIYh6+2bY3jirzdYUxuNKGbvM4gky/6M/P9zHF/uALKOE02yArdqemf4UxUvrYCc
|
||||
JdXsAMqvbpdvW1aGgNRB32YCkG0CgYEA8d89vawsCjNCEUh0VWTMoBLFoex3qBMZ
|
||||
rfzYQeBo6bDCRlAlUVzl+ouBUxSYxP/U8rzeNaRzGUwRLmlGMjyIr58FBlHsg2cR
|
||||
DlsX3HVCUjpS6sgPXOqakdiLfhMcHZAspislSyVfeS3TbUWiA45+5PuNUq+EZYwl
|
||||
ESsB1+yfRT0CgYEA0Ct49ksnWM8iZbXJgeeD3FFlk2rBd2TDqEem5W4Bv8T3p+0/
|
||||
6b7yR2HyrGj5gys3yFmWFP1JLESN3xWWkhMhEQcrg+LuN3Iwi8vHNR3GXu892f7W
|
||||
96q4OAt8Hf2S+j/igkB99YyANDbIt63gOh/zMF67X/14j5wkOpC3gK+maqkCgYEA
|
||||
s7nIrPoUt3ejLiiCmTmPe5q3VDzcJP4cZNau8zSHgK6hjZHcSPsYwPWMoWl6o1fe
|
||||
qoiBLacHB9MoKS58xLOKdcVZ/Ho/ntylJd+2eVCAeY1xM5h5IfgJ5znbXVFh4O3S
|
||||
357L1Wzt5qOQqW/GlZH65LevKbPWU4axvHISqpnfN5kCgYEAqiqLuAPu84VSsqsE
|
||||
GFh25t+1f0JY1sNfilE3/t9AdQeeCFv/5z9KB1kMt3a5ZFeVonsFIvCyaOJjhSkj
|
||||
4HCB94vWS7NuN5G9r874lMaPbZYQGwrcVaf265tN7cYYr3gUx1qB6+u+fh/kcft1
|
||||
BBmTzhb0zp5k8ngwAkA1g/LK204=
|
||||
-----END PRIVATE KEY-----""")
|
||||
.setPublicKeyId("PUB_KEY_ID_0116437794082025111000382377001000")
|
||||
.setDomain("https://api.mch.weixin.qq.com");
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.czg.third.wechat.dto.req.entry;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 微信进件-补充信息
|
||||
*
|
||||
* @author yjjie
|
||||
* @date 2025/12/26 13:43
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class WechatEntryAdditionReqDto {
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 法定代表人开户承诺函
|
||||
* 模板下载地址 <a href="https://kf.qq.com/faq/191018yUFjEj191018Vfmaei.html">...</a>
|
||||
* 通过图片上传完成后 MediaID
|
||||
*/
|
||||
@JSONField(name = "legal_person_commitment")
|
||||
private String legalPersonCommitment;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 法定代表人开户意愿视频
|
||||
* 通过视频上传完成后 MediaID
|
||||
*/
|
||||
@JSONField(name = "legal_person_video")
|
||||
private String legalPersonVideo;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 补充材料
|
||||
* 最多可上传5张照片
|
||||
* 通过图片上传完成后 MediaID
|
||||
*/
|
||||
@JSONField(name = "business_addition_pics")
|
||||
private List<String> businessAdditionPics;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 补充说明 512字以内
|
||||
*/
|
||||
@JSONField(name = "business_addition_msg")
|
||||
private String businessAdditionMsg;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user