积分
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.vo.PointsExchangeSummaryVo;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.market.dto.MkPointsGoodsRecordDTO;
|
||||
import com.czg.market.dto.MkPointsGoodsRecordQueryDTO;
|
||||
import com.czg.market.service.MkPointsGoodsRecordService;
|
||||
import com.czg.market.service.MkPointsGoodsService;
|
||||
import com.czg.order.dto.PointGoodsRefundDTO;
|
||||
import com.czg.order.service.PointsGoodPayService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 积分商品
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/points/goodsRecord")
|
||||
public class PointsGoodsRecordController {
|
||||
|
||||
@Resource
|
||||
private MkPointsGoodsRecordService goodsRecordService;
|
||||
@Resource
|
||||
private MkPointsGoodsService pointsGoodsService;
|
||||
@Resource
|
||||
private PointsGoodPayService goodPayService;
|
||||
|
||||
/**
|
||||
* 积分:积分商品:兑换记录列表
|
||||
*/
|
||||
@GetMapping("page")
|
||||
@SaAdminCheckPermission(value = "points:goodsRecord:list", name = "积分-积分商品-兑换记录")
|
||||
public CzgResult<Page<MkPointsGoodsRecordDTO>> getGoodsRecordPage(MkPointsGoodsRecordQueryDTO param) {
|
||||
param.setShopId(StpKit.USER.getShopId());
|
||||
Page<MkPointsGoodsRecordDTO> page = goodsRecordService.getGoodsRecordPage(param);
|
||||
return CzgResult.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分:积分商品:统计
|
||||
*/
|
||||
@GetMapping("total")
|
||||
@SaAdminCheckPermission(value = "points:goodsRecord:total", name = "积分-积分商品-统计")
|
||||
public CzgResult<PointsExchangeSummaryVo> total(MkPointsGoodsRecordQueryDTO param) {
|
||||
param.setShopId(StpKit.USER.getShopId());
|
||||
PointsExchangeSummaryVo data = goodsRecordService.total(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销
|
||||
*
|
||||
* @param couponCode 兑换码
|
||||
*/
|
||||
@PostMapping("checkout")
|
||||
@OperationLog("积分兑换-核销")
|
||||
@SaAdminCheckPermission(value = "points:goodsRecord:checkout", name = "积分-积分商品-核销")
|
||||
public CzgResult<Boolean> checkout(@RequestBody String couponCode) {
|
||||
return CzgResult.success(goodsRecordService.checkout(couponCode, StpKit.USER.getShopId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 退单/同意退单
|
||||
*/
|
||||
@PostMapping("/agreeRefund")
|
||||
public CzgResult<Boolean> agreeRefund(@RequestBody @Validated PointGoodsRefundDTO param) {
|
||||
return CzgResult.success(goodPayService.applyRefund(param, StpKit.USER.getShopId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 驳回退单
|
||||
*/
|
||||
@PostMapping("/rejectRefund")
|
||||
public CzgResult<Boolean> rejectRefund(@RequestBody @Validated PointGoodsRefundDTO param) {
|
||||
return CzgResult.success(pointsGoodsService.cancelRefund(param, StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.czg.controller.user;
|
||||
|
||||
import com.czg.market.entity.MkPointsGoods;
|
||||
import com.czg.market.entity.MkPointsGoodsRecord;
|
||||
import com.czg.market.service.MkPointsGoodsService;
|
||||
import com.czg.order.dto.PointGoodsRefundDTO;
|
||||
import com.czg.order.service.PointsGoodPayService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.order.dto.PointGoodsExchangeDTO;
|
||||
import com.czg.utils.ServletUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 积分商城
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/pointGoods/")
|
||||
public class UPointGoodsController {
|
||||
|
||||
@Resource
|
||||
private MkPointsGoodsService pointsGoodsService;
|
||||
|
||||
@Resource
|
||||
private PointsGoodPayService goodPayService;
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
public CzgResult<Page<MkPointsGoods>> getPointsGoodsSettingPage(@RequestParam(defaultValue = "1", required = false) Integer page,
|
||||
@RequestParam(defaultValue = "10", required = false) Integer size,
|
||||
Long shopId) {
|
||||
Page<MkPointsGoods> data = pointsGoodsService.getPointsGoodsPageByUser(page, size, shopId, StpKit.USER.getLoginIdAsLong());
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成订单
|
||||
* 小程序支付
|
||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("/exchange")
|
||||
public CzgResult<Map<String, Object>> exchange(HttpServletRequest request, @Validated @RequestBody PointGoodsExchangeDTO param) {
|
||||
param.setUserId(StpKit.USER.getLoginIdAsLong());
|
||||
return goodPayService.exchange(ServletUtil.getClientIP(request), param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请退单
|
||||
*/
|
||||
@PostMapping("/applyRefund")
|
||||
public CzgResult<Boolean> applyRefund(@RequestBody @Validated PointGoodsRefundDTO param) {
|
||||
return CzgResult.success(pointsGoodsService.applyRefund(param, StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消退单
|
||||
*/
|
||||
@PostMapping("/cancelRefund")
|
||||
public CzgResult<Boolean> cancelRefund(@RequestBody @Validated PointGoodsRefundDTO param) {
|
||||
return CzgResult.success(pointsGoodsService.cancelRefund(param, StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的兑换记录
|
||||
*/
|
||||
@GetMapping("/record/page")
|
||||
public CzgResult<Page<MkPointsGoodsRecord>> getGoodsRecordPage(@RequestParam(defaultValue = "1", required = false) int page,
|
||||
@RequestParam(defaultValue = "10", required = false) int size,
|
||||
@RequestParam Long shopId) {
|
||||
Page<MkPointsGoodsRecord> pages = pointsGoodsService.getGoodsRecordPage(page, size, shopId, StpKit.USER.getLoginIdAsLong());
|
||||
return CzgResult.success(pages);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,24 @@
|
||||
package com.czg.task;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.czg.market.service.OrderInfoService;
|
||||
import com.czg.order.entity.CashierCart;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.service.CashierCartService;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.service.order.enums.OrderStatusEnums;
|
||||
import com.czg.service.order.service.PayService;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单定时任务
|
||||
*
|
||||
@@ -25,6 +32,10 @@ public class OTimeTask {
|
||||
private OrderInfoService orderInfoService;
|
||||
@Resource
|
||||
private CashierCartService cartService;
|
||||
@Resource
|
||||
private OrderPaymentService orderPaymentService;
|
||||
@Resource
|
||||
private PayService payService;
|
||||
|
||||
/**
|
||||
* order 过期
|
||||
@@ -44,4 +55,22 @@ public class OTimeTask {
|
||||
});
|
||||
cartService.remove(cartUpdateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退钱补偿
|
||||
*/
|
||||
@Scheduled(cron = "0 50 23 * * ? ")
|
||||
public void refundCompensate() {
|
||||
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, "refund")
|
||||
.ne(OrderPayment::getPayStatus, "success"));
|
||||
for (OrderPayment payment : list) {
|
||||
String refPayOrderNo = "REP" + IdUtil.getSnowflakeNextId();
|
||||
payService.unifyRefund(payment, refPayOrderNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user