支付调整
This commit is contained in:
@@ -3,9 +3,9 @@ package com.czg.controller;
|
|||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.CzgPayUtils;
|
import com.czg.PolyPayUtils;
|
||||||
import com.czg.constants.PayTypeConstants;
|
import com.czg.constants.PayTypeConstants;
|
||||||
import com.czg.entity.CzgBaseRespParams;
|
import com.czg.entity.PolyBaseResp;
|
||||||
import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
import com.czg.market.entity.MkShopConsumeDiscountRecord;
|
||||||
import com.czg.market.service.MkDistributionUserService;
|
import com.czg.market.service.MkDistributionUserService;
|
||||||
import com.czg.market.service.MkShopConsumeDiscountRecordService;
|
import com.czg.market.service.MkShopConsumeDiscountRecordService;
|
||||||
@@ -61,8 +61,8 @@ public class NotifyController {
|
|||||||
|
|
||||||
|
|
||||||
@RequestMapping("/payCallBack")
|
@RequestMapping("/payCallBack")
|
||||||
public String notifyCallBack(@RequestBody CzgBaseRespParams respParams) {
|
public String notifyCallBack(@RequestBody PolyBaseResp respParams) {
|
||||||
JSONObject czg = CzgPayUtils.getCzg(respParams);
|
JSONObject czg = PolyPayUtils.getCzg(respParams);
|
||||||
AssertUtil.isNull(czg, "支付回调数据为空");
|
AssertUtil.isNull(czg, "支付回调数据为空");
|
||||||
log.info("支付回调数据为:{}", czg);
|
log.info("支付回调数据为:{}", czg);
|
||||||
orderInfoCustomService.payCallBackOrder(czg.getString("mchOrderNo"), czg, 0);
|
orderInfoCustomService.payCallBackOrder(czg.getString("mchOrderNo"), czg, 0);
|
||||||
@@ -89,10 +89,10 @@ public class NotifyController {
|
|||||||
|
|
||||||
@RequestMapping("/native/wx/pay/distributionRecharge")
|
@RequestMapping("/native/wx/pay/distributionRecharge")
|
||||||
public String nativeNotify(HttpServletRequest request) throws IOException {
|
public String nativeNotify(HttpServletRequest request) throws IOException {
|
||||||
String timestamp = request.getHeader("Wechatpay-Timestamp");
|
// String timestamp = request.getHeader("Wechatpay-Timestamp");
|
||||||
String nonce = request.getHeader("Wechatpay-Nonce");
|
// String nonce = request.getHeader("Wechatpay-Nonce");
|
||||||
String serialNo = request.getHeader("Wechatpay-Serial");
|
// String serialNo = request.getHeader("Wechatpay-Serial");
|
||||||
String signature = request.getHeader("Wechatpay-Signature");
|
// String signature = request.getHeader("Wechatpay-Signature");
|
||||||
String result = IoUtil.readUtf8(request.getInputStream());
|
String result = IoUtil.readUtf8(request.getInputStream());
|
||||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||||
JSONObject resource = jsonObject.getJSONObject("resource");
|
JSONObject resource = jsonObject.getJSONObject("resource");
|
||||||
@@ -127,8 +127,8 @@ public class NotifyController {
|
|||||||
|
|
||||||
|
|
||||||
@RequestMapping("/refundCallBack")
|
@RequestMapping("/refundCallBack")
|
||||||
public String refundCallBack(@RequestBody CzgBaseRespParams respParams) {
|
public String refundCallBack(@RequestBody PolyBaseResp respParams) {
|
||||||
JSONObject czg = CzgPayUtils.getCzg(respParams);
|
JSONObject czg = PolyPayUtils.getCzg(respParams);
|
||||||
AssertUtil.isNull(czg, "退款回调数据为空");
|
AssertUtil.isNull(czg, "退款回调数据为空");
|
||||||
log.info("退款回调数据为:{}", czg);
|
log.info("退款回调数据为:{}", czg);
|
||||||
orderInfoCustomService.refundCallBackOrder(czg.getString("mchOrderNo"), czg);
|
orderInfoCustomService.refundCallBackOrder(czg.getString("mchOrderNo"), czg);
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
package com.czg.controller.admin;
|
package com.czg.controller.admin;
|
||||||
|
|
||||||
import com.czg.account.dto.merchant.ShopMerchantEditDTO;
|
|
||||||
import com.czg.account.entity.ShopMerchant;
|
|
||||||
import com.czg.account.service.ShopMerchantService;
|
|
||||||
import com.czg.annotation.SaAdminCheckPermission;
|
import com.czg.annotation.SaAdminCheckPermission;
|
||||||
import com.czg.annotation.SaAdminCheckRole;
|
import com.czg.annotation.SaAdminCheckRole;
|
||||||
|
import com.czg.order.dto.ShopMerchantDTO;
|
||||||
|
import com.czg.order.entity.ShopDirectMerchant;
|
||||||
|
import com.czg.order.service.ShopMerchantService;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商户信息管理
|
* 商户信息管理
|
||||||
|
*
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@@ -24,25 +24,36 @@ public class ShopMerchantController {
|
|||||||
/**
|
/**
|
||||||
* 商户支付信息获取
|
* 商户支付信息获取
|
||||||
* 权限标识: shopMerchant:detail
|
* 权限标识: shopMerchant:detail
|
||||||
|
*
|
||||||
* @param shopId 店铺id
|
* @param shopId 店铺id
|
||||||
* @return 支付信息
|
* @return 支付信息
|
||||||
*/
|
*/
|
||||||
@SaAdminCheckRole("管理员")
|
@SaAdminCheckRole("管理员")
|
||||||
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:detail", name = "商户支付信息获取")
|
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:detail", name = "商户支付信息获取")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public CzgResult<ShopMerchant> detail(@RequestParam Integer shopId) {
|
public CzgResult<ShopMerchantDTO> detail(@RequestParam Long shopId) {
|
||||||
return CzgResult.success(shopMerchantService.detail(shopId));
|
return CzgResult.success(shopMerchantService.detail(shopId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商户支付信息修改
|
* 商户支付信息修改
|
||||||
* 权限标识: shopMerchant:edit
|
* 权限标识: shopMerchant:edit
|
||||||
|
*
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
@SaAdminCheckRole("管理员")
|
@SaAdminCheckRole("管理员")
|
||||||
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:edit", name = "商户支付信息修改")
|
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:edit", name = "商户支付信息修改")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public CzgResult<Boolean> edit(@RequestBody @Validated ShopMerchantEditDTO shopMerchantEditDTO) {
|
public CzgResult<Boolean> edit(@RequestBody ShopMerchantDTO shopMerchant) {
|
||||||
return CzgResult.success(shopMerchantService.edit(shopMerchantEditDTO));
|
shopMerchant.setShopId(StpKit.USER.getShopId());
|
||||||
|
return CzgResult.success(shopMerchantService.editEntry(shopMerchant, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前店铺的主店进件信息
|
||||||
|
*/
|
||||||
|
@GetMapping("getMainMerchant")
|
||||||
|
public CzgResult<ShopDirectMerchant> getMainMerchant() {
|
||||||
|
return CzgResult.success(shopMerchantService.getMainMerchant(StpKit.USER.getShopId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,9 +4,12 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.czg.EntryManager;
|
import com.czg.EntryManager;
|
||||||
import com.czg.PayCst;
|
import com.czg.PayCst;
|
||||||
import com.czg.account.service.ShopInfoService;
|
import com.czg.constant.PayChannelCst;
|
||||||
import com.czg.dto.resp.QueryStatusResp;
|
import com.czg.dto.resp.QueryStatusResp;
|
||||||
|
import com.czg.order.dto.ShopMerchantDTO;
|
||||||
import com.czg.order.entity.ShopDirectMerchant;
|
import com.czg.order.entity.ShopDirectMerchant;
|
||||||
|
import com.czg.order.service.ShopMerchantService;
|
||||||
|
import com.czg.pay.NativeMerchantDTO;
|
||||||
import com.czg.service.order.service.ShopDirectMerchantService;
|
import com.czg.service.order.service.ShopDirectMerchantService;
|
||||||
import com.mybatisflex.core.query.QueryWrapper;
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@@ -28,7 +31,7 @@ public class EntryManagerTask {
|
|||||||
@Resource
|
@Resource
|
||||||
private ShopDirectMerchantService shopDirectMerchantService;
|
private ShopDirectMerchantService shopDirectMerchantService;
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private ShopInfoService shopInfoService;
|
private ShopMerchantService shopMerchantService;
|
||||||
|
|
||||||
//每10分钟查一次
|
//每10分钟查一次
|
||||||
@Scheduled(cron = "0 0/10 * * * ? ")
|
@Scheduled(cron = "0 0/10 * * * ? ")
|
||||||
@@ -58,7 +61,8 @@ public class EntryManagerTask {
|
|||||||
QueryStatusResp wechatStatus = EntryManager.queryWechatEntryStatus(shopDirectMerchant.getWechatApplyId());
|
QueryStatusResp wechatStatus = EntryManager.queryWechatEntryStatus(shopDirectMerchant.getWechatApplyId());
|
||||||
shopDirectMerchant.setWechatStatus(wechatStatus.getStatus());
|
shopDirectMerchant.setWechatStatus(wechatStatus.getStatus());
|
||||||
shopDirectMerchant.setWechatErrorMsg(wechatStatus.getFailReason());
|
shopDirectMerchant.setWechatErrorMsg(wechatStatus.getFailReason());
|
||||||
shopDirectMerchant.setWechatSignUrl(wechatStatus.getSignUrl());
|
shopDirectMerchant.setWechatSignUrl("");
|
||||||
|
shopDirectMerchant.setWechatMerchantId(wechatStatus.getThirdMerchantId());
|
||||||
if (PayCst.EntryStatus.FINISH.equals(wechatStatus.getStatus())) {
|
if (PayCst.EntryStatus.FINISH.equals(wechatStatus.getStatus())) {
|
||||||
wechatMerchantId = wechatStatus.getThirdMerchantId();
|
wechatMerchantId = wechatStatus.getThirdMerchantId();
|
||||||
}
|
}
|
||||||
@@ -67,14 +71,24 @@ public class EntryManagerTask {
|
|||||||
QueryStatusResp alipayStatus = EntryManager.queryAlipayEntryStatus(shopDirectMerchant.getAlipayOrderId());
|
QueryStatusResp alipayStatus = EntryManager.queryAlipayEntryStatus(shopDirectMerchant.getAlipayOrderId());
|
||||||
shopDirectMerchant.setAlipayStatus(alipayStatus.getStatus());
|
shopDirectMerchant.setAlipayStatus(alipayStatus.getStatus());
|
||||||
shopDirectMerchant.setAlipayErrorMsg(alipayStatus.getFailReason());
|
shopDirectMerchant.setAlipayErrorMsg(alipayStatus.getFailReason());
|
||||||
shopDirectMerchant.setAlipaySignUrl(alipayStatus.getSignUrl());
|
shopDirectMerchant.setAlipaySignUrl("");
|
||||||
|
shopDirectMerchant.setAlipayMerchantId(alipayStatus.getThirdMerchantId());
|
||||||
if (PayCst.EntryStatus.FINISH.equals(alipayStatus.getStatus())) {
|
if (PayCst.EntryStatus.FINISH.equals(alipayStatus.getStatus())) {
|
||||||
alipayMerchantId = alipayStatus.getThirdMerchantId();
|
alipayMerchantId = alipayStatus.getThirdMerchantId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
shopDirectMerchantService.updateById(shopDirectMerchant);
|
shopDirectMerchantService.updateById(shopDirectMerchant);
|
||||||
if (StrUtil.isNotBlank(wechatMerchantId) || StrUtil.isNotBlank(alipayMerchantId)) {
|
if (StrUtil.isNotBlank(wechatMerchantId) || StrUtil.isNotBlank(alipayMerchantId)) {
|
||||||
shopInfoService.editEntry(shopDirectMerchant.getShopId(), wechatMerchantId, alipayMerchantId, shopDirectMerchant.getAlipayAuthInfo());
|
ShopMerchantDTO shopMerchantDTO = new ShopMerchantDTO();
|
||||||
|
shopMerchantDTO.setShopId(shopId);
|
||||||
|
shopMerchantDTO.setChannel(PayChannelCst.NATIVE);
|
||||||
|
shopMerchantDTO.setRelatedLicenceNo(licenceNo);
|
||||||
|
NativeMerchantDTO nativeMerchantDTO = new NativeMerchantDTO();
|
||||||
|
nativeMerchantDTO.setWechatMerchantId(wechatMerchantId);
|
||||||
|
nativeMerchantDTO.setAlipayMerchantId(alipayMerchantId);
|
||||||
|
shopMerchantDTO.setNativeMerchantDTO(nativeMerchantDTO);
|
||||||
|
shopMerchantDTO.setNativeMerchantDTO(nativeMerchantDTO);
|
||||||
|
shopMerchantService.editEntry(shopMerchantDTO, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ public class ShopInfo implements Serializable {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用系统用户 sys_user id
|
* 使用系统用户 sys_user id
|
||||||
*/
|
*/
|
||||||
@@ -142,18 +141,6 @@ public class ShopInfo implements Serializable {
|
|||||||
* -1 平台禁用 0-过期,1正式营业,
|
* -1 平台禁用 0-过期,1正式营业,
|
||||||
*/
|
*/
|
||||||
private Integer status;
|
private Integer status;
|
||||||
/**
|
|
||||||
* 微信商户id
|
|
||||||
*/
|
|
||||||
private String wechatMerchantId;
|
|
||||||
/**
|
|
||||||
* 支付宝商户id
|
|
||||||
*/
|
|
||||||
private String alipayMerchantId;
|
|
||||||
/**
|
|
||||||
* 支付宝授权信息
|
|
||||||
*/
|
|
||||||
private String alipayAuthInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 到期时间
|
* 到期时间
|
||||||
|
|||||||
@@ -38,11 +38,6 @@ public interface ShopInfoService extends IService<ShopInfo> {
|
|||||||
|
|
||||||
Boolean edit(ShopInfoEditDTO shopInfoEditDTO);
|
Boolean edit(ShopInfoEditDTO shopInfoEditDTO);
|
||||||
|
|
||||||
/**
|
|
||||||
* 进件结果保存
|
|
||||||
*/
|
|
||||||
Boolean editEntry(Long shopId, String wechatMerchantId, String alipayMerchantId, String alipayAuthInfo);
|
|
||||||
|
|
||||||
ShopDetailDTO detail(Long id) throws CzgException;
|
ShopDetailDTO detail(Long id) throws CzgException;
|
||||||
|
|
||||||
ShopInfoByCodeDTO getByCode(String tableCode, String lat, String lng, boolean checkState);
|
ShopInfoByCodeDTO getByCode(String tableCode, String lat, String lng, boolean checkState);
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.czg.account.service;
|
|
||||||
|
|
||||||
import com.czg.account.dto.merchant.ShopMerchantEditDTO;
|
|
||||||
import com.czg.account.entity.ShopMerchant;
|
|
||||||
import com.mybatisflex.core.service.IService;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 第三方商户进件 服务层。
|
|
||||||
*
|
|
||||||
* @author Administrator
|
|
||||||
* @since 2025-02-11
|
|
||||||
*/
|
|
||||||
public interface ShopMerchantService extends IService<ShopMerchant> {
|
|
||||||
|
|
||||||
ShopMerchant detail(Integer shopId);
|
|
||||||
|
|
||||||
Boolean edit(ShopMerchantEditDTO shopMerchantEditDTO);
|
|
||||||
@Override
|
|
||||||
ShopMerchant getById(Serializable id);
|
|
||||||
}
|
|
||||||
@@ -79,7 +79,9 @@ public interface ParamCodeCst {
|
|||||||
* 超掌柜支付回调地址
|
* 超掌柜支付回调地址
|
||||||
* <p>支付宝/微信支付完成后,支付平台回调我方系统的地址</p>
|
* <p>支付宝/微信支付完成后,支付平台回调我方系统的地址</p>
|
||||||
*/
|
*/
|
||||||
public static String PAY_CZG_NOTIFY_URL = "pay_czg_notify_url";
|
// public static String PAY_CZG_NOTIFY_URL = "pay_czg_notify_url";
|
||||||
|
public static String NATIVE_PAY_NOTIFY_URL = "native_pay_notify_url";
|
||||||
|
public static String POLY_PAY_NOTIFY_URL = "poly_pay_notify_url";
|
||||||
/**
|
/**
|
||||||
* 排队到号通知
|
* 排队到号通知
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public class OrderInfoAddDTO implements Serializable {
|
|||||||
* 已出菜 SENT_OUT
|
* 已出菜 SENT_OUT
|
||||||
* 已上菜 DELIVERED
|
* 已上菜 DELIVERED
|
||||||
* 已超时 EXPIRED
|
* 已超时 EXPIRED
|
||||||
|
* 加急 URGENT
|
||||||
*/
|
*/
|
||||||
private String subStatus;
|
private String subStatus;
|
||||||
//限时折扣部分
|
//限时折扣部分
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.czg.order.dto;
|
||||||
|
|
||||||
|
import com.czg.order.entity.ShopDirectMerchant;
|
||||||
|
import com.czg.pay.NativeMerchantDTO;
|
||||||
|
import com.czg.pay.PolyMerchantDTO;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付信息
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ShopMerchantDTO {
|
||||||
|
|
||||||
|
private Long shopId;
|
||||||
|
/**
|
||||||
|
* poly 聚合(支付平台) native 原生(wx/ali 原生)
|
||||||
|
* {@link com.czg.constant.PayChannelCst}
|
||||||
|
*/
|
||||||
|
private String channel;
|
||||||
|
/**
|
||||||
|
* 聚合支付商户
|
||||||
|
* native 必填 对应 tb_shop_direct_merchant 的 licence_no 营业执照
|
||||||
|
*/
|
||||||
|
private String relatedLicenceNo;
|
||||||
|
/**
|
||||||
|
* 原生支付参数
|
||||||
|
*/
|
||||||
|
private NativeMerchantDTO nativeMerchantDTO;
|
||||||
|
/**
|
||||||
|
* 聚合支付参数
|
||||||
|
*/
|
||||||
|
private PolyMerchantDTO polyMerchantDTO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺绑定的商户信息
|
||||||
|
*/
|
||||||
|
private ShopDirectMerchant shopDirectMerchant;
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import com.mybatisflex.annotation.Column;
|
|||||||
import com.mybatisflex.annotation.Id;
|
import com.mybatisflex.annotation.Id;
|
||||||
import com.mybatisflex.annotation.KeyType;
|
import com.mybatisflex.annotation.KeyType;
|
||||||
import com.mybatisflex.annotation.Table;
|
import com.mybatisflex.annotation.Table;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -40,6 +41,12 @@ public class OrderPayment implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Long shopId;
|
private Long shopId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付渠道
|
||||||
|
* {@link com.czg.constant.PayChannelCst}
|
||||||
|
*/
|
||||||
|
private String channel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 来源Id 订单Id或充值id
|
* 来源Id 订单Id或充值id
|
||||||
*/
|
*/
|
||||||
@@ -104,28 +111,66 @@ public class OrderPayment implements Serializable {
|
|||||||
public OrderPayment() {
|
public OrderPayment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderPayment(@NonNull Long shopId,@NonNull Long sourceId, @NotBlank String sourceType,@NotBlank String payType, @NotBlank String orderNo,
|
/**
|
||||||
String authCode, @NonNull BigDecimal amount) {
|
* 订单专用支付
|
||||||
this.shopId = shopId;
|
*
|
||||||
this.sourceId = sourceId;
|
* @param sourceId 订单Id
|
||||||
this.sourceType = sourceType;
|
* @param amount 单元 元
|
||||||
this.payType = payType;
|
* @param authCode 扫码支付时必填 扫描码
|
||||||
this.orderNo = orderNo;
|
*/
|
||||||
this.authCode = authCode;
|
public static OrderPayment orderPay(@NonNull Long shopId, @NonNull Long sourceId,
|
||||||
this.amount = amount;
|
@NotBlank String orderNo, @NonNull BigDecimal amount, String authCode) {
|
||||||
this.payStatus = PayTypeConstants.PayStatus.INIT;
|
OrderPayment orderPayment = getInstance(shopId, sourceId, PayTypeConstants.SourceType.ORDER, orderNo, amount, authCode, null);
|
||||||
|
orderPayment.setPayType(PayTypeConstants.PayType.PAY);
|
||||||
|
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
|
||||||
|
return orderPayment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderPayment(@NonNull Long shopId,@NonNull Long sourceId, @NotBlank String sourceType,@NotBlank String payType, @NotBlank String orderNo,
|
/**
|
||||||
String authCode, @NonNull BigDecimal amount, Long relatedId) {
|
* 初始化支付参数
|
||||||
this.shopId = shopId;
|
*
|
||||||
this.sourceId = sourceId;
|
* @param sourceId 充值时为会员Id shopUserID
|
||||||
this.sourceType = sourceType;
|
* 购买时为商品Id
|
||||||
this.payType = payType;
|
* @param sourceType {@link PayTypeConstants.SourceType} 支付来源
|
||||||
this.orderNo = orderNo;
|
* @param amount 单元 元
|
||||||
this.authCode = authCode;
|
* @param authCode 扫码支付时必填 扫描码
|
||||||
this.amount = amount;
|
* @param relatedId 霸王餐充值为 订单id 会员充值为 活动id 充值并支付时 为 MkShopRechargeDetail
|
||||||
this.relatedId = relatedId;
|
*/
|
||||||
this.payStatus = PayTypeConstants.PayStatus.INIT;
|
public static OrderPayment pay(@NonNull Long shopId, @NonNull Long sourceId, @NotBlank String sourceType,
|
||||||
|
@NotBlank String orderNo, @NonNull BigDecimal amount,
|
||||||
|
String authCode, Long relatedId) {
|
||||||
|
OrderPayment orderPayment = getInstance(shopId, sourceId, sourceType, orderNo, amount, authCode, relatedId);
|
||||||
|
orderPayment.setPayType(PayTypeConstants.PayType.PAY);
|
||||||
|
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
|
||||||
|
return orderPayment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OrderPayment refund(@NonNull Long shopId, @NonNull Long sourceId, @NotBlank String sourceType,
|
||||||
|
@NotBlank String orderNo, @NonNull BigDecimal amount, Long relatedId) {
|
||||||
|
OrderPayment orderPayment = getInstance(shopId, sourceId, sourceType, orderNo, amount, null, relatedId);
|
||||||
|
orderPayment.setPayType(PayTypeConstants.PayType.REFUND);
|
||||||
|
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
|
||||||
|
return orderPayment;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OrderPayment refundCompensate(@NonNull Long shopId, @NonNull Long sourceId, @NotBlank String sourceType,
|
||||||
|
@NotBlank String orderNo, @NonNull BigDecimal amount, Long relatedId) {
|
||||||
|
OrderPayment orderPayment = getInstance(shopId, sourceId, sourceType, orderNo, amount, null, relatedId);
|
||||||
|
orderPayment.setPayType(PayTypeConstants.PayType.REFUND_COMPENSATE);
|
||||||
|
orderPayment.setPayStatus(PayTypeConstants.PayStatus.INIT);
|
||||||
|
return orderPayment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OrderPayment getInstance(Long shopId, Long sourceId, String sourceType,
|
||||||
|
String orderNo, BigDecimal amount, String authCode, Long relatedId) {
|
||||||
|
OrderPayment orderPayment = new OrderPayment();
|
||||||
|
orderPayment.shopId = shopId;
|
||||||
|
orderPayment.sourceId = sourceId;
|
||||||
|
orderPayment.sourceType = sourceType;
|
||||||
|
orderPayment.orderNo = orderNo;
|
||||||
|
orderPayment.authCode = authCode;
|
||||||
|
orderPayment.amount = amount;
|
||||||
|
orderPayment.relatedId = relatedId;
|
||||||
|
return orderPayment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ public class ShopDirectMerchant implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 营业执照编号
|
* 营业执照编号
|
||||||
*/
|
*/
|
||||||
@Id
|
|
||||||
private String licenceNo;
|
private String licenceNo;
|
||||||
/**
|
/**
|
||||||
* 支付宝账号
|
* 支付宝账号
|
||||||
@@ -124,11 +123,6 @@ public class ShopDirectMerchant implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String alipayStatus;
|
private String alipayStatus;
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付宝授信息
|
|
||||||
*/
|
|
||||||
private String alipayAuthInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝进件错误信息
|
* 支付宝进件错误信息
|
||||||
*/
|
*/
|
||||||
@@ -138,4 +132,18 @@ public class ShopDirectMerchant implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String alipaySignUrl;
|
private String alipaySignUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付宝授信息
|
||||||
|
*/
|
||||||
|
private String alipayAuthInfo;
|
||||||
|
/**
|
||||||
|
* 微信商户id
|
||||||
|
*/
|
||||||
|
private String wechatMerchantId;
|
||||||
|
/**
|
||||||
|
* 支付宝商户id
|
||||||
|
*/
|
||||||
|
private String alipayMerchantId;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.czg.account.entity;
|
package com.czg.order.entity;
|
||||||
|
|
||||||
import com.mybatisflex.annotation.Column;
|
import com.mybatisflex.annotation.Column;
|
||||||
import com.mybatisflex.annotation.Id;
|
import com.mybatisflex.annotation.Id;
|
||||||
@@ -18,57 +18,45 @@ import java.time.LocalDateTime;
|
|||||||
* @since 2025-02-11
|
* @since 2025-02-11
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Table("tb_shop_merchant")
|
@Table("tb_shop_merchant2")
|
||||||
public class ShopMerchant implements Serializable {
|
public class ShopMerchant implements Serializable {
|
||||||
|
|
||||||
@Serial
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private Long id;
|
||||||
/**
|
/**
|
||||||
* 店铺id
|
* 店铺id
|
||||||
*/
|
*/
|
||||||
@Id
|
|
||||||
private Long shopId;
|
private Long shopId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付系统商户id
|
* poly 聚合(支付平台) native 原生(wx/ali 原生)
|
||||||
|
* {@link com.czg.constant.PayChannelCst}
|
||||||
*/
|
*/
|
||||||
private String storeId;
|
private String channel;
|
||||||
|
|
||||||
private String merchantName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商户应用id
|
* 聚合支付商户
|
||||||
|
* native 必填 对应 tb_shop_direct_merchant 的 licence_no 营业执照
|
||||||
*/
|
*/
|
||||||
private String appId;
|
private String relatedLicenceNo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商户token
|
* 聚合支付参数
|
||||||
*/
|
*/
|
||||||
private String appSecret;
|
private String polyPayJson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信小程序appid
|
* 原生支付参数
|
||||||
*/
|
*/
|
||||||
private String wechatSmallAppid;
|
private String nativePayJson;
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付宝小程序appid
|
|
||||||
*/
|
|
||||||
private String alipaySmallAppid;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付密码
|
|
||||||
*/
|
|
||||||
private String payPassword;
|
|
||||||
|
|
||||||
@Column(onInsertValue = "now()")
|
@Column(onInsertValue = "now()")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
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.mybatisflex.core.service.IService;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第三方商户进件 服务层。
|
||||||
|
*
|
||||||
|
* @author Administrator
|
||||||
|
* @since 2025-02-11
|
||||||
|
*/
|
||||||
|
public interface ShopMerchantService extends IService<ShopMerchant> {
|
||||||
|
|
||||||
|
ShopMerchantDTO detail(Long shopId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进件结果保存/ 支付参数修改
|
||||||
|
*/
|
||||||
|
Boolean editEntry(ShopMerchantDTO shopMerchantParam, boolean isUp);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ShopMerchant getById(Serializable id);
|
||||||
|
|
||||||
|
|
||||||
|
ShopDirectMerchant getMainMerchant(Long shopId);
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.czg.third.alipay.dto;
|
package com.czg.pay;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.annotation.JSONField;
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
package com.czg.pay;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NonNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ww
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CzgPayBaseReq<T> {
|
||||||
|
//必填范围
|
||||||
|
/**
|
||||||
|
* 订单标题
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付类型
|
||||||
|
*/
|
||||||
|
private String payType;
|
||||||
|
/**
|
||||||
|
* 用户唯一标识 String(30)
|
||||||
|
* 微信支付时,传入用户的openId;
|
||||||
|
* 支付宝支付和银联支付时,传入用户的userId
|
||||||
|
*/
|
||||||
|
private String userId;
|
||||||
|
/**
|
||||||
|
* 用户IP
|
||||||
|
* 需要传付款用户客户端IP地址
|
||||||
|
*/
|
||||||
|
private String clientIp;
|
||||||
|
/**
|
||||||
|
* 子商户 appid ,微信付款支付的时候 需要上送
|
||||||
|
* isScreen 为 false 的情况下需要传入
|
||||||
|
*/
|
||||||
|
private String subAppid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 额外参数
|
||||||
|
*/
|
||||||
|
private T data;
|
||||||
|
|
||||||
|
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<String> microPay(@NonNull String mchOrderNo, @NonNull String detail, @NonNull Long amount, @NonNull String authCode) {
|
||||||
|
CzgPayBaseReq<String> stringReq = new CzgPayBaseReq<>(mchOrderNo, detail, amount, null, null, null);
|
||||||
|
stringReq.setData(authCode);
|
||||||
|
return stringReq;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.czg.entity.req;
|
package com.czg.pay;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@@ -23,7 +23,10 @@ public class CzgRefundReq {
|
|||||||
* 单位为分
|
* 单位为分
|
||||||
*/
|
*/
|
||||||
private Long refundAmount;
|
private Long refundAmount;
|
||||||
|
/**
|
||||||
|
* 原订单总金额 单位 分
|
||||||
|
*/
|
||||||
|
private Long orderTotalAmount;
|
||||||
|
|
||||||
//非必填范围
|
//非必填范围
|
||||||
/**
|
/**
|
||||||
@@ -51,10 +54,11 @@ public class CzgRefundReq {
|
|||||||
* payOrderId和mchOrderNo 二选一 必填
|
* payOrderId和mchOrderNo 二选一 必填
|
||||||
*/
|
*/
|
||||||
public CzgRefundReq(@NonNull String mchRefundNo, @NonNull String refundReason, @NonNull Long refundAmount,
|
public CzgRefundReq(@NonNull String mchRefundNo, @NonNull String refundReason, @NonNull Long refundAmount,
|
||||||
String mchOrderNo, String extParam) {
|
@NonNull Long orderTotalAmount, String mchOrderNo, String extParam) {
|
||||||
this.mchRefundNo = mchRefundNo;
|
this.mchRefundNo = mchRefundNo;
|
||||||
this.refundReason = refundReason;
|
this.refundReason = refundReason;
|
||||||
this.refundAmount = refundAmount;
|
this.refundAmount = refundAmount;
|
||||||
|
this.orderTotalAmount = orderTotalAmount;
|
||||||
this.mchOrderNo = mchOrderNo;
|
this.mchOrderNo = mchOrderNo;
|
||||||
this.extParam = extParam;
|
this.extParam = extParam;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.czg.pay;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 原生支付参数
|
||||||
|
* @author ww
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class NativeMerchantDTO {
|
||||||
|
private String wechatMerchantId;
|
||||||
|
private String alipayMerchantId;
|
||||||
|
/**
|
||||||
|
* 支付宝 授权信息解析
|
||||||
|
*/
|
||||||
|
private AlipayAuthInfoDto alipayAuthInfo;
|
||||||
|
}
|
||||||
@@ -1,16 +1,14 @@
|
|||||||
package com.czg.account.dto.merchant;
|
package com.czg.pay;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotEmpty;
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Administrator
|
* 聚合支付参数
|
||||||
|
* @author ww
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ShopMerchantEditDTO {
|
public class PolyMerchantDTO {
|
||||||
@NotNull(message = "店铺id不为空")
|
|
||||||
private Long shopId;
|
|
||||||
@NotEmpty(message = "支付系统商户id不为空")
|
@NotEmpty(message = "支付系统商户id不为空")
|
||||||
private String storeId;
|
private String storeId;
|
||||||
@NotEmpty(message = "支付系统商户名称不为空")
|
@NotEmpty(message = "支付系统商户名称不为空")
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.czg.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付渠道常量
|
||||||
|
* @author ww
|
||||||
|
*/
|
||||||
|
public interface PayChannelCst {
|
||||||
|
/**
|
||||||
|
* 聚合支付
|
||||||
|
* 对应 类 PolyPay
|
||||||
|
*/
|
||||||
|
String POLY = "poly";
|
||||||
|
/**
|
||||||
|
* 原生支付
|
||||||
|
* 对应 类 NativePay
|
||||||
|
*/
|
||||||
|
String NATIVE = "native";
|
||||||
|
}
|
||||||
@@ -44,7 +44,6 @@
|
|||||||
<netty.version>4.1.128.Final</netty.version>
|
<netty.version>4.1.128.Final</netty.version>
|
||||||
<wechatpay.version>0.2.17</wechatpay.version>
|
<wechatpay.version>0.2.17</wechatpay.version>
|
||||||
<apipay-v3.version>3.1.65.ALL</apipay-v3.version>
|
<apipay-v3.version>3.1.65.ALL</apipay-v3.version>
|
||||||
<dom4j.version>2.2.0</dom4j.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@@ -283,13 +282,6 @@
|
|||||||
<artifactId>alipay-sdk-java-v3</artifactId>
|
<artifactId>alipay-sdk-java-v3</artifactId>
|
||||||
<version>${apipay-v3.version}</version>
|
<version>${apipay-v3.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dom4j</groupId>
|
|
||||||
<artifactId>dom4j</artifactId>
|
|
||||||
<version>${dom4j.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
@@ -35,13 +35,6 @@
|
|||||||
<artifactId>ocr_api20210707</artifactId>
|
<artifactId>ocr_api20210707</artifactId>
|
||||||
<version>3.1.2</version>
|
<version>3.1.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Source: https://mvnrepository.com/artifact/org.dom4j/dom4j -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.dom4j</groupId>
|
|
||||||
<artifactId>dom4j</artifactId>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -9,7 +9,6 @@ import com.czg.exception.CzgException;
|
|||||||
import com.czg.third.alipay.AlipayEntryManager;
|
import com.czg.third.alipay.AlipayEntryManager;
|
||||||
import com.czg.third.alipay.AlipayIsvEntryManager;
|
import com.czg.third.alipay.AlipayIsvEntryManager;
|
||||||
import com.czg.third.wechat.WechatEntryManager;
|
import com.czg.third.wechat.WechatEntryManager;
|
||||||
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryStoreInfoReqDto;
|
|
||||||
import com.czg.utils.AssertUtil;
|
import com.czg.utils.AssertUtil;
|
||||||
import com.czg.utils.AsyncTaskExecutor;
|
import com.czg.utils.AsyncTaskExecutor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -385,8 +384,8 @@ public class EntryManager {
|
|||||||
// verifyEntryParam(merchantDto);
|
// verifyEntryParam(merchantDto);
|
||||||
// uploadParamImage(merchantDto);
|
// uploadParamImage(merchantDto);
|
||||||
//// System.out.println(merchantDto);
|
//// System.out.println(merchantDto);
|
||||||
// EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.WECHAT);
|
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.WECHAT);
|
||||||
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.ALIPAY);
|
// entryMerchant(merchantDto, PayCst.Platform.ALIPAY);
|
||||||
// entryMerchant(merchantDto, PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY);
|
// entryMerchant(merchantDto, PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY);
|
||||||
System.out.println(respDto);
|
System.out.println(respDto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +1,22 @@
|
|||||||
package com.czg;
|
package com.czg;
|
||||||
|
|
||||||
import com.czg.dto.req.PayParamsDto;
|
import com.czg.dto.req.PayParamsDto;
|
||||||
import com.czg.exception.CzgException;
|
|
||||||
import com.czg.third.alipay.AlipayIsvPayManager;
|
import com.czg.third.alipay.AlipayIsvPayManager;
|
||||||
import com.czg.third.wechat.WechatPayManager;
|
import com.czg.third.wechat.WechatPayManager;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author yjjie
|
* @author yjjie
|
||||||
* @date 2026/1/9 11:24
|
* @date 2026/1/9 11:24
|
||||||
*/
|
*/
|
||||||
public class PayManager {
|
public class PayManager {
|
||||||
|
|
||||||
/**
|
public static void jsapiPay(PayParamsDto paramsDto) {
|
||||||
* jsapi支付
|
|
||||||
*
|
|
||||||
* @param paramsDto 参数
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public static Map<String, Object> jsapiPay(PayParamsDto paramsDto) {
|
|
||||||
paramsDto.verifyParams();
|
paramsDto.verifyParams();
|
||||||
|
|
||||||
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
|
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
|
||||||
return WechatPayManager.jsapiPay(null, paramsDto);
|
WechatPayManager.jsapiPay(null, paramsDto);
|
||||||
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
|
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
|
||||||
return AlipayIsvPayManager.jsapiPay(null, paramsDto);
|
AlipayIsvPayManager.jsapiPay(null, paramsDto);
|
||||||
} else {
|
|
||||||
throw new CzgException("不支持的支付平台");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 条码支付
|
|
||||||
*
|
|
||||||
* @param paramsDto 参数
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public static Map<String, Object> barPay(PayParamsDto paramsDto) {
|
|
||||||
paramsDto.verifyParams();
|
|
||||||
|
|
||||||
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
|
|
||||||
return WechatPayManager.barPay(null, paramsDto);
|
|
||||||
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
|
|
||||||
return AlipayIsvPayManager.barPay(null, paramsDto);
|
|
||||||
} else {
|
|
||||||
throw new CzgException("不支持的支付平台");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,10 +35,10 @@ public class PayManager {
|
|||||||
jsapiPay(new PayParamsDto()
|
jsapiPay(new PayParamsDto()
|
||||||
.setPlatform(PayCst.Platform.WECHAT)
|
.setPlatform(PayCst.Platform.WECHAT)
|
||||||
.setAppId("wxd88fffa983758a30")
|
.setAppId("wxd88fffa983758a30")
|
||||||
.setOpenId("or1l86yipGvwyfPhrKIAcQuSfAV8")
|
.setOpenId("123123123")
|
||||||
.setOrderNo("1111231231213")
|
.setOrderNo("1111231231213")
|
||||||
.setTitle("1213")
|
.setTitle("1213")
|
||||||
.setMerchantId("1738216504")
|
.setMerchantId("1665469114")
|
||||||
.setBody("1213")
|
.setBody("1213")
|
||||||
.setAmount(1000L)
|
.setAmount(1000L)
|
||||||
.setPayParams("{\"app_auth_token\": \"ssss\"}")
|
.setPayParams("{\"app_auth_token\": \"ssss\"}")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.czg.dto.req;
|
|||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.PayCst;
|
import com.czg.PayCst;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.third.alipay.dto.AlipayAuthInfoDto;
|
import com.czg.pay.AlipayAuthInfoDto;
|
||||||
import com.czg.utils.AssertUtil;
|
import com.czg.utils.AssertUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|||||||
@@ -9,13 +9,12 @@ import com.czg.dto.req.*;
|
|||||||
import com.czg.dto.resp.EntryThirdRespDto;
|
import com.czg.dto.resp.EntryThirdRespDto;
|
||||||
import com.czg.dto.resp.QueryStatusResp;
|
import com.czg.dto.resp.QueryStatusResp;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.third.alipay.dto.AlipayAuthInfoDto;
|
import com.czg.pay.AlipayAuthInfoDto;
|
||||||
import com.czg.third.alipay.dto.config.AlipayConfigDto;
|
import com.czg.third.alipay.dto.config.AlipayConfigDto;
|
||||||
import com.czg.utils.UploadFileUtil;
|
import com.czg.utils.UploadFileUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝服务商进件管理
|
* 支付宝服务商进件管理
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ public class WechatPayConfigDto {
|
|||||||
return new WechatPayConfigDto()
|
return new WechatPayConfigDto()
|
||||||
.setMerchantId("1643779408")
|
.setMerchantId("1643779408")
|
||||||
.setApiV3Key("a92baac5eb7a36ed8ec198113e769a03")
|
.setApiV3Key("a92baac5eb7a36ed8ec198113e769a03")
|
||||||
.setApiV2Key("3caf37225b6ea77a624ee03b7e3d03bb")
|
|
||||||
.setSerialNumber("4DE9BAC2EA584C3F274F694C9753CA814C4E9BF4")
|
.setSerialNumber("4DE9BAC2EA584C3F274F694C9753CA814C4E9BF4")
|
||||||
.setPublicKey("""
|
.setPublicKey("""
|
||||||
-----BEGIN PUBLIC KEY-----
|
-----BEGIN PUBLIC KEY-----
|
||||||
|
|||||||
@@ -1,124 +0,0 @@
|
|||||||
package com.czg.entity.req;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NonNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author ww
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class CzgBaseReq {
|
|
||||||
//必填范围
|
|
||||||
/**
|
|
||||||
* 订单标题
|
|
||||||
*/
|
|
||||||
private String subject;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 订单描述 String(256)
|
|
||||||
*/
|
|
||||||
private String body;
|
|
||||||
/**
|
|
||||||
* 交易金额
|
|
||||||
*/
|
|
||||||
private Long amount;
|
|
||||||
/**
|
|
||||||
* 货币类型 cny
|
|
||||||
*/
|
|
||||||
private String currency = "cny";
|
|
||||||
/**
|
|
||||||
* 商户订单号 String(30)
|
|
||||||
* 操作方式+雪花算法
|
|
||||||
* 收银机客户端 PC+雪花ID
|
|
||||||
* 微信小程序 WX+雪花ID
|
|
||||||
* 支付宝小程序 ALI+雪花ID
|
|
||||||
* PC管理端 WEB+雪花ID
|
|
||||||
* APP管理端 APP+雪花ID
|
|
||||||
* <p>
|
|
||||||
* 退款 re+雪花ID
|
|
||||||
*/
|
|
||||||
private String mchOrderNo;
|
|
||||||
/**
|
|
||||||
* 门店编号 tb_shop_merchant 的 store_id
|
|
||||||
*/
|
|
||||||
private String storeId;
|
|
||||||
|
|
||||||
|
|
||||||
//非必填项
|
|
||||||
/**
|
|
||||||
* 订单备注 String(50)
|
|
||||||
*/
|
|
||||||
private String buyerRemark;
|
|
||||||
/**
|
|
||||||
* 异步通知地址 String(128)
|
|
||||||
* 支付结果异步回调URL,只有传了该值才会发起回调
|
|
||||||
*/
|
|
||||||
private String notifyUrl;
|
|
||||||
/**
|
|
||||||
* 失效时间 int 15
|
|
||||||
* 订单失效时间,单位分钟,默认15小时.
|
|
||||||
* 取值范围 5-1440 分钟
|
|
||||||
* 订单在(创建时间+失效时间)后失效
|
|
||||||
*/
|
|
||||||
private Integer expiredTime;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分账模式:
|
|
||||||
* 0-该笔订单不允许分账[默认],
|
|
||||||
* 1-实时分账
|
|
||||||
* 2-延时分账
|
|
||||||
*/
|
|
||||||
private Integer divisionMode;
|
|
||||||
/**
|
|
||||||
* 分账详情
|
|
||||||
*/
|
|
||||||
private String divisionDetail;
|
|
||||||
/**
|
|
||||||
* 扩展参数 String(512)
|
|
||||||
* 商户扩展参数,回调时会原样返回
|
|
||||||
* * 扩展参数
|
|
||||||
* * {
|
|
||||||
* * "pay_type": "order/vip"
|
|
||||||
* * }
|
|
||||||
*/
|
|
||||||
private String extParam;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 花呗分期数
|
|
||||||
* 支付宝交易时可传 而且金额需要大于或等于 100.00元时生效
|
|
||||||
* 3/6/12
|
|
||||||
*/
|
|
||||||
private Integer hbFqNum;
|
|
||||||
/**
|
|
||||||
* 卖家是否承担手续费
|
|
||||||
* 100,卖家承担手续费
|
|
||||||
* 0,买家承担手续费
|
|
||||||
*/
|
|
||||||
private Integer hbFqPercent;
|
|
||||||
/**
|
|
||||||
* 是否禁用信用卡
|
|
||||||
* -1:不禁用 1:禁用
|
|
||||||
* 不传默认为不限制
|
|
||||||
*/
|
|
||||||
private Integer limitPay;
|
|
||||||
|
|
||||||
public CzgBaseReq() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public CzgBaseReq(String mchOrderNo, Long amount, String body,
|
|
||||||
String buyerRemark, String extParam) {
|
|
||||||
this.mchOrderNo = mchOrderNo;
|
|
||||||
this.body = body;
|
|
||||||
this.amount = amount;
|
|
||||||
this.buyerRemark = buyerRemark;
|
|
||||||
this.extParam = extParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void assignMerchant(@NonNull String storeId, @NonNull String subject, @NonNull String notifyUrl) {
|
|
||||||
this.storeId = storeId;
|
|
||||||
this.subject = subject;
|
|
||||||
this.notifyUrl = notifyUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package com.czg.entity.req;
|
|
||||||
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NonNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* h5支付请求参数
|
|
||||||
*
|
|
||||||
* @author ww
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class CzgH5PayReq extends CzgBaseReq {
|
|
||||||
//必填范围
|
|
||||||
/**
|
|
||||||
* 用户IP 支付的用户IP
|
|
||||||
*/
|
|
||||||
private String clientIp;
|
|
||||||
private String payType;
|
|
||||||
//?
|
|
||||||
private String openId;
|
|
||||||
|
|
||||||
//非必填范围
|
|
||||||
/**
|
|
||||||
* 跳转通知地址
|
|
||||||
* 支付结果同步跳转通知URL
|
|
||||||
*/
|
|
||||||
private String returnUrl;
|
|
||||||
|
|
||||||
|
|
||||||
public CzgH5PayReq(@NonNull String mchOrderNo, @NonNull Long amount, String body, @NonNull String clientIp,
|
|
||||||
String returnUrl, String buyerRemark, @NonNull String extParam) {
|
|
||||||
super(mchOrderNo, amount, body, buyerRemark, extParam);
|
|
||||||
this.clientIp = clientIp;
|
|
||||||
this.returnUrl = returnUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
package com.czg.entity.req;
|
|
||||||
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NonNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 公众号/生活号/银联js支付
|
|
||||||
*
|
|
||||||
* @author ww
|
|
||||||
* <p>
|
|
||||||
* ● 码牌、台卡、立牌等
|
|
||||||
* 用户通过扫描微信/支付宝/云闪付APP静态二维码,输入订单金额进行付款动作。
|
|
||||||
* ● 公众号 / 生活号商城
|
|
||||||
* 用户通过公众号下单,输入密码完成付款动作。适用于自有公众号主体交易
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class CzgJsPayReq extends CzgBaseReq {
|
|
||||||
//必填范围
|
|
||||||
/**
|
|
||||||
* 用户唯一标识 String(30)
|
|
||||||
* 微信支付时,传入用户的openId;
|
|
||||||
* 支付宝支付和银联支付时,传入用户的userId
|
|
||||||
*/
|
|
||||||
private String userId;
|
|
||||||
/**
|
|
||||||
* 用户IP
|
|
||||||
* 需要传付款用户客户端IP地址
|
|
||||||
*/
|
|
||||||
private String clientIp;
|
|
||||||
/**
|
|
||||||
* 微信 WECHAT;
|
|
||||||
* 支付宝 ALIPAY;
|
|
||||||
* 银联云闪付 UNIONPAY
|
|
||||||
*/
|
|
||||||
private String payType;
|
|
||||||
|
|
||||||
|
|
||||||
//非必填范围
|
|
||||||
/**
|
|
||||||
* 子商户appid ,微信付款支付的时候 需要上送
|
|
||||||
*/
|
|
||||||
private String subAppid;
|
|
||||||
/**
|
|
||||||
* 跳转通知地址
|
|
||||||
* 支付结果同步跳转通知URL
|
|
||||||
*/
|
|
||||||
private String returnUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 银联js支付成功前端跳转
|
|
||||||
*/
|
|
||||||
private String frontUrl;
|
|
||||||
/**
|
|
||||||
* 银联js支付失败前端跳转地址
|
|
||||||
*/
|
|
||||||
private String frontFailUrl;
|
|
||||||
|
|
||||||
public CzgJsPayReq(@NonNull String mchOrderNo,
|
|
||||||
@NonNull Long amount, String body,
|
|
||||||
@NonNull String openId, @NonNull String clientIp,
|
|
||||||
String returnUrl, String buyerRemark,@NonNull String extParam) {
|
|
||||||
super(mchOrderNo, amount, body, buyerRemark, extParam);
|
|
||||||
this.userId = openId;
|
|
||||||
this.clientIp = clientIp;
|
|
||||||
this.returnUrl = returnUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package com.czg.entity.req;
|
|
||||||
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NonNull;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 小程序支付
|
|
||||||
*
|
|
||||||
* @author ww
|
|
||||||
* 自有小程序拉起支付
|
|
||||||
* 自有小程序拉起服务商小程序,(微信)半屏小程序支付
|
|
||||||
* 半屏小程序需要在商户自己的小程序中的半屏小程序配置里面申请 否则会拉起全屏小程序支付
|
|
||||||
* <p>
|
|
||||||
* 半屏小程序支付适用场景是商户自己的小程序被纳入微信实物电商类型小程序,导致间联商户无法绑定这类的小程序APPID
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class CzgLtPayReq extends CzgBaseReq {
|
|
||||||
//必填范围
|
|
||||||
/**
|
|
||||||
* 用户唯一标识 String(30)
|
|
||||||
* 微信支付时,传入用户的 openId;
|
|
||||||
* 支付宝支付和银联支付时,传入用户的 userId
|
|
||||||
*/
|
|
||||||
private String userId;
|
|
||||||
private String payType;
|
|
||||||
/**
|
|
||||||
* 用户 IP 支付的用户 IP
|
|
||||||
*/
|
|
||||||
private String clientIp;
|
|
||||||
|
|
||||||
|
|
||||||
//非必填范围
|
|
||||||
/**
|
|
||||||
* 跳转通知地址
|
|
||||||
* 支付结果同步跳转通知 URL
|
|
||||||
*/
|
|
||||||
private String returnUrl;
|
|
||||||
/**
|
|
||||||
* 子商户 appid ,微信付款支付的时候 需要上送
|
|
||||||
* isScreen 为 false 的情况下需要传入
|
|
||||||
*/
|
|
||||||
private String subAppid;
|
|
||||||
/**
|
|
||||||
* 是否半屏
|
|
||||||
* 是否使用半屏小程序,默认为 false
|
|
||||||
* 前提小程序被纳入了实物电商类型的小程序,间联商户无法绑定这类的小程序的 appid
|
|
||||||
*/
|
|
||||||
private boolean isScreen;
|
|
||||||
|
|
||||||
public CzgLtPayReq(@NonNull String mchOrderNo, @NonNull Long amount, @NonNull String payType,
|
|
||||||
String body, @NonNull String openId, @NonNull String clientIp,
|
|
||||||
String returnUrl, String buyerRemark, @NonNull String extParam) {
|
|
||||||
super(mchOrderNo, amount, body, buyerRemark, extParam);
|
|
||||||
this.userId = openId;
|
|
||||||
this.payType = "aliPay".equals(payType) ? "ALIPAY" : "WECHAT";
|
|
||||||
this.clientIp = clientIp;
|
|
||||||
this.returnUrl = returnUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package com.czg.entity.req;
|
|
||||||
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NonNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 反扫请求参数
|
|
||||||
*
|
|
||||||
* @author ww
|
|
||||||
* <p>
|
|
||||||
* 被扫免密同步返回支付结果,不推送异步通知。
|
|
||||||
* 被扫输密,推送异步通知。
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class CzgMicroPayReq extends CzgBaseReq {
|
|
||||||
//必填范围
|
|
||||||
/**
|
|
||||||
* 付款码信息 String(30)
|
|
||||||
* 扫码设备获取微信或支付宝上付款的信息
|
|
||||||
*/
|
|
||||||
private String authCode;
|
|
||||||
|
|
||||||
//非必填范围
|
|
||||||
/**
|
|
||||||
* 子商户appid ,微信付款支付的时候 需要上送
|
|
||||||
*/
|
|
||||||
private String subAppid;
|
|
||||||
|
|
||||||
public CzgMicroPayReq(@NonNull String mchOrderNo, @NonNull Long amount, String body,
|
|
||||||
@NonNull String authCode, String buyerRemark, @NonNull String extParam) {
|
|
||||||
super(mchOrderNo, amount, body, buyerRemark, extParam);
|
|
||||||
this.authCode = authCode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
package com.czg.entity.req;
|
|
||||||
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NonNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 正扫支付请求参数
|
|
||||||
*
|
|
||||||
* @author ww
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class CzgScanPayReq extends CzgBaseReq {
|
|
||||||
// 必填项
|
|
||||||
/**
|
|
||||||
* 用户IP 支付的用户IP
|
|
||||||
*/
|
|
||||||
private String clientIp;
|
|
||||||
|
|
||||||
//非必填项
|
|
||||||
/**
|
|
||||||
* 跳转通知地址
|
|
||||||
* String(128)
|
|
||||||
*/
|
|
||||||
private String returnUrl;
|
|
||||||
|
|
||||||
public CzgScanPayReq(@NonNull String mchOrderNo, @NonNull Long amount, String body,
|
|
||||||
@NonNull String clientIp, String returnUrl, String buyerRemark, @NonNull String extParam) {
|
|
||||||
super(mchOrderNo, amount, body, buyerRemark, extParam);
|
|
||||||
this.clientIp = clientIp;
|
|
||||||
this.returnUrl = returnUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>czg-pay</artifactId>
|
<artifactId>poly-pay</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
@@ -8,11 +8,12 @@ import cn.hutool.http.HttpRequest;
|
|||||||
import cn.hutool.http.HttpResponse;
|
import cn.hutool.http.HttpResponse;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.alibaba.fastjson2.TypeReference;
|
import com.alibaba.fastjson2.TypeReference;
|
||||||
import com.czg.entity.CzgBaseReqParams;
|
import com.czg.entity.PolyBaseReq;
|
||||||
import com.czg.entity.CzgBaseRespParams;
|
import com.czg.entity.PolyBaseResp;
|
||||||
import com.czg.entity.req.*;
|
|
||||||
import com.czg.entity.resp.*;
|
import com.czg.entity.resp.*;
|
||||||
import com.czg.enums.CzgPayEnum;
|
import com.czg.enums.CzgPayEnum;
|
||||||
|
import com.czg.pay.CzgPayBaseReq;
|
||||||
|
import com.czg.pay.CzgRefundReq;
|
||||||
import com.czg.resp.CzgRespCode;
|
import com.czg.resp.CzgRespCode;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.utils.AssertUtil;
|
import com.czg.utils.AssertUtil;
|
||||||
@@ -26,10 +27,10 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ww
|
* @author ww
|
||||||
* @description 超掌柜支付类
|
* @description 聚合支付类
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CzgPayUtils {
|
public class PolyPayUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* h5支付
|
* h5支付
|
||||||
@@ -39,8 +40,8 @@ public class CzgPayUtils {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgH5PayResp>
|
* CzgResult<CzgH5PayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> h5Pay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgH5PayReq bizData) {
|
public static CzgResult<Map<String, Object>> h5Pay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
||||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.H5PAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgH5PayResp.class));
|
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.H5_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgH5PayResp.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,8 +52,8 @@ public class CzgPayUtils {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgJsPayResp>
|
* CzgResult<CzgJsPayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> jsPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgJsPayReq bizData) {
|
public static CzgResult<Map<String, Object>> jsPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
||||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.JSPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgJsPayResp.class));
|
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.JS_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgJsPayResp.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,8 +64,8 @@ public class CzgPayUtils {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgLtPayResp>
|
* CzgResult<CzgLtPayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> ltPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgLtPayReq bizData) {
|
public static CzgResult<Map<String, Object>> ltPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
||||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.LTPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgLtPayResp.class));
|
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.LT_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgLtPayResp.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -75,8 +76,8 @@ public class CzgPayUtils {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgScanPayResp>
|
* CzgResult<CzgScanPayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> scanPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgScanPayReq bizData) {
|
public static CzgResult<Map<String, Object>> scanPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
||||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.SCANPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgScanPayResp.class));
|
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.SCAN_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgScanPayResp.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,8 +88,8 @@ public class CzgPayUtils {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* CzgResult<CzgMicroPayResp>
|
* CzgResult<CzgMicroPayResp>
|
||||||
*/
|
*/
|
||||||
public static CzgResult<Map<String, Object>> microPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgMicroPayReq bizData) {
|
public static CzgResult<Map<String, Object>> microPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgPayBaseReq<?> bizData) {
|
||||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.MICROPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgMicroPayResp.class));
|
return execPayResult(sendPolyPay(domain.concat(CzgPayEnum.MICRO_PAY.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgMicroPayResp.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -105,7 +106,7 @@ public class CzgPayUtils {
|
|||||||
JSONObject queryPayOrder = new JSONObject();
|
JSONObject queryPayOrder = new JSONObject();
|
||||||
queryPayOrder.put("payOrderId", payOrderId);
|
queryPayOrder.put("payOrderId", payOrderId);
|
||||||
queryPayOrder.put("mchOrderNo", mchOrderNo);
|
queryPayOrder.put("mchOrderNo", mchOrderNo);
|
||||||
return sendCzg(domain.concat(CzgPayEnum.TRADE.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, queryPayOrder), CzgBaseResp.class);
|
return sendPolyPay(domain.concat(CzgPayEnum.TRADE.getUri()), PolyBaseReq.getInstance(appId, appSecret, queryPayOrder), CzgBaseResp.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -117,7 +118,7 @@ public class CzgPayUtils {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
*/
|
*/
|
||||||
public static CzgResult<CzgRefundResp> refundOrder(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgRefundReq bizData) {
|
public static CzgResult<CzgRefundResp> refundOrder(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgRefundReq bizData) {
|
||||||
return sendCzg(domain.concat(CzgPayEnum.REFUND.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgRefundResp.class);
|
return sendPolyPay(domain.concat(CzgPayEnum.REFUND.getUri()), PolyBaseReq.getInstance(appId, appSecret, bizData), CzgRefundResp.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,23 +135,23 @@ public class CzgPayUtils {
|
|||||||
JSONObject queryPayOrder = new JSONObject();
|
JSONObject queryPayOrder = new JSONObject();
|
||||||
queryPayOrder.put("mchRefundNo", mchRefundNo);
|
queryPayOrder.put("mchRefundNo", mchRefundNo);
|
||||||
queryPayOrder.put("refundOrderId", refundOrderId);
|
queryPayOrder.put("refundOrderId", refundOrderId);
|
||||||
return sendCzg(domain.concat(CzgPayEnum.QUERY_REFUND.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, queryPayOrder), CzgRefundResp.class);
|
return sendPolyPay(domain.concat(CzgPayEnum.QUERY_REFUND.getUri()), PolyBaseReq.getInstance(appId, appSecret, queryPayOrder), CzgRefundResp.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 回调数据处理
|
* 回调数据处理
|
||||||
*/
|
*/
|
||||||
public static JSONObject getCzg(CzgBaseRespParams respParams) {
|
public static JSONObject getCzg(PolyBaseResp respParams) {
|
||||||
AssertUtil.isNull(respParams, "超掌柜交易 回调数据为空");
|
AssertUtil.isNull(respParams, "聚合交易 回调数据为空");
|
||||||
log.info("超掌柜交易请求响应,{}", respParams);
|
log.info("聚合交易请求响应,{}", respParams);
|
||||||
if (!"000000".equals(respParams.getCode())) {
|
if (!"000000".equals(respParams.getCode())) {
|
||||||
log.error("超掌柜回调响应失败,{}", respParams);
|
log.error("聚合回调响应失败,{}", respParams);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// if (StrUtil.isNotBlank(respParams.getSign())) {
|
// if (StrUtil.isNotBlank(respParams.getSign())) {
|
||||||
// if (validateSign(respParams.getSign(), respParams.getBizData())) {
|
// if (validateSign(respParams.getSign(), respParams.getBizData())) {
|
||||||
// log.error("超掌柜回调 验签失败");
|
// log.error("聚合回调 验签失败");
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
return JSONObject.parse(respParams.getBizData());
|
return JSONObject.parse(respParams.getBizData());
|
||||||
@@ -168,19 +169,19 @@ public class CzgPayUtils {
|
|||||||
* "data": "返回Json数据",
|
* "data": "返回Json数据",
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
private static <T> CzgResult<T> sendCzg(String url, CzgBaseReqParams params, Class<T> clazz) {
|
private static <T> CzgResult<T> sendPolyPay(String url, PolyBaseReq params, Class<T> clazz) {
|
||||||
CzgResult<T> result = CzgResult.success();
|
CzgResult<T> result = CzgResult.success();
|
||||||
Map<String, Object> reqMap = BeanUtil.beanToMap(params, false, false);
|
Map<String, Object> reqMap = BeanUtil.beanToMap(params, false, false);
|
||||||
params.setSign(MD5.create().digestHex(sortFields(new TreeMap<>(reqMap))));
|
params.setSign(MD5.create().digestHex(sortFields(new TreeMap<>(reqMap))));
|
||||||
log.info("超掌柜交易请求参数,{}", JSONObject.toJSONString(params));
|
log.info("聚合交易请求参数,{}", JSONObject.toJSONString(params));
|
||||||
try (HttpResponse resp = HttpRequest.post(url).body(JSONObject.toJSONString(params)).execute()) {
|
try (HttpResponse resp = HttpRequest.post(url).body(JSONObject.toJSONString(params)).execute()) {
|
||||||
if (resp.isOk()) {
|
if (resp.isOk()) {
|
||||||
// 获取响应体
|
// 获取响应体
|
||||||
String respStr = resp.body();
|
String respStr = resp.body();
|
||||||
if (StrUtil.isNotEmpty(respStr)) {
|
if (StrUtil.isNotEmpty(respStr)) {
|
||||||
log.info("超掌柜交易请求响应元数据,{}", respStr);
|
log.info("聚合交易请求响应元数据,{}", respStr);
|
||||||
CzgBaseRespParams respParams = JSONObject.parseObject(respStr, CzgBaseRespParams.class);
|
PolyBaseResp respParams = JSONObject.parseObject(respStr, PolyBaseResp.class);
|
||||||
log.info("超掌柜交易请求响应,{}", respParams);
|
log.info("聚合交易请求响应,{}", respParams);
|
||||||
|
|
||||||
result.setCode("000000".equals(respParams.getCode()) ? 200 : Integer.parseInt(respParams.getCode()));
|
result.setCode("000000".equals(respParams.getCode()) ? 200 : Integer.parseInt(respParams.getCode()));
|
||||||
result.setMsg(respParams.getMsg());
|
result.setMsg(respParams.getMsg());
|
||||||
@@ -194,15 +195,15 @@ public class CzgPayUtils {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.setCode(resp.getStatus());
|
result.setCode(resp.getStatus());
|
||||||
result.setMsg("超掌柜交易请求失败");
|
result.setMsg("聚合交易请求失败");
|
||||||
log.error("超掌柜交易请求失败,状态码: {}", resp.getStatus());
|
log.error("聚合交易请求失败,状态码: {}", resp.getStatus());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.setCode(resp.getStatus());
|
result.setCode(resp.getStatus());
|
||||||
result.setMsg("超掌柜交易请求失败");
|
result.setMsg("聚合交易请求失败");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("超掌柜交易请求异常", e);
|
log.error("聚合交易请求异常", e);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -221,7 +222,7 @@ public class CzgPayUtils {
|
|||||||
|
|
||||||
private static String sortFields(TreeMap<String, Object> map) {
|
private static String sortFields(TreeMap<String, Object> map) {
|
||||||
if (CollectionUtil.isEmpty(map)) {
|
if (CollectionUtil.isEmpty(map)) {
|
||||||
log.error("超掌柜支付参数为空!!!");
|
log.error("聚合支付参数为空!!!");
|
||||||
throw new RuntimeException("参数为空");
|
throw new RuntimeException("参数为空");
|
||||||
}
|
}
|
||||||
String sortParam = map.entrySet().stream()
|
String sortParam = map.entrySet().stream()
|
||||||
@@ -12,7 +12,7 @@ import lombok.Data;
|
|||||||
* @author ww
|
* @author ww
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class CzgBaseReqParams {
|
public class PolyBaseReq {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 应用ID tb_shop_merchant 表中的 app_id
|
* 应用ID tb_shop_merchant 表中的 app_id
|
||||||
@@ -69,7 +69,7 @@ public class CzgBaseReqParams {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* @param bizData JSON 形式的字符串
|
* @param bizData JSON 形式的字符串
|
||||||
*/
|
*/
|
||||||
public CzgBaseReqParams(String appId, String bizData, String appSecret) {
|
public PolyBaseReq(String appId, String bizData, String appSecret) {
|
||||||
this.appId = appId;
|
this.appId = appId;
|
||||||
this.bizData = bizData;
|
this.bizData = bizData;
|
||||||
this.appSecret = appSecret;
|
this.appSecret = appSecret;
|
||||||
@@ -82,8 +82,8 @@ public class CzgBaseReqParams {
|
|||||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||||
* @param bizData JSON 形式的字符串
|
* @param bizData JSON 形式的字符串
|
||||||
*/
|
*/
|
||||||
public static CzgBaseReqParams getInstance(String appId, String appSecret, Object bizData) {
|
public static PolyBaseReq getInstance(String appId, String appSecret, Object bizData) {
|
||||||
return new CzgBaseReqParams(appId, ObjectUtil.isNotEmpty(bizData) ? JSONObject.toJSONString(bizData) : "", appSecret);
|
return new PolyBaseReq(appId, ObjectUtil.isNotEmpty(bizData) ? JSONObject.toJSONString(bizData) : "", appSecret);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@ import lombok.Data;
|
|||||||
* @author ww
|
* @author ww
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class CzgBaseRespParams {
|
public class PolyBaseResp {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -8,11 +8,11 @@ import lombok.Getter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum CzgPayEnum {
|
public enum CzgPayEnum {
|
||||||
SCANPAY("/api/open/payment/scanpay", "PC扫码支付"),
|
SCAN_PAY("/api/open/payment/scanpay", "PC扫码支付"),
|
||||||
MICROPAY("/api/open/payment/micropay", "聚合反扫(B扫C)/ 快捷收款"),
|
MICRO_PAY("/api/open/payment/micropay", "聚合反扫(B扫C)/ 快捷收款"),
|
||||||
JSPAY("/api/open/payment/jspay", "公众号/生活号/银联js支付"),
|
JS_PAY("/api/open/payment/jspay", "公众号/生活号/银联js支付"),
|
||||||
LTPAY("/api/open/payment/ltpay", "小程序支付"),
|
LT_PAY("/api/open/payment/ltpay", "小程序支付"),
|
||||||
H5PAY("/api/open/payment/h5pay", "手机网页支付"),
|
H5_PAY("/api/open/payment/h5pay", "手机网页支付"),
|
||||||
|
|
||||||
TRADE("/api/open/query/trade", "订单状态查询"),
|
TRADE("/api/open/query/trade", "订单状态查询"),
|
||||||
REFUND("/api/open/order/refund", "统一退款 D0退款需要使用平台户退款"),
|
REFUND("/api/open/order/refund", "统一退款 D0退款需要使用平台户退款"),
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
<name>third sdk</name>
|
<name>third sdk</name>
|
||||||
<description>第三方内容</description>
|
<description>第三方内容</description>
|
||||||
<modules>
|
<modules>
|
||||||
<module>czg-pay</module>
|
<module>poly-pay</module>
|
||||||
<module>aggregation-pay</module>
|
<module>aggregation-pay</module>
|
||||||
</modules>
|
</modules>
|
||||||
<artifactId>cash-sdk</artifactId>
|
<artifactId>cash-sdk</artifactId>
|
||||||
@@ -29,5 +29,10 @@
|
|||||||
<artifactId>cash-common-tools</artifactId>
|
<artifactId>cash-common-tools</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.czg</groupId>
|
||||||
|
<artifactId>cash-common-service</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@@ -17,6 +17,7 @@ import com.czg.constants.ParamCodeCst;
|
|||||||
import com.czg.constants.ShopSwitchTypeEnum;
|
import com.czg.constants.ShopSwitchTypeEnum;
|
||||||
import com.czg.constants.SystemConstants;
|
import com.czg.constants.SystemConstants;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
|
import com.czg.order.service.ShopMerchantService;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.sa.MyStpLogic;
|
import com.czg.sa.MyStpLogic;
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
@@ -77,6 +78,8 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
|||||||
private FreeDineConfigService freeDineConfigService;
|
private FreeDineConfigService freeDineConfigService;
|
||||||
@Resource
|
@Resource
|
||||||
private ShopConfigService shopConfigService;
|
private ShopConfigService shopConfigService;
|
||||||
|
@Resource
|
||||||
|
private ShopMerchantService shopMerchantService;
|
||||||
|
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private SysParamsService sysParamsService;
|
private SysParamsService sysParamsService;
|
||||||
@@ -324,16 +327,6 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@CacheEvict(key = "#shopId")
|
|
||||||
public Boolean editEntry(Long shopId, String wechatMerchantId, String alipayMerchantId, String alipayAuthInfo) {
|
|
||||||
ShopInfo shopInfo = new ShopInfo();
|
|
||||||
shopInfo.setWechatMerchantId(wechatMerchantId);
|
|
||||||
shopInfo.setAlipayMerchantId(alipayMerchantId);
|
|
||||||
shopInfo.setAlipayAuthInfo(alipayAuthInfo);
|
|
||||||
return update(shopInfo, new QueryWrapper().eq(ShopInfo::getId, shopId));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ShopDetailDTO detail(Long id) throws CzgException {
|
public ShopDetailDTO detail(Long id) throws CzgException {
|
||||||
ShopInfo shopInfo = queryChain().eq(ShopInfo::getId, id == null ? StpKit.USER.getShopId() : id).one();
|
ShopInfo shopInfo = queryChain().eq(ShopInfo::getId, id == null ? StpKit.USER.getShopId() : id).one();
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
package com.czg.service.account.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
|
||||||
import com.czg.account.dto.merchant.ShopMerchantEditDTO;
|
|
||||||
import com.czg.account.entity.ShopMerchant;
|
|
||||||
import com.czg.account.service.ShopMerchantService;
|
|
||||||
import com.czg.sa.StpKit;
|
|
||||||
import com.czg.service.account.mapper.ShopMerchantMapper;
|
|
||||||
import com.czg.utils.AssertUtil;
|
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
|
||||||
import org.apache.dubbo.config.annotation.DubboService;
|
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 第三方商户进件 服务层实现。
|
|
||||||
*
|
|
||||||
* @author Administrator
|
|
||||||
* @since 2025-02-11
|
|
||||||
*/
|
|
||||||
@CacheConfig(cacheNames = "shop:merchant")
|
|
||||||
@DubboService
|
|
||||||
public class ShopMerchantServiceImpl extends ServiceImpl<ShopMerchantMapper, ShopMerchant> implements ShopMerchantService {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ShopMerchant detail(Integer shopId) {
|
|
||||||
ShopMerchant one = queryChain().eq(ShopMerchant::getShopId, shopId).one();
|
|
||||||
return one == null ? new ShopMerchant() : one;
|
|
||||||
}
|
|
||||||
|
|
||||||
@CacheEvict(key = "#shopMerchantEditDTO.shopId")
|
|
||||||
@Override
|
|
||||||
public Boolean edit(ShopMerchantEditDTO shopMerchantEditDTO) {
|
|
||||||
ShopMerchant shopMerchant = queryChain().eq(ShopMerchant::getShopId, shopMerchantEditDTO.getShopId()).one();
|
|
||||||
if (shopMerchant == null) {
|
|
||||||
shopMerchant = new ShopMerchant();
|
|
||||||
shopMerchant.setShopId(shopMerchantEditDTO.getShopId());
|
|
||||||
BeanUtil.copyProperties(shopMerchantEditDTO, shopMerchant);
|
|
||||||
return save(shopMerchant);
|
|
||||||
}
|
|
||||||
BeanUtil.copyProperties(shopMerchantEditDTO, shopMerchant);
|
|
||||||
return updateById(shopMerchant);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Cacheable(key = "#id")
|
|
||||||
@Override
|
|
||||||
public ShopMerchant getById(Serializable id) {
|
|
||||||
ShopMerchant shopMerchant = getMapper().selectOneById(id);
|
|
||||||
AssertUtil.isNull(shopMerchant, "暂未开通支付");
|
|
||||||
return shopMerchant;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,9 +18,8 @@
|
|||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.czg</groupId>
|
<groupId>com.github.javen205</groupId>
|
||||||
<artifactId>pay-service</artifactId>
|
<artifactId>IJPay-All</artifactId>
|
||||||
<version>1.0.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.czg.service.market.service.impl;
|
package com.czg.service.market.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.crypto.SecureUtil;
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.constants.ParamCodeCst;
|
import com.czg.constants.ParamCodeCst;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.service.RedisService;
|
import com.czg.service.RedisService;
|
||||||
import com.czg.system.service.SysParamsService;
|
import com.czg.system.service.SysParamsService;
|
||||||
import com.ijpay.core.kit.RsaKit;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -14,7 +14,6 @@ import org.springframework.context.annotation.Primary;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信支付service
|
* 微信支付service
|
||||||
@@ -80,7 +79,7 @@ public class AppWxServiceImpl extends BaseWx {
|
|||||||
// api支付证书公钥
|
// api支付证书公钥
|
||||||
config.apiCert = payKeyMap.get(ParamCodeCst.Wechat.Pay.WX_API_CLIENT_CERT);
|
config.apiCert = payKeyMap.get(ParamCodeCst.Wechat.Pay.WX_API_CLIENT_CERT);
|
||||||
try {
|
try {
|
||||||
config.privateKey = RsaKit.loadPrivateKey(config.apiCertKey);
|
config.privateKey = SecureUtil.rsa(config.apiCertKey, null).getPrivateKey();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("微信加载api证书失败");
|
log.warn("微信加载api证书失败");
|
||||||
}
|
}
|
||||||
@@ -98,10 +97,6 @@ public class AppWxServiceImpl extends BaseWx {
|
|||||||
config.refundNotifyUrl = "";
|
config.refundNotifyUrl = "";
|
||||||
config.transferNotifyUrl = payKeyMap.get(ParamCodeCst.System.NATIVE_NOTIFY_URL) + "/wx/transfer";
|
config.transferNotifyUrl = payKeyMap.get(ParamCodeCst.System.NATIVE_NOTIFY_URL) + "/wx/transfer";
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseWx getAppService() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,21 +18,16 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>com.czg</groupId>
|
|
||||||
<artifactId>czg-pay</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.czg</groupId>
|
|
||||||
<artifactId>aggregation-pay</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.czg</groupId>
|
<groupId>com.czg</groupId>
|
||||||
<artifactId>market-service</artifactId>
|
<artifactId>market-service</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.czg</groupId>
|
||||||
|
<artifactId>pay-service</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
<!-- 订单服务依赖消息队列 从 market 拿 -->
|
<!-- 订单服务依赖消息队列 从 market 拿 -->
|
||||||
<!-- <dependency>-->
|
<!-- <dependency>-->
|
||||||
<!-- <groupId>com.czg</groupId>-->
|
<!-- <groupId>com.czg</groupId>-->
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.czg.service.account.mapper;
|
package com.czg.service.order.mapper;
|
||||||
|
|
||||||
import com.czg.account.entity.ShopMerchant;
|
import com.czg.order.entity.ShopMerchant;
|
||||||
import com.mybatisflex.core.BaseMapper;
|
import com.mybatisflex.core.BaseMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
package com.czg.service.order.service;
|
package com.czg.service.order.service;
|
||||||
|
|
||||||
import com.czg.entity.req.*;
|
|
||||||
import com.czg.entity.resp.CzgBaseResp;
|
import com.czg.entity.resp.CzgBaseResp;
|
||||||
import com.czg.entity.resp.CzgRefundResp;
|
import com.czg.entity.resp.CzgRefundResp;
|
||||||
|
import com.czg.enums.CzgPayEnum;
|
||||||
import com.czg.order.dto.LtPayOtherDTO;
|
import com.czg.order.dto.LtPayOtherDTO;
|
||||||
import com.czg.order.entity.OrderPayment;
|
import com.czg.order.entity.OrderPayment;
|
||||||
|
import com.czg.pay.CzgPayBaseReq;
|
||||||
|
import com.czg.pay.CzgRefundReq;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
@@ -21,14 +23,10 @@ public interface PayService {
|
|||||||
BigDecimal MONEY_RATE = new BigDecimal("100");
|
BigDecimal MONEY_RATE = new BigDecimal("100");
|
||||||
|
|
||||||
|
|
||||||
Long initOrderPayment(OrderPayment payment);
|
Long initPayment(OrderPayment payment);
|
||||||
|
|
||||||
//-----------------------------------------------------------------付款 ----------------------------------------------------------
|
//-----------------------------------------------------------------付款 ----------------------------------------------------------
|
||||||
CzgResult<Map<String, Object>> h5Pay(@NonNull Long shopId, CzgH5PayReq bizData);
|
CzgResult<Map<String, Object>> pay(@NonNull Long shopId, CzgPayEnum payType, CzgPayBaseReq<?> bizData);
|
||||||
CzgResult<Map<String, Object>> jsPay(@NonNull Long shopId, @NonNull String payType, CzgJsPayReq bizData);
|
|
||||||
CzgResult<Map<String, Object>> ltPay(@NonNull Long shopId, String payType, CzgLtPayReq bizData);
|
|
||||||
CzgResult<Map<String, Object>> scanPay(@NonNull Long shopId, CzgScanPayReq bizData);
|
|
||||||
CzgResult<Map<String, Object>> microPay(@NonNull Long shopId, CzgMicroPayReq bizData);
|
|
||||||
//-----------------------------------------------------------------积分商品/拼团 付款 ----------------------------------------------------------
|
//-----------------------------------------------------------------积分商品/拼团 付款 ----------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,13 +7,14 @@ import com.czg.account.service.ShopUserService;
|
|||||||
import com.czg.account.service.UserInfoService;
|
import com.czg.account.service.UserInfoService;
|
||||||
import com.czg.constant.TableValueConstant;
|
import com.czg.constant.TableValueConstant;
|
||||||
import com.czg.constants.PayTypeConstants;
|
import com.czg.constants.PayTypeConstants;
|
||||||
import com.czg.entity.req.CzgLtPayReq;
|
import com.czg.enums.CzgPayEnum;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.market.service.MkDistributionConfigService;
|
import com.czg.market.service.MkDistributionConfigService;
|
||||||
import com.czg.market.vo.MkDistributionConfigVO;
|
import com.czg.market.vo.MkDistributionConfigVO;
|
||||||
import com.czg.order.dto.MkDistributionPayDTO;
|
import com.czg.order.dto.MkDistributionPayDTO;
|
||||||
import com.czg.order.entity.OrderPayment;
|
import com.czg.order.entity.OrderPayment;
|
||||||
import com.czg.order.service.OrderPaymentService;
|
import com.czg.order.service.OrderPaymentService;
|
||||||
|
import com.czg.pay.CzgPayBaseReq;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.service.market.service.impl.WxServiceImpl;
|
import com.czg.service.market.service.impl.WxServiceImpl;
|
||||||
import com.czg.service.order.service.DistributionPayService;
|
import com.czg.service.order.service.DistributionPayService;
|
||||||
@@ -67,7 +68,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
|||||||
ShopUser shopUserInfo = shopUserService.getShopUserInfo(payParam.getShopId(), userId);
|
ShopUser shopUserInfo = shopUserService.getShopUserInfo(payParam.getShopId(), userId);
|
||||||
|
|
||||||
OrderPayment orderPayment = new OrderPayment().setShopId(payParam.getShopId()).setSourceId(isRecharge ? payParam.getShopId() : shopUserInfo.getId())
|
OrderPayment orderPayment = new OrderPayment().setShopId(payParam.getShopId()).setSourceId(isRecharge ? payParam.getShopId() : shopUserInfo.getId())
|
||||||
.setSourceType(isRecharge ? PayTypeConstants.SourceType.DISTRIBUTION_RECHARGE : PayTypeConstants.SourceType.DISTRIBUTION )
|
.setSourceType(isRecharge ? PayTypeConstants.SourceType.DISTRIBUTION_RECHARGE : PayTypeConstants.SourceType.DISTRIBUTION)
|
||||||
.setPayType(PayTypeConstants.PayType.PAY)
|
.setPayType(PayTypeConstants.PayType.PAY)
|
||||||
.setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId())
|
.setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId())
|
||||||
.setAmount(isRecharge ? payParam.getAmount() : detail.getPayAmount());
|
.setAmount(isRecharge ? payParam.getAmount() : detail.getPayAmount());
|
||||||
@@ -89,12 +90,13 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
|||||||
@Override
|
@Override
|
||||||
public CzgResult<Map<String, Object>> ltPayOrder(String clintIp, MkDistributionPayDTO payParam) {
|
public CzgResult<Map<String, Object>> ltPayOrder(String clintIp, MkDistributionPayDTO payParam) {
|
||||||
InitInfo initInfo = initPayment(payParam.getUserId(), payParam, false);
|
InitInfo initInfo = initPayment(payParam.getUserId(), payParam, false);
|
||||||
return payService.ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(initInfo.payment.getOrderNo(), initInfo.payment.getAmount().multiply(MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
|
||||||
payParam.getPayType(), "分销员开通", initInfo.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.ltPayReq(initInfo.payment.getOrderNo(), "分销员开通", initInfo.payment.getAmount().multiply(MONEY_RATE).longValue(),
|
||||||
|
payParam.getPayType(), initInfo.getOpenId(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> mchRecharge(String clientIP, MkDistributionPayDTO payParam) {
|
public Map<String, String> mchRecharge(MkDistributionPayDTO payParam) {
|
||||||
InitInfo initInfo = initPayment(payParam.getUserId() == null ? payParam.getShopId() : payParam.getUserId(), payParam, true);
|
InitInfo initInfo = initPayment(payParam.getUserId() == null ? payParam.getShopId() : payParam.getUserId(), payParam, true);
|
||||||
return wxService.v3Pay(initInfo.openId, payParam.getAmount(), "商户运营余额充值", initInfo.payment.getOrderNo(), initInfo.payment.getSourceType());
|
return wxService.v3Pay(initInfo.openId, payParam.getAmount(), "商户运营余额充值", initInfo.payment.getOrderNo(), initInfo.payment.getSourceType());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import com.czg.account.service.UserInfoService;
|
|||||||
import com.czg.config.RabbitPublisher;
|
import com.czg.config.RabbitPublisher;
|
||||||
import com.czg.config.RedisCst;
|
import com.czg.config.RedisCst;
|
||||||
import com.czg.constants.PayTypeConstants;
|
import com.czg.constants.PayTypeConstants;
|
||||||
import com.czg.entity.req.*;
|
|
||||||
import com.czg.entity.resp.CzgRefundResp;
|
import com.czg.entity.resp.CzgRefundResp;
|
||||||
|
import com.czg.enums.CzgPayEnum;
|
||||||
import com.czg.enums.ShopUserFlowBizEnum;
|
import com.czg.enums.ShopUserFlowBizEnum;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.exception.PaySuccessException;
|
import com.czg.exception.PaySuccessException;
|
||||||
@@ -36,6 +36,8 @@ import com.czg.order.service.CreditBuyerOrderService;
|
|||||||
import com.czg.order.service.OrderDetailService;
|
import com.czg.order.service.OrderDetailService;
|
||||||
import com.czg.order.service.OrderInfoCustomService;
|
import com.czg.order.service.OrderInfoCustomService;
|
||||||
import com.czg.order.service.OrderPaymentService;
|
import com.czg.order.service.OrderPaymentService;
|
||||||
|
import com.czg.pay.CzgPayBaseReq;
|
||||||
|
import com.czg.pay.CzgRefundReq;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.service.RedisService;
|
import com.czg.service.RedisService;
|
||||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||||
@@ -62,6 +64,9 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ww
|
||||||
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class OrderPayServiceImpl implements OrderPayService {
|
public class OrderPayServiceImpl implements OrderPayService {
|
||||||
@@ -227,13 +232,15 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
return CzgResult.failure("支付失败 充值金额必须大雨订单金额");
|
return CzgResult.failure("支付失败 充值金额必须大雨订单金额");
|
||||||
}
|
}
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN, PayTypeConstants.PayType.PAY, payOrderNo,
|
Long paymentId = payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN,
|
||||||
"", rechargeDetail.getAmount(), rechargeDetail.getId()));
|
payOrderNo, rechargeDetail.getAmount(), "", rechargeDetail.getId()));
|
||||||
upOrderPayInfo(orderInfo.getId(), PayEnums.VIP_PAY, paymentId,
|
upOrderPayInfo(orderInfo.getId(), PayEnums.VIP_PAY, paymentId,
|
||||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||||
return payService.ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, rechargeDetail.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
|
||||||
payParam.getPayType(), "充值并支付", "wechatPay".equals(payParam.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId(),
|
CzgPayBaseReq.ltPayReq(
|
||||||
clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
payOrderNo, "充值并支付",
|
||||||
|
rechargeDetail.getAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getPayType(),
|
||||||
|
"wechatPay".equals(payParam.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -241,12 +248,10 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
public CzgResult<Map<String, Object>> h5PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> h5PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
upOrderPayInfo(orderInfo.getId(), PayEnums.H5_PAY, paymentId, payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||||
upOrderPayInfo(orderInfo.getId(), PayEnums.H5_PAY, paymentId,
|
return payService.pay(payParam.getShopId(), CzgPayEnum.H5_PAY,
|
||||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
CzgPayBaseReq.h5PayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), clintIp));
|
||||||
return payService.h5Pay(payParam.getShopId(), new CzgH5PayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
|
||||||
"点餐支付", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -257,12 +262,12 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
|
||||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||||
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
|
||||||
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.jsPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||||
|
payParam.getPayType(), payParam.getOpenId(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -281,12 +286,12 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId());
|
orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId());
|
||||||
}
|
}
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
|
||||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||||
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
|
||||||
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.jsPayReq(payOrderNo, "扫码支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||||
|
payParam.getPayType(), payParam.getOpenId(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -296,12 +301,12 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
|
||||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||||
return payService.ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
|
||||||
payParam.getPayType(), "点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.ltPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||||
|
payParam.getPayType(), payParam.getOpenId(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -317,12 +322,11 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
BigDecimal amount = shopRechargeService.checkRecharge(mainShopId, payParam.getShopId(), shopUser.getUserId(), payParam.getRechargeDetailId(), payParam.getAmount());
|
BigDecimal amount = shopRechargeService.checkRecharge(mainShopId, payParam.getShopId(), shopUser.getUserId(), payParam.getRechargeDetailId(), payParam.getAmount());
|
||||||
payParam.setAmount(amount);
|
payParam.setAmount(amount);
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
|
||||||
upOrderPayInfo(orderInfo.getId(), PayEnums.MAIN_SCAN, paymentId,
|
upOrderPayInfo(orderInfo.getId(), PayEnums.MAIN_SCAN, paymentId,
|
||||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||||
return payService.scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.SCAN_PAY,
|
||||||
"点餐支付", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.scanPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -344,10 +348,9 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), payParam.getAuthCode()));
|
||||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, payParam.getAuthCode(), orderInfo.getOrderAmount()));
|
CzgResult<Map<String, Object>> mapCzgResult = payService.pay(payParam.getShopId(), CzgPayEnum.MICRO_PAY,
|
||||||
CzgResult<Map<String, Object>> mapCzgResult = payService.microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
CzgPayBaseReq.microPay(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getAuthCode()));
|
||||||
"点餐支付", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
|
|
||||||
if (mapCzgResult.getCode() == 200) {
|
if (mapCzgResult.getCode() == 200) {
|
||||||
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||||
LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN);
|
LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN);
|
||||||
@@ -508,8 +511,11 @@ public class OrderPayServiceImpl implements OrderPayService {
|
|||||||
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
|
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
|
||||||
OrderPayment payment = paymentService.getById(payOrderId);
|
OrderPayment payment = paymentService.getById(payOrderId);
|
||||||
AssertUtil.isNull(payment, "退款失败支付记录不存在");
|
AssertUtil.isNull(payment, "退款失败支付记录不存在");
|
||||||
Long refundId = payService.initOrderPayment(new OrderPayment(shopId, orderId, PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refundAmount, payment.getId()));
|
Long refundId = payService.initPayment(OrderPayment.refund(shopId, orderId, PayTypeConstants.SourceType.ORDER,
|
||||||
CzgResult<CzgRefundResp> refund = payService.refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
refPayOrderNo, refundAmount, payment.getId()));
|
||||||
|
|
||||||
|
CzgResult<CzgRefundResp> refund = payService.refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(PayService.MONEY_RATE).longValue(),
|
||||||
|
payment.getAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
||||||
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
|
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
|
||||||
if (refund.getData() != null && refund.getData().getNote() != null) {
|
if (refund.getData() != null && refund.getData().getNote() != null) {
|
||||||
throw new CzgException(refund.getData().getNote());
|
throw new CzgException(refund.getData().getNote());
|
||||||
|
|||||||
@@ -2,19 +2,24 @@ package com.czg.service.order.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.CzgPayUtils;
|
import com.czg.PayAdapter;
|
||||||
import com.czg.account.entity.ShopMerchant;
|
import com.czg.PayAdapterFactory;
|
||||||
import com.czg.account.service.ShopMerchantService;
|
import com.czg.order.entity.ShopMerchant;
|
||||||
|
import com.czg.order.service.ShopMerchantService;
|
||||||
|
import com.czg.constant.PayChannelCst;
|
||||||
import com.czg.constants.ParamCodeCst;
|
import com.czg.constants.ParamCodeCst;
|
||||||
import com.czg.constants.PayTypeConstants;
|
import com.czg.constants.PayTypeConstants;
|
||||||
import com.czg.entity.req.*;
|
|
||||||
import com.czg.entity.resp.CzgBaseResp;
|
import com.czg.entity.resp.CzgBaseResp;
|
||||||
import com.czg.entity.resp.CzgRefundResp;
|
import com.czg.entity.resp.CzgRefundResp;
|
||||||
|
import com.czg.enums.CzgPayEnum;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.order.dto.LtPayOtherDTO;
|
import com.czg.order.dto.LtPayOtherDTO;
|
||||||
import com.czg.order.entity.OrderPayment;
|
import com.czg.order.entity.OrderPayment;
|
||||||
import com.czg.order.service.OrderPaymentService;
|
import com.czg.order.service.OrderPaymentService;
|
||||||
|
import com.czg.pay.CzgPayBaseReq;
|
||||||
|
import com.czg.pay.CzgRefundReq;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.service.order.mapper.OrderPaymentMapper;
|
import com.czg.service.order.mapper.OrderPaymentMapper;
|
||||||
import com.czg.service.order.service.PayService;
|
import com.czg.service.order.service.PayService;
|
||||||
@@ -49,66 +54,16 @@ public class PayServiceImpl implements PayService {
|
|||||||
private OrderPaymentMapper paymentMapper;
|
private OrderPaymentMapper paymentMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CzgResult<Map<String, Object>> h5Pay(@NonNull Long shopId, CzgH5PayReq bizData) {
|
public CzgResult<Map<String, Object>> pay(@NonNull Long shopId, CzgPayEnum payType, CzgPayBaseReq<?> bizData) {
|
||||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
|
||||||
getNotifyUrl());
|
String payData = null;
|
||||||
return CzgPayUtils.h5Pay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
|
||||||
}
|
payData = shopMerchant.getNativePayJson();
|
||||||
|
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
|
||||||
@Override
|
payData = shopMerchant.getPolyPayJson();
|
||||||
public CzgResult<Map<String, Object>> jsPay(@NonNull Long shopId, @NonNull String payType, CzgJsPayReq bizData) {
|
|
||||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
|
||||||
bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
|
|
||||||
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序");
|
|
||||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
|
||||||
getNotifyUrl());
|
|
||||||
bizData.setPayType("aliPay".equals(payType) ? "ALIPAY" : "WECHAT");
|
|
||||||
return CzgPayUtils.jsPay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CzgResult<Map<String, Object>> ltPay(@NonNull Long shopId, String payType, CzgLtPayReq bizData) {
|
|
||||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
|
||||||
bizData.setSubAppid("aliPay".equals(payType) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
|
|
||||||
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(payType) ? "支付宝" : "微信") + "小程序");
|
|
||||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
|
||||||
getNotifyUrl());
|
|
||||||
return CzgPayUtils.ltPay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CzgResult<Map<String, Object>> scanPay(@NonNull Long shopId, CzgScanPayReq bizData) {
|
|
||||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
|
||||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
|
||||||
getNotifyUrl());
|
|
||||||
return CzgPayUtils.scanPay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CzgResult<Map<String, Object>> microPay(@NonNull Long shopId, CzgMicroPayReq bizData) {
|
|
||||||
AssertUtil.isBlank(bizData.getAuthCode(), "扫码失败,请重试");
|
|
||||||
if (bizData.getAuthCode().length() > 26) {
|
|
||||||
throw new CzgException("支付失败,不支持的条码");
|
|
||||||
}
|
}
|
||||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
return adapter.pay(payType, payData, getDomain(), getNotifyUrl(shopMerchant.getChannel()), bizData);
|
||||||
bizData.assignMerchant(shopMerchant.getStoreId(), shopMerchant.getMerchantName(),
|
|
||||||
getNotifyUrl());
|
|
||||||
String firstTwoDigitsStr = bizData.getAuthCode().substring(0, 2);
|
|
||||||
// 将截取的字符串转换为整数
|
|
||||||
int firstTwoDigits = Integer.parseInt(firstTwoDigitsStr);
|
|
||||||
// 判断范围
|
|
||||||
if (firstTwoDigits >= 10 && firstTwoDigits <= 15) {
|
|
||||||
//微信支付
|
|
||||||
bizData.setSubAppid(shopMerchant.getWechatSmallAppid());
|
|
||||||
} else if (firstTwoDigits >= 25 && firstTwoDigits <= 30) {
|
|
||||||
//支付宝支付
|
|
||||||
bizData.setSubAppid(shopMerchant.getAlipaySmallAppid());
|
|
||||||
} else {
|
|
||||||
throw new CzgException("扫描码非法或暂不支持");
|
|
||||||
}
|
|
||||||
return CzgPayUtils.microPay(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -117,17 +72,25 @@ public class PayServiceImpl implements PayService {
|
|||||||
AssertUtil.isBlank(param.getOpenId(), "用户小程序ID不能为空");
|
AssertUtil.isBlank(param.getOpenId(), "用户小程序ID不能为空");
|
||||||
AssertUtil.isBlank(param.getPayType(), "支付方式不能为空");
|
AssertUtil.isBlank(param.getPayType(), "支付方式不能为空");
|
||||||
String payOrderNo = "LT" + IdUtil.getSnowflakeNextId();
|
String payOrderNo = "LT" + IdUtil.getSnowflakeNextId();
|
||||||
initOrderPayment(new OrderPayment(param.getShopId(), param.getRecordId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
initPayment(OrderPayment.pay(param.getShopId(), param.getRecordId(), payType, payOrderNo,
|
||||||
"", param.getPrice(), null));
|
param.getPrice(), "", null));
|
||||||
return ltPay(param.getShopId(), param.getPayType(), new CzgLtPayReq(payOrderNo, param.getPrice().multiply(MONEY_RATE).longValue(),
|
return pay(param.getShopId(), CzgPayEnum.LT_PAY,
|
||||||
param.getPayType(), detail, param.getOpenId(), param.getIp(), "", "", ""));
|
CzgPayBaseReq.ltPayReq(payOrderNo, detail, param.getPrice().multiply(MONEY_RATE).longValue(),
|
||||||
|
param.getPayType(), param.getOpenId(), param.getIp()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CzgResult<CzgRefundResp> refund(@NonNull Long shopId, CzgRefundReq bizData) {
|
public CzgResult<CzgRefundResp> refund(@NonNull Long shopId, CzgRefundReq bizData) {
|
||||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||||
bizData.setNotifyUrl(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_REFUND_NOTIFY_URL));
|
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
|
||||||
return CzgPayUtils.refundOrder(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
String payData = null;
|
||||||
|
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
|
||||||
|
payData = shopMerchant.getNativePayJson();
|
||||||
|
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
|
||||||
|
payData = shopMerchant.getPolyPayJson();
|
||||||
|
}
|
||||||
|
// bizData.setNotifyUrl(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_REFUND_NOTIFY_URL));
|
||||||
|
return adapter.refund(getDomain(), payData, "", bizData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -136,9 +99,9 @@ public class PayServiceImpl implements PayService {
|
|||||||
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
|
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
|
||||||
OrderPayment payment = paymentService.getById(payOrderId);
|
OrderPayment payment = paymentService.getById(payOrderId);
|
||||||
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
|
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
|
||||||
Long refundId = initOrderPayment(new OrderPayment(shopId, sourceId, payment.getSourceType(), PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refundAmount, payment.getId()));
|
Long refundId = initPayment(OrderPayment.refund(shopId, sourceId, payment.getSourceType(), refPayOrderNo, refundAmount, payment.getId()));
|
||||||
CzgResult<CzgRefundResp> refund = refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(MONEY_RATE).longValue(),
|
CzgResult<CzgRefundResp> refund = refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(MONEY_RATE).longValue(),
|
||||||
payment.getOrderNo(), ""));
|
payment.getAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
||||||
OrderPayment uOrderPayment = new OrderPayment();
|
OrderPayment uOrderPayment = new OrderPayment();
|
||||||
uOrderPayment.setRespJson(JSONObject.toJSONString(refund.getData()));
|
uOrderPayment.setRespJson(JSONObject.toJSONString(refund.getData()));
|
||||||
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
|
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
|
||||||
@@ -157,10 +120,10 @@ public class PayServiceImpl implements PayService {
|
|||||||
//支付的 订单
|
//支付的 订单
|
||||||
OrderPayment payment = paymentService.getById(refundPayment.getRelatedId());
|
OrderPayment payment = paymentService.getById(refundPayment.getRelatedId());
|
||||||
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
|
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
|
||||||
Long refundCompensate = initOrderPayment(new OrderPayment(refundPayment.getShopId(), refundPayment.getSourceId(), payment.getSourceType(), PayTypeConstants.PayType.REFUND_COMPENSATE,
|
Long refundCompensate = initPayment(OrderPayment.refundCompensate(refundPayment.getShopId(), refundPayment.getSourceId(),
|
||||||
refPayOrderNo, null, refundPayment.getAmount(), refundPayment.getId()));
|
payment.getSourceType(), refPayOrderNo, refundPayment.getAmount(), refundPayment.getId()));
|
||||||
CzgResult<CzgRefundResp> refund = refund(payment.getShopId(), new CzgRefundReq(refPayOrderNo, "退款补偿", refundPayment.getAmount().multiply(MONEY_RATE).longValue(),
|
CzgResult<CzgRefundResp> refund = refund(payment.getShopId(), new CzgRefundReq(refPayOrderNo, "退款补偿", refundPayment.getAmount().multiply(MONEY_RATE).longValue(),
|
||||||
payment.getOrderNo(), ""));
|
payment.getAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
||||||
OrderPayment uOrderPayment = new OrderPayment();
|
OrderPayment uOrderPayment = new OrderPayment();
|
||||||
uOrderPayment.setTradeNumber(refund.getData().getRefundOrderId());
|
uOrderPayment.setTradeNumber(refund.getData().getRefundOrderId());
|
||||||
uOrderPayment.setRespJson(JSONObject.toJSONString(refund.getData()));
|
uOrderPayment.setRespJson(JSONObject.toJSONString(refund.getData()));
|
||||||
@@ -178,26 +141,55 @@ public class PayServiceImpl implements PayService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public CzgResult<CzgBaseResp> queryPayOrder(@NonNull Long shopId, String payOrderId, String mchOrderNo) {
|
public CzgResult<CzgBaseResp> queryPayOrder(@NonNull Long shopId, String payOrderId, String mchOrderNo) {
|
||||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||||
return CzgPayUtils.queryPayOrder(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), payOrderId, mchOrderNo);
|
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
|
||||||
|
String payData = null;
|
||||||
|
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
|
||||||
|
payData = shopMerchant.getNativePayJson();
|
||||||
|
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
|
||||||
|
payData = shopMerchant.getPolyPayJson();
|
||||||
|
}
|
||||||
|
return adapter.queryPayOrder(getDomain(), payData, payOrderId, mchOrderNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public CzgResult<CzgRefundResp> queryRefund(@NonNull Long shopId, String mchRefundNo, String refundOrderId) {
|
public CzgResult<CzgRefundResp> queryRefund(@NonNull Long shopId, String mchRefundNo, String refundOrderId) {
|
||||||
ShopMerchant shopMerchant = getMerchant(shopId);
|
ShopMerchant shopMerchant = getMerchant(shopId);
|
||||||
return CzgPayUtils.queryRefundOrder(getDomain(), shopMerchant.getAppId(), shopMerchant.getAppSecret(), mchRefundNo, refundOrderId);
|
PayAdapter adapter = PayAdapterFactory.getAdapter(shopMerchant.getChannel());
|
||||||
|
String payData = null;
|
||||||
|
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
|
||||||
|
payData = shopMerchant.getNativePayJson();
|
||||||
|
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
|
||||||
|
payData = shopMerchant.getPolyPayJson();
|
||||||
|
}
|
||||||
|
return adapter.queryRefund(getDomain(), payData, mchRefundNo, refundOrderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long initOrderPayment(OrderPayment payment) {
|
public Long initPayment(OrderPayment payment) {
|
||||||
paymentMapper.insert(payment);
|
paymentMapper.insert(payment);
|
||||||
return payment.getId();
|
return payment.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ShopMerchant getMerchant(Long shopId) {
|
private ShopMerchant getMerchant(Long shopId) {
|
||||||
try {
|
try {
|
||||||
return shopMerchantService.getById(shopId);
|
ShopMerchant shopMerchant = shopMerchantService.getById(shopId);
|
||||||
|
if (shopMerchant == null || StrUtil.isBlank(shopMerchant.getChannel())) {
|
||||||
|
throw new CzgException("暂未开通支付");
|
||||||
|
}
|
||||||
|
if (shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
|
||||||
|
if (StrUtil.isNotBlank(shopMerchant.getNativePayJson())) {
|
||||||
|
throw new CzgException("原生支付未开通");
|
||||||
|
}
|
||||||
|
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
|
||||||
|
if (StrUtil.isNotBlank(shopMerchant.getPolyPayJson())) {
|
||||||
|
throw new CzgException("聚合支付未开通");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new CzgException("暂不支持的支付渠道");
|
||||||
|
}
|
||||||
|
return shopMerchant;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new CzgException("暂未开通支付");
|
throw new CzgException("暂未开通支付");
|
||||||
}
|
}
|
||||||
@@ -207,7 +199,16 @@ public class PayServiceImpl implements PayService {
|
|||||||
return sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN);
|
return sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNotifyUrl() {
|
private String getNotifyUrl(String channel) {
|
||||||
return sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_NOTIFY_URL);
|
String notifyUrl = "";
|
||||||
|
if (channel.equals(PayChannelCst.NATIVE)) {
|
||||||
|
notifyUrl = sysParamsService.getSysParamValue(ParamCodeCst.System.NATIVE_PAY_NOTIFY_URL);
|
||||||
|
} else if (channel.equals(PayChannelCst.POLY)) {
|
||||||
|
notifyUrl = sysParamsService.getSysParamValue(ParamCodeCst.System.POLY_PAY_NOTIFY_URL);
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(notifyUrl)) {
|
||||||
|
throw new CzgException(channel.equals(PayChannelCst.NATIVE) ? "原生支付回调地址未配置" : "聚合支付回调地址未配置");
|
||||||
|
}
|
||||||
|
return notifyUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package com.czg.service.order.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.czg.account.service.ShopInfoService;
|
||||||
|
import com.czg.constant.PayChannelCst;
|
||||||
|
import com.czg.order.dto.ShopMerchantDTO;
|
||||||
|
import com.czg.order.entity.ShopDirectMerchant;
|
||||||
|
import com.czg.order.entity.ShopMerchant;
|
||||||
|
import com.czg.order.service.ShopMerchantService;
|
||||||
|
import com.czg.pay.NativeMerchantDTO;
|
||||||
|
import com.czg.pay.PolyMerchantDTO;
|
||||||
|
import com.czg.service.order.mapper.ShopMerchantMapper;
|
||||||
|
import com.czg.service.order.service.ShopDirectMerchantService;
|
||||||
|
import com.czg.utils.AssertUtil;
|
||||||
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第三方商户进件 服务层实现。
|
||||||
|
*
|
||||||
|
* @author Administrator
|
||||||
|
* @since 2025-02-11
|
||||||
|
*/
|
||||||
|
@CacheConfig(cacheNames = "shop:merchant")
|
||||||
|
@Service
|
||||||
|
public class ShopMerchantServiceImpl extends ServiceImpl<ShopMerchantMapper, ShopMerchant> implements ShopMerchantService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ShopDirectMerchantService shopDirectMerchantService;
|
||||||
|
@DubboReference
|
||||||
|
private ShopInfoService shopInfoService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ShopMerchantDTO detail(Long shopId) {
|
||||||
|
ShopMerchantDTO shopMerchantVO = new ShopMerchantDTO();
|
||||||
|
ShopMerchant one = queryChain().eq(ShopMerchant::getShopId, shopId).one();
|
||||||
|
if (one == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
shopMerchantVO.setShopId(shopId);
|
||||||
|
shopMerchantVO.setChannel(one.getChannel());
|
||||||
|
shopMerchantVO.setRelatedLicenceNo(one.getRelatedLicenceNo());
|
||||||
|
if (StrUtil.isNotBlank(one.getNativePayJson())) {
|
||||||
|
shopMerchantVO.setNativeMerchantDTO(JSONObject.parseObject(one.getNativePayJson(), NativeMerchantDTO.class));
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(one.getPolyPayJson())) {
|
||||||
|
shopMerchantVO.setPolyMerchantDTO(JSONObject.parseObject(one.getPolyPayJson(), PolyMerchantDTO.class));
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(one.getRelatedLicenceNo())) {
|
||||||
|
shopMerchantVO.setShopDirectMerchant(shopDirectMerchantService.getOne(query().eq(ShopDirectMerchant::getLicenceNo, one.getRelatedLicenceNo())));
|
||||||
|
}
|
||||||
|
return shopMerchantVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * shopId 修改的店铺Id
|
||||||
|
* * relatedLicenceNo 关联值 原生native必填 对应 tb_shop_direct_merchant 的 licence_no营业执照
|
||||||
|
* * channel {@link com.czg.constant.PayChannelCst}
|
||||||
|
* * jsonObject 支付参数 详情
|
||||||
|
* * isUp 是否要修改 传否时 如果存在支付数据 且与当前渠道不一致 则不修改
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@CacheEvict(key = "#shopMerchantParam.shopId")
|
||||||
|
public Boolean editEntry(ShopMerchantDTO shopMerchantParam, boolean isUp) {
|
||||||
|
ShopMerchant shopMerchant = getOne(query().eq(ShopMerchant::getShopId, shopMerchantParam.getShopId()));
|
||||||
|
if (shopMerchant == null) {
|
||||||
|
shopMerchant = new ShopMerchant();
|
||||||
|
shopMerchant.setChannel(shopMerchantParam.getChannel());
|
||||||
|
shopMerchant.setRelatedLicenceNo(shopMerchantParam.getRelatedLicenceNo());
|
||||||
|
if (PayChannelCst.NATIVE.equals(shopMerchantParam.getChannel()) && shopMerchantParam.getNativeMerchantDTO() != null) {
|
||||||
|
shopMerchant.setNativePayJson(JSONObject.toJSONString(shopMerchantParam.getNativeMerchantDTO()));
|
||||||
|
} else if (PayChannelCst.POLY.equals(shopMerchantParam.getChannel()) && shopMerchantParam.getPolyMerchantDTO() != null) {
|
||||||
|
shopMerchant.setPolyPayJson(JSONObject.toJSONString(shopMerchantParam.getPolyMerchantDTO()));
|
||||||
|
}
|
||||||
|
} else if (isUp) {
|
||||||
|
shopMerchant.setChannel(shopMerchantParam.getChannel());
|
||||||
|
shopMerchant.setShopId(shopMerchantParam.getShopId());
|
||||||
|
shopMerchant.setRelatedLicenceNo(shopMerchantParam.getRelatedLicenceNo());
|
||||||
|
|
||||||
|
if (PayChannelCst.NATIVE.equals(shopMerchantParam.getChannel()) && shopMerchantParam.getNativeMerchantDTO() != null) {
|
||||||
|
shopMerchant.setNativePayJson(JSONObject.toJSONString(shopMerchantParam.getNativeMerchantDTO()));
|
||||||
|
} else if (PayChannelCst.POLY.equals(shopMerchantParam.getChannel()) && shopMerchantParam.getPolyMerchantDTO() != null) {
|
||||||
|
shopMerchant.setPolyPayJson(JSONObject.toJSONString(shopMerchantParam.getPolyMerchantDTO()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//不是新增且不是修改 只有进件完成会进入这里
|
||||||
|
if (StrUtil.isBlank(shopMerchant.getRelatedLicenceNo())) {
|
||||||
|
shopMerchant.setRelatedLicenceNo(shopMerchantParam.getRelatedLicenceNo());
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(shopMerchant.getNativePayJson()) && shopMerchantParam.getNativeMerchantDTO() != null) {
|
||||||
|
shopMerchant.setNativePayJson(JSONObject.toJSONString(shopMerchantParam.getNativeMerchantDTO()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return saveOrUpdate(shopMerchant);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cacheable(key = "#id")
|
||||||
|
@Override
|
||||||
|
public ShopMerchant getById(Serializable id) {
|
||||||
|
ShopMerchant shopMerchant = getMapper().selectOneById(id);
|
||||||
|
AssertUtil.isNull(shopMerchant, "暂未开通支付");
|
||||||
|
return shopMerchant;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ShopDirectMerchant getMainMerchant(Long shopId) {
|
||||||
|
Long mainIdByShopId = shopInfoService.getMainIdByShopId(shopId);
|
||||||
|
if (mainIdByShopId != null) {
|
||||||
|
return shopDirectMerchantService.getOne(query().eq(ShopDirectMerchant::getShopId, mainIdByShopId));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,8 +7,8 @@ import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
|||||||
import com.czg.account.entity.*;
|
import com.czg.account.entity.*;
|
||||||
import com.czg.account.service.*;
|
import com.czg.account.service.*;
|
||||||
import com.czg.constants.PayTypeConstants;
|
import com.czg.constants.PayTypeConstants;
|
||||||
import com.czg.entity.req.*;
|
|
||||||
import com.czg.entity.resp.CzgRefundResp;
|
import com.czg.entity.resp.CzgRefundResp;
|
||||||
|
import com.czg.enums.CzgPayEnum;
|
||||||
import com.czg.enums.ShopUserFlowBizEnum;
|
import com.czg.enums.ShopUserFlowBizEnum;
|
||||||
import com.czg.exception.CzgException;
|
import com.czg.exception.CzgException;
|
||||||
import com.czg.market.dto.MemberOrderDTO;
|
import com.czg.market.dto.MemberOrderDTO;
|
||||||
@@ -24,6 +24,8 @@ import com.czg.order.entity.OrderInfo;
|
|||||||
import com.czg.order.entity.OrderPayment;
|
import com.czg.order.entity.OrderPayment;
|
||||||
import com.czg.order.service.OrderInfoCustomService;
|
import com.czg.order.service.OrderInfoCustomService;
|
||||||
import com.czg.order.service.OrderPaymentService;
|
import com.czg.order.service.OrderPaymentService;
|
||||||
|
import com.czg.pay.CzgPayBaseReq;
|
||||||
|
import com.czg.pay.CzgRefundReq;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.service.order.dto.VipMemberPayParamDTO;
|
import com.czg.service.order.dto.VipMemberPayParamDTO;
|
||||||
import com.czg.service.order.dto.VipPayParamDTO;
|
import com.czg.service.order.dto.VipPayParamDTO;
|
||||||
@@ -131,15 +133,16 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||||
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||||
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), payType, payOrderNo,
|
||||||
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
payParam.getAmount(), "", isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||||
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
|
||||||
"会员充值", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.jsPayReq(payOrderNo, "会员充值", payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||||
|
payParam.getPayType(), payParam.getOpenId(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public CzgResult<Map<String, Object>> ltPayMember(String clientIP, VipMemberPayParamDTO payParam) {
|
public CzgResult<Map<String, Object>> ltPayMember(String clientIp, VipMemberPayParamDTO payParam) {
|
||||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, shopInfoService.getMainIdByShopId(payParam.getShopId())).eq(ShopUser::getId, payParam.getShopUserId()));
|
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, shopInfoService.getMainIdByShopId(payParam.getShopId())).eq(ShopUser::getId, payParam.getShopUserId()));
|
||||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||||
MemberOrder memberOrder = memberOrderService.createMemberOrder(new MemberOrderDTO().setName(payParam.getName())
|
MemberOrder memberOrder = memberOrderService.createMemberOrder(new MemberOrderDTO().setName(payParam.getName())
|
||||||
@@ -155,7 +158,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
.setShopId(payParam.getShopId())
|
.setShopId(payParam.getShopId())
|
||||||
.setRecordId(shopUser.getId())
|
.setRecordId(shopUser.getId())
|
||||||
.setPrice(memberOrder.getAmount())
|
.setPrice(memberOrder.getAmount())
|
||||||
.setIp(clientIP);
|
.setIp(clientIp);
|
||||||
return payService.ltPayOther(payParam1, PayTypeConstants.SourceType.MEMBER_PAY, "会员充值");
|
return payService.ltPayOther(payParam1, PayTypeConstants.SourceType.MEMBER_PAY, "会员充值");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +194,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CzgResult<Map<String, Object>> recharge(String clientIP, VipPayParamDTO rechargeDTO, Long shopUserId) {
|
public CzgResult<Map<String, Object>> recharge(String clientIp, VipPayParamDTO rechargeDTO, Long shopUserId) {
|
||||||
boolean isFree = checkPayVip(rechargeDTO);
|
boolean isFree = checkPayVip(rechargeDTO);
|
||||||
Long mainShopId = shopInfoService.getMainIdByShopId(rechargeDTO.getShopId());
|
Long mainShopId = shopInfoService.getMainIdByShopId(rechargeDTO.getShopId());
|
||||||
|
|
||||||
@@ -212,7 +215,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
.setShopId(rechargeDTO.getShopId())
|
.setShopId(rechargeDTO.getShopId())
|
||||||
.setRecordId(shopUser.getId())
|
.setRecordId(shopUser.getId())
|
||||||
.setPrice(amount)
|
.setPrice(amount)
|
||||||
.setIp(clientIP);
|
.setIp(clientIp);
|
||||||
return payService.ltPayOther(payParam, payType, "会员充值");
|
return payService.ltPayOther(payParam, payType, "会员充值");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,10 +227,10 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||||
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||||
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), payType, payOrderNo,
|
||||||
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
payParam.getAmount(), "", isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||||
return payService.scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
return payService.pay(payParam.getShopId(), CzgPayEnum.SCAN_PAY,
|
||||||
"会员充值", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
CzgPayBaseReq.scanPayReq(payOrderNo, "会员充值", payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(), clintIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -239,10 +242,9 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||||
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
||||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||||
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
payService.initPayment(OrderPayment.pay(payParam.getShopId(), shopUser.getId(), payType, payOrderNo, payParam.getAmount(), "", isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||||
payParam.getAuthCode(), payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
CzgResult<Map<String, Object>> mapCzgResult = payService.pay(payParam.getShopId(), CzgPayEnum.MICRO_PAY,
|
||||||
CzgResult<Map<String, Object>> mapCzgResult = payService.microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
CzgPayBaseReq.microPay(payOrderNo, "会员充值", payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getAuthCode()));
|
||||||
"会员充值", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
|
|
||||||
mapCzgResult.setData(Map.of("payOrderNo", payOrderNo));
|
mapCzgResult.setData(Map.of("payOrderNo", payOrderNo));
|
||||||
return mapCzgResult;
|
return mapCzgResult;
|
||||||
}
|
}
|
||||||
@@ -309,10 +311,11 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
|||||||
return CzgResult.failure("退款失败,该充值记录不存在");
|
return CzgResult.failure("退款失败,该充值记录不存在");
|
||||||
}
|
}
|
||||||
String refPayOrderNo = "REFVIP" + IdUtil.getSnowflakeNextId();
|
String refPayOrderNo = "REFVIP" + IdUtil.getSnowflakeNextId();
|
||||||
refPaymentId = payService.initOrderPayment(new OrderPayment(refPayParam.getShopId(), shopUser.getId(),
|
refPaymentId = payService.initPayment(OrderPayment.refund(refPayParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN,
|
||||||
PayTypeConstants.SourceType.MEMBER_IN, PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refPayParam.getRefAmount()));
|
refPayOrderNo, refPayParam.getRefAmount(), inFlow.getId()));
|
||||||
CzgResult<CzgRefundResp> refund = payService.refund(refPayParam.getShopId(), new CzgRefundReq(refPayOrderNo, refPayParam.getRemark(),
|
CzgResult<CzgRefundResp> refund = payService.refund(refPayParam.getShopId(), new CzgRefundReq(refPayOrderNo, refPayParam.getRemark(),
|
||||||
refPayParam.getRefAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
refPayParam.getRefAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||||
|
payment.getOrderNo(), ""));
|
||||||
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
|
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
|
||||||
throw new CzgException(refund.getMsg());
|
throw new CzgException(refund.getMsg());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
<!DOCTYPE mapper
|
<!DOCTYPE mapper
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.czg.service.account.mapper.ShopMerchantMapper">
|
<mapper namespace="com.czg.service.order.mapper.ShopMerchantMapper">
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
37
cash-service/pay-service/pom.xml
Normal file
37
cash-service/pay-service/pom.xml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.czg</groupId>
|
||||||
|
<artifactId>cash</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<relativePath>../../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>pay-service</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
|
<maven.compiler.target>21</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.czg</groupId>
|
||||||
|
<artifactId>cash-common-tools</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.czg</groupId>
|
||||||
|
<artifactId>poly-pay</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.czg</groupId>
|
||||||
|
<artifactId>aggregation-pay</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.czg;
|
||||||
|
|
||||||
|
import com.czg.pay.CzgPayBaseReq;
|
||||||
|
import com.czg.pay.CzgRefundReq;
|
||||||
|
import com.czg.entity.resp.CzgBaseResp;
|
||||||
|
import com.czg.entity.resp.CzgRefundResp;
|
||||||
|
import com.czg.enums.CzgPayEnum;
|
||||||
|
import com.czg.pay.NativeMerchantDTO;
|
||||||
|
import com.czg.pay.PolyMerchantDTO;
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.NonNull;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付适配器接口
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface PayAdapter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付渠道
|
||||||
|
* {@link com.czg.constant.PayChannelCst}
|
||||||
|
*/
|
||||||
|
String getChannel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统一支付接口
|
||||||
|
*
|
||||||
|
* @param payType 支付类型
|
||||||
|
* @param payData 支付数据 Json类型
|
||||||
|
* 对应 聚合支付参数 {@link PolyMerchantDTO}
|
||||||
|
* 对应 原生支付参数 {@link NativeMerchantDTO}
|
||||||
|
* @param domain 域名 请求地址
|
||||||
|
* @param notifyUrl 通知地址
|
||||||
|
* @param bizData 业务数据
|
||||||
|
*/
|
||||||
|
CzgResult<Map<String, Object>> pay(@NonNull CzgPayEnum payType, @NotBlank String payData, @NotBlank String domain,
|
||||||
|
@NotBlank String notifyUrl, CzgPayBaseReq<?> bizData);
|
||||||
|
|
||||||
|
CzgResult<CzgRefundResp> refund(@NotBlank String domain, @NotBlank String payData, String notifyUrl, CzgRefundReq bizData);
|
||||||
|
|
||||||
|
CzgResult<CzgBaseResp> queryPayOrder(@NotBlank String domain, @NotBlank String payData, String payOrderId, String mchOrderNo);
|
||||||
|
|
||||||
|
CzgResult<CzgRefundResp> queryRefund(@NotBlank String domain, @NotBlank String payData, String mchRefundNo, String refundOrderId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.czg;
|
||||||
|
|
||||||
|
import com.czg.constant.PayChannelCst;
|
||||||
|
import com.czg.impl.NativePayAdapter;
|
||||||
|
import com.czg.impl.PolyPayAdapter;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付适配器工厂
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
*/
|
||||||
|
public class PayAdapterFactory {
|
||||||
|
|
||||||
|
private static final Map<String, PayAdapter> ADAPTER_MAP = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
ADAPTER_MAP.put(PayChannelCst.POLY, new PolyPayAdapter());
|
||||||
|
ADAPTER_MAP.put(PayChannelCst.NATIVE, new NativePayAdapter());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取支付适配器
|
||||||
|
*
|
||||||
|
* @param channel 支付渠道,仅支持 {@link PayChannelCst}
|
||||||
|
*/
|
||||||
|
public static PayAdapter getAdapter(String channel) {
|
||||||
|
PayAdapter adapter = ADAPTER_MAP.get(channel);
|
||||||
|
if (adapter == null) {
|
||||||
|
throw new IllegalStateException("支付渠道未注册适配器: " + channel);
|
||||||
|
}
|
||||||
|
return adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.czg.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.czg.PayAdapter;
|
||||||
|
import com.czg.constant.PayChannelCst;
|
||||||
|
import com.czg.entity.resp.CzgBaseResp;
|
||||||
|
import com.czg.entity.resp.CzgRefundResp;
|
||||||
|
import com.czg.enums.CzgPayEnum;
|
||||||
|
import com.czg.exception.CzgException;
|
||||||
|
import com.czg.pay.CzgPayBaseReq;
|
||||||
|
import com.czg.pay.CzgRefundReq;
|
||||||
|
import com.czg.pay.NativeMerchantDTO;
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 原生支付适配器
|
||||||
|
*
|
||||||
|
* @author ww
|
||||||
|
* @date 2023/10/20 14:20
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class NativePayAdapter implements PayAdapter {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getChannel() {
|
||||||
|
return PayChannelCst.NATIVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<Map<String, Object>> pay(@NonNull CzgPayEnum payType, String payData, String domain, String notifyUrl, CzgPayBaseReq<?> bizData) {
|
||||||
|
try {
|
||||||
|
NativeMerchantDTO polyMerchantDTO = JSONObject.parseObject(payData, NativeMerchantDTO.class);
|
||||||
|
switch (payType) {
|
||||||
|
// case H5_PAY:
|
||||||
|
// return h5Pay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
|
// case JS_PAY:
|
||||||
|
// return jsPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
|
// case LT_PAY:
|
||||||
|
// return ltPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
|
// case SCAN_PAY:
|
||||||
|
// return scanPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
|
// case MICRO_PAY:
|
||||||
|
// //扫码支付 扫描码
|
||||||
|
// return microPay(polyMerchantDTO, domain, notifyUrl, (CzgPayBaseReq<String>) bizData);
|
||||||
|
default:
|
||||||
|
throw new CzgException("原生支付不支持该支付方式: " + bizData.getPayType());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("聚合支付处理失败: {}", e.getMessage(), e);
|
||||||
|
return CzgResult.failure("聚合支付处理失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<CzgRefundResp> refund(String domain, String payData, String notifyUrl, CzgRefundReq bizData) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<CzgBaseResp> queryPayOrder(String domain, String payData, String payOrderId, String mchOrderNo) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<CzgRefundResp> queryRefund(String domain, String payData, String mchRefundNo, String refundOrderId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
package com.czg.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.czg.PayAdapter;
|
||||||
|
import com.czg.PolyPayUtils;
|
||||||
|
import com.czg.constant.PayChannelCst;
|
||||||
|
import com.czg.entity.resp.CzgBaseResp;
|
||||||
|
import com.czg.entity.resp.CzgRefundResp;
|
||||||
|
import com.czg.enums.CzgPayEnum;
|
||||||
|
import com.czg.exception.CzgException;
|
||||||
|
import com.czg.pay.CzgPayBaseReq;
|
||||||
|
import com.czg.pay.CzgRefundReq;
|
||||||
|
import com.czg.pay.PolyMerchantDTO;
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import com.czg.utils.AssertUtil;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author ww
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class PolyPayAdapter implements PayAdapter {
|
||||||
|
@Override
|
||||||
|
public String getChannel() {
|
||||||
|
return PayChannelCst.POLY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<Map<String, Object>> pay(@NonNull CzgPayEnum payType, @NotBlank String payData, @NotBlank String domain,
|
||||||
|
@NotBlank String notifyUrl, CzgPayBaseReq<?> bizData) {
|
||||||
|
try {
|
||||||
|
PolyMerchantDTO polyMerchantDTO = JSONObject.parseObject(payData, PolyMerchantDTO.class);
|
||||||
|
return switch (payType) {
|
||||||
|
case H5_PAY -> h5Pay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
|
case JS_PAY -> jsPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
|
case LT_PAY -> ltPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
|
case SCAN_PAY -> scanPay(polyMerchantDTO, domain, notifyUrl, bizData);
|
||||||
|
case MICRO_PAY -> microPay(polyMerchantDTO, domain, notifyUrl, (CzgPayBaseReq<String>) bizData);
|
||||||
|
default -> throw new CzgException("聚合支付不支持该支付方式: " + bizData.getPayType());
|
||||||
|
};
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("聚合支付处理失败: {}", e.getMessage(), e);
|
||||||
|
return CzgResult.failure("聚合支付处理失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<CzgRefundResp> refund(@NotBlank String domain, @NotBlank String payData, String notifyUrl, CzgRefundReq bizData) {
|
||||||
|
PolyMerchantDTO shopMerchant = JSONObject.parseObject(payData, PolyMerchantDTO.class);
|
||||||
|
bizData.setNotifyUrl(notifyUrl);
|
||||||
|
return PolyPayUtils.refundOrder(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<CzgBaseResp> queryPayOrder(@NotBlank String payData, @NotBlank String domain, String payOrderId, String mchOrderNo) {
|
||||||
|
PolyMerchantDTO shopMerchant = JSONObject.parseObject(payData, PolyMerchantDTO.class);
|
||||||
|
PolyPayUtils.queryPayOrder(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), payOrderId, mchOrderNo);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CzgResult<CzgRefundResp> queryRefund(@NotBlank String payData, @NotBlank String domain, String mchRefundNo, String refundOrderId) {
|
||||||
|
PolyMerchantDTO shopMerchant = JSONObject.parseObject(payData, PolyMerchantDTO.class);
|
||||||
|
return PolyPayUtils.queryRefundOrder(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), mchRefundNo, refundOrderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CzgResult<Map<String, Object>> h5Pay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq<?> bizData) {
|
||||||
|
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
||||||
|
return PolyPayUtils.h5Pay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CzgResult<Map<String, Object>> jsPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq<?> bizData) {
|
||||||
|
bizData.setSubAppid("aliPay".equals(bizData.getPayType()) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
|
||||||
|
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
|
||||||
|
bizData.setPayType("aliPay".equals(bizData.getPayType()) ? "ALIPAY" : "WECHAT");
|
||||||
|
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
||||||
|
return PolyPayUtils.jsPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private CzgResult<Map<String, Object>> ltPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq<?> bizData) {
|
||||||
|
bizData.setSubAppid("aliPay".equals(bizData.getPayType()) ? shopMerchant.getAlipaySmallAppid() : shopMerchant.getWechatSmallAppid());
|
||||||
|
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
|
||||||
|
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
||||||
|
return PolyPayUtils.ltPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CzgResult<Map<String, Object>> scanPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq<?> bizData) {
|
||||||
|
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
||||||
|
return PolyPayUtils.scanPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CzgResult<Map<String, Object>> microPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq<String> bizData) {
|
||||||
|
AssertUtil.isBlank(bizData.getData(), "扫码失败,请重试");
|
||||||
|
if (bizData.getData().length() > 26) {
|
||||||
|
throw new CzgException("支付失败,不支持的条码");
|
||||||
|
}
|
||||||
|
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
||||||
|
|
||||||
|
String firstTwoDigitsStr = bizData.getData().substring(0, 2);
|
||||||
|
// 将截取的字符串转换为整数
|
||||||
|
int firstTwoDigits = Integer.parseInt(firstTwoDigitsStr);
|
||||||
|
// 判断范围
|
||||||
|
if (firstTwoDigits >= 10 && firstTwoDigits <= 15) {
|
||||||
|
//微信支付
|
||||||
|
bizData.setSubAppid(shopMerchant.getWechatSmallAppid());
|
||||||
|
} else if (firstTwoDigits >= 25 && firstTwoDigits <= 30) {
|
||||||
|
//支付宝支付
|
||||||
|
bizData.setSubAppid(shopMerchant.getAlipaySmallAppid());
|
||||||
|
} else {
|
||||||
|
throw new CzgException("扫描码非法或暂不支持");
|
||||||
|
}
|
||||||
|
return PolyPayUtils.microPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||||
|
}
|
||||||
|
}
|
||||||
1
pom.xml
1
pom.xml
@@ -27,6 +27,7 @@
|
|||||||
<module>cash-sdk</module>
|
<module>cash-sdk</module>
|
||||||
<module>cash-dependencies</module>
|
<module>cash-dependencies</module>
|
||||||
<module>cash-api/market-server</module>
|
<module>cash-api/market-server</module>
|
||||||
|
<module>cash-service/pay-service</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|||||||
Reference in New Issue
Block a user