套餐推广支付接口
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
package com.czg.service.market.service.impl;
|
||||
|
||||
import com.czg.account.dto.user.userinfo.UserInfoDTO;
|
||||
import com.czg.account.service.SysUserService;
|
||||
import com.czg.account.service.UserInfoService;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.market.entity.PpHelpRecord;
|
||||
import com.czg.market.service.PpHelpRecordService;
|
||||
import com.czg.service.market.mapper.PpHelpRecordMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 套餐推广助力记录 服务层实现。
|
||||
@@ -46,4 +45,10 @@ public class PpHelpRecordServiceImpl extends ServiceImpl<PpHelpRecordMapper, PpH
|
||||
.setUserAvator(info.getHeadImg());
|
||||
return save(helpRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void removeHelpRecord(Long orderId) {
|
||||
remove(QueryWrapper.create().eq(PpHelpRecord::getOrderId, orderId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,12 @@ import com.czg.utils.PageUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.update.UpdateChain;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@@ -40,7 +41,7 @@ import java.util.List;
|
||||
* @author gyj
|
||||
* @since 2025-12-18
|
||||
*/
|
||||
@Service
|
||||
@DubboService
|
||||
public class PpPackageOrderServiceImpl extends ServiceImpl<PpPackageOrderMapper, PpPackageOrder> implements PpPackageOrderService {
|
||||
|
||||
@Resource
|
||||
@@ -77,8 +78,7 @@ public class PpPackageOrderServiceImpl extends ServiceImpl<PpPackageOrderMapper,
|
||||
}
|
||||
|
||||
@Override
|
||||
public PpPackageOrderDTO getOrderDetailById(Long orderId) {
|
||||
long loginUserId = StpKit.USER.getLoginIdAsLong();
|
||||
public PpPackageOrderDTO getOrderDetailById(Long orderId, Long userId) {
|
||||
PpPackageOrder order = getById(orderId);
|
||||
if (order == null) {
|
||||
throw new CzgException("订单不存在");
|
||||
@@ -86,10 +86,10 @@ public class PpPackageOrderServiceImpl extends ServiceImpl<PpPackageOrderMapper,
|
||||
|
||||
PpPackageOrderDTO orderDto = BeanUtil.copyProperties(order, PpPackageOrderDTO.class);
|
||||
|
||||
orderDto.setIsMyself(order.getUserId().equals(loginUserId) ? SystemConstants.OneZero.ONE : SystemConstants.OneZero.ZERO);
|
||||
orderDto.setIsMyself(order.getUserId().equals(userId) ? SystemConstants.OneZero.ONE : SystemConstants.OneZero.ZERO);
|
||||
if (PpPackageConstants.OrderStatus.PROCESSING.equals(order.getStatus())) {
|
||||
if (orderDto.getIsMyself().equals(SystemConstants.OneZero.ZERO)) {
|
||||
boolean canHelp = ppHelpRecordService.canHelp(loginUserId, orderId);
|
||||
boolean canHelp = ppHelpRecordService.canHelp(userId, orderId);
|
||||
orderDto.setCanHelp(canHelp ? SystemConstants.OneZero.ONE : SystemConstants.OneZero.ZERO);
|
||||
} else {
|
||||
orderDto.setCanHelp(SystemConstants.OneZero.ZERO);
|
||||
@@ -148,7 +148,8 @@ public class PpPackageOrderServiceImpl extends ServiceImpl<PpPackageOrderMapper,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean cancelOrder(Long orderId) {
|
||||
@Transactional
|
||||
public boolean cancelOrder(Long orderId) {
|
||||
PpPackageOrder order = getById(orderId);
|
||||
if (order == null) {
|
||||
throw new CzgException("订单不存在");
|
||||
@@ -162,11 +163,102 @@ public class PpPackageOrderServiceImpl extends ServiceImpl<PpPackageOrderMapper,
|
||||
throw new CzgException("无权限");
|
||||
}
|
||||
|
||||
return UpdateChain.of(PpPackageOrder.class)
|
||||
.set(PpPackageOrder::getStatus, PpPackageConstants.OrderStatus.CANCEL)
|
||||
.set(PpPackageOrder::getCancelTime, LocalDateTime.now())
|
||||
.set(PpPackageOrder::getCancelReason, "用户取消")
|
||||
ppHelpRecordService.removeHelpRecord(orderId);
|
||||
|
||||
order.setStatus(PpPackageConstants.OrderStatus.CANCEL);
|
||||
order.setCancelTime(LocalDateTime.now());
|
||||
order.setCancelReason("用户取消");
|
||||
|
||||
return updateById(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean applyRefund(Long orderId, Long userId, String refundReason) {
|
||||
PpPackageOrder order = getById(orderId);
|
||||
if (order == null) {
|
||||
throw new CzgException("订单不存在");
|
||||
}
|
||||
if (!PpPackageConstants.OrderStatus.WAIT_VERIFY.equals(order.getStatus())) {
|
||||
throw new CzgException("订单状态错误");
|
||||
}
|
||||
|
||||
ppHelpRecordService.removeHelpRecord(orderId);
|
||||
|
||||
order.setStatus(PpPackageConstants.OrderStatus.REFUNDING);
|
||||
order.setRefundReason(refundReason);
|
||||
return updateById(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void confirmRefund(Long orderId, Long shopId) {
|
||||
PpPackageOrder order = getOne(QueryWrapper.create().eq(PpPackageOrder::getId, orderId)
|
||||
.eq(PpPackageOrder::getShopId, shopId));
|
||||
if (order == null) {
|
||||
throw new CzgException("订单不存在");
|
||||
}
|
||||
if (!PpPackageConstants.OrderStatus.REFUNDING.equals(order.getStatus())
|
||||
&& !PpPackageConstants.OrderStatus.WAIT_VERIFY.equals(order.getStatus())
|
||||
&& !PpPackageConstants.OrderStatus.FINISH.equals(order.getStatus())) {
|
||||
throw new CzgException("订单状态错误");
|
||||
}
|
||||
|
||||
ppHelpRecordService.removeHelpRecord(orderId);
|
||||
|
||||
UpdateChain.of(PpPackageOrder.class)
|
||||
.set(PpPackageOrder::getStatus, PpPackageConstants.OrderStatus.REFUND)
|
||||
.eq(PpPackageOrder::getId, orderId)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean cancelRefund(Long orderId, Long userId, String refundReason) {
|
||||
PpPackageOrder order = getById(orderId);
|
||||
if (order == null) {
|
||||
throw new CzgException("订单不存在");
|
||||
}
|
||||
if (!PpPackageConstants.OrderStatus.REFUNDING.equals(order.getStatus())) {
|
||||
throw new CzgException("订单状态错误");
|
||||
}
|
||||
|
||||
ppHelpRecordService.removeHelpRecord(orderId);
|
||||
|
||||
order.setStatus(PpPackageConstants.OrderStatus.WAIT_VERIFY);
|
||||
order.setRefundReason(refundReason);
|
||||
return updateById(order);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void paySuccess(Long orderId, Long payOrderId) {
|
||||
PpPackageOrder order = getById(orderId);
|
||||
|
||||
order.setStatus(PpPackageConstants.OrderStatus.WAIT_VERIFY);
|
||||
order.setPayOrderId(payOrderId);
|
||||
order.setPayTime(LocalDateTime.now());
|
||||
order.setVerifyCode(CzgRandomUtils.randomNumber(12, true));
|
||||
updateById(order);
|
||||
|
||||
ppHelpRecordService.removeHelpRecord(orderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkout(String verifyCode, Long shopId) {
|
||||
PpPackageOrder packageOrder = getOne(QueryWrapper.create().eq(PpPackageOrder::getVerifyCode, verifyCode)
|
||||
.eq(PpPackageOrder::getShopId, shopId));
|
||||
if (packageOrder == null) {
|
||||
throw new CzgException("核销失败,核销码不存在");
|
||||
}
|
||||
if (!PpPackageConstants.OrderStatus.WAIT_VERIFY.equals(packageOrder.getStatus())
|
||||
&& !PpPackageConstants.OrderStatus.REFUNDING.equals(packageOrder.getStatus())) {
|
||||
throw new CzgException("核销失败,该订单不可核销");
|
||||
}
|
||||
|
||||
packageOrder.setStatus(PpPackageConstants.OrderStatus.FINISH);
|
||||
packageOrder.setVerifyTime(LocalDateTime.now());
|
||||
|
||||
return updateById(packageOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +141,8 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
private MkShopRechargeService shopRechargeService;
|
||||
@Resource
|
||||
private MkConsumeCashbackService consumeCashbackService;
|
||||
@DubboReference
|
||||
private PpPackageOrderService ppPackageOrderService;
|
||||
// 延迟 5 秒
|
||||
private static final long DELAY = 5;
|
||||
//重试次数
|
||||
@@ -1179,6 +1181,9 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
else if (PaymentPayTypeEnum.SourceType.WARE.equals(payment.getSourceType())) {
|
||||
gbOrderService.payCallBack(payment.getSourceId(), payment.getId());
|
||||
}
|
||||
else if (PaymentPayTypeEnum.SourceType.PP.equals(payment.getSourceType())) {
|
||||
ppPackageOrderService.paySuccess(payment.getSourceId(), payment.getId());
|
||||
}
|
||||
}
|
||||
paymentService.updateById(payment);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user