额外参数

This commit is contained in:
2025-12-17 18:09:08 +08:00
parent 4978c1910b
commit 2a353e587e
13 changed files with 174 additions and 99 deletions

View File

@@ -11,6 +11,7 @@ import com.czg.market.service.MkShopConsumeDiscountRecordService;
import com.czg.market.service.OrderInfoService;
import com.czg.order.entity.OrderInfo;
import com.czg.order.entity.OrderPayment;
import com.czg.order.enums.PaymentPayTypeEnum;
import com.czg.order.service.OrderInfoCustomService;
import com.czg.order.service.OrderPaymentService;
import com.czg.service.market.service.impl.AppWxServiceImpl;
@@ -28,6 +29,7 @@ import java.io.IOException;
/**
* 回调
*
* @author ww
* @description
*/
@@ -78,7 +80,7 @@ public class NotifyController {
String failReason = jsonObject.getString("fail_reason");
try {
distributionUserService.withdrawNotify(outBillNo, state, failReason);
}catch (Exception e) {
} catch (Exception e) {
log.warn("转账回调失败", e);
}
return SUCCESS;
@@ -106,15 +108,15 @@ public class NotifyController {
String tradeState = plainTextJson.getString("trade_state");
String transactionId = plainTextJson.getString("transaction_id");
OrderPayment payment = paymentService.getOne(new QueryWrapper().eq(OrderPayment::getOrderNo, outTradeNo));
payment.setPayStatus("fail");
payment.setPayStatus(PaymentPayTypeEnum.PayStatus.FAIL);
if ("SUCCESS".equals(tradeState)) {
try {
payment.setTradeNumber(transactionId);
payment.setPayTime(DateUtil.date().toLocalDateTime());
payment.setRespJson(plainTextJson.toJSONString());
payment.setPayStatus("success");
payment.setPayStatus(PaymentPayTypeEnum.PayStatus.SUCCESS);
distributionUserService.rechargeCallBack(payment.getShopId(), payment.getAmount(), payment.getId());
}catch (Exception e) {
} catch (Exception e) {
log.error("充值回调失败", e);
return "SUCCESS";
}

View File

@@ -1,7 +1,6 @@
package com.czg.task;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.czg.enums.OrderNoPrefixEnum;
import com.czg.market.service.OrderInfoService;
import com.czg.order.entity.CashierCart;
@@ -20,7 +19,9 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 订单定时任务
@@ -59,18 +60,30 @@ public class OTimeTask {
cartService.remove(cartUpdateWrapper);
}
/**
* 订单 过期 退钱
*/
public void gbOrderExpire() {
}
/**
* 退钱补偿
* 积分 和 拼团
*/
@Scheduled(cron = "0 50 23 * * ? ")
public void refundCompensate() {
//积分 和 拼团
List<String> ware = List.of(PaymentPayTypeEnum.SourceType.WARE, PaymentPayTypeEnum.SourceType.POINT);
LocalDateTime tenMinutesAgo = LocalDateTime.now().minusMinutes(10);
LocalDateTime thirdDayAgo = LocalDateTime.now().minusDays(3);
List<OrderPayment> list = orderPaymentService.list(QueryWrapper.create()
.gt(OrderPayment::getUpdateTime, thirdDayAgo)
.lt(OrderPayment::getUpdateTime, tenMinutesAgo)
.eq(OrderPayment::getPayType, PaymentPayTypeEnum.REFUND.getValue())
.ne(OrderPayment::getPayStatus, "success"));
.in(OrderPayment::getSourceType, ware)
.eq(OrderPayment::getPayType, PaymentPayTypeEnum.PayType.REFUND)
.ne(OrderPayment::getPayStatus, PaymentPayTypeEnum.PayStatus.SUCCESS));
for (OrderPayment payment : list) {
String refPayOrderNo = CzgRandomUtils.snowflake(OrderNoPrefixEnum.REP);
payService.unifyRefund(payment, refPayOrderNo);

View File

@@ -1,5 +1,6 @@
package com.czg.order.entity;
import com.czg.order.enums.PaymentPayTypeEnum;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
@@ -58,8 +59,14 @@ public class OrderPayment implements Serializable {
private Long relatedId;
/**
* 支付方式order,refund, memberIn,memberRefund, free
* {@link com.czg.order.enums.PaymentPayTypeEnum}
* 订单来源类型
* {@link com.czg.order.enums.PaymentPayTypeEnum.SourceType}
*
*/
private String sourceType;
/**
* 支付类型
* {@link com.czg.order.enums.PaymentPayTypeEnum.PayType}
*/
private String payType;
@@ -90,8 +97,10 @@ public class OrderPayment implements Serializable {
* 支付相应结果 json
*/
private String respJson;
/**
* 支付状态success, fail, init
* 支付状态
* {@link com.czg.order.enums.PaymentPayTypeEnum.PayStatus}
*/
private String payStatus;
@@ -104,26 +113,28 @@ public class OrderPayment implements Serializable {
public OrderPayment() {
}
public OrderPayment(@NonNull Long shopId,@NonNull Long sourceId, @NotBlank String payType, @NotBlank String orderNo,
public OrderPayment(@NonNull Long shopId,@NonNull Long sourceId, @NotBlank String sourceType,@NotBlank String payType, @NotBlank String orderNo,
String authCode, @NonNull BigDecimal amount) {
this.shopId = shopId;
this.sourceId = sourceId;
this.sourceType = sourceType;
this.payType = payType;
this.orderNo = orderNo;
this.authCode = authCode;
this.amount = amount;
this.payStatus = "init";
this.payStatus = PaymentPayTypeEnum.PayStatus.INIT;
}
public OrderPayment(@NonNull Long shopId,@NonNull Long sourceId, @NotBlank String payType, @NotBlank String orderNo,
public OrderPayment(@NonNull Long shopId,@NonNull Long sourceId, @NotBlank String sourceType,@NotBlank String payType, @NotBlank String orderNo,
String authCode, @NonNull BigDecimal amount, Long relatedId) {
this.shopId = shopId;
this.sourceId = sourceId;
this.sourceType = sourceType;
this.payType = payType;
this.orderNo = orderNo;
this.authCode = authCode;
this.amount = amount;
this.relatedId = relatedId;
this.payStatus = "init";
this.payStatus = PaymentPayTypeEnum.PayStatus.INIT;
}
}

View File

@@ -1,35 +1,64 @@
package com.czg.order.enums;
import lombok.Getter;
/**
* 支付类型枚举
* tb_order_payment
*
* @author ww
*/
@Getter
public enum PaymentPayTypeEnum {
ORDER("order", "订单支付"),
FREE("free", "霸王餐"),
MEMBER_IN("memberIn", "会员充值"),
MEMBER_PAY("memberPay", "会员购买开通"),
DISTRIBUTION("distribution", "分销员购买开通"),
DISTRIBUTION_RECHARGE("distributionRecharge", "商家运营余额充值"),
POINT("point", "积分商品购买"),
WARE("ware", "拼团商品"),
REFUND("refund", "订单退款"),
MEMBER_REFUND("memberRefund", "会员充值的退款"),
;
private final String value;
private final String msg;
PaymentPayTypeEnum(String value, String msg) {
this.value = value;
this.msg = msg;
public interface PaymentPayTypeEnum {
class SourceType {
/**
* 订单支付
*/
public static final String ORDER = "order";
/**
* 霸王餐
*/
public static final String FREE = "free";
/**
* 会员充值
*/
public static final String MEMBER_IN = "memberIn";
/**
* 会员购买开通
*/
public static final String MEMBER_PAY = "memberPay";
/**
* 分销员购买开通
*/
public static final String DISTRIBUTION = "distribution";
/**
* 商家运营余额充值
*/
public static final String DISTRIBUTION_RECHARGE = "distributionRecharge";
/**
* 积分商品购买
*/
public static final String POINT = "point";
/**
* 拼团商品购买
*/
public static final String WARE = "ware";
}
}
class PayType {
//支付
public static final String PAY = "pay";
//退款
public static final String REFUND = "refund";
/**
* 退款补偿 退款失败的情况 会触发补偿
* {@link com.czg.task.OTimeTask#refundCompensate()}
*/
public static final String REFUND_COMPENSATE = "refundCompensate";
}
class PayStatus {
//初始化
public static final String INIT = "init";
//支付成功
public static final String SUCCESS = "success";
//支付失败
public static final String FAIL = "fail";
}
}

View File

@@ -5,6 +5,7 @@ import com.czg.order.entity.GbOrderDetail;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@@ -33,6 +34,15 @@ public class GbOrderDetailVO extends GbOrderDetail {
* 要求成团人数
*/
private Integer groupPeopleNum;
/**
* 商品原价
*/
private BigDecimal wareOriginalPrice;
/**
* 商品拼团价
*/
private BigDecimal wareGroupPrice;
/**
* 店铺地址
*/

View File

@@ -180,17 +180,18 @@ public interface ShopOrderStatisticMapper extends BaseMapper<ShopOrderStatistic>
* memberRefund 会员充值的退款
*/
@Select("SELECT " +
" SUM(CASE WHEN pay_type = 'order' THEN amount ELSE 0 END) AS onlinePayAmount," +
" SUM(CASE WHEN pay_type = 'refund' THEN amount ELSE 0 END) AS onlineRefundAmount," +
" SUM(CASE WHEN pay_type = 'free' THEN amount ELSE 0 END) AS backDiscountAmount," +
" SUM(CASE WHEN pay_type = 'memberIn' THEN amount ELSE 0 END) AS onlineRechargeAmount, " +
" SUM(CASE WHEN pay_type = 'memberRefund' THEN amount ELSE 0 END) AS onlineRechargeRefundAmount " +
" SUM(CASE WHEN pay_type = 'pay' and source_type = 'order' THEN amount ELSE 0 END) AS onlinePayAmount," +
" SUM(CASE WHEN pay_type = 'refund' and source_type = 'order' THEN amount ELSE 0 END) AS onlineRefundAmount," +
" SUM(CASE WHEN pay_type = 'pay' and source_type = 'free' THEN amount ELSE 0 END) AS backDiscountAmount," +
" SUM(CASE WHEN pay_type = 'pay' and source_type = 'memberIn' THEN amount ELSE 0 END) AS onlineRechargeAmount, " +
" SUM(CASE WHEN pay_type = 'refund' and source_type = 'memberIn' THEN amount ELSE 0 END) AS onlineRechargeRefundAmount " +
"FROM" +
" tb_order_payment " +
"WHERE " +
" pay_status = 'success' " +
" AND shop_id = #{shopId}" +
" AND pay_type NOT IN ('memberPay', 'distribution', 'distributionRecharge')" +
" AND source_type NOT IN ('memberPay', 'distribution', 'distributionRecharge', 'point' ,'ware')" +
" AND pay_type != 'refundCompensate'" +
" AND pay_date = #{tradeDay} ;")
ShopOrderStatistic getOnlineStatSingleDate(Long shopId, LocalDate tradeDay);

View File

@@ -4,11 +4,12 @@ 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.dto.PointGoodsExchangeDTO;
import com.czg.order.entity.OrderPayment;
import com.czg.order.enums.PaymentPayTypeEnum;
import com.czg.resp.CzgResult;
import com.czg.service.order.dto.*;
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;
@@ -114,7 +115,7 @@ public interface PayService {
* @param payType 暂时只有 POINT 积分 和 WARE 拼团商品
* @param detail 操作描述 如 积分商品购买 / 拼团商品购买
*/
CzgResult<Map<String, Object>> ltPayOther(LtPayOtherDTO param, PaymentPayTypeEnum payType, String detail);
CzgResult<Map<String, Object>> ltPayOther(LtPayOtherDTO param, String payType, String detail);
//-----------------------------------------------------------------退款-----------------------------------------------------------------

View File

@@ -14,6 +14,7 @@ import com.czg.market.service.MkDistributionConfigService;
import com.czg.market.vo.MkDistributionConfigVO;
import com.czg.order.dto.MkDistributionPayDTO;
import com.czg.order.entity.OrderPayment;
import com.czg.order.enums.PaymentPayTypeEnum;
import com.czg.order.service.OrderPaymentService;
import com.czg.resp.CzgResult;
import com.czg.service.market.service.impl.WxServiceImpl;
@@ -70,7 +71,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
ShopUser shopUserInfo = shopUserService.getShopUserInfo(payParam.getShopId(), userId);
OrderPayment orderPayment = new OrderPayment().setShopId(payParam.getShopId()).setSourceId(isRecharge ? payParam.getShopId() : shopUserInfo.getId())
.setPayType(isRecharge ? "distributionRecharge" : "distribution")
.setPayType(isRecharge ? PaymentPayTypeEnum.SourceType.DISTRIBUTION_RECHARGE : PaymentPayTypeEnum.SourceType.DISTRIBUTION )
.setOrderNo(payParam.getPlatformType() + IdUtil.getSnowflakeNextId())
.setAmount(isRecharge ? payParam.getAmount() : detail.getPayAmount());
orderPaymentService.save(orderPayment);

View File

@@ -182,6 +182,7 @@ public class GbOrderServiceImpl extends ServiceImpl<GbOrderMapper, GbOrder> impl
param.setPrice(ware.getGroupPrice().multiply(BigDecimal.valueOf(param.getNumber())));
GbOrderDetail record = new GbOrderDetail();
record.setGroupOrderNo(param.getGroupOrderNo());
record.setShopId(param.getShopId());
record.setUserId(param.getUserId());
record.setWareId(param.getParamId());
@@ -194,7 +195,7 @@ public class GbOrderServiceImpl extends ServiceImpl<GbOrderMapper, GbOrder> impl
detailService.save(record);
param.setRecordId(record.getId());
CzgResult<Map<String, Object>> result = CzgResult.success();
CzgResult<Map<String, Object>> mapCzgResult = payService.ltPayOther(param, PaymentPayTypeEnum.WARE, "拼团商品购买");
CzgResult<Map<String, Object>> mapCzgResult = payService.ltPayOther(param, PaymentPayTypeEnum.SourceType.WARE, "拼团商品购买");
if (200 != mapCzgResult.getCode()) {
return mapCzgResult;
}

View File

@@ -1043,10 +1043,10 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
}
payment.setTradeNumber(czgCallBackDto.getPayOrderId());
payment.setRespJson(resultJson.toString());
payment.setPayStatus("fail");
payment.setPayStatus(PaymentPayTypeEnum.PayStatus.FAIL);
if ("TRADE_SUCCESS".equals(czgCallBackDto.getState())) {
payment.setPayStatus("success");
if (PaymentPayTypeEnum.ORDER.getValue().equals(payment.getPayType())) {
payment.setPayStatus(PaymentPayTypeEnum.PayStatus.SUCCESS);
if (PaymentPayTypeEnum.SourceType.ORDER.equals(payment.getPayType())) {
OrderInfo orderInfo = orderInfoService.getById(payment.getSourceId());
if (orderInfo == null) {
log.error("订单支付回调失败,订单不存在,支付记录Id,{}", payment.getId());
@@ -1058,8 +1058,9 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
distributionUserService.costUpgradeLevelBefore(orderInfo.getUserId(), orderInfo.getShopId());
// 分销奖励
distributionUserService.distribute(orderInfo.getId(), orderInfo.getOrderNo(), payment.getAmount(), orderInfo.getUserId(), orderInfo.getShopId(), "order");
} else if (PaymentPayTypeEnum.MEMBER_IN.getValue().equals(payment.getPayType()) || PaymentPayTypeEnum.FREE.getValue().equals(payment.getPayType())) {
boolean isFree = PaymentPayTypeEnum.FREE.getValue().equals(payment.getPayType());
}
else if (PaymentPayTypeEnum.SourceType.MEMBER_IN.equals(payment.getPayType()) || PaymentPayTypeEnum.SourceType.FREE.equals(payment.getPayType())) {
boolean isFree = PaymentPayTypeEnum.SourceType.FREE.equals(payment.getPayType());
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
OrderInfo orderInfo = null;
if (shopUser == null) {
@@ -1159,7 +1160,8 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
// if (orderInfo != null) {
// distributionUserService.distribute(payment.getId(), payment.getOrderNo(), payment.getAmount(), orderInfo.getUserId(), payment.getShopId(), "recharge");
// }
} else if (PaymentPayTypeEnum.MEMBER_PAY.getValue().equals(payment.getPayType())) {
}
else if (PaymentPayTypeEnum.SourceType.MEMBER_PAY.equals(payment.getPayType())) {
//购买会员
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
memberConfigService.joinMember(payment.getShopId(), shopUser.getUserId(), payment.getRelatedId());
@@ -1167,11 +1169,12 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
// memberConfigService.deliver(shopUser.getMainShopId(), shopUser.getUserId(), TableValueConstant.MemberExpFlow.Type.COST, payment.getAmount(), null, payment.getId());
// 分销员开通
} else if (PaymentPayTypeEnum.DISTRIBUTION.getValue().equals(payment.getPayType())) {
}
else if (PaymentPayTypeEnum.SourceType.DISTRIBUTION.equals(payment.getPayType())) {
distributionUserService.open(payment.getSourceId(), payment.getAmount(), payment.getShopId(), payment.getId());
} else if (PaymentPayTypeEnum.POINT.getValue().equals(payment.getPayType())) {
} else if (PaymentPayTypeEnum.SourceType.POINT.equals(payment.getPayType())) {
goodPayService.payCallBack(payment.getSourceId(), payment.getId());
} else if (PaymentPayTypeEnum.WARE.getValue().equals(payment.getPayType())) {
} else if (PaymentPayTypeEnum.SourceType.WARE.equals(payment.getPayType())) {
gbOrderService.payCallBack(payment.getSourceId(), payment.getId());
}
}
@@ -1186,9 +1189,9 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
log.info("订单处理过payment id{}", payment.getId());
return;
}
payment.setPayStatus("success");
payment.setPayStatus(PaymentPayTypeEnum.PayStatus.SUCCESS);
if (!"SUCCESS".equals(czgCallBackDto.getState())) {
payment.setPayStatus("fail");
payment.setPayStatus(PaymentPayTypeEnum.PayStatus.FAIL);
if ("refund".equals(payment.getPayType())) {
//TODO 订单退款失败 暂不考虑回滚 填充退款原因
orderInfoService.updateById(new OrderInfo()

View File

@@ -282,7 +282,7 @@ public class PayServiceImpl implements PayService {
return CzgResult.failure("支付失败 充值金额必须大雨订单金额");
}
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), "memberIn", payOrderNo,
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), PaymentPayTypeEnum.SourceType.MEMBER_IN, PaymentPayTypeEnum.PayType.PAY, payOrderNo,
"", rechargeDetail.getAmount(), rechargeDetail.getId()));
upOrderPayInfo(orderInfo.getId(), PayEnums.VIP_PAY, paymentId,
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
@@ -296,7 +296,7 @@ public class PayServiceImpl implements PayService {
OrderInfo orderInfo = checkPay(payParam.getCheckOrderPay());
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
"order", payOrderNo, "", orderInfo.getOrderAmount()));
PaymentPayTypeEnum.SourceType.ORDER, PaymentPayTypeEnum.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
upOrderPayInfo(orderInfo.getId(), PayEnums.H5_PAY, paymentId,
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
return h5Pay(payParam.getShopId(), new CzgH5PayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
@@ -312,7 +312,7 @@ public class PayServiceImpl implements PayService {
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
"order", payOrderNo, "", orderInfo.getOrderAmount()));
PaymentPayTypeEnum.SourceType.ORDER, PaymentPayTypeEnum.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 jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
@@ -336,7 +336,7 @@ public class PayServiceImpl implements PayService {
}
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
"order", payOrderNo, "", orderInfo.getOrderAmount()));
PaymentPayTypeEnum.SourceType.ORDER, PaymentPayTypeEnum.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 jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
@@ -351,7 +351,7 @@ public class PayServiceImpl implements PayService {
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
"order", payOrderNo, "", orderInfo.getOrderAmount()));
PaymentPayTypeEnum.SourceType.ORDER, PaymentPayTypeEnum.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 ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
@@ -374,7 +374,7 @@ public class PayServiceImpl implements PayService {
payParam.setAmount(amount);
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
"order", payOrderNo, "", orderInfo.getOrderAmount()));
PaymentPayTypeEnum.SourceType.ORDER, PaymentPayTypeEnum.PayType.PAY, payOrderNo, "", orderInfo.getOrderAmount()));
upOrderPayInfo(orderInfo.getId(), PayEnums.MAIN_SCAN, paymentId,
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
return scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
@@ -401,7 +401,7 @@ public class PayServiceImpl implements PayService {
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), orderInfo.getId(),
"order", payOrderNo, payParam.getAuthCode(), orderInfo.getOrderAmount()));
PaymentPayTypeEnum.SourceType.ORDER, PaymentPayTypeEnum.PayType.PAY, payOrderNo, payParam.getAuthCode(), orderInfo.getOrderAmount()));
CzgResult<Map<String, Object>> mapCzgResult = microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
"点餐支付", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
if (mapCzgResult.getCode() == 200) {
@@ -449,7 +449,8 @@ public class PayServiceImpl implements PayService {
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo,
String payType = isFree ? PaymentPayTypeEnum.SourceType.FREE : PaymentPayTypeEnum.SourceType.MEMBER_IN;
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PaymentPayTypeEnum.PayType.PAY, payOrderNo,
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
return jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
"会员充值", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
@@ -469,7 +470,7 @@ public class PayServiceImpl implements PayService {
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), "memberPay", payOrderNo,
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), PaymentPayTypeEnum.SourceType.MEMBER_PAY, PaymentPayTypeEnum.PayType.PAY, payOrderNo,
"", memberOrder.getAmount(), memberOrder.getId()));
return ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, memberOrder.getAmount().multiply(MONEY_RATE).longValue(),
payParam.getPayType(), "会员充值", "wechatPay".equals(payParam.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId(), clientIP, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
@@ -496,7 +497,8 @@ public class PayServiceImpl implements PayService {
}
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo,
String payType = isFree ? PaymentPayTypeEnum.SourceType.FREE : PaymentPayTypeEnum.SourceType.MEMBER_IN;
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PaymentPayTypeEnum.PayType.PAY, payOrderNo,
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
return ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
payParam.getPayType(), "会员充值", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
@@ -518,7 +520,8 @@ public class PayServiceImpl implements PayService {
BigDecimal amount = shopRechargeService.checkRecharge(mainShopId, rechargeDTO.getShopId(), shopUser.getUserId(), rechargeDTO.getRechargeDetailId(), rechargeDTO.getAmount());
String payOrderNo = rechargeDTO.getPlatformType() + CzgRandomUtils.snowflake();
initOrderPayment(new OrderPayment(rechargeDTO.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo,
String payType = isFree ? PaymentPayTypeEnum.SourceType.FREE : PaymentPayTypeEnum.SourceType.MEMBER_IN;
initOrderPayment(new OrderPayment(rechargeDTO.getShopId(), shopUser.getId(), payType, PaymentPayTypeEnum.PayType.PAY, payOrderNo,
"", amount, isFree ? rechargeDTO.getOrderId() : rechargeDTO.getRechargeDetailId()));
return ltPay(rechargeDTO.getShopId(), rechargeDTO.getPayType(), new CzgLtPayReq(payOrderNo, amount.multiply(MONEY_RATE).longValue(),
rechargeDTO.getPayType(), "会员充值", "wechatPay".equals(rechargeDTO.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId(),
@@ -532,7 +535,8 @@ public class PayServiceImpl implements PayService {
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo,
String payType = isFree ? PaymentPayTypeEnum.SourceType.FREE : PaymentPayTypeEnum.SourceType.MEMBER_IN;
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PaymentPayTypeEnum.PayType.PAY, payOrderNo,
"", payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
return scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
"会员充值", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
@@ -546,7 +550,8 @@ public class PayServiceImpl implements PayService {
ShopUser shopUser = shopUserService.getById(payParam.getShopUserId());
AssertUtil.isNull(shopUser, "充值失败 该店铺用户不存在");
String payOrderNo = payParam.getPlatformType() + CzgRandomUtils.snowflake();
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), isFree ? "free" : "memberIn", payOrderNo,
String payType = isFree ? PaymentPayTypeEnum.SourceType.FREE : PaymentPayTypeEnum.SourceType.MEMBER_IN;
initOrderPayment(new OrderPayment(payParam.getShopId(), shopUser.getId(), payType, PaymentPayTypeEnum.PayType.PAY, payOrderNo,
payParam.getAuthCode(), payParam.getAmount(), isFree ? payParam.getOrderId() : payParam.getActivateId()));
CzgResult<Map<String, Object>> mapCzgResult = microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, payParam.getAmount().multiply(MONEY_RATE).longValue(),
"会员充值", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
@@ -557,11 +562,11 @@ public class PayServiceImpl implements PayService {
@Override
@Transactional
public CzgResult<Map<String, Object>> ltPayOther(LtPayOtherDTO param, PaymentPayTypeEnum payType, String detail) {
public CzgResult<Map<String, Object>> ltPayOther(LtPayOtherDTO param, String payType, String detail) {
AssertUtil.isBlank(param.getOpenId(), "用户小程序ID不能为空");
AssertUtil.isBlank(param.getPayType(), "支付方式不能为空");
String payOrderNo = "DH" + IdUtil.getSnowflakeNextId();
initOrderPayment(new OrderPayment(param.getShopId(), param.getRecordId(), payType.getValue(), payOrderNo,
initOrderPayment(new OrderPayment(param.getShopId(), param.getRecordId(), payType, PaymentPayTypeEnum.PayType.PAY, payOrderNo,
"", param.getPrice(), null));
return ltPay(param.getShopId(), param.getPayType(), new CzgLtPayReq(payOrderNo, param.getPrice().multiply(MONEY_RATE).longValue(),
param.getPayType(), detail, param.getOpenId(), param.getIp(), "", "", ""));
@@ -629,7 +634,7 @@ public class PayServiceImpl implements PayService {
}
String refPayOrderNo = "REFVIP" + IdUtil.getSnowflakeNextId();
refPaymentId = initOrderPayment(new OrderPayment(refPayParam.getShopId(), shopUser.getId(),
PaymentPayTypeEnum.MEMBER_REFUND.getValue(), refPayOrderNo, null, refPayParam.getRefAmount()));
PaymentPayTypeEnum.SourceType.MEMBER_IN, PaymentPayTypeEnum.PayType.REFUND, refPayOrderNo, null, refPayParam.getRefAmount()));
CzgResult<CzgRefundResp> refund = refund(refPayParam.getShopId(), new CzgRefundReq(refPayOrderNo, refPayParam.getRemark(),
refPayParam.getRefAmount().multiply(MONEY_RATE).longValue(), payment.getOrderNo(), ""));
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
@@ -639,7 +644,7 @@ public class PayServiceImpl implements PayService {
.eq(OrderPayment::getId, refPaymentId)
.set(OrderPayment::getPayTime, refund.getData().getRefundTime())
.set(OrderPayment::getTradeNumber, refund.getData().getRefundOrderId())
.set(OrderPayment::getPayStatus, "success")
.set(OrderPayment::getPayStatus, PaymentPayTypeEnum.PayStatus.SUCCESS)
.set(OrderPayment::getRespJson, JSONObject.toJSONString(refund.getData()))
.update();
}
@@ -824,7 +829,7 @@ public class PayServiceImpl implements PayService {
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
OrderPayment payment = paymentService.getById(payOrderId);
AssertUtil.isNull(payment, "退款失败支付记录不存在");
Long refundId = initOrderPayment(new OrderPayment(shopId, orderId, PaymentPayTypeEnum.REFUND.getValue(), refPayOrderNo, null, refundAmount, payment.getId()));
Long refundId = initOrderPayment(new OrderPayment(shopId, orderId, PaymentPayTypeEnum.SourceType.ORDER, PaymentPayTypeEnum.PayType.REFUND, refPayOrderNo, null, refundAmount, payment.getId()));
CzgResult<CzgRefundResp> refund = refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(MONEY_RATE).longValue(),
payment.getOrderNo(), ""));
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
@@ -848,22 +853,16 @@ public class PayServiceImpl implements PayService {
@NonNull String refundReason, @NonNull BigDecimal refundAmount) {
OrderPayment payment = paymentService.getById(payOrderId);
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
Long refundId = initOrderPayment(new OrderPayment(shopId, sourceId, PaymentPayTypeEnum.REFUND.getValue(), refPayOrderNo, null, refundAmount, payment.getId()));
Long refundId = initOrderPayment(new OrderPayment(shopId, sourceId, payment.getSourceType(), PaymentPayTypeEnum.PayType.REFUND, refPayOrderNo, null, refundAmount, payment.getId()));
CzgResult<CzgRefundResp> refund = refund(shopId, new CzgRefundReq(refPayOrderNo, refundReason, refundAmount.multiply(MONEY_RATE).longValue(),
payment.getOrderNo(), ""));
OrderPayment uOrderPayment = new OrderPayment();
uOrderPayment.setTradeNumber(refund.getData().getRefundOrderId());
uOrderPayment.setRespJson(JSONObject.toJSONString(refund.getData()));
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
uOrderPayment.setPayStatus("fail");
// paymentService.updateChain()
// .eq(OrderPayment::getId, refundId)
// .set(OrderPayment::getTradeNumber, refund.getData().getRefundOrderId())
// .set(OrderPayment::getRespJson, JSONObject.toJSONString(refund.getData()))
// .set(OrderPayment::getPayStatus, "fail")
// .update();
uOrderPayment.setPayStatus(PaymentPayTypeEnum.PayStatus.FAIL);
} else {
uOrderPayment.setPayStatus("success");
uOrderPayment.setPayStatus(PaymentPayTypeEnum.PayStatus.SUCCESS);
uOrderPayment.setPayTime(LocalDateTimeUtil.parse(refund.getData().getRefundTime(), "yyyy-MM-dd HH:mm:ss"));
}
paymentService.update(uOrderPayment, QueryWrapper.create().eq(OrderPayment::getId, refundId));
@@ -872,21 +871,24 @@ public class PayServiceImpl implements PayService {
@Override
@Transactional
public void unifyRefund(OrderPayment refundPayment, String refPayOrderNo) {
//支付的 订单
OrderPayment payment = paymentService.getById(refundPayment.getRelatedId());
AssertUtil.isNull(payment, "退款失败,支付记录不存在");
Long refundId = refundPayment.getId();
Long refundCompensate = initOrderPayment(new OrderPayment(refundPayment.getShopId(), refundPayment.getSourceId(), payment.getSourceType(), PaymentPayTypeEnum.PayType.REFUND_COMPENSATE,
refPayOrderNo, null, refundPayment.getAmount(), refundPayment.getId()));
CzgResult<CzgRefundResp> refund = refund(payment.getShopId(), new CzgRefundReq(refPayOrderNo, "退款补偿", refundPayment.getAmount().multiply(MONEY_RATE).longValue(),
payment.getOrderNo(), ""));
OrderPayment uOrderPayment = new OrderPayment();
uOrderPayment.setTradeNumber(refund.getData().getRefundOrderId());
uOrderPayment.setRespJson(JSONObject.toJSONString(refund.getData()));
if (refund.getCode() != 200 || refund.getData() == null || !"SUCCESS".equals(refund.getData().getState())) {
uOrderPayment.setPayStatus("fail");
uOrderPayment.setPayStatus(PaymentPayTypeEnum.PayStatus.FAIL);
} else {
uOrderPayment.setPayStatus("success");
uOrderPayment.setPayStatus(PaymentPayTypeEnum.PayStatus.SUCCESS);
uOrderPayment.setPayTime(LocalDateTimeUtil.parse(refund.getData().getRefundTime(), "yyyy-MM-dd HH:mm:ss"));
}
paymentService.update(uOrderPayment, QueryWrapper.create().eq(OrderPayment::getId, refundId));
paymentService.update(uOrderPayment, QueryWrapper.create().eq(OrderPayment::getId, refundPayment.getId()));
paymentService.update(uOrderPayment, QueryWrapper.create().eq(OrderPayment::getId, refundCompensate));
}
@Override

View File

@@ -109,7 +109,7 @@ public class PointsGoodPayServiceImpl implements PointsGoodPayService {
goodsRecordService.save(record);
param.setRecordId(record.getId());
CzgResult<Map<String, Object>> result = CzgResult.success();
CzgResult<Map<String, Object>> mapCzgResult = payService.ltPayOther(param, PaymentPayTypeEnum.POINT, "积分商品购买");
CzgResult<Map<String, Object>> mapCzgResult = payService.ltPayOther(param, PaymentPayTypeEnum.SourceType.POINT, "积分商品购买");
if (200 != mapCzgResult.getCode()) {
return mapCzgResult;
}

View File

@@ -6,8 +6,8 @@
<select id="getGbOrderPage" resultType="com.czg.order.vo.GbOrderDetailVO">
SELECT
detail.* ,`order`.ware_json as wareJson,`order`.group_end_time as groupEndTime,`order`.group_people_num as groupPeopleNum
,`user`.nick_name as userName,`user`.phone as userPhone,shop.shop_name as shopName,shop.address as shopAddress
detail.* ,`order`.ware_json as wareJson,`order`.group_end_time as groupEndTime,`order`.group_people_num as groupPeopleNum,`order`.ware_group_price as wareGroupPrice,
`order`.ware_original_price as wareOriginalPrice,`user`.nick_name as userName,`user`.phone as userPhone,shop.shop_name as shopName,shop.address as shopAddress
FROM
`gb_order_detail` detail
LEFT JOIN gb_order `order` on detail.group_order_no = `order`.group_order_no and `order`.shop_id = #{shopId}
@@ -44,8 +44,8 @@
<select id="getGbOrderDetail" resultType="com.czg.order.vo.GbOrderDetailVO">
SELECT
detail.* ,`order`.ware_json as wareJson,`order`.group_end_time as groupEndTime,`user`.nick_name as userName,
`user`.phone as userPhone,shop.shop_name as shopName,shop.address as shopAddress
detail.* ,`order`.ware_json as wareJson,`order`.group_end_time as groupEndTime,`order`.group_people_num as groupPeopleNum,`order`.ware_group_price as wareGroupPrice,
`order`.ware_original_price as wareOriginalPrice,`user`.nick_name as userName,`user`.phone as userPhone,shop.shop_name as shopName,shop.address as shopAddress
FROM
`gb_order_detail` detail
LEFT JOIN gb_order `order` on detail.group_order_no = `order`.group_order_no and `order`.shop_id = #{shopId}
@@ -55,6 +55,7 @@
detail.shop_id = #{shopId} and detail.id=#{detailId}
order by detail.create_time desc
</select>
<select id="getGbOrderDetailUsers" resultType="com.czg.order.vo.GbOrderUserVO">
select `user`.nick_name as userName, `user`.phone as userPhone, `user`.head_img as userAvatar
from gb_order_detail detail