Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.czg.controller.user;
|
package com.czg.controller.user;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.market.dto.PpPackageOrderDTO;
|
import com.czg.market.dto.PpPackageOrderDTO;
|
||||||
import com.czg.market.service.PpPackageOrderService;
|
import com.czg.market.service.PpPackageOrderService;
|
||||||
import com.czg.market.service.PpPackageService;
|
import com.czg.market.service.PpPackageService;
|
||||||
@@ -9,11 +10,10 @@ import com.czg.market.vo.PpPackageVO;
|
|||||||
import com.czg.order.dto.GbOrderQueryParam;
|
import com.czg.order.dto.GbOrderQueryParam;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
|
import com.czg.utils.AssertUtil;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户端/套餐推广
|
* 用户端/套餐推广
|
||||||
@@ -31,6 +31,18 @@ public class UPpPackageController {
|
|||||||
@Resource
|
@Resource
|
||||||
private PpPackageOrderService ppPackageOrderService;
|
private PpPackageOrderService ppPackageOrderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建套餐推广订单
|
||||||
|
* 参数: {"packageId": 123}
|
||||||
|
*/
|
||||||
|
@PostMapping("/order")
|
||||||
|
public CzgResult<Long> createOrder(@RequestBody JSONObject params) {
|
||||||
|
AssertUtil.isNull(params, "参数不能为空");
|
||||||
|
Long packageId = params.getLong("packageId");
|
||||||
|
AssertUtil.isNull(packageId, "参数错误");
|
||||||
|
return CzgResult.success(ppPackageOrderService.createPackageOrder(packageId));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取套餐列表
|
* 获取套餐列表
|
||||||
*/
|
*/
|
||||||
@@ -68,6 +80,6 @@ public class UPpPackageController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/order/detail")
|
@GetMapping("/order/detail")
|
||||||
public CzgResult<PpPackageOrderDTO> getOrderDetail(Long orderId) {
|
public CzgResult<PpPackageOrderDTO> getOrderDetail(Long orderId) {
|
||||||
return CzgResult.success(ppPackageOrderService.getOrderDetailById(orderId));
|
return CzgResult.success(ppPackageOrderService.getOrderDetailById(orderId, StpKit.USER.getLoginIdAsLong()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
package com.czg.controller.admin;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.czg.annotation.SaAdminCheckPermission;
|
||||||
|
import com.czg.enums.OrderNoPrefixEnum;
|
||||||
|
import com.czg.log.annotation.OperationLog;
|
||||||
|
import com.czg.market.dto.PpPackageOrderDTO;
|
||||||
|
import com.czg.market.service.PpPackageOrderService;
|
||||||
|
import com.czg.order.dto.CommonRefundDTO;
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import com.czg.sa.StpKit;
|
||||||
|
import com.czg.service.order.service.PayService;
|
||||||
|
import com.czg.utils.AssertUtil;
|
||||||
|
import com.czg.utils.CzgRandomUtils;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理端/套餐推广
|
||||||
|
*
|
||||||
|
* @author yjjie
|
||||||
|
* @date 2025/12/18 19:26
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/ppOrder")
|
||||||
|
public class PpOrderController {
|
||||||
|
|
||||||
|
@DubboReference
|
||||||
|
private PpPackageOrderService ppPackageOrderService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PayService payService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认退单
|
||||||
|
*/
|
||||||
|
@PostMapping("/confirmRefund")
|
||||||
|
@Transactional
|
||||||
|
public CzgResult<Boolean> confirmRefund(@RequestBody @Validated CommonRefundDTO param) {
|
||||||
|
PpPackageOrderDTO detail = ppPackageOrderService.getOrderDetailById(param.getRecordId(), StpKit.USER.getLoginIdAsLong());
|
||||||
|
if (detail == null) {
|
||||||
|
return CzgResult.failure("订单不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
ppPackageOrderService.confirmRefund(param.getRecordId(), StpKit.USER.getShopId());
|
||||||
|
|
||||||
|
//退钱
|
||||||
|
String refPayOrderNo = CzgRandomUtils.snowflake(OrderNoPrefixEnum.REPP);
|
||||||
|
payService.unifyRefund(detail.getShopId(), detail.getId(), detail.getPayOrderId(), refPayOrderNo,
|
||||||
|
StrUtil.isBlankIfStr(detail.getRefundReason()) ? "拼团退款" : detail.getRefundReason(), detail.getFinalPrice());
|
||||||
|
|
||||||
|
return CzgResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 驳回退单
|
||||||
|
*/
|
||||||
|
@PostMapping("/rejectRefund")
|
||||||
|
public CzgResult<Boolean> rejectRefund(@RequestBody @Validated CommonRefundDTO param) {
|
||||||
|
return CzgResult.success(ppPackageOrderService.cancelRefund(param.getRecordId(),
|
||||||
|
StpKit.USER.getLoginIdAsLong(), param.getReason()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐推广-核销
|
||||||
|
*/
|
||||||
|
@PostMapping("checkout")
|
||||||
|
@OperationLog("套餐推广-核销")
|
||||||
|
@SaAdminCheckPermission(parentName = "套餐推广", value = "market:package:checkout", name = "套餐推广-核销")
|
||||||
|
public CzgResult<Boolean> checkout(@RequestBody JSONObject param) {
|
||||||
|
AssertUtil.isNull(param, "核销码不能为空");
|
||||||
|
String verifyCode = param.getString("verifyCode");
|
||||||
|
AssertUtil.isBlank(verifyCode, "核销码不能为空");
|
||||||
|
return CzgResult.success(ppPackageOrderService.checkout(verifyCode, StpKit.USER.getShopId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package com.czg.controller.user;
|
||||||
|
|
||||||
|
import com.czg.market.dto.PpPackageOrderDTO;
|
||||||
|
import com.czg.market.entity.PpPackageOrder;
|
||||||
|
import com.czg.market.service.PpPackageOrderService;
|
||||||
|
import com.czg.market.vo.PpPackageVO;
|
||||||
|
import com.czg.order.dto.CommonRefundDTO;
|
||||||
|
import com.czg.order.dto.LtPayOtherDTO;
|
||||||
|
import com.czg.order.enums.PaymentPayTypeEnum;
|
||||||
|
import com.czg.resp.CzgResult;
|
||||||
|
import com.czg.sa.StpKit;
|
||||||
|
import com.czg.service.order.service.PayService;
|
||||||
|
import com.czg.utils.ServletUtil;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户端/套餐推广
|
||||||
|
*
|
||||||
|
* @author yjjie
|
||||||
|
* @date 2025/12/18 18:54
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/user/ppOrder")
|
||||||
|
public class UPpOrderController {
|
||||||
|
|
||||||
|
@DubboReference
|
||||||
|
private PpPackageOrderService ppPackageOrderService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PayService payService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小程序支付
|
||||||
|
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||||
|
* openId 必填
|
||||||
|
*/
|
||||||
|
@PostMapping("/pay")
|
||||||
|
@Transactional
|
||||||
|
public CzgResult<Map<String, Object>> exchange(HttpServletRequest request, @Validated @RequestBody LtPayOtherDTO param) {
|
||||||
|
param.setUserId(StpKit.USER.getLoginIdAsLong());
|
||||||
|
param.setIp(ServletUtil.getClientIP(request));
|
||||||
|
param.setRecordId(param.getParamId());
|
||||||
|
|
||||||
|
PpPackageOrderDTO detail = ppPackageOrderService.getOrderDetailById(param.getRecordId(), StpKit.USER.getLoginIdAsLong());
|
||||||
|
|
||||||
|
PpPackageVO packageInfo = detail.getPackageInfo();
|
||||||
|
// 计算订单金额
|
||||||
|
BigDecimal price = packageInfo.getPrice();
|
||||||
|
// 如果存在优惠层级 并且 分享人数大于 0 则计算新的价格
|
||||||
|
if (packageInfo.getTieredDiscount() != null && !packageInfo.getTieredDiscount().isEmpty() && detail.getShareNum() > 0) {
|
||||||
|
// 倒序遍历优惠层级
|
||||||
|
for (int i = packageInfo.getTieredDiscount().size() - 1; i >= 0; i--) {
|
||||||
|
PpPackageVO.TieredDiscount tieredDiscount = packageInfo.getTieredDiscount().get(i);
|
||||||
|
if (detail.getShareNum() >= tieredDiscount.getPeopleNum()) {
|
||||||
|
price = tieredDiscount.getPrice();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
param.setPrice(price);
|
||||||
|
|
||||||
|
CzgResult<Map<String, Object>> result = CzgResult.success();
|
||||||
|
CzgResult<Map<String, Object>> mapCzgResult = payService.ltPayOther(param, PaymentPayTypeEnum.SourceType.PP, "套餐推广购买");
|
||||||
|
if (200 != mapCzgResult.getCode()) {
|
||||||
|
return mapCzgResult;
|
||||||
|
}
|
||||||
|
Map<String, Object> resultMap = new HashMap<>(1);
|
||||||
|
resultMap.put("payInfo", mapCzgResult.getData());
|
||||||
|
result.setData(resultMap);
|
||||||
|
|
||||||
|
PpPackageOrder order = ppPackageOrderService.getById(param.getRecordId());
|
||||||
|
order.setFinalPrice(price);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请退单
|
||||||
|
*/
|
||||||
|
@PostMapping("/applyRefund")
|
||||||
|
public CzgResult<Boolean> applyRefund(@RequestBody @Validated CommonRefundDTO param) {
|
||||||
|
return CzgResult.success(ppPackageOrderService.applyRefund(param.getRecordId(), StpKit.USER.getLoginIdAsLong(), param.getReason()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消退单
|
||||||
|
*/
|
||||||
|
@PostMapping("/cancelRefund")
|
||||||
|
public CzgResult<Boolean> cancelRefund(@RequestBody @Validated CommonRefundDTO param) {
|
||||||
|
return CzgResult.success(ppPackageOrderService.cancelRefund(param.getRecordId(), StpKit.USER.getLoginIdAsLong(), ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@ import java.io.Serial;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 套餐推广订单 实体类。
|
* 套餐推广订单 实体类。
|
||||||
@@ -121,6 +120,11 @@ public class PpPackageOrderDTO implements Serializable {
|
|||||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
private LocalDateTime expireTime;
|
private LocalDateTime expireTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请退款原因
|
||||||
|
*/
|
||||||
|
private String refundReason;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否可以助力:0: 不可以 1: 可以
|
* 是否可以助力:0: 不可以 1: 可以
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -124,4 +124,9 @@ public class PpPackageOrder implements Serializable {
|
|||||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
private LocalDateTime expireTime;
|
private LocalDateTime expireTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请退款原因
|
||||||
|
*/
|
||||||
|
private String refundReason;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,4 +14,6 @@ public interface PpHelpRecordService extends IService<PpHelpRecord> {
|
|||||||
boolean canHelp(Long userId, Long orderId);
|
boolean canHelp(Long userId, Long orderId);
|
||||||
|
|
||||||
boolean help(Long userId, Long orderId);
|
boolean help(Long userId, Long orderId);
|
||||||
|
|
||||||
|
void removeHelpRecord(Long orderId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public interface PpPackageOrderService extends IService<PpPackageOrder> {
|
|||||||
/**
|
/**
|
||||||
* 根据订单 Id 查询推广订单详情
|
* 根据订单 Id 查询推广订单详情
|
||||||
*/
|
*/
|
||||||
PpPackageOrderDTO getOrderDetailById(Long orderId);
|
PpPackageOrderDTO getOrderDetailById(Long orderId, Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 助力订单
|
* 助力订单
|
||||||
@@ -38,5 +38,30 @@ public interface PpPackageOrderService extends IService<PpPackageOrder> {
|
|||||||
/**
|
/**
|
||||||
* 取消订单
|
* 取消订单
|
||||||
*/
|
*/
|
||||||
Boolean cancelOrder(Long orderId);
|
boolean cancelOrder(Long orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请退款
|
||||||
|
*/
|
||||||
|
boolean applyRefund(Long orderId, Long userId, String refundReason);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认退款
|
||||||
|
*/
|
||||||
|
void confirmRefund(Long orderId, Long shopId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消退款
|
||||||
|
*/
|
||||||
|
boolean cancelRefund(Long orderId, Long userId, String refundReason);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付成功
|
||||||
|
*/
|
||||||
|
void paySuccess(Long orderId, Long payOrderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 核销
|
||||||
|
*/
|
||||||
|
boolean checkout(String verifyCode, Long shopId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,4 +24,5 @@ public class CommonRefundDTO {
|
|||||||
|
|
||||||
private String reason;
|
private String reason;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,12 @@ public interface PaymentPayTypeEnum {
|
|||||||
* 拼团商品购买
|
* 拼团商品购买
|
||||||
*/
|
*/
|
||||||
public static final String WARE = "ware";
|
public static final String WARE = "ware";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 套餐推广
|
||||||
|
* package promotion
|
||||||
|
*/
|
||||||
|
public static final String PP = "pp";
|
||||||
}
|
}
|
||||||
|
|
||||||
class PayType {
|
class PayType {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public enum OrderNoPrefixEnum {
|
|||||||
BK("BK", "预约"),
|
BK("BK", "预约"),
|
||||||
DH("DH", "积分商品兑换单号"),
|
DH("DH", "积分商品兑换单号"),
|
||||||
REP("REP", "积分商品退款"),
|
REP("REP", "积分商品退款"),
|
||||||
|
REPP("REPP", "套餐推广退款"),
|
||||||
|
|
||||||
GB("GB", "拼团-团单号"),
|
GB("GB", "拼团-团单号"),
|
||||||
GBO("GBO", "拼团-订单号"),
|
GBO("GBO", "拼团-订单号"),
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
package com.czg.service.market.service.impl;
|
package com.czg.service.market.service.impl;
|
||||||
|
|
||||||
import com.czg.account.dto.user.userinfo.UserInfoDTO;
|
import com.czg.account.dto.user.userinfo.UserInfoDTO;
|
||||||
import com.czg.account.service.SysUserService;
|
|
||||||
import com.czg.account.service.UserInfoService;
|
import com.czg.account.service.UserInfoService;
|
||||||
import com.czg.exception.CzgException;
|
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.entity.PpHelpRecord;
|
||||||
import com.czg.market.service.PpHelpRecordService;
|
import com.czg.market.service.PpHelpRecordService;
|
||||||
import com.czg.service.market.mapper.PpHelpRecordMapper;
|
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.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.springframework.stereotype.Service;
|
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());
|
.setUserAvator(info.getHeadImg());
|
||||||
return save(helpRecord);
|
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.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
|
import com.mybatisflex.core.query.QueryWrapper;
|
||||||
import com.mybatisflex.core.update.UpdateChain;
|
import com.mybatisflex.core.update.UpdateChain;
|
||||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
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 org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -40,7 +41,7 @@ import java.util.List;
|
|||||||
* @author gyj
|
* @author gyj
|
||||||
* @since 2025-12-18
|
* @since 2025-12-18
|
||||||
*/
|
*/
|
||||||
@Service
|
@DubboService
|
||||||
public class PpPackageOrderServiceImpl extends ServiceImpl<PpPackageOrderMapper, PpPackageOrder> implements PpPackageOrderService {
|
public class PpPackageOrderServiceImpl extends ServiceImpl<PpPackageOrderMapper, PpPackageOrder> implements PpPackageOrderService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@@ -77,8 +78,7 @@ public class PpPackageOrderServiceImpl extends ServiceImpl<PpPackageOrderMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PpPackageOrderDTO getOrderDetailById(Long orderId) {
|
public PpPackageOrderDTO getOrderDetailById(Long orderId, Long userId) {
|
||||||
long loginUserId = StpKit.USER.getLoginIdAsLong();
|
|
||||||
PpPackageOrder order = getById(orderId);
|
PpPackageOrder order = getById(orderId);
|
||||||
if (order == null) {
|
if (order == null) {
|
||||||
throw new CzgException("订单不存在");
|
throw new CzgException("订单不存在");
|
||||||
@@ -86,10 +86,10 @@ public class PpPackageOrderServiceImpl extends ServiceImpl<PpPackageOrderMapper,
|
|||||||
|
|
||||||
PpPackageOrderDTO orderDto = BeanUtil.copyProperties(order, PpPackageOrderDTO.class);
|
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 (PpPackageConstants.OrderStatus.PROCESSING.equals(order.getStatus())) {
|
||||||
if (orderDto.getIsMyself().equals(SystemConstants.OneZero.ZERO)) {
|
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);
|
orderDto.setCanHelp(canHelp ? SystemConstants.OneZero.ONE : SystemConstants.OneZero.ZERO);
|
||||||
} else {
|
} else {
|
||||||
orderDto.setCanHelp(SystemConstants.OneZero.ZERO);
|
orderDto.setCanHelp(SystemConstants.OneZero.ZERO);
|
||||||
@@ -148,7 +148,8 @@ public class PpPackageOrderServiceImpl extends ServiceImpl<PpPackageOrderMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean cancelOrder(Long orderId) {
|
@Transactional
|
||||||
|
public boolean cancelOrder(Long orderId) {
|
||||||
PpPackageOrder order = getById(orderId);
|
PpPackageOrder order = getById(orderId);
|
||||||
if (order == null) {
|
if (order == null) {
|
||||||
throw new CzgException("订单不存在");
|
throw new CzgException("订单不存在");
|
||||||
@@ -162,11 +163,102 @@ public class PpPackageOrderServiceImpl extends ServiceImpl<PpPackageOrderMapper,
|
|||||||
throw new CzgException("无权限");
|
throw new CzgException("无权限");
|
||||||
}
|
}
|
||||||
|
|
||||||
return UpdateChain.of(PpPackageOrder.class)
|
ppHelpRecordService.removeHelpRecord(orderId);
|
||||||
.set(PpPackageOrder::getStatus, PpPackageConstants.OrderStatus.CANCEL)
|
|
||||||
.set(PpPackageOrder::getCancelTime, LocalDateTime.now())
|
order.setStatus(PpPackageConstants.OrderStatus.CANCEL);
|
||||||
.set(PpPackageOrder::getCancelReason, "用户取消")
|
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)
|
.eq(PpPackageOrder::getId, orderId)
|
||||||
.update();
|
.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;
|
private MkShopRechargeService shopRechargeService;
|
||||||
@Resource
|
@Resource
|
||||||
private MkConsumeCashbackService consumeCashbackService;
|
private MkConsumeCashbackService consumeCashbackService;
|
||||||
|
@DubboReference
|
||||||
|
private PpPackageOrderService ppPackageOrderService;
|
||||||
// 延迟 5 秒
|
// 延迟 5 秒
|
||||||
private static final long DELAY = 5;
|
private static final long DELAY = 5;
|
||||||
//重试次数
|
//重试次数
|
||||||
@@ -1179,6 +1181,9 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
|||||||
else if (PaymentPayTypeEnum.SourceType.WARE.equals(payment.getSourceType())) {
|
else if (PaymentPayTypeEnum.SourceType.WARE.equals(payment.getSourceType())) {
|
||||||
gbOrderService.payCallBack(payment.getSourceId(), payment.getId());
|
gbOrderService.payCallBack(payment.getSourceId(), payment.getId());
|
||||||
}
|
}
|
||||||
|
else if (PaymentPayTypeEnum.SourceType.PP.equals(payment.getSourceType())) {
|
||||||
|
ppPackageOrderService.paySuccess(payment.getSourceId(), payment.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
paymentService.updateById(payment);
|
paymentService.updateById(payment);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user