Merge branch 'pay' into test
This commit is contained in:
@@ -9,7 +9,7 @@ import com.czg.order.vo.HistoryOrderVo;
|
||||
import com.czg.order.vo.OrderInfoVo;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.order.service.PayService;
|
||||
import com.czg.service.order.service.OrderPayService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.ServletUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
@@ -31,7 +31,7 @@ public class AdminOrderController {
|
||||
@Resource
|
||||
private OrderInfoCustomService orderInfoService;
|
||||
@Resource
|
||||
private PayService payService;
|
||||
private OrderPayService orderPayService;
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
@@ -94,7 +94,7 @@ public class AdminOrderController {
|
||||
@PostMapping("/refundOrder")
|
||||
@Debounce(value = "#refundDTO.orderId")
|
||||
public CzgResult<Object> refundOrder(@Validated @RequestBody OrderInfoRefundDTO refundDTO) {
|
||||
return payService.refundOrderBefore(refundDTO);
|
||||
return orderPayService.refundOrderBefore(refundDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.EntryManager;
|
||||
import com.czg.annotation.Debounce;
|
||||
import com.czg.dto.req.AggregateMerchantDto;
|
||||
@@ -30,6 +31,25 @@ public class EntryManagerController {
|
||||
@Resource
|
||||
private EntryManagerTask entryManagerTask;
|
||||
|
||||
/**
|
||||
* ocr识别填充
|
||||
* 阿里 ocr识别图片
|
||||
* 本接口支持:PNG、JPG、JPEG、BMP、GIF、TIFF、WebP、PDF。
|
||||
* 图片长宽需要大于 15 像素,小于 8192 像素。
|
||||
* 长宽比需要小于 50。长宽均大于 500px。
|
||||
* 图片二进制文件不能超过 10MB。
|
||||
* 图片过大会影响接口响应速度,建议使用小于 1.5M 图片进行识别,
|
||||
*
|
||||
* @param url 图片地址
|
||||
* @param type IdCard 身份证
|
||||
* BankCard 银行卡
|
||||
* BusinessLicense 营业执照
|
||||
*/
|
||||
@GetMapping("getInfoByImg")
|
||||
public CzgResult<JSONObject> getInfoByImg(String url, String type) throws Exception {
|
||||
return CzgResult.success(shopDirectMerchantService.getInfoByImg(url, type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询银行支行列表
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.czg.controller;
|
||||
package com.czg.controller.pay;
|
||||
|
||||
import com.czg.annotation.Debounce;
|
||||
import com.czg.order.dto.MkDistributionPayDTO;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.czg.controller;
|
||||
package com.czg.controller.pay;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
@@ -10,7 +10,7 @@ import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.service.OrderInfoCustomService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||
import com.czg.service.order.service.PayService;
|
||||
import com.czg.service.order.service.OrderPayService;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.ServletUtil;
|
||||
@@ -35,7 +35,7 @@ import java.util.Map;
|
||||
@RequestMapping("/pay")
|
||||
public class OrderPayController {
|
||||
@Resource
|
||||
private PayService payService;
|
||||
private OrderPayService orderPayService;
|
||||
@Resource
|
||||
private OrderInfoCustomService orderInfoCustomService;
|
||||
@Resource
|
||||
@@ -47,14 +47,14 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Object> creditPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.creditPayOrder(payParam);
|
||||
return orderPayService.creditPayOrder(payParam);
|
||||
}
|
||||
|
||||
@PostMapping("/cashPay")
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Object> cashPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.cashPayOrder(payParam);
|
||||
return orderPayService.cashPayOrder(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> rechargePayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.rechargePayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return orderPayService.rechargePayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ public class OrderPayController {
|
||||
public CzgResult<Object> vipPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付类型不可为空");
|
||||
return payService.vipPayOrder(payParam);
|
||||
return orderPayService.vipPayOrder(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +93,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> h5PayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.h5PayOrder(ServletUtil.getClientIP(request, ""), payParam);
|
||||
return orderPayService.h5PayOrder(ServletUtil.getClientIP(request, ""), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> jsPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.jsPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return orderPayService.jsPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +118,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> ltPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return orderPayService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> scanPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return orderPayService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> microPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.microPayOrder(payParam);
|
||||
return orderPayService.microPayOrder(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ public class OrderPayController {
|
||||
@PostMapping("/shopPayApi/js2Pay")
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> js2PayOrder(HttpServletRequest request, @RequestBody OrderPayParamDTO payParam) {
|
||||
return payService.js2PayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return orderPayService.js2PayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.czg.controller;
|
||||
package com.czg.controller.pay;
|
||||
|
||||
import com.czg.annotation.Debounce;
|
||||
import com.czg.entity.resp.CzgBaseResp;
|
||||
@@ -7,6 +7,7 @@ import com.czg.service.order.dto.VipMemberPayParamDTO;
|
||||
import com.czg.service.order.dto.VipPayParamDTO;
|
||||
import com.czg.service.order.dto.VipRefundDTO;
|
||||
import com.czg.service.order.service.PayService;
|
||||
import com.czg.service.order.service.ShopUserPayService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.ServletUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -28,6 +29,8 @@ import java.util.Map;
|
||||
public class VipPayController {
|
||||
@Resource
|
||||
private PayService payService;
|
||||
@Resource
|
||||
private ShopUserPayService shopUserPayService;
|
||||
|
||||
/**
|
||||
* 现金充值
|
||||
@@ -39,7 +42,7 @@ public class VipPayController {
|
||||
public CzgResult<Object> cashPayVip(@Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return payService.cashPayVip(payParam);
|
||||
return shopUserPayService.cashPayVip(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +55,7 @@ public class VipPayController {
|
||||
public CzgResult<Map<String, Object>> jsPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return payService.jsPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
return shopUserPayService.jsPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +68,7 @@ public class VipPayController {
|
||||
public CzgResult<Map<String, Object>> ltPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return payService.ltPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
return shopUserPayService.ltPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +84,7 @@ public class VipPayController {
|
||||
return CzgResult.failure("充值失败 未指定充值金额");
|
||||
}
|
||||
rechargeDTO.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return payService.recharge(ServletUtil.getClientIP(request), rechargeDTO, rechargeDTO.getShopUserId());
|
||||
return shopUserPayService.recharge(ServletUtil.getClientIP(request), rechargeDTO, rechargeDTO.getShopUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +98,7 @@ public class VipPayController {
|
||||
public CzgResult<Map<String, Object>> ltPayMember(HttpServletRequest request, @Validated @RequestBody VipMemberPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "购买失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return payService.ltPayMember(ServletUtil.getClientIP(request), payParam);
|
||||
return shopUserPayService.ltPayMember(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +111,7 @@ public class VipPayController {
|
||||
public CzgResult<Map<String, Object>> scanPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(request, "platformType"));
|
||||
return payService.scanPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
return shopUserPayService.scanPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +124,7 @@ public class VipPayController {
|
||||
public CzgResult<Map<String, Object>> microPayVip(@Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return payService.microPayVip(payParam);
|
||||
return shopUserPayService.microPayVip(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +135,7 @@ public class VipPayController {
|
||||
@PostMapping("/refundVipBefore")
|
||||
@Debounce(value = "#payParam.flowId")
|
||||
public CzgResult<Map<String, BigDecimal>> refundVipBefore(@Validated @RequestBody VipRefundDTO payParam) {
|
||||
return payService.refundVipBefore(payParam);
|
||||
return shopUserPayService.refundVipBefore(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +158,7 @@ public class VipPayController {
|
||||
return CzgResult.failure("退款金额过大");
|
||||
}
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(request, "platformType"));
|
||||
return payService.refundVip(payParam);
|
||||
return shopUserPayService.refundVip(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,9 +75,11 @@ public class EntryManagerMqListener {
|
||||
ShopDirectMerchant merchant = new ShopDirectMerchant();
|
||||
merchant.setShopId(entry.getShopId());
|
||||
|
||||
merchant.setWechatApplyId(resp.getWechatApplyId());
|
||||
merchant.setWechatStatus(resp.getWechatStatus());
|
||||
merchant.setWechatErrorMsg(resp.getWechatErrorMsg());
|
||||
|
||||
merchant.setAlipayOrderId(resp.getAlipayOrderId());
|
||||
merchant.setAlipayStatus(resp.getAlipayStatus());
|
||||
merchant.setAlipayErrorMsg(resp.getAlipayErrorMsg());
|
||||
shopDirectMerchantService.updateById(merchant);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.czg.order.dto;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@@ -13,6 +14,7 @@ import java.math.BigDecimal;
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class LtPayOtherDTO {
|
||||
/**
|
||||
* 积分商品id/团购商品id
|
||||
|
||||
@@ -80,6 +80,7 @@ public class ShopDirectMerchant implements Serializable {
|
||||
|
||||
private String errorMsg;
|
||||
|
||||
private String wechatApplyId;
|
||||
/**
|
||||
* 微信状态
|
||||
*/
|
||||
@@ -94,6 +95,8 @@ public class ShopDirectMerchant implements Serializable {
|
||||
*/
|
||||
private String wechatSignUrl;
|
||||
|
||||
private String alipayOrderId;
|
||||
|
||||
/**
|
||||
* 支付宝状态
|
||||
*/
|
||||
|
||||
@@ -37,6 +37,10 @@ public class SysCategoryInfo implements Serializable {
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private BigInteger id;
|
||||
|
||||
/**
|
||||
* 一级类目code
|
||||
*/
|
||||
private String firstCategoryCode;
|
||||
/**
|
||||
* 一级类目
|
||||
*/
|
||||
|
||||
@@ -30,6 +30,11 @@
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java-v3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ocr_api20210707</artifactId>
|
||||
<version>3.1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
68
cash-sdk/aggregation-pay/src/main/java/com/czg/OcrUtils.java
Normal file
68
cash-sdk/aggregation-pay/src/main/java/com/czg/OcrUtils.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.czg;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.aliyun.ocr_api20210707.models.RecognizeAllTextResponse;
|
||||
import com.aliyun.tea.*;
|
||||
import com.czg.exception.CzgException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
*/
|
||||
@Slf4j
|
||||
public class OcrUtils {
|
||||
/**
|
||||
* 阿里 ocr识别图片
|
||||
* 本接口支持:PNG、JPG、JPEG、BMP、GIF、TIFF、WebP、PDF。
|
||||
* 图片长宽需要大于 15 像素,小于 8192 像素。
|
||||
* 长宽比需要小于 50。长宽均大于 500px。
|
||||
* 图片二进制文件不能超过 10MB。
|
||||
* 图片过大会影响接口响应速度,建议使用小于 1.5M 图片进行识别,
|
||||
*
|
||||
* @param url 图片地址
|
||||
* @param type IdCard 身份证
|
||||
* BankCard 银行卡
|
||||
* BusinessLicense 营业执照
|
||||
* 目前使用的角色为 czg-oss@1413456038175003.onaliyun.com
|
||||
* 需要 AliyunOCRFullAccess 权限
|
||||
* AliyunBSSContractFullAccess 权限
|
||||
* 文档地址 <a href="https://help.aliyun.com/zh/ocr/developer-reference/api-ocr-api-2021-07-07-recognizealltext?spm=a2c4g.11186623.0.0.543669f32I79Gw#api-detail-35">
|
||||
*/
|
||||
public static JSONObject getInfoByImg(String accessKeyId, String accessKeySecret,
|
||||
String url, String type) throws Exception {
|
||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||
.setAccessKeyId(accessKeyId)
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||
.setAccessKeySecret(accessKeySecret);
|
||||
config.endpoint = "ocr-api.cn-hangzhou.aliyuncs.com";
|
||||
|
||||
com.aliyun.ocr_api20210707.Client client = new com.aliyun.ocr_api20210707.Client(config);
|
||||
com.aliyun.ocr_api20210707.models.RecognizeAllTextRequest recognizeAllTextRequest = new com.aliyun.ocr_api20210707.models.RecognizeAllTextRequest()
|
||||
.setUrl(url).setType(type);
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
try {
|
||||
RecognizeAllTextResponse resp = client.recognizeAllTextWithOptions(recognizeAllTextRequest, runtime);
|
||||
return JSONObject.from(resp.body.data);
|
||||
} catch (TeaException error) {
|
||||
// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// // 错误 message
|
||||
// System.out.println(error.getMessage());
|
||||
// // 诊断地址
|
||||
// System.out.println(error.getData().get("Recommend"));
|
||||
// com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
log.error("识别失败, msg: {}", error.getMessage());
|
||||
throw new CzgException(error.getMessage());
|
||||
} catch (Exception error) {
|
||||
// TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// // 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// // 错误 message
|
||||
// System.out.println(error.getMessage());
|
||||
// // 诊断地址
|
||||
// System.out.println(error.getData().get("Recommend"));
|
||||
// com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
log.error("识别失败, msg: {}", error.getMessage());
|
||||
throw new CzgException(error.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.czg.third.alipay.dto.entry;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 经营地址
|
||||
* @author yjjie
|
||||
* @date 2026/1/4 11:20
|
||||
*/
|
||||
@Data
|
||||
public class AlipayAddressReqDto {
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 城市编码
|
||||
* 蚂蚁店铺请按照蚂蚁店铺地区码 表格中填写。
|
||||
* 直付通商户请按照直付通商户地区码 表格中内容填写。
|
||||
*/
|
||||
@JSONField(name = "city_code")
|
||||
private String cityCode;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 区县编码
|
||||
*/
|
||||
@JSONField(name = "district_code")
|
||||
private String districtCode;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 详细地址
|
||||
*/
|
||||
@JSONField(name = "address")
|
||||
private String address;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 省份编码
|
||||
*/
|
||||
@JSONField(name = "province_code")
|
||||
private String provinceCode;
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package com.czg.third.alipay.dto.entry;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 结算银行卡信息
|
||||
* @author yjjie
|
||||
* @date 2026/1/4 11:14
|
||||
*/
|
||||
@Data
|
||||
public class AlipayBizCardsReqDto {
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 开户支行名
|
||||
*/
|
||||
@JSONField(name = "account_branch_name")
|
||||
private String accountBranchName;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 卡户名
|
||||
*/
|
||||
@JSONField(name = "account_holder_name")
|
||||
private String accountHolderName;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 开户行所在地-省
|
||||
*/
|
||||
@JSONField(name = "account_inst_province")
|
||||
private String accountInstProvince;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 开户行所在地-市
|
||||
*/
|
||||
@JSONField(name = "account_inst_city")
|
||||
private String accountInstCity;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 开户行简称缩写
|
||||
*/
|
||||
@JSONField(name = "account_inst_id")
|
||||
private String accountInstId;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 银行名称
|
||||
*/
|
||||
@JSONField(name = "account_inst_name")
|
||||
private String accountInstName;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 银行卡号
|
||||
*/
|
||||
@JSONField(name = "account_no")
|
||||
private String accountNo;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 银行卡类型
|
||||
* 【枚举值】
|
||||
* 借记卡: DC
|
||||
* 信用卡: CC
|
||||
*/
|
||||
@JSONField(name = "account_type")
|
||||
private String accountType;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 账号使用类型
|
||||
* 【枚举值】
|
||||
* 对公: 01
|
||||
* 对私: 02
|
||||
*/
|
||||
@JSONField(name = "usage_type")
|
||||
private String usageType;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 联行号
|
||||
*/
|
||||
@JSONField(name = "bank_code")
|
||||
private String bankCode;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package com.czg.third.alipay.dto.entry;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商户联系人信息
|
||||
* @author yjjie
|
||||
* @date 2026/1/4 11:02
|
||||
*/
|
||||
@Data
|
||||
public class AlipayContactInfoReqDto {
|
||||
/**
|
||||
* 【必填】
|
||||
* 联系人名字
|
||||
*/
|
||||
@JSONField(name = "name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* email | mobile | phone 三选一
|
||||
* 电子邮箱
|
||||
*/
|
||||
@JSONField(name = "email")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* email | mobile | phone 三选一
|
||||
* 手机号码
|
||||
*/
|
||||
@JSONField(name = "mobile")
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* email | mobile | phone 三选一
|
||||
* 电话
|
||||
*/
|
||||
@JSONField(name = "phone")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 身份证号
|
||||
*/
|
||||
@JSONField(name = "id_card_no")
|
||||
private String idCardNo;
|
||||
}
|
||||
@@ -1,249 +0,0 @@
|
||||
package com.czg.third.alipay.dto.entry;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 平台商提交二级商户资料进行进件,完成二级商户入驻
|
||||
* <a href="https://opendocs.alipay.com/solution/9434dd99_ant.merchant.expand.indirect.zft.simplecreate?scene=bf5951260023430e944c2e9afdf7f9e2&pathHash=d3136936">...</a>
|
||||
* @author yjjie
|
||||
* @date 2025/12/29 14:19
|
||||
*/
|
||||
@Data
|
||||
public class AlipayEntryReqDto {
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户编号,由一级商户定义,保证在一级商户下唯一即可
|
||||
*/
|
||||
@JSONField(name = "external_id")
|
||||
private String externalId;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户别名。支付宝收银台及账单中的商户名称会展示此处设置的别名。如果涉及支付宝APP内的支付,支付结果页也会展示该别名;如果涉及线下当面付场景,请填写线下店铺名称
|
||||
*/
|
||||
@JSONField(name = "alias_name")
|
||||
private String aliasName;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户联系人信息。在本业务中,ContactInfo对象中联系人姓名、手机号必填,其他选填
|
||||
*/
|
||||
@JSONField(name = "contact_infos")
|
||||
private AlipayContactInfoReqDto contactInfo;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 默认结算规则。当调用收单接口,settle_info中设置默认结算规则(defaultSettle)时,交易资金将结算至此处设置的默认结算目标账户中。其详细描述及收单接口传参示例参考功能包文档
|
||||
*/
|
||||
@JSONField(name = "default_settle_rule")
|
||||
private AlipaySettleRuleReqDto defaultSettleRule;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户使用服务
|
||||
* 可选值有:当面付、jsapi支付、app支付、wap支付、电脑支付、预授权支付、商户代扣、小程序支付、订单码支付。其值会影响其他字段必填性,详见其他字段描述
|
||||
* 当面付: 当面付
|
||||
* jsapi支付: jsapi支付
|
||||
* app支付: app支付
|
||||
* wap支付: wap支付
|
||||
* 电脑支付: 电脑支付
|
||||
* 预授权支付: 预授权支付
|
||||
* 商户代扣: 商户代扣
|
||||
* 小程序支付: 小程序支付
|
||||
* 订单码支付: 订单码支付
|
||||
*/
|
||||
@JSONField(name = "service")
|
||||
private List<String> service;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户证件编号
|
||||
* 按商户类型merchant_type的说明提供对应的证件编号
|
||||
*/
|
||||
@JSONField(name = "cert_no")
|
||||
private String certNo;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户类别码 mcc
|
||||
* <a href="https://mdn.alipayobjects.com/huamei_fctrxv/afts/file/A*3TMHRZ8ppa4AAAAAAAAAAAAADs2DAQ/%E8%BF%9B%E4%BB%B6MCC%E4%B8%8E%E8%B5%84%E8%B4%A8%E8%A6%81%E6%B1%82202212.xlsx">...</a>
|
||||
* 可查看 进件MCC与资质要求 202212.xlsx,特殊行业要按照MCC说明中的资质一栏上传辅助资质,辅助资质要在 qualifications 中上传,会有人工审核。
|
||||
* 【示例值】B0007
|
||||
*/
|
||||
@JSONField(name = "mcc")
|
||||
private String mcc;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 结算支付宝账号
|
||||
* 结算账号使用支付宝账号时必填,本字段指定交易资金结算的具体支付宝账号,与binding_alipay_logon_id同主体的支付宝账号即可
|
||||
*/
|
||||
@JSONField(name = "alipay_logon_id")
|
||||
private String alipayLogonId;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 法人名称
|
||||
* 非个人商户类型必填
|
||||
*/
|
||||
@JSONField(name = "legal_name")
|
||||
private String legalName;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 法人证件编号
|
||||
* 法人证件编号,非个人商户类型必填
|
||||
*/
|
||||
@JSONField(name = "legal_cert_no")
|
||||
private String legalCertNo;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 商户证件图
|
||||
* 目前只有当商户类型是个人商户且使用当面付服务时才需填写
|
||||
*/
|
||||
@JSONField(name = "cert_image_back")
|
||||
private String certImageBack;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 商户证件图片
|
||||
* 本业务接口中,如果是特殊行业必填;使用当面付服务时,非个人必填,个人结算到卡时必填。其值为使用ant.merchant.expand.indirect.image.upload上传图片得到的一串oss key。
|
||||
*/
|
||||
@JSONField(name = "cert_image")
|
||||
private String certImage;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 进件的二级商户名称
|
||||
* 一般情况下要与证件的名称相同。个体工商户类型可以放宽到法人名称
|
||||
*/
|
||||
@JSONField(name = "name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 法人证件类型
|
||||
* 默认可不填,认为legal_cert_no是大陆身份证。类型包括:100 大陆身份证;105 港澳居民往来内地通行证;106 台湾同胞往来大陆通行证;108 外国人居留证
|
||||
* 【枚举值】
|
||||
* 大陆身份证: 100
|
||||
* 港澳居民往来内地通行证: 105
|
||||
* 台湾同胞往来大陆通行证: 106
|
||||
* 外国人居留证: 108
|
||||
*/
|
||||
@JSONField(name = "legal_cert_type")
|
||||
private String legalCertType;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 商户类型
|
||||
* 01:企业;cert_type填写201(营业执照);cert_no填写营业执照号;
|
||||
* 02:事业单位:cert_type填写218(事业单位法人证书);cert_no填写事业单位法人证书编号;
|
||||
* 03:民办非企业组织:cert_type填写204(民办非企业登记证书);cert_no填写民办非企业登记证书编号;
|
||||
* 04:社会团体:cert_type填写206(社会团体法人登记证书);cert_no填写社会团体法人登记证书编号;
|
||||
* 05:党政及国家机关:cert_type填写219(党政机关批准设立文件/行政执法主体资格证);cert_no填写党政机关批准设立文件/行政执法主体资格证编号;
|
||||
* 06:个人商户:cert_type填写100(个人身份证);cert_no填写个人身份证号码;
|
||||
* 07:个体工商户:cert_type填写201(营业执照);cert_no填写营业执照编号;
|
||||
*/
|
||||
@JSONField(name = "merchant_type")
|
||||
private String merchantType;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 商户证件类型
|
||||
* 按商户类型merchant_type的说明提供对应的证件类型。
|
||||
* 营业执照: 201
|
||||
* 事业单位法人证书: 218
|
||||
* 民办非企业登记证书: 204
|
||||
* 社会团体法人登记证书: 206
|
||||
* 党政机关批准设立文件/行政执法主体资格证: 219
|
||||
* 个人身份证: 100
|
||||
*/
|
||||
@JSONField(name = "cert_type")
|
||||
private String certType;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 证件名称
|
||||
* 目前只有个体工商户商户类型要求填入本字段,填写值为个体工商户营业执照上的名称
|
||||
*/
|
||||
@JSONField(name = "cert_name")
|
||||
private String certName;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 结算银行卡信息
|
||||
* 结算银行卡信息,结算账号使用银行卡时必填。本业务当前只允许传入一张结算卡。个人类型商户不允许结算到银行卡
|
||||
* 【必选条件】结算银行卡信息,结算账号使用银行卡时必填。本业务当前只允许传入一张结算卡。个人类型商户不允许结算到银行卡
|
||||
*/
|
||||
@JSONField(name = "biz_cards")
|
||||
private AlipayBizCardsReqDto bizCards;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 经营地址
|
||||
* 使用当面付服务时必填。地址对象中省、市、区、地址必填,其余选填
|
||||
*/
|
||||
@JSONField(name = "business_address")
|
||||
private AlipayAddressReqDto businessAddress;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 门头照
|
||||
* 使用当面付服务时必填。其值为使用ant.merchant.expand.indirect.image.upload上传图片得到的一串oss key
|
||||
*/
|
||||
@JSONField(name = "out_door_images")
|
||||
private String outDoorImages;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 内景照
|
||||
* 使用当面付服务时必填。其值为使用ant.merchant.expand.indirect.image.upload上传图片得到的一串oss key
|
||||
*/
|
||||
@JSONField(name = "in_door_images")
|
||||
private String inDoorImages;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 授权函
|
||||
* <a href="https://opendocs.alipay.com/open/direct-payment/cg5mkp#%E7%9B%B8%E5%85%B3%E8%B5%84%E6%96%99">《说明函》模板参考</a>
|
||||
* 当商户名与结算卡户名不一致。《说明函》模板参考。涉及外籍法人(这种情况上传任意能证明身份的图片)时必填,
|
||||
* 其值为使用ant.merchant.expand.indirect.image.upload上传图片得到的一串oss key。(商户类型为个体工商户时,本字段仅需上传营业执照非授权函)
|
||||
*/
|
||||
@JSONField(name = "license_auth_letter_image")
|
||||
private String licenseAuthLetterImage;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 商户站点信息
|
||||
* 包括网站、app、小程序。商户使用服务包含电脑支付、wap支付时,必须填充一个类型为01(网站)的SiteInfo对象,site_type/site_url/site_name必填;
|
||||
* 当包含app支付时,必须至少填充类型为02(APP)或06(支付宝小程序)中一种类型的SiteInfo对象,site_type/site_name必填;当包含jsapi支付时,必须填充一个类型为06(支付宝小程序)的SiteInfo对象;
|
||||
*/
|
||||
@JSONField(name = "sites")
|
||||
private AlipaySitesReqDto sites;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 商户行业资质图片
|
||||
* 当商户的经营类目选择了特殊行业时该字段必填,需要特殊行业资质文件。每项行业资质信息中,industry_qualification_type和industry_qualification_image均必填。
|
||||
*/
|
||||
@JSONField(name = "qualifications")
|
||||
private List<AlipayQualificationsReqDto> qualifications;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 交易场景
|
||||
* 【枚举值】
|
||||
* 小程序支付场景: TINY_APP
|
||||
* H5场景: WAP
|
||||
* 线下当面付场景: OFFLINE
|
||||
* APP支付场景: APP
|
||||
* 网站支付场景: PC
|
||||
*/
|
||||
@JSONField(name = "trade_scene")
|
||||
private List<String> tradeScene;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.czg.third.alipay.dto.entry;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 图片上传
|
||||
* @author yjjie
|
||||
* @date 2026/1/4 13:46
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AlipayImageUploadReqDto {
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 图片格式
|
||||
* 支持格式:bmp、jpg、jpeg、png、gif.
|
||||
*/
|
||||
@JSONField(name = "image_type")
|
||||
private String imageType;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 图片二进制字节流
|
||||
* 最大为10M
|
||||
*/
|
||||
@JSONField(name = "image_content")
|
||||
private byte[] imageContent;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.czg.third.alipay.dto.entry;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 商户行业资质
|
||||
* @author yjjie
|
||||
* @date 2026/1/4 11:40
|
||||
*/
|
||||
@Data
|
||||
public class AlipayQualificationsReqDto {
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户行业资质类型 具体选值参见 <a href="https://gw.alipayobjects.com/os/bmw-prod/7aa3a36b-2bc2-4d57-815f-08edd55ef67e.xlsx">文档</a>
|
||||
* 【枚举值】
|
||||
* 金融许可证: 323
|
||||
* 【示例值】323
|
||||
*/
|
||||
@JSONField(name = "industry_qualification_type")
|
||||
private String industryQualificationType;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 商户行业资质图片
|
||||
*/
|
||||
@JSONField(name = "industry_qualification_image")
|
||||
private String industryQualificationImage;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.czg.third.alipay.dto.entry;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 结算规则
|
||||
* @author yjjie
|
||||
* @date 2026/1/4 11:06
|
||||
*/
|
||||
@Data
|
||||
public class AlipaySettleRuleReqDto {
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 默认结算类型
|
||||
* 可选值有bankCard/alipayAccount。bankCard表示结算到银行卡;alipayAccount表示结算到支付宝账号
|
||||
*/
|
||||
@JSONField(name = "default_settle_type")
|
||||
private String defaultSettleType;
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 默认结算目标
|
||||
* 当默认结算类型为bankCard时填写银行卡卡号,其值需在进件填写的结算银行卡范围内;当默认结算类型为alipayAccount时填写支付宝账号登录号,其值需在进件填写的结算支付宝账号范围内。
|
||||
*/
|
||||
@JSONField(name = "default_settle_target")
|
||||
private String defaultSettleTarget;
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
package com.czg.third.alipay.dto.entry;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author yjjie
|
||||
* @date 2026/1/4 11:31
|
||||
*/
|
||||
@Data
|
||||
public class AlipaySitesReqDto {
|
||||
|
||||
/**
|
||||
* 【必填】
|
||||
* 网站类型
|
||||
* 【枚举值】
|
||||
* 网站: 01
|
||||
* APP: 02
|
||||
* 服务窗: 03
|
||||
* 公众号: 04
|
||||
* 其他: 05
|
||||
* 支付宝小程序: 06
|
||||
* 手机网站/H5: 07
|
||||
*/
|
||||
@JSONField(name = "site_type")
|
||||
private String siteType;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 站点地址
|
||||
* 当传入service,且包含jsapi支付时,sites的site_type=06, site_url必填
|
||||
*/
|
||||
@JSONField(name = "site_url")
|
||||
private String siteUrl;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 站点名称
|
||||
* 当传入service,且包含jsapi支付、小程序支付时,sites的site_type=06, site_name必填
|
||||
*/
|
||||
@JSONField(name = "site_name")
|
||||
private String siteName;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 截图照片
|
||||
* 当传入交易场景trade_scene,且当传入trade_scene=WAP、trade_scene=APP、trade_scene=PC时该参数必传
|
||||
*/
|
||||
@JSONField(name = "screenshot_image")
|
||||
private String screenshotImage;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 小程序appId
|
||||
* 当传入service,且包含jsapi支付时,sites的site_type=06, tiny_app_id必填。
|
||||
*/
|
||||
@JSONField(name = "tiny_app_id")
|
||||
private String tinyAppId;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 测试账号
|
||||
*/
|
||||
@JSONField(name = "account")
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 测试账号密码
|
||||
*/
|
||||
@JSONField(name = "password")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 上架状态
|
||||
* 【枚举值】
|
||||
* 已上线: ONLINE
|
||||
* 已上线-内部: ONLINE_INNER
|
||||
* 未上线: OFFLINE
|
||||
*/
|
||||
@JSONField(name = "status")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 授权函照片
|
||||
*/
|
||||
@JSONField(name = "auth_letter_image")
|
||||
private String authLetterImage;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 备注说明
|
||||
*/
|
||||
@JSONField(name = "remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 备注说明图片
|
||||
*/
|
||||
@JSONField(name = "remark_image")
|
||||
private String remarkImage;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 网站域名
|
||||
*/
|
||||
@JSONField(name = "site_domain")
|
||||
private String siteDomain;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* ICP备案主体信息服务名称
|
||||
*/
|
||||
@JSONField(name = "icp_service_name")
|
||||
private String icpServiceName;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* ICP备案/许可证号
|
||||
*/
|
||||
@JSONField(name = "icp_no")
|
||||
private String icpNo;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* ICP备案主体主办单位名称
|
||||
*/
|
||||
@JSONField(name = "icp_org_name")
|
||||
private String icpOrgName;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 下载地址
|
||||
*/
|
||||
@JSONField(name = "download")
|
||||
private String download;
|
||||
|
||||
/**
|
||||
* 【选填】
|
||||
* 应用市场
|
||||
* 【示例值】豌豆荚
|
||||
*/
|
||||
@JSONField(name = "market")
|
||||
private String market;
|
||||
}
|
||||
@@ -13,11 +13,13 @@ import com.czg.entity.CzgBaseRespParams;
|
||||
import com.czg.entity.req.*;
|
||||
import com.czg.entity.resp.*;
|
||||
import com.czg.enums.CzgPayEnum;
|
||||
import com.czg.resp.CzgRespCode;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -35,9 +37,10 @@ public class CzgPayUtils {
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgH5PayResp>
|
||||
*/
|
||||
public static CzgResult<CzgH5PayResp> h5Pay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgH5PayReq bizData) {
|
||||
return sendCzg(domain.concat(CzgPayEnum.H5PAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgH5PayResp.class);
|
||||
public static CzgResult<Map<String, Object>> h5Pay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgH5PayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.H5PAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgH5PayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,9 +49,10 @@ public class CzgPayUtils {
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgJsPayResp>
|
||||
*/
|
||||
public static CzgResult<CzgJsPayResp> jsPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgJsPayReq bizData) {
|
||||
return sendCzg(domain.concat(CzgPayEnum.JSPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgJsPayResp.class);
|
||||
public static CzgResult<Map<String, Object>> jsPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgJsPayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.JSPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgJsPayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,9 +61,10 @@ public class CzgPayUtils {
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgLtPayResp>
|
||||
*/
|
||||
public static CzgResult<CzgLtPayResp> ltPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgLtPayReq bizData) {
|
||||
return sendCzg(domain.concat(CzgPayEnum.LTPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgLtPayResp.class);
|
||||
public static CzgResult<Map<String, Object>> ltPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgLtPayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.LTPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgLtPayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,9 +73,10 @@ public class CzgPayUtils {
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgScanPayResp>
|
||||
*/
|
||||
public static CzgResult<CzgScanPayResp> scanPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgScanPayReq bizData) {
|
||||
return sendCzg(domain.concat(CzgPayEnum.SCANPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgScanPayResp.class);
|
||||
public static CzgResult<Map<String, Object>> scanPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgScanPayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.SCANPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgScanPayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,9 +85,10 @@ public class CzgPayUtils {
|
||||
* @param domain 域名
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* CzgResult<CzgMicroPayResp>
|
||||
*/
|
||||
public static CzgResult<CzgMicroPayResp> microPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgMicroPayReq bizData) {
|
||||
return sendCzg(domain.concat(CzgPayEnum.MICROPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgMicroPayResp.class);
|
||||
public static CzgResult<Map<String, Object>> microPay(@NonNull String domain, @NonNull String appId, @NonNull String appSecret, CzgMicroPayReq bizData) {
|
||||
return execPayResult(sendCzg(domain.concat(CzgPayEnum.MICROPAY.getUri()), CzgBaseReqParams.getInstance(appId, appSecret, bizData), CzgMicroPayResp.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,51 +236,41 @@ public class CzgPayUtils {
|
||||
}
|
||||
return sortParam;
|
||||
}
|
||||
private static CzgResult<Map<String, Object>> execPayResult(CzgResult<? extends CzgBaseResp> res) {
|
||||
CzgResult<Map<String, Object>> result = CzgResult.success();
|
||||
if (res.getCode() != 200 || res.getData() == null) {
|
||||
result.setCode(500);
|
||||
result.setMsg(res.getMsg());
|
||||
return result;
|
||||
}
|
||||
|
||||
CzgBaseResp data = res.getData();
|
||||
|
||||
// public static void main(String[] args) {
|
||||
//// String appId = "66691a6afdf641f0bf1dc701";
|
||||
// String appId = "66e3dd399a7621f45a6293c1";
|
||||
//// String appSecret = "jikd52TefZcSPI5hRWrfPSpQcXZrbqshbnLmqH6UattqspIDEzjbGvZmfwTW58RMf1XuPhN4zE1GbIjKy3b1oabgOx5n79faT93Si6i7g2IPSQJAln2NNsCSNynHIJ8";
|
||||
// String appSecret = "2p7TCixkN3FuhTqJyr23GNAfrqAqUt84T1IOSunCEEqFBP9gVkSO8CqrfNwNAJqLYuWmQou7lbwdW0Lb4zJVkBEdV7CPq3VhnbGDRIpQXpBNPOjJbor1IFGuLLOA7oll";
|
||||
// CzgJsPayReq bizData = new CzgJsPayReq("20250428150248328893", 100L,
|
||||
// "订单支付", "or1l867cx6JFbLgmppwtG46AUhwg","1.80.211.145", "http://store.sxczgkj.com/h5/#/pages/user-order/user-order", "", "");
|
||||
// bizData.setCurrency("cny");
|
||||
// bizData.setPayType("WECHAT");
|
||||
// bizData.setSubAppid("wxd88fffa983758a30");
|
||||
//
|
||||
// bizData.setSubject("订单支付");
|
||||
//// bizData.setStoreId("S2409148611");
|
||||
// bizData.setStoreId("S2406120331");
|
||||
//
|
||||
// CzgBaseReqParams params = CzgBaseReqParams.getInstance(appId, appSecret, bizData);
|
||||
// params.setVersion("1.0");
|
||||
// params.setReqId("57143686759273485473");
|
||||
// params.setReqTime("20250428150248");
|
||||
// params.setSignType("MD5");
|
||||
// CzgResult<CzgH5PayResp> czgH5PayRespCzgResult = sendCzg("https://paymentapi.sxczgkj.cn/api/open/payment/jspay", params, CzgH5PayResp.class);
|
||||
// System.out.println(czgH5PayRespCzgResult);
|
||||
// }
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
switch (data) {
|
||||
case CzgMicroPayResp ignored -> {
|
||||
if ("TRADE_SUCCESS".equals(data.getState())) {
|
||||
return result;
|
||||
} else if ("TRADE_AWAIT".equals(data.getState())) {
|
||||
result.setCode(CzgRespCode.WAIT_PAY.getCode());
|
||||
result.setMsg("等待用户付款");
|
||||
} else {
|
||||
result.setCode(CzgRespCode.FAILURE.getCode());
|
||||
}
|
||||
}
|
||||
case CzgH5PayResp h5PayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(h5PayResp.getPayInfo()));
|
||||
case CzgJsPayResp jsPayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(jsPayResp.getPayInfo()));
|
||||
case CzgLtPayResp ltPayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(ltPayResp.getPayInfo()));
|
||||
case CzgScanPayResp scanPayResp ->
|
||||
map = JSONObject.parseObject(JSONObject.toJSONString(scanPayResp.getPayInfo()));
|
||||
default -> throw new IllegalStateException("Unexpected value: " + data);
|
||||
}
|
||||
|
||||
result.setData(map);
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// CzgResult<Object> result = CzgResult.success();
|
||||
// CzgBaseRespParams respParams = new CzgBaseRespParams();
|
||||
// respParams.setCode("000000");
|
||||
// respParams.setMsg("成功");
|
||||
// respParams.setSign("6c0f1e11b0d3a16298c2dfeee8c1491a");
|
||||
// respParams.setBizData("{\"amount\":500,\"currency\":\"cny\",\"ifCode\":\"lklspay\",\"mchOrderNo\":\"WX1889977729515615615\",\"mercNo\":\"B240612563201\",\"note\":\"成功\",\"payOrderId\":\"202502151890598483156443138V6W\",\"payType\":\"WECHAT\",\"settlementType\":\"D1\",\"state\":\"TRADE_SUCCESS\",\"storeId\":\"S2406125309\",\"subject\":\"超掌柜\",\"tradeFee\":2}");
|
||||
// respParams.setTimestamp("20250215110620");
|
||||
// log.info("超掌柜交易请求响应,{}", respParams);
|
||||
//
|
||||
// result.setCode("000000".equals(respParams.getCode()) ? 200 : Integer.parseInt(respParams.getCode()));
|
||||
// result.setMsg(respParams.getMsg());
|
||||
// if ("000000".equals(respParams.getCode()) && StrUtil.isNotBlank(respParams.getSign())) {
|
||||
// if (validateSign(respParams.getSign(), JSONObject.toJSONString(respParams))) {
|
||||
// log.info("验签失败");
|
||||
// }
|
||||
// result.setData(JSONObject.parseObject(respParams.getBizData(), CzgMicroPayResp.class));
|
||||
// }
|
||||
// System.out.println(JSONObject.toJSONString(result));
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,12 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.czg</groupId>
|
||||
<artifactId>pay-service</artifactId>
|
||||
<artifactId>czg-pay</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.czg</groupId>
|
||||
<artifactId>aggregation-pay</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -32,6 +32,8 @@ public class AggregateMerchantVO extends AggregateMerchantDto{
|
||||
* 微信进件签名地址
|
||||
*/
|
||||
private String wechatSignUrl;
|
||||
private String wechatApplyId;
|
||||
private String alipayOrderId;
|
||||
|
||||
/**
|
||||
* {@link com.czg.PayCst.EntryStatus}
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.czg.service.order.dto;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
* @author ww
|
||||
*/
|
||||
@Data
|
||||
public class CreateOrderDTO {
|
||||
@NotBlank(message = "桌号不能为空")
|
||||
private String tableCode;
|
||||
@NotBlank(message = "用餐模式 堂食 dine-in 外带 take-out 外卖 take-away")
|
||||
private String dineMode;
|
||||
/**
|
||||
* 平台类型
|
||||
* 微信小程序 WX
|
||||
* 支付宝小程序 ALI
|
||||
* 收银机客户端 PC
|
||||
* PC管理端 APC
|
||||
* APP管理端 APP
|
||||
*/
|
||||
@NotBlank(message = "平台类型不能为空")
|
||||
private String platformType;
|
||||
|
||||
/**
|
||||
* 是否使用了霸王餐
|
||||
*/
|
||||
private boolean isFreeDine = false;
|
||||
|
||||
private String remark;
|
||||
|
||||
// 使用的积分抵扣数量
|
||||
private Integer pointsNum;
|
||||
|
||||
// 使用的优惠券
|
||||
@Valid
|
||||
private List<UserCouponInfoDTO> userCouponInfos = new ArrayList<>();
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.czg.service.order.dto;
|
||||
|
||||
import jakarta.validation.constraints.DecimalMin;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 支付接收参数 实体类
|
||||
*
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
public class RechargeDTO {
|
||||
@NotNull(message = "店铺不能为空")
|
||||
private Long shopId;
|
||||
private Long shopUserId;
|
||||
|
||||
/**
|
||||
* 充值金额id
|
||||
*/
|
||||
private Long rechargeDetailId;
|
||||
@DecimalMin("0.01")
|
||||
private BigDecimal amount;
|
||||
private Integer allPack;
|
||||
|
||||
/**
|
||||
* 跳转地址
|
||||
*/
|
||||
private String returnUrl;
|
||||
/**
|
||||
* 平台类型 pc 收银机客户端 wechat 微信小程序 alipay 支付宝小程序 admin-pc PC管理端 admin-app APP管理端
|
||||
*/
|
||||
private String platformType;
|
||||
|
||||
private String openId;
|
||||
|
||||
private String buyerRemark;
|
||||
|
||||
private String payType;
|
||||
|
||||
private Long orderId;
|
||||
private Integer seatNum;
|
||||
/**
|
||||
* 用户端 使用 全打包 或者 全不打包
|
||||
*/
|
||||
private Integer userAllPack;
|
||||
|
||||
public boolean isAllPack() {
|
||||
return allPack != null && allPack == 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.czg.service.order.dto;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class UserCouponInfoDTO {
|
||||
private Long userCouponId;
|
||||
@Min(1)
|
||||
private Integer num;
|
||||
}
|
||||
@@ -7,33 +7,20 @@ import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 支付
|
||||
* 分销员支付
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
public interface DistributionPayService {
|
||||
/**
|
||||
* 现金支付
|
||||
*/
|
||||
CzgResult<Object> cashPayOrder(MkDistributionPayDTO payParam);
|
||||
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> ltPayOrder(String clintIp, MkDistributionPayDTO payParam);
|
||||
|
||||
/**
|
||||
* PC扫码支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> scanPayOrder(String clintIp, MkDistributionPayDTO payParam);
|
||||
|
||||
/**
|
||||
* 反扫
|
||||
* 运营端小程序余额充值
|
||||
*/
|
||||
CzgResult<Map<String, Object>> microPayOrder(MkDistributionPayDTO payParam);
|
||||
|
||||
|
||||
Map<String, String> mchRecharge(String clientIP, MkDistributionPayDTO payParam);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.czg.service.order.service;
|
||||
|
||||
import com.czg.order.dto.OrderInfoRefundDTO;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
*/
|
||||
public interface OrderPayService {
|
||||
|
||||
/**
|
||||
* 挂账
|
||||
*/
|
||||
CzgResult<Object> creditPayOrder(OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 现金支付
|
||||
*/
|
||||
CzgResult<Object> cashPayOrder(OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 余额支付
|
||||
*/
|
||||
CzgResult<Object> vipPayOrder(OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* h5支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> h5PayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* js支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> jsPayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 空订单支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> js2PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> ltPayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* PC扫码支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> scanPayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 聚合反扫
|
||||
*/
|
||||
CzgResult<Map<String, Object>> microPayOrder(OrderPayParamDTO payParam);
|
||||
//-----------------------------------------------------------------订单+会员 一起支付-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 充值并付款
|
||||
*/
|
||||
CzgResult<Map<String, Object>> rechargePayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||
|
||||
|
||||
//-----------------------------------------------------------------退款-----------------------------------------------------------------
|
||||
|
||||
//订单退款
|
||||
CzgResult<Object> refundOrderBefore(OrderInfoRefundDTO param);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
package com.czg.service.order.service;
|
||||
|
||||
import com.czg.entity.req.*;
|
||||
import com.czg.entity.resp.CzgBaseResp;
|
||||
import com.czg.entity.resp.CzgRefundResp;
|
||||
import com.czg.order.dto.LtPayOtherDTO;
|
||||
import com.czg.order.dto.OrderInfoRefundDTO;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||
import com.czg.service.order.dto.VipMemberPayParamDTO;
|
||||
import com.czg.service.order.dto.VipPayParamDTO;
|
||||
import com.czg.service.order.dto.VipRefundDTO;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -22,129 +18,45 @@ import java.util.Map;
|
||||
* @author ww
|
||||
*/
|
||||
public interface PayService {
|
||||
//-----------------------------------------------------------------订单支付--------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 挂账
|
||||
*/
|
||||
CzgResult<Object> creditPayOrder(OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 现金支付
|
||||
*/
|
||||
CzgResult<Object> cashPayOrder(OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 余额支付
|
||||
*/
|
||||
CzgResult<Object> vipPayOrder(OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* h5支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> h5PayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* js支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> jsPayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 空订单支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> js2PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> ltPayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* PC扫码支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> scanPayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 聚合反扫
|
||||
*/
|
||||
CzgResult<Map<String, Object>> microPayOrder(OrderPayParamDTO payParam);
|
||||
//-----------------------------------------------------------------订单+会员 一起支付-----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 充值并付款
|
||||
*/
|
||||
CzgResult<Map<String, Object>> rechargePayOrder(String clintIp, OrderPayParamDTO payParam);
|
||||
//-----------------------------------------------------------------会员支付--------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 现金充值
|
||||
*/
|
||||
CzgResult<Object> cashPayVip(VipPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* js支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> jsPayVip(String clintIp, VipPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> ltPayVip(String clintIp, VipPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* PC扫码支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> scanPayVip(String clintIp, VipPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 聚合反扫
|
||||
*/
|
||||
CzgResult<Map<String, Object>> microPayVip(VipPayParamDTO payParam);
|
||||
//-----------------------------------------------------------------会员开通购买 ----------------------------------------------------------
|
||||
|
||||
CzgResult<Map<String, Object>> ltPayMember(String clientIP, VipMemberPayParamDTO payParam);
|
||||
|
||||
CzgResult<Map<String, Object>> recharge(String clientIP, VipPayParamDTO rechargeDTO, Long userId);
|
||||
BigDecimal MONEY_RATE = new BigDecimal("100");
|
||||
|
||||
|
||||
Long initOrderPayment(OrderPayment payment);
|
||||
|
||||
//-----------------------------------------------------------------付款 ----------------------------------------------------------
|
||||
CzgResult<Map<String, Object>> h5Pay(@NonNull Long shopId, CzgH5PayReq bizData);
|
||||
CzgResult<Map<String, Object>> jsPay(@NonNull Long shopId, @NonNull String payType, CzgJsPayReq bizData);
|
||||
CzgResult<Map<String, Object>> ltPay(@NonNull Long shopId, String payType, CzgLtPayReq bizData);
|
||||
CzgResult<Map<String, Object>> scanPay(@NonNull Long shopId, CzgScanPayReq bizData);
|
||||
CzgResult<Map<String, Object>> microPay(@NonNull Long shopId, CzgMicroPayReq bizData);
|
||||
//-----------------------------------------------------------------积分商品/拼团 付款 ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @param param 支付参数
|
||||
* @param payType 暂时只有 POINT 积分 和 WARE 拼团商品
|
||||
* @param payType {@link com.czg.constants.PayTypeConstants.SourceType} 常量
|
||||
* @param detail 操作描述 如 积分商品购买 / 拼团商品购买
|
||||
*/
|
||||
CzgResult<Map<String, Object>> ltPayOther(LtPayOtherDTO param, String payType, String detail);
|
||||
|
||||
//-----------------------------------------------------------------退款-----------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 退款前校验
|
||||
*/
|
||||
CzgResult<Map<String, BigDecimal>> refundVipBefore(VipRefundDTO payParam);
|
||||
|
||||
/**
|
||||
* 会员退款
|
||||
* 退款
|
||||
* 目前订单 会员 使用
|
||||
*/
|
||||
CzgResult<Object> refundVip(VipRefundDTO payParam);
|
||||
|
||||
CzgResult<Object> refundOrderBefore(OrderInfoRefundDTO param);
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
*/
|
||||
void refundOrder(Long shopId, Long orderId, Long payOrderId, String refPayOrderNo, String refundReason, BigDecimal refundAmount);
|
||||
|
||||
CzgResult<CzgRefundResp> refund(@NonNull Long shopId, CzgRefundReq bizData);
|
||||
/**
|
||||
* 统一退款接口
|
||||
*
|
||||
* 目前 拼团商品 积分商品 套餐推广 使用
|
||||
* @param refPayOrderNo 自定义退单号 {@link com.czg.enums.OrderNoPrefixEnum} + 雪花Id
|
||||
*/
|
||||
void unifyRefund(Long shopId, Long sourceId, Long payOrderId, String refPayOrderNo, String refundReason, BigDecimal refundAmount);
|
||||
|
||||
/**
|
||||
* 退款补偿使用
|
||||
* 目前 拼团商品 积分商品 套餐推广 使用
|
||||
* (退款 账户余额不足时 会失败定时任务)
|
||||
*/
|
||||
void unifyRefund(OrderPayment payment, String refPayOrderNo);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package com.czg.service.order.service;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.dto.req.AggregateMerchantDto;
|
||||
import com.czg.service.order.dto.AggregateMerchantVO;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
@@ -12,8 +13,22 @@ import com.czg.order.entity.ShopDirectMerchant;
|
||||
*/
|
||||
public interface ShopDirectMerchantService extends IService<ShopDirectMerchant> {
|
||||
|
||||
/**
|
||||
* ocr识别图片
|
||||
* @param url 图片地址
|
||||
* @param type IdCard 身份证
|
||||
* BankCard 银行卡
|
||||
* BusinessLicense 营业执照
|
||||
*/
|
||||
JSONObject getInfoByImg(String url, String type) throws Exception;
|
||||
|
||||
/**
|
||||
* 获取进件信息
|
||||
*/
|
||||
AggregateMerchantVO getEntry(Long shopId);
|
||||
|
||||
/**
|
||||
* 申请进件
|
||||
*/
|
||||
boolean entryManager(AggregateMerchantDto reqDto);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.czg.service.order.service;
|
||||
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.order.dto.VipMemberPayParamDTO;
|
||||
import com.czg.service.order.dto.VipPayParamDTO;
|
||||
import com.czg.service.order.dto.VipRefundDTO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 用户余额 充值/会员购买开通
|
||||
* @author ww
|
||||
*/
|
||||
public interface ShopUserPayService {
|
||||
|
||||
//-----------------------------------------------------------------会员支付--------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 现金充值
|
||||
*/
|
||||
CzgResult<Object> cashPayVip(VipPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* js支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> jsPayVip(String clintIp, VipPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> ltPayVip(String clintIp, VipPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* PC扫码支付
|
||||
*/
|
||||
CzgResult<Map<String, Object>> scanPayVip(String clintIp, VipPayParamDTO payParam);
|
||||
|
||||
/**
|
||||
* 聚合反扫
|
||||
*/
|
||||
CzgResult<Map<String, Object>> microPayVip(VipPayParamDTO payParam);
|
||||
//-----------------------------------------------------------------会员开通购买 ----------------------------------------------------------
|
||||
|
||||
CzgResult<Map<String, Object>> ltPayMember(String clientIP, VipMemberPayParamDTO payParam);
|
||||
|
||||
CzgResult<Map<String, Object>> recharge(String clientIP, VipPayParamDTO rechargeDTO, Long userId);
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------退款-----------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 退款前校验
|
||||
*/
|
||||
CzgResult<Map<String, BigDecimal>> refundVipBefore(VipRefundDTO payParam);
|
||||
|
||||
/**
|
||||
* 会员退款
|
||||
*/
|
||||
CzgResult<Object> refundVip(VipRefundDTO payParam);
|
||||
}
|
||||
@@ -3,17 +3,16 @@ package com.czg.service.order.service.impl;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.account.service.UserInfoService;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.entity.req.CzgLtPayReq;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.service.MkDistributionConfigService;
|
||||
import com.czg.market.vo.MkDistributionConfigVO;
|
||||
import com.czg.order.dto.MkDistributionPayDTO;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.market.service.impl.WxServiceImpl;
|
||||
@@ -44,8 +43,6 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
||||
@Resource
|
||||
private PayServiceImpl payService;
|
||||
|
||||
@DubboReference
|
||||
private ShopInfoService shopInfoService;
|
||||
@DubboReference
|
||||
private ShopUserService shopUserService;
|
||||
@DubboReference
|
||||
@@ -89,11 +86,6 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
||||
return initInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<Object> cashPayOrder(MkDistributionPayDTO payParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> ltPayOrder(String clintIp, MkDistributionPayDTO payParam) {
|
||||
InitInfo initInfo = initPayment(payParam.getUserId(), payParam, false);
|
||||
@@ -106,14 +98,4 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
||||
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());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> scanPayOrder(String clintIp, MkDistributionPayDTO payParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> microPayOrder(MkDistributionPayDTO payParam) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,561 @@
|
||||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.digest.MD5;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.account.service.UserInfoService;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.entity.req.*;
|
||||
import com.czg.entity.resp.CzgRefundResp;
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.exception.PaySuccessException;
|
||||
import com.czg.market.entity.MkShopRechargeDetail;
|
||||
import com.czg.market.enums.PointsConstant;
|
||||
import com.czg.market.service.*;
|
||||
import com.czg.market.vo.MkShopRechargeVO;
|
||||
import com.czg.order.dto.CheckOrderPay;
|
||||
import com.czg.order.dto.OrderInfoRefundDTO;
|
||||
import com.czg.order.entity.OrderDetail;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.enums.PayEnums;
|
||||
import com.czg.order.service.CreditBuyerOrderService;
|
||||
import com.czg.order.service.OrderDetailService;
|
||||
import com.czg.order.service.OrderInfoCustomService;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||
import com.czg.service.order.enums.OrderStatusEnums;
|
||||
import com.czg.service.order.service.OrderPayService;
|
||||
import com.czg.service.order.service.PayService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.CzgRandomUtils;
|
||||
import com.czg.utils.FunUtils;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class OrderPayServiceImpl implements OrderPayService {
|
||||
@Resource
|
||||
private PayService payService;
|
||||
@Resource
|
||||
private OrderPaymentService paymentService;
|
||||
@DubboReference
|
||||
private ShopUserService shopUserService;
|
||||
@DubboReference
|
||||
private UserInfoService userInfoService;
|
||||
@DubboReference
|
||||
private ShopInfoService shopInfoService;
|
||||
@Resource
|
||||
private OrderInfoCustomService orderInfoCustomService;
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
@Resource
|
||||
private CreditBuyerOrderService buyerOrderService;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
@Resource
|
||||
private RabbitPublisher rabbitPublisher;
|
||||
@Resource
|
||||
private MkShopRechargeService shopRechargeService;
|
||||
@Resource
|
||||
private MkShopRechargeDetailService shopRechargeDetailService;
|
||||
@Resource
|
||||
private OrderDetailService orderDetailService;
|
||||
@Resource
|
||||
private MkDistributionUserService distributionUserService;
|
||||
@Resource
|
||||
private MkShopConsumerCouponService consumerCouponService;
|
||||
@Resource
|
||||
private MkPointsUserService mkPointsUserService;
|
||||
@Resource
|
||||
private MkConsumeCashbackService consumeCashbackService;
|
||||
@Resource
|
||||
private MkPointsConfigService pointsConfigService;
|
||||
|
||||
private OrderInfo checkPay(CheckOrderPay checkOrderPay) {
|
||||
OrderInfo orderInfo = orderInfoCustomService.checkOrderPay(checkOrderPay);
|
||||
if (orderInfo.getOrderAmount().compareTo(BigDecimal.ZERO) == 0) {
|
||||
//发送打票信息
|
||||
//orderId_0_0 订单ID_先付后付(1先付0后付)_订单状态 0未完成 1完成
|
||||
//orderInfo.getId() + "_" + (!"after-pay".equals(orderInfo.getPayMode()) ? 1 : 0) + "_0"
|
||||
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId() + "_" + (!"after-pay".equals(orderInfo.getPayMode()) ? 1 : 0) + "_1", orderInfo.getIsPrint() == 1);
|
||||
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
|
||||
throw new PaySuccessException("支付成功");
|
||||
}
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Object> creditPayOrder(OrderPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getCreditBuyerId(), "请选择挂账人后支付");
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
orderInfo.setCreditBuyerId(payParam.getCreditBuyerId());
|
||||
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), null, PayEnums.CREDIT_PAY);
|
||||
//挂账后续逻辑
|
||||
buyerOrderService.save(payParam.getCreditBuyerId().toString(), orderInfo.getId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Object> cashPayOrder(OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), null, PayEnums.CASH_PAY);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Object> vipPayOrder(OrderPayParamDTO payParam) {
|
||||
ShopInfo shopInfo = shopInfoService.getById(payParam.getShopId());
|
||||
AssertUtil.isNull(shopInfo, "店铺不存在");
|
||||
if (!shopInfo.getIsAccountPay().equals(1)) {
|
||||
return CzgResult.failure("支付失败,店铺暂未开启会员余额支付。");
|
||||
}
|
||||
ShopUser shopUser = new ShopUser();
|
||||
if ("scanCode".equals(payParam.getPayType())) {
|
||||
AssertUtil.isBlank(payParam.getAuthCode(), "会员码不能为空");
|
||||
Object o = redisService.get(RedisCst.SHOP_USER_DYNAMIC_CODE + payParam.getShopId() + ":" + payParam.getAuthCode());
|
||||
AssertUtil.isNull(o, "会员码已失效");
|
||||
shopUser = shopUserService.getById(o.toString());
|
||||
} else {
|
||||
if ("userPay".equals(payParam.getPayType())) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "请选择付款人后重试");
|
||||
shopUser = shopUserService.getById(payParam.getShopUserId());
|
||||
} else if ("accountPay".equals(payParam.getPayType())) {
|
||||
shopUser = shopUserService.getById(payParam.getShopUserId());
|
||||
AssertUtil.isNull(shopUser, "会员不存在");
|
||||
UserInfo userInfo = userInfoService.getById(shopUser.getUserId());
|
||||
AssertUtil.isNull(userInfo, "用户信息不存在");
|
||||
if (userInfo.getUsePayPwd() == 1) {
|
||||
AssertUtil.isBlank(payParam.getPwd(), "支付密码不能为空");
|
||||
if (userInfo.getPayPwd() == null || !userInfo.getPayPwd().equals(MD5.create().digestHex((payParam.getPwd())))) {
|
||||
return CzgResult.failure("支付密码错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shopUser == null || shopUser.getId() == null) {
|
||||
AssertUtil.isNull(shopUser, "会员不存在");
|
||||
}
|
||||
payParam.getCheckOrderPay().setUserId(shopUser.getUserId());
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
if (shopInfo.getIsHeadShop().equals(1)) {
|
||||
if (!shopUser.getMainShopId().equals(orderInfo.getShopId())) {
|
||||
return CzgResult.failure("违规操作,请确认店铺后重试");
|
||||
}
|
||||
} else {
|
||||
boolean exists = shopInfoService.exists(QueryWrapper.create()
|
||||
.eq(ShopInfo::getMainId, shopInfo.getMainId())
|
||||
.eq(ShopInfo::getId, orderInfo.getShopId()));
|
||||
if (!exists) {
|
||||
return CzgResult.failure("违规操作,请确认店铺后重试");
|
||||
}
|
||||
}
|
||||
if (shopUser.getAmount().compareTo(orderInfo.getOrderAmount()) < 0) {
|
||||
return CzgResult.failure("会员余额不足");
|
||||
}
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
|
||||
.setId(shopUser.getId())
|
||||
.setMoney(orderInfo.getOrderAmount())
|
||||
.setType(0)
|
||||
.setBizEnum(ShopUserFlowBizEnum.ORDER_PAY)
|
||||
.setRelationId(orderInfo.getId());
|
||||
//更新会员余额 并生成流水
|
||||
if (payParam.getCheckOrderPay() != null && StrUtil.isNotBlank(payParam.getCheckOrderPay().getRemark())) {
|
||||
orderInfo.setRemark(payParam.getCheckOrderPay().getRemark());
|
||||
}
|
||||
|
||||
Long flowId = shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), flowId, PayEnums.VIP_PAY);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> rechargePayOrder(String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
ShopInfo shopInfo = shopInfoService.getById(payParam.getShopId());
|
||||
AssertUtil.isNull(shopInfo, "店铺不存在");
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "请选择付款人后重试");
|
||||
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
|
||||
AssertUtil.isNull(shopUser, "支付失败 该店铺用户不存在");
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
UserInfo userInfo = userInfoService.getById(shopUser.getUserId());
|
||||
AssertUtil.isNull(payParam.getRechargeId(), "请选择充值配置后重试");
|
||||
AssertUtil.isNull(payParam.getRechargeDetailId(), "请选择充值配置后重试");
|
||||
//查询活动Id 获取金额字段
|
||||
MkShopRechargeDetail rechargeDetail = shopRechargeDetailService.getOne(
|
||||
new QueryWrapper().eq(MkShopRechargeDetail::getId, payParam.getRechargeDetailId())
|
||||
.eq(MkShopRechargeDetail::getShopRechargeId, payParam.getRechargeId()));
|
||||
AssertUtil.isNull(rechargeDetail, "充值配置不存在");
|
||||
if (orderInfo.getOrderAmount().compareTo(rechargeDetail.getAmount()) >= 0) {
|
||||
log.info("充值金额小于订单金额,充值金额:{} 订单金额:{}", rechargeDetail.getAmount(), orderInfo.getOrderAmount());
|
||||
return CzgResult.failure("支付失败 充值金额必须大雨订单金额");
|
||||
}
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), PayTypeConstants.SourceType.MEMBER_IN, PayTypeConstants.PayType.PAY, payOrderNo,
|
||||
"", rechargeDetail.getAmount(), rechargeDetail.getId()));
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.VIP_PAY, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, rechargeDetail.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
payParam.getPayType(), "充值并支付", "wechatPay".equals(payParam.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId(),
|
||||
clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Map<String, Object>> h5PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.H5_PAY, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.h5Pay(payParam.getShopId(), new CzgH5PayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"点餐支付", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Map<String, Object>> jsPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Map<String, Object>> js2PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
OrderInfo orderInfo;
|
||||
if (payParam.getCheckOrderPay().getOrderId() == null) {
|
||||
if (payParam.getCheckOrderPay().getOrderAmount() == null || payParam.getCheckOrderPay().getOrderAmount().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new CzgException("支付金额不合法");
|
||||
}
|
||||
orderInfo = orderInfoCustomService.createPayOrder(payParam.getShopId(), payParam.getCheckOrderPay().getOrderAmount(),
|
||||
payParam.getCheckOrderPay().getRemark());
|
||||
} else {
|
||||
orderInfo = orderInfoService.getById(payParam.getCheckOrderPay().getOrderId());
|
||||
}
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Map<String, Object>> ltPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
payParam.getPayType(), "点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Map<String, Object>> scanPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
|
||||
MkShopRechargeVO rechargeVO = shopRechargeService.detail(payParam.getShopId());
|
||||
if (payParam.getRechargeDetailId() == null && rechargeVO.getIsCustom() == 0) {
|
||||
throw new CzgException("未开启自定义充值金额");
|
||||
}
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(payParam.getShopId());
|
||||
BigDecimal amount = shopRechargeService.checkRecharge(mainShopId, payParam.getShopId(), shopUser.getUserId(), payParam.getRechargeDetailId(), payParam.getAmount());
|
||||
payParam.setAmount(amount);
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.MAIN_SCAN, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"点餐支付", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(noRollbackFor = PaySuccessException.class)
|
||||
public CzgResult<Map<String, Object>> microPayOrder(OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
|
||||
AssertUtil.isBlank(payParam.getAuthCode(), "扫描码不能为空");
|
||||
|
||||
|
||||
if (payParam.getShopUserId() != null) {
|
||||
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
|
||||
MkShopRechargeVO rechargeVO = shopRechargeService.detail(payParam.getShopId());
|
||||
if (payParam.getRechargeDetailId() == null && rechargeVO.getIsCustom() == 0) {
|
||||
throw new CzgException("未开启自定义充值金额");
|
||||
}
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(payParam.getShopId());
|
||||
BigDecimal amount = shopRechargeService.checkRecharge(mainShopId, payParam.getShopId(), shopUser.getUserId(), payParam.getRechargeDetailId(), payParam.getAmount());
|
||||
payParam.setAmount(amount);
|
||||
}
|
||||
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
|
||||
PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.PAY, payOrderNo, payParam.getAuthCode(), orderInfo.getOrderAmount()));
|
||||
CzgResult<Map<String, Object>> mapCzgResult = payService.microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"点餐支付", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
|
||||
if (mapCzgResult.getCode() == 200) {
|
||||
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN);
|
||||
} else {
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.BACK_SCAN, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
}
|
||||
return mapCzgResult;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Object> refundOrderBefore(OrderInfoRefundDTO param) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(param.getOrderId());
|
||||
if (orderInfo.getStatus().equals(OrderStatusEnums.CANCELLED.getCode())) {
|
||||
throw new CzgException("订单已过期不可退单");
|
||||
}
|
||||
boolean isFirstRefund = true;
|
||||
if (orderInfo.getRefundAmount().compareTo(BigDecimal.ZERO) != 0) {
|
||||
isFirstRefund = false;
|
||||
}
|
||||
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
|
||||
Map<String, BigDecimal> returnProMap = new HashMap<>();
|
||||
boolean isPay = true;
|
||||
String refPayOrderNo = "REFO" + IdUtil.getSnowflakeNextId();
|
||||
if (orderInfo.getStatus().equals(OrderStatusEnums.UNPAID.getCode())) {
|
||||
isPay = false;
|
||||
refPayOrderNo = "";
|
||||
}
|
||||
if (isPay) {
|
||||
if (shopInfo.getIsReturnPwd().equals(1)) {
|
||||
AssertUtil.isBlank(shopInfo.getOperationPwd(), "请设置操作密码后使用");
|
||||
if (!SecureUtil.md5(param.getPwd()).equals(shopInfo.getOperationPwd())) {
|
||||
throw new CzgException("操作密码错误");
|
||||
}
|
||||
}
|
||||
orderInfo.setRefundAmount(orderInfo.getRefundAmount().add(param.getRefundAmount()));
|
||||
if (orderInfo.getRefundAmount().compareTo(orderInfo.getPayAmount()) > 0) {
|
||||
throw new CzgException("退单失败,可退金额不足");
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(param.getRefundDetails())) {
|
||||
for (OrderDetail refundDetail : param.getRefundDetails()) {
|
||||
AssertUtil.isNull(refundDetail.getNum(), "退单数量不能为空");
|
||||
//退款数量
|
||||
BigDecimal refNum = refundDetail.getNum();
|
||||
OrderDetail orderDetail = orderDetailService.getById(refundDetail.getId());
|
||||
//可退数量=订单数量-退单数量-退菜数量
|
||||
BigDecimal returnNum = orderDetail.getNum().subtract(orderDetail.getRefundNum()).subtract(orderDetail.getReturnNum());
|
||||
if (returnNum.compareTo(BigDecimal.ZERO) <= 0 || returnNum.compareTo(refundDetail.getNum()) < 0) {
|
||||
throw new CzgException("退单失败," + orderDetail.getProductName() + "可退数量不足");
|
||||
}
|
||||
refundDetail.setReturnAmount(refundDetail.getNum().multiply(orderDetail.getUnitPrice()).setScale(2, RoundingMode.UP));
|
||||
if (isPay) {
|
||||
orderDetail.setRefundNum(orderDetail.getRefundNum().add(refNum));
|
||||
if (orderDetail.getNum().compareTo(orderDetail.getRefundNum().add(orderDetail.getReturnNum())) == 0) {
|
||||
orderDetail.setStatus(OrderStatusEnums.REFUND.getCode());
|
||||
} else {
|
||||
orderDetail.setStatus(OrderStatusEnums.PART_REFUND.getCode());
|
||||
}
|
||||
} else {
|
||||
orderDetail.setReturnNum(orderDetail.getReturnNum().add(refNum));
|
||||
if (orderDetail.getPackNumber().compareTo(BigDecimal.ZERO) > 0 && orderDetail.getPackNumber().compareTo(orderDetail.getNum().subtract(orderDetail.getReturnNum())) > 0) {
|
||||
orderDetail.setPackNumber(orderDetail.getNum().subtract(orderDetail.getReturnNum()));
|
||||
}
|
||||
}
|
||||
orderDetail.setRefundNo(refPayOrderNo);
|
||||
orderDetail.setRefundRemark(orderDetail.getRefundRemark() + param.getRefundReason());
|
||||
// if (isPay) {
|
||||
orderDetail.setReturnAmount(orderDetail.getReturnAmount().add(refundDetail.getReturnAmount()));
|
||||
if (orderDetail.getReturnAmount().compareTo(orderDetail.getPayAmount()) > 0) {
|
||||
orderDetail.setReturnAmount(orderDetail.getPayAmount());
|
||||
}
|
||||
// }
|
||||
orderDetailService.updateById(orderDetail);
|
||||
if (orderDetail.getProductId() != null && orderDetail.getProductId() > 0) {
|
||||
returnProMap.put(Convert.toStr(orderDetail.getProductId()), refundDetail.getNum());
|
||||
}
|
||||
}
|
||||
long count = orderDetailService.queryChain()
|
||||
.eq(OrderDetail::getOrderId, orderInfo.getId())
|
||||
.ne(OrderDetail::getStatus, OrderStatusEnums.REFUND.getCode()).count();
|
||||
if (count > 0 && isPay) {
|
||||
orderInfo.setStatus(OrderStatusEnums.PART_REFUND.getCode());
|
||||
} else if (isPay) {
|
||||
orderInfo.setStatus(OrderStatusEnums.REFUND.getCode());
|
||||
}
|
||||
} else {
|
||||
orderInfo.setStatus(OrderStatusEnums.REFUND.getCode());
|
||||
List<OrderDetail> orderDetails = orderDetailService.queryChain()
|
||||
.select(OrderDetail::getId, OrderDetail::getProductId, OrderDetail::getNum, OrderDetail::getReturnNum, OrderDetail::getPackAmount, OrderDetail::getReturnNum)
|
||||
.eq(OrderDetail::getOrderId, orderInfo.getId())
|
||||
.list();
|
||||
for (OrderDetail orderDetail : orderDetails) {
|
||||
if (isPay) {
|
||||
if (orderDetail.getProductId() != null && orderDetail.getProductId() > 0) {
|
||||
returnProMap.put(Convert.toStr(orderDetail.getProductId()), orderDetail.getNum().subtract(orderDetail.getReturnNum()).subtract(orderDetail.getRefundNum()));
|
||||
}
|
||||
orderDetail.setReturnAmount(orderDetail.getPayAmount());
|
||||
orderDetail.setRefundNum(orderDetail.getNum().subtract(orderDetail.getReturnNum()));
|
||||
orderDetail.setStatus(OrderStatusEnums.REFUND.getCode());
|
||||
} else {
|
||||
if (orderDetail.getProductId() != null && orderDetail.getProductId() > 0) {
|
||||
returnProMap.put(Convert.toStr(orderDetail.getProductId()), orderDetail.getNum().subtract(orderDetail.getReturnNum()));
|
||||
}
|
||||
orderDetail.setReturnNum(orderDetail.getNum());
|
||||
orderDetail.setStatus(OrderStatusEnums.CANCELLED.getCode());
|
||||
}
|
||||
}
|
||||
orderDetailService.updateBatch(orderDetails);
|
||||
}
|
||||
//总退款金额
|
||||
//TODO 退款 券 未处理
|
||||
if (isPay) {
|
||||
orderInfo.setRefundType("cash");
|
||||
//非现金退款
|
||||
if (!param.isCash()) {
|
||||
if (orderInfo.getPayType().equals(PayEnums.VIP_PAY.getValue())) {
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(orderInfo.getShopId(), orderInfo.getUserId());
|
||||
//会员支付 退钱
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
|
||||
.setId(shopUser.getId())
|
||||
.setMoney(param.getRefundAmount())
|
||||
.setType(1)
|
||||
.setRelationId(orderInfo.getId())
|
||||
.setBizEnum(ShopUserFlowBizEnum.ORDER_REFUND);
|
||||
shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
} else if (orderInfo.getPayType().equals(PayEnums.CREDIT_PAY.getValue())) {
|
||||
AssertUtil.isNull(orderInfo.getCreditBuyerId(), "挂账单退款失败,未查询到挂账人");
|
||||
buyerOrderService.partRefund(orderInfo.getCreditBuyerId().toString(), orderInfo.getId(), param.getRefundAmount());
|
||||
} else if (!orderInfo.getPayType().equals(PayEnums.CASH_PAY.getValue())) {
|
||||
//退款 param.getRefundAmount()
|
||||
if (orderInfo.getPayOrderId() == null) {
|
||||
throw new CzgException("退款失败,支付记录不存在");
|
||||
}
|
||||
refundOrder(orderInfo.getShopId(), orderInfo.getId(), orderInfo.getPayOrderId(),
|
||||
refPayOrderNo, StrUtil.isBlank(param.getRefundReason()) ? "退款" : param.getRefundReason(), param.getRefundAmount());
|
||||
}
|
||||
orderInfo.setRefundType("payBack");
|
||||
}
|
||||
} else {
|
||||
orderInfo.setOrderAmount(orderInfo.getOrderAmount().subtract(param.getRefundAmount()));
|
||||
}
|
||||
orderInfo.setRefundRemark(orderInfo.getRefundRemark() + param.getRefundReason());
|
||||
orderInfoService.updateById(orderInfo);
|
||||
//退款后续
|
||||
//退款返还库存
|
||||
if (!returnProMap.isEmpty()) {
|
||||
rabbitPublisher.sendOrderRefundMsg(JSONObject.toJSONString(Map.of("orderId", orderInfo.getId(), "returnProMap", returnProMap)));
|
||||
}
|
||||
refundOrderAfter(orderInfo.getId(), orderInfo.getShopId(), orderInfo.getUserId(), orderInfo.getOrderNo(),
|
||||
orderInfo.getPointsNum(), isFirstRefund, orderInfo.getStatus().equals(OrderStatusEnums.REFUND.getCode()));
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
private void refundOrder(@NonNull Long shopId, @NonNull Long orderId, @NonNull Long payOrderId, @NonNull String refPayOrderNo,
|
||||
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
|
||||
OrderPayment payment = paymentService.getById(payOrderId);
|
||||
AssertUtil.isNull(payment, "退款失败支付记录不存在");
|
||||
Long refundId = payService.initOrderPayment(new OrderPayment(shopId, orderId, PayTypeConstants.SourceType.ORDER, PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refundAmount, payment.getId()));
|
||||
CzgResult<CzgRefundResp> refund = payService.refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
||||
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
|
||||
if (refund.getData() != null && refund.getData().getNote() != null) {
|
||||
throw new CzgException(refund.getData().getNote());
|
||||
}
|
||||
throw new CzgException(refund.getMsg());
|
||||
} else {
|
||||
paymentService.updateChain()
|
||||
.eq(OrderPayment::getId, refundId)
|
||||
.set(OrderPayment::getPayTime, refund.getData().getRefundTime())
|
||||
.set(OrderPayment::getTradeNumber, refund.getData().getRefundOrderId())
|
||||
.set(OrderPayment::getRespJson, JSONObject.toJSONString(refund.getData()))
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
//触发订单退款时 后续处理
|
||||
@Async
|
||||
public void refundOrderAfter(@NonNull Long orderId, @NonNull Long shopId, Long userId, String orderNo,
|
||||
Integer pointsNum, boolean isFirstRefund, boolean isAllRefund) {
|
||||
if (isFirstRefund) {
|
||||
// 退款分销还原
|
||||
FunUtils.safeRunVoid(() -> distributionUserService.refund(orderId, orderNo),
|
||||
"订单id:{} 退款,分销处理失败", orderId);
|
||||
if (userId == null) {
|
||||
return;
|
||||
}
|
||||
FunUtils.safeRunVoid(() -> consumerCouponService.removeConsumerCoupon(shopId, userId, orderId),
|
||||
"订单id:{} 退款,消费赠券回撤处理失败", orderId);
|
||||
FunUtils.safeRunVoid(() -> consumeCashbackService.removeCashback(shopId, userId, orderId, orderNo),
|
||||
"订单id:{} 退款,消费返现扣除处理失败", orderId);
|
||||
FunUtils.safeRunVoid(() -> pointsConfigService.removeConsumeAwardPoints(shopId, userId, orderId, orderNo),
|
||||
"订单id:{} 退款,赠送积分扣除失败", orderId);
|
||||
}
|
||||
if (isAllRefund && userId != null && pointsNum != null && pointsNum > 0) {
|
||||
FunUtils.safeRunVoid(() -> mkPointsUserService.alterPoints(userId, null, shopId, PointsConstant.ADD,
|
||||
pointsNum, orderId, StrUtil.format("订单退款返还{}积分", pointsNum)),
|
||||
"订单id:{} 退款,赠送积分扣除失败", orderId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void upOrderPayInfo(@NonNull Long orderId, @NonNull PayEnums payType, @NotBlank Long paymentId, String remark) {
|
||||
if (paymentId == null) {
|
||||
throw new CzgException("未获取到支付记录");
|
||||
}
|
||||
orderInfoCustomService.updatePayOrderId(orderId, paymentId, payType.getValue(), remark);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,27 +1,27 @@
|
||||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.io.unit.DataSizeUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.EntryManager;
|
||||
import com.czg.OcrUtils;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.constants.ParamCodeCst;
|
||||
import com.czg.dto.req.*;
|
||||
import com.czg.service.order.dto.AggregateMerchantVO;
|
||||
import com.czg.utils.FunUtils;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.order.entity.ShopDirectMerchant;
|
||||
import com.czg.service.order.service.ShopDirectMerchantService;
|
||||
import com.czg.service.order.dto.AggregateMerchantVO;
|
||||
import com.czg.service.order.mapper.ShopDirectMerchantMapper;
|
||||
import com.czg.service.order.service.ShopDirectMerchantService;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import com.czg.utils.FunUtils;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
@@ -35,11 +35,21 @@ public class ShopDirectMerchantServiceImpl extends ServiceImpl<ShopDirectMerchan
|
||||
|
||||
@Resource
|
||||
private RabbitPublisher rabbitPublisher;
|
||||
@DubboReference
|
||||
private SysParamsService sysParamsService;
|
||||
|
||||
|
||||
// 全局原子计数器,按天重置(避免数值过大)
|
||||
private static final AtomicLong COUNTER = new AtomicLong(0);
|
||||
// 记录上一次的日期,用于重置计数器
|
||||
private static String LAST_DATE = DateUtil.format(new Date(), "yyyyMMdd");
|
||||
|
||||
@Override
|
||||
public JSONObject getInfoByImg(String url, String type) throws Exception {
|
||||
Map<String, String> aliOssKeys = sysParamsService.getParamsByMap("ali_oss_key_set", ParamCodeCst.ALI_OSS_KEY_SET);
|
||||
return OcrUtils.getInfoByImg(aliOssKeys.get(ParamCodeCst.AliYun.ALI_SMS_KEY), aliOssKeys.get(ParamCodeCst.AliYun.ALI_SMS_SECRET), url, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AggregateMerchantVO getEntry(Long shopId) {
|
||||
ShopDirectMerchant merchant = getById(shopId);
|
||||
@@ -121,9 +131,11 @@ public class ShopDirectMerchantServiceImpl extends ServiceImpl<ShopDirectMerchan
|
||||
// 设置其他字段
|
||||
vo.setCreateTime(entity.getCreateTime());
|
||||
vo.setUpdateTime(entity.getUpdateTime());
|
||||
vo.setWechatApplyId(entity.getWechatApplyId());
|
||||
vo.setWechatStatus(entity.getWechatStatus());
|
||||
vo.setWechatErrorMsg(entity.getWechatErrorMsg());
|
||||
vo.setWechatSignUrl(entity.getWechatSignUrl());
|
||||
vo.setAlipayOrderId(entity.getAlipayOrderId());
|
||||
vo.setAlipayStatus(entity.getAlipayStatus());
|
||||
vo.setAlipayErrorMsg(entity.getAlipayErrorMsg());
|
||||
vo.setAlipaySignUrl(entity.getAlipaySignUrl());
|
||||
|
||||
@@ -0,0 +1,360 @@
|
||||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||
import com.czg.account.entity.*;
|
||||
import com.czg.account.service.*;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.entity.req.*;
|
||||
import com.czg.entity.resp.CzgRefundResp;
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.dto.MemberOrderDTO;
|
||||
import com.czg.market.entity.MemberOrder;
|
||||
import com.czg.market.entity.MkShopCouponRecord;
|
||||
import com.czg.market.service.MemberOrderService;
|
||||
import com.czg.market.service.MkShopCouponRecordService;
|
||||
import com.czg.market.service.MkShopRechargeService;
|
||||
import com.czg.market.vo.MkShopRechargeVO;
|
||||
import com.czg.order.dto.CheckOrderPay;
|
||||
import com.czg.order.dto.LtPayOtherDTO;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.service.OrderInfoCustomService;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.order.dto.VipMemberPayParamDTO;
|
||||
import com.czg.service.order.dto.VipPayParamDTO;
|
||||
import com.czg.service.order.dto.VipRefundDTO;
|
||||
import com.czg.service.order.service.PayService;
|
||||
import com.czg.service.order.service.ShopUserPayService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.CzgRandomUtils;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
*/
|
||||
@Service
|
||||
public class ShopUserServiceImpl implements ShopUserPayService {
|
||||
@Resource
|
||||
private PayService payService;
|
||||
|
||||
@DubboReference
|
||||
private ShopUserService shopUserService;
|
||||
@DubboReference
|
||||
private UserInfoService userInfoService;
|
||||
@DubboReference
|
||||
private ShopInfoService shopInfoService;
|
||||
@DubboReference
|
||||
private FreeDineConfigService freeConfigService;
|
||||
@Resource
|
||||
private OrderInfoCustomService orderInfoCustomService;
|
||||
@DubboReference
|
||||
private MemberOrderService memberOrderService;
|
||||
@Resource
|
||||
private MkShopRechargeService shopRechargeService;
|
||||
@DubboReference
|
||||
private ShopUserFlowService userFlowService;
|
||||
@Resource
|
||||
private MkShopCouponRecordService recordService;
|
||||
@Resource
|
||||
private OrderPaymentService paymentService;
|
||||
|
||||
/**
|
||||
* 会员充值 校验
|
||||
*
|
||||
* @return 是否是霸王餐充值
|
||||
*/
|
||||
private boolean checkPayVip(VipPayParamDTO payParam) {
|
||||
if (payParam.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new CzgException("充值金额不正确");
|
||||
}
|
||||
if (payParam.getOrderId() != null) {
|
||||
FreeDineConfig freeConfig = freeConfigService.getById(shopInfoService.getMainIdByShopId(payParam.getShopId()));
|
||||
AssertUtil.isNull(freeConfig, "该店铺未启用霸王餐");
|
||||
if (!freeConfig.getEnable()) {
|
||||
throw new CzgException("该店铺未启用霸王餐");
|
||||
}
|
||||
CheckOrderPay checkOrderPay = payParam.getCheckOrderPay();
|
||||
OrderInfo orderInfo = orderInfoCustomService.checkOrderPay(checkOrderPay.setFreeDine(true).setWithCoupon(freeConfig.getWithCoupon()).setWithPoints(freeConfig.getWithPoints()));
|
||||
payParam.setAmount(orderInfo.getOrderAmount().multiply(BigDecimal.valueOf(freeConfig.getRechargeTimes())));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Object> cashPayVip(VipPayParamDTO payParam) {
|
||||
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
|
||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||
ShopInfo shopInfo = shopInfoService.getById(payParam.getShopId());
|
||||
AssertUtil.isNull(shopInfo, "店铺不存在");
|
||||
if (shopInfo.getIsMemberInPwd().equals(1)) {
|
||||
AssertUtil.isBlank(shopInfo.getOperationPwd(), "请设置操作密码后使用");
|
||||
AssertUtil.isBlank(payParam.getPwd(), "请输入操作密码后充值");
|
||||
if (!shopInfo.getOperationPwd().equals(SecureUtil.md5(payParam.getPwd()))) {
|
||||
return CzgResult.failure("支付密码错误");
|
||||
}
|
||||
}
|
||||
// if (shopUser.getIsVip().equals(0)) {
|
||||
// //更新会员
|
||||
// ShopUser updateInfo = new ShopUser();
|
||||
// updateInfo.setIsVip(1);
|
||||
// updateInfo.setJoinTime(LocalDateTime.now());
|
||||
// updateInfo.setId(payParam.getShopUserId());
|
||||
// shopUserService.updateById(updateInfo);
|
||||
// }
|
||||
shopRechargeService.recharge(shopUser.getMainShopId(), shopUser.getId(), payParam.getRechargeDetailId(),
|
||||
payParam.getAmount(), null, "cash", ShopUserFlowBizEnum.CASH_IN, true);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Map<String, Object>> jsPayVip(String clintIp, VipPayParamDTO payParam) {
|
||||
boolean isFree = checkPayVip(payParam);
|
||||
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
|
||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
||||
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||
return payService.jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"会员充值", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CzgResult<Map<String, Object>> ltPayMember(String clientIP, VipMemberPayParamDTO payParam) {
|
||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, shopInfoService.getMainIdByShopId(payParam.getShopId())).eq(ShopUser::getId, payParam.getShopUserId()));
|
||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||
MemberOrder memberOrder = memberOrderService.createMemberOrder(new MemberOrderDTO().setName(payParam.getName())
|
||||
.setNum(1).setNickName(payParam.getNickName()).setOrderType(payParam.getOrderType())
|
||||
.setPlatformType(payParam.getPlatformType()).setSex(payParam.getSex()).setUserId(shopUser.getUserId())
|
||||
.setShopId(payParam.getShopId()).setBirthDay(payParam.getBirthDay()));
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
|
||||
LtPayOtherDTO payParam1 = new LtPayOtherDTO()
|
||||
.setOpenId(payParam.getOpenId())
|
||||
.setPayType(payParam.getPayType())
|
||||
.setShopId(payParam.getShopId())
|
||||
.setRecordId(shopUser.getId())
|
||||
.setPrice(memberOrder.getAmount())
|
||||
.setIp(clientIP);
|
||||
return payService.ltPayOther(payParam1, PayTypeConstants.SourceType.MEMBER_PAY, "会员充值");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Map<String, Object>> ltPayVip(String clintIp, VipPayParamDTO payParam) {
|
||||
// 霸王餐校验
|
||||
boolean isFree = checkPayVip(payParam);
|
||||
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
|
||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
|
||||
MkShopRechargeVO rechargeVO = shopRechargeService.detail(payParam.getShopId());
|
||||
if (payParam.getRechargeDetailId() == null && rechargeVO.getIsCustom() == 0) {
|
||||
throw new CzgException("未开启自定义充值金额");
|
||||
}
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(payParam.getShopId());
|
||||
if (isFree) {
|
||||
BigDecimal amount = shopRechargeService.checkRecharge(mainShopId, payParam.getShopId(), shopUser.getUserId(), payParam.getRechargeDetailId(), payParam.getAmount());
|
||||
payParam.setAmount(amount);
|
||||
}
|
||||
|
||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||
LtPayOtherDTO payParam1 = new LtPayOtherDTO()
|
||||
.setOpenId(payParam.getOpenId())
|
||||
.setPayType(payParam.getPayType())
|
||||
.setShopId(payParam.getShopId())
|
||||
.setRecordId(shopUser.getId())
|
||||
.setPrice(payParam.getAmount())
|
||||
.setIp(clintIp);
|
||||
return payService.ltPayOther(payParam1, payType, "会员充值");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, Object>> recharge(String clientIP, VipPayParamDTO rechargeDTO, Long shopUserId) {
|
||||
boolean isFree = checkPayVip(rechargeDTO);
|
||||
Long mainShopId = shopInfoService.getMainIdByShopId(rechargeDTO.getShopId());
|
||||
|
||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getMainShopId, mainShopId)
|
||||
.eq(ShopUser::getId, shopUserId));
|
||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||
MkShopRechargeVO rechargeVO = shopRechargeService.detail(rechargeDTO.getShopId());
|
||||
if (rechargeDTO.getRechargeDetailId() == null && rechargeVO.getIsCustom() == 0) {
|
||||
throw new CzgException("未开启自定义充值金额");
|
||||
}
|
||||
UserInfo userInfo = userInfoService.getById(shopUser.getUserId());
|
||||
BigDecimal amount = shopRechargeService.checkRecharge(mainShopId, rechargeDTO.getShopId(), shopUser.getUserId(), rechargeDTO.getRechargeDetailId(), rechargeDTO.getAmount());
|
||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||
|
||||
LtPayOtherDTO payParam = new LtPayOtherDTO()
|
||||
.setOpenId("wechatPay".equals(rechargeDTO.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId())
|
||||
.setPayType(rechargeDTO.getPayType())
|
||||
.setShopId(rechargeDTO.getShopId())
|
||||
.setRecordId(shopUser.getId())
|
||||
.setPrice(amount)
|
||||
.setIp(clientIP);
|
||||
return payService.ltPayOther(payParam, payType, "会员充值");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Map<String, Object>> scanPayVip(String clintIp, VipPayParamDTO payParam) {
|
||||
boolean isFree = checkPayVip(payParam);
|
||||
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
|
||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
||||
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||
return payService.scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"会员充值", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Map<String, Object>> microPayVip(VipPayParamDTO payParam) {
|
||||
boolean isFree = checkPayVip(payParam);
|
||||
AssertUtil.isBlank(payParam.getAuthCode(), "扫描码不能为空");
|
||||
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
|
||||
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
|
||||
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||
payService.initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PayTypeConstants.PayType.PAY, payOrderNo,
|
||||
payParam.getAuthCode(), payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
|
||||
CzgResult<Map<String, Object>> mapCzgResult = payService.microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, payParam.getAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
"会员充值", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
|
||||
mapCzgResult.setData(Map.of("payOrderNo", payOrderNo));
|
||||
return mapCzgResult;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CzgResult<Map<String, BigDecimal>> refundVipBefore(VipRefundDTO payParam) {
|
||||
Map<String, BigDecimal> resultMap = new HashMap<>(5);
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(payParam.getShopId(), payParam.getUserId());
|
||||
AssertUtil.isNull(shopUser, "该店铺用户不存在");
|
||||
ShopUserFlow inFlow = userFlowService.getById(payParam.getFlowId());
|
||||
AssertUtil.isNull(inFlow, "充值记录不存在");
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq(ShopUserFlow::getRelationId, payParam.getFlowId());
|
||||
queryWrapper.eq(ShopUserFlow::getBizCode, ShopUserFlowBizEnum.AWARD_IN.getCode());
|
||||
ShopUserFlow giftFlow = userFlowService.getOne(queryWrapper);
|
||||
resultMap.put("amount", shopUser.getAmount());
|
||||
resultMap.put("inAmount", inFlow.getAmount());
|
||||
resultMap.put("inRefundAmount", inFlow.getRefundAmount());
|
||||
resultMap.put("giftAmount", giftFlow == null ? BigDecimal.ZERO : giftFlow.getAmount());
|
||||
resultMap.put("giftRefundAmount", giftFlow == null ? BigDecimal.ZERO : giftFlow.getRefundAmount());
|
||||
return CzgResult.success(resultMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Object> refundVip(VipRefundDTO refPayParam) {
|
||||
ShopInfo shopInfo = shopInfoService.getById(refPayParam.getShopId());
|
||||
if (shopInfo.getIsReturnPwd().equals(1)) {
|
||||
AssertUtil.isBlank(shopInfo.getOperationPwd(), "请设置操作密码后使用");
|
||||
if (!SecureUtil.md5(refPayParam.getPwd()).equals(shopInfo.getOperationPwd())) {
|
||||
throw new CzgException("操作密码错误");
|
||||
}
|
||||
}
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(refPayParam.getShopId(), refPayParam.getUserId());
|
||||
ShopUserFlow inFlow = userFlowService.getById(refPayParam.getFlowId());
|
||||
AssertUtil.isNull(inFlow, "充值记录不存在");
|
||||
if ("cashIn".equals(inFlow.getBizCode()) || "adminIn".equals(inFlow.getBizCode())) {
|
||||
refPayParam.setCashRefund(true);
|
||||
}
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq(ShopUserFlow::getRelationId, refPayParam.getFlowId());
|
||||
queryWrapper.eq(ShopUserFlow::getBizCode, ShopUserFlowBizEnum.AWARD_IN.getCode());
|
||||
ShopUserFlow giftFlow = userFlowService.getOne(queryWrapper);
|
||||
if ((inFlow.getAmount().subtract(inFlow.getRefundAmount())).compareTo(refPayParam.getRefAmount()) < 0) {
|
||||
return CzgResult.failure("退款失败,退款金额不可大于可退金额");
|
||||
}
|
||||
//用户余额减去赠送金额 小于 退款金额 则需要勾选 超额退款
|
||||
if (giftFlow != null) {
|
||||
if (shopUser.getAmount().subtract(giftFlow.getAmount().subtract(giftFlow.getRefundAmount())).compareTo(refPayParam.getRefAmount()) < 0 && !refPayParam.isOutOfRange()) {
|
||||
return CzgResult.failure("超额退款,请勾选 超额退款后重试");
|
||||
}
|
||||
} else {
|
||||
if (shopUser.getAmount().compareTo(refPayParam.getRefAmount()) < 0 && !refPayParam.isOutOfRange()) {
|
||||
return CzgResult.failure("超额退款,请勾选 超额退款后重试");
|
||||
}
|
||||
}
|
||||
Long refPaymentId = null;
|
||||
if (!refPayParam.isCashRefund()) {
|
||||
OrderPayment payment;
|
||||
if (inFlow.getRelationId() != null) {
|
||||
payment = paymentService.getById(inFlow.getRelationId());
|
||||
} else {
|
||||
return CzgResult.failure("退款失败,该充值记录不存在");
|
||||
}
|
||||
String refPayOrderNo = "REFVIP" + IdUtil.getSnowflakeNextId();
|
||||
refPaymentId = payService.initOrderPayment(new OrderPayment(refPayParam.getShopId(), shopUser.getId(),
|
||||
PayTypeConstants.SourceType.MEMBER_IN, PayTypeConstants.PayType.REFUND, refPayOrderNo, null, refPayParam.getRefAmount()));
|
||||
CzgResult<CzgRefundResp> refund = payService.refund(refPayParam.getShopId(), new CzgRefundReq(refPayOrderNo, refPayParam.getRemark(),
|
||||
refPayParam.getRefAmount().multiply(PayService.MONEY_RATE).longValue(), payment.getOrderNo(), ""));
|
||||
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
|
||||
throw new CzgException(refund.getMsg());
|
||||
} else {
|
||||
paymentService.updateChain()
|
||||
.eq(OrderPayment::getId, refPaymentId)
|
||||
.set(OrderPayment::getPayTime, refund.getData().getRefundTime())
|
||||
.set(OrderPayment::getTradeNumber, refund.getData().getRefundOrderId())
|
||||
.set(OrderPayment::getPayStatus, PayTypeConstants.PayStatus.SUCCESS)
|
||||
.set(OrderPayment::getRespJson, JSONObject.toJSONString(refund.getData()))
|
||||
.update();
|
||||
}
|
||||
}
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
|
||||
.setId(shopUser.getId())
|
||||
.setMoney(refPayParam.getRefAmount())
|
||||
.setType(0)
|
||||
.setRemark("退款")
|
||||
.setBizEnum(refPayParam.isCashRefund() ? ShopUserFlowBizEnum.RECHARGE_CASH_REFUND : ShopUserFlowBizEnum.RECHARGE_REFUND)
|
||||
.setRelationId(refPaymentId)
|
||||
.setRechargeId(inFlow.getId());
|
||||
//更新会员余额 并生成流水
|
||||
shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
userFlowService.updateRefund(inFlow.getId(), refPayParam.getRefAmount());
|
||||
if (giftFlow != null && (giftFlow.getAmount().subtract(giftFlow.getRefundAmount())).compareTo(BigDecimal.ZERO) > 0) {
|
||||
ShopUserMoneyEditDTO giftFlowEdit = new ShopUserMoneyEditDTO()
|
||||
.setId(shopUser.getId())
|
||||
.setMoney(giftFlow.getAmount())
|
||||
.setType(0)
|
||||
.setRemark("退款")
|
||||
.setBizEnum(ShopUserFlowBizEnum.RECHARGE_REFUND)
|
||||
.setRelationId(refPaymentId)
|
||||
.setRechargeId(giftFlow.getId());
|
||||
//更新会员余额 并生成流水
|
||||
shopUserService.updateMoney(giftFlowEdit);
|
||||
userFlowService.updateRefund(giftFlow.getId(), giftFlow.getAmount());
|
||||
}
|
||||
//移除优惠券
|
||||
recordService.remove(QueryWrapper.create()
|
||||
.eq(MkShopCouponRecord::getSourceFlowId, inFlow.getId())
|
||||
.eq(MkShopCouponRecord::getSource, "activate")
|
||||
.eq(MkShopCouponRecord::getStatus, 0));
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.czg</groupId>
|
||||
<artifactId>cash-service</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</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.github.javen205</groupId>
|
||||
<artifactId>IJPay-All</artifactId>
|
||||
</dependency>
|
||||
<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>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,87 +0,0 @@
|
||||
package com.czg.service;
|
||||
|
||||
import com.czg.entity.notify.CzgPayNotifyDTO;
|
||||
import com.czg.entity.notify.CzgRefundNotifyDTO;
|
||||
import com.czg.entity.req.*;
|
||||
import com.czg.entity.resp.*;
|
||||
import com.czg.resp.CzgResult;
|
||||
import lombok.NonNull;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description
|
||||
*/
|
||||
public interface CzgPayService {
|
||||
/**
|
||||
* h5支付
|
||||
*
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
*/
|
||||
CzgResult<CzgH5PayResp> h5Pay(@NonNull String appId, @NonNull String appSecret, CzgH5PayReq bizData);
|
||||
|
||||
/**
|
||||
* js支付
|
||||
*
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
*/
|
||||
CzgResult<CzgJsPayResp> jsPay(@NonNull String appId, @NonNull String appSecret, CzgJsPayReq bizData);
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
*
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
*/
|
||||
CzgResult<CzgLtPayResp> ltPay(@NonNull String appId, @NonNull String appSecret, CzgLtPayReq bizData);
|
||||
|
||||
/**
|
||||
* PC扫码支付
|
||||
*
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
*/
|
||||
CzgResult<CzgScanPayResp> scanPay(@NonNull String appId, @NonNull String appSecret, CzgScanPayReq bizData);
|
||||
|
||||
/**
|
||||
* 聚合反扫
|
||||
*
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
*/
|
||||
CzgResult<CzgMicroPayResp> microPay(@NonNull String appId, @NonNull String appSecret, CzgMicroPayReq bizData);
|
||||
|
||||
/**
|
||||
* 订单查询
|
||||
*
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* @param payOrderId 平台订单号
|
||||
* @param mchOrderNo 商户订单号
|
||||
*/
|
||||
CzgResult<CzgBaseResp> queryPayOrder(@NonNull String appId, @NonNull String appSecret,
|
||||
String payOrderId, String mchOrderNo);
|
||||
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
*
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
*/
|
||||
CzgResult<CzgRefundResp> refundOrder(@NonNull String appId, @NonNull String appSecret, CzgRefundReq bizData);
|
||||
|
||||
/**
|
||||
* 退款订单查询
|
||||
*
|
||||
* @param appId 应用id tb_shop_merchant 表中的 app_id
|
||||
* @param appSecret 应用密钥 tb_shop_merchant 表中的 app_secret
|
||||
* @param mchRefundNo 商户退款订单号 二选一
|
||||
* @param refundOrderId 平台退款订单号 二选一
|
||||
*/
|
||||
CzgResult<CzgRefundResp> queryRefundOrder(@NonNull String appId, @NonNull String appSecret,
|
||||
String mchRefundNo, String refundOrderId);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.czg.service.Impl;
|
||||
|
||||
import com.czg.CzgPayUtils;
|
||||
import com.czg.constants.ParamCodeCst;
|
||||
import com.czg.entity.req.*;
|
||||
import com.czg.entity.resp.*;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.CzgPayService;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import lombok.NonNull;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author ww
|
||||
* @description 1
|
||||
*/
|
||||
@Service
|
||||
public class CzgPayServiceImpl implements CzgPayService {
|
||||
|
||||
@DubboReference
|
||||
private SysParamsService sysParamsService;
|
||||
|
||||
@Override
|
||||
public CzgResult<CzgH5PayResp> h5Pay(@NonNull String appId, @NonNull String appSecret, CzgH5PayReq bizData) {
|
||||
return CzgPayUtils.h5Pay(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, bizData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<CzgJsPayResp> jsPay(@NonNull String appId, @NonNull String appSecret, CzgJsPayReq bizData) {
|
||||
return CzgPayUtils.jsPay(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, bizData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<CzgLtPayResp> ltPay(@NonNull String appId, @NonNull String appSecret, CzgLtPayReq bizData) {
|
||||
return CzgPayUtils.ltPay(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, bizData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<CzgScanPayResp> scanPay(@NonNull String appId, @NonNull String appSecret, CzgScanPayReq bizData) {
|
||||
return CzgPayUtils.scanPay(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, bizData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<CzgMicroPayResp> microPay(@NonNull String appId, @NonNull String appSecret, CzgMicroPayReq bizData) {
|
||||
return CzgPayUtils.microPay(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, bizData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<CzgBaseResp> queryPayOrder(@NonNull String appId, @NonNull String appSecret, String payOrderId, String mchOrderNo) {
|
||||
return CzgPayUtils.queryPayOrder(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, payOrderId, mchOrderNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<CzgRefundResp> refundOrder(@NonNull String appId, @NonNull String appSecret, CzgRefundReq bizData) {
|
||||
return CzgPayUtils.refundOrder(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, bizData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CzgResult<CzgRefundResp> queryRefundOrder(@NonNull String appId, @NonNull String appSecret, String mchRefundNo, String refundOrderId) {
|
||||
return CzgPayUtils.queryRefundOrder(sysParamsService.getSysParamValue(ParamCodeCst.System.PAY_CZG_DOMAIN), appId, appSecret, mchRefundNo, refundOrderId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
<module>product-service</module>
|
||||
<module>system-service</module>
|
||||
<module>code-generator</module>
|
||||
<module>pay-service</module>
|
||||
<module>market-service</module>
|
||||
</modules>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user