积分
This commit is contained in:
@@ -1,103 +0,0 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.dto.points.OrderDeductionPointsDTO;
|
||||
import com.czg.account.entity.MemberPoints;
|
||||
import com.czg.account.param.ConsumeAwardPointsParam;
|
||||
import com.czg.account.param.MemberPointsParam;
|
||||
import com.czg.account.param.PayedDeductPointsParam;
|
||||
import com.czg.account.service.MemberPointsService;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* 会员积分
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-25
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/admin/points/memberPoints")
|
||||
public class MemberPointsController {
|
||||
|
||||
private final MemberPointsService memberPointsService;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("page")
|
||||
@OperationLog("会员积分-分页")
|
||||
//@SaAdminCheckPermission("memberPoints:page")
|
||||
public CzgResult<Page<MemberPoints>> getMemberPointsPage(MemberPointsParam param) {
|
||||
Page<MemberPoints> page = memberPointsService.getMemberPointsPage(param);
|
||||
return CzgResult.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 001-会员积分账户信息
|
||||
*/
|
||||
@GetMapping("userPoints")
|
||||
public CzgResult<MemberPoints> getMemberPoints(@RequestParam Long shopUserId) {
|
||||
MemberPoints data = memberPointsService.getMemberPoints(shopUserId);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 002-获取订单可用积分及抵扣金额(支付页面使用)
|
||||
*
|
||||
* @param shopUserId 用户id
|
||||
* @param orderAmount 订单金额
|
||||
*/
|
||||
@GetMapping("calcUsablePoints")
|
||||
public CzgResult<OrderDeductionPointsDTO> getMemberUsablePoints(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount) {
|
||||
OrderDeductionPointsDTO usablePoints = memberPointsService.getMemberUsablePoints(shopUserId, orderAmount);
|
||||
return CzgResult.success(usablePoints);
|
||||
}
|
||||
|
||||
/**
|
||||
* 004-根据抵扣金额计算所需积分
|
||||
*
|
||||
* @param shopUserId 用户id
|
||||
* @param orderAmount 订单金额
|
||||
* @param deductionAmount 抵扣金额
|
||||
*/
|
||||
@GetMapping("calcUsedPoints")
|
||||
public CzgResult<Integer> calcUsedPoints(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount, @RequestParam BigDecimal deductionAmount) {
|
||||
int points = memberPointsService.calcUsedPoints(shopUserId, orderAmount, deductionAmount);
|
||||
return CzgResult.success(points);
|
||||
}
|
||||
|
||||
/**
|
||||
* 003-根据积分计算可抵扣金额
|
||||
*/
|
||||
@GetMapping("calcDeductionAmount")
|
||||
public CzgResult<BigDecimal> calcDeductionAmount(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount, @RequestParam Integer points) {
|
||||
BigDecimal deductionAmount = memberPointsService.calcDeductionAmount(shopUserId, orderAmount, points);
|
||||
return CzgResult.success(deductionAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 005-支付完成扣减积分(支付成功回调中使用)
|
||||
*/
|
||||
@PostMapping("payedDeductPoints")
|
||||
public CzgResult<Boolean> deductPoints(@RequestBody PayedDeductPointsParam param) {
|
||||
//boolean ret = memberPointsService.deductPoints(param.getUserId(), param.getPoints(), param.getContent(), param.getOrderId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 006-消费赠送积分(支付成功回调中使用)
|
||||
*/
|
||||
@PostMapping("consumeAwardPoints")
|
||||
public CzgResult<Void> consumeAwardPoints(@RequestBody ConsumeAwardPointsParam param) {
|
||||
//memberPointsService.consumeAwardPoints(param.getUserId(), param.getOrderId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.dto.points.MemberPointsLogDTO;
|
||||
import com.czg.account.service.MemberPointsLogService;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* 会员积分变动记录
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-25
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/admin/points/memberPointsLog")
|
||||
public class MemberPointsLogController {
|
||||
|
||||
private final MemberPointsLogService memberPointsLogService;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("page")
|
||||
@OperationLog("会员积分变动记录-分页")
|
||||
//@SaAdminCheckPermission("memberPointsLog:page")
|
||||
public CzgResult<Page<MemberPointsLogDTO>> getMemberPointsLogPage(MemberPointsLogDTO param) {
|
||||
Page<MemberPointsLogDTO> page = memberPointsLogService.getMemberPointsLogPage(param);
|
||||
return CzgResult.success(page);
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.czg.account.dto.points.PointsBasicSettingDTO;
|
||||
import com.czg.account.entity.PointsBasicSetting;
|
||||
import com.czg.account.service.PointsBasicSettingService;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.validator.ValidatorUtil;
|
||||
import com.czg.validator.group.DefaultGroup;
|
||||
import com.czg.validator.group.InsertGroup;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* 积分基本设置
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-25
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/admin/points/basicSetting")
|
||||
public class PointsBasicSettingController {
|
||||
|
||||
private final PointsBasicSettingService pointsBasicSettingService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping()
|
||||
@OperationLog("积分基本设置-详情")
|
||||
//@SaAdminCheckPermission("basicSetting:info")
|
||||
public CzgResult<PointsBasicSettingDTO> getPointsBasicSetting() {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
PointsBasicSetting entity = pointsBasicSettingService.getById(shopId);
|
||||
PointsBasicSettingDTO data = BeanUtil.copyProperties(entity, PointsBasicSettingDTO.class);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
@PostMapping
|
||||
@OperationLog("积分基本设置-保存")
|
||||
//@SaAdminCheckPermission("basicSetting:save")
|
||||
public CzgResult<Void> savePointsBasicSetting(@RequestBody PointsBasicSettingDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
ValidatorUtil.validateEntity(dto, InsertGroup.class, DefaultGroup.class);
|
||||
validateDTO(dto);
|
||||
PointsBasicSetting entity = BeanUtil.copyProperties(dto, PointsBasicSetting.class);
|
||||
PointsBasicSetting record = pointsBasicSettingService.getById(shopId);
|
||||
if (record == null) {
|
||||
pointsBasicSettingService.save(entity);
|
||||
} else {
|
||||
pointsBasicSettingService.updateById(entity);
|
||||
}
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
private void validateDTO(PointsBasicSettingDTO dto) {
|
||||
try {
|
||||
Assert.notNull(dto.getShopId(), "{}({})不能为空", "店铺id", "shopId");
|
||||
Assert.notNull(dto.getEnableRewards(), "{}({})不能为空", "开启消费赠送积分", "enableRewards");
|
||||
Assert.notEmpty(dto.getRewardsGroup(), "{}({})不能为空", "赠积分适用群体", "rewardsGroup");
|
||||
Assert.notNull(dto.getConsumeAmount(), "{}({})不能为空", "每消费xx元赠送1积分", "consumeAmount");
|
||||
Assert.notNull(dto.getEnableDeduction(), "{}({})不能为空", "开启下单积分抵扣", "enableDeduction");
|
||||
Assert.notEmpty(dto.getDeductionGroup(), "{}({})不能为空", "抵扣适用群体", "deductionGroup");
|
||||
Assert.notNull(dto.getMinPaymentAmount(), "{}({})不能为空", "下单实付抵扣门槛", "minPaymentAmount");
|
||||
Assert.notNull(dto.getMaxDeductionRatio(), "{}({})不能为空", "下单最高抵扣比例", "maxDeductionRatio");
|
||||
Assert.notNull(dto.getEquivalentPoints(), "{}({})不能为空", "下单抵扣积分比例", "equivalentPoints");
|
||||
Assert.notNull(dto.getEnablePointsMall(), "{}({})不能为空", "开启积分商城", "enablePointsMall");
|
||||
Assert.notEmpty(dto.getBrowseMode(), "{}({})不能为空", "浏览模式", "browseMode");
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new CzgException(e.getMessage());
|
||||
}
|
||||
if (NumberUtil.isLessOrEqual(dto.getMinPaymentAmount(), BigDecimal.ZERO)) {
|
||||
throw new CzgException("下单实付抵扣门槛不能小于等于0");
|
||||
}
|
||||
if (NumberUtil.isLessOrEqual(dto.getMaxDeductionRatio(), BigDecimal.ZERO)) {
|
||||
throw new CzgException("下单最高抵扣比例不能小于等于0");
|
||||
}
|
||||
if (NumberUtil.isGreater(dto.getMaxDeductionRatio(), new BigDecimal("100"))) {
|
||||
throw new CzgException("下单最高抵扣比例不能大于100");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.dto.points.PointsExchangeRecordDTO;
|
||||
import com.czg.account.param.PointsExchangeRecordParam;
|
||||
import com.czg.account.service.PointsExchangeRecordService;
|
||||
import com.czg.account.vo.PointsExchangeSummaryVo;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 积分兑换记录
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-25
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/admin/points/exchangeRecord")
|
||||
public class PointsExchangeRecordController {
|
||||
|
||||
private final PointsExchangeRecordService pointsExchangeRecordService;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("page")
|
||||
@OperationLog("积分兑换-分页")
|
||||
//@SaAdminCheckPermission("pointsExchangeRecord:page")
|
||||
public CzgResult<Page<PointsExchangeRecordDTO>> getPointsExchangeRecordPage(PointsExchangeRecordParam param) {
|
||||
Page<PointsExchangeRecordDTO> page = pointsExchangeRecordService.getPointsExchangeRecordPage(param);
|
||||
return CzgResult.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*
|
||||
* @param id 兑换id
|
||||
*/
|
||||
@GetMapping("{id}")
|
||||
@OperationLog("积分兑换-详情")
|
||||
//@SaAdminCheckPermission("pointsExchangeRecord:info")
|
||||
public CzgResult<PointsExchangeRecordDTO> getPointsExchangeRecordById(@PathVariable("id") Long id) {
|
||||
PointsExchangeRecordDTO data = pointsExchangeRecordService.getPointsExchangeRecordById(id);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销
|
||||
*
|
||||
* @param couponCode 兑换码
|
||||
*/
|
||||
@PostMapping("checkout")
|
||||
@OperationLog("积分兑换-核销")
|
||||
//@SaAdminCheckPermission("pointsExchangeRecord:checkout")
|
||||
public CzgResult<Void> checkout(@RequestParam String couponCode) {
|
||||
pointsExchangeRecordService.checkout(couponCode);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计
|
||||
*/
|
||||
@GetMapping("total")
|
||||
@OperationLog("积分兑换-统计")
|
||||
//@SaAdminCheckPermission("pointsExchangeRecord:total")
|
||||
public CzgResult<PointsExchangeSummaryVo> total(PointsExchangeRecordParam param) {
|
||||
PointsExchangeSummaryVo data = pointsExchangeRecordService.total(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import com.czg.account.dto.points.PointsGoodsSettingDTO;
|
||||
import com.czg.account.entity.PointsGoodsSetting;
|
||||
import com.czg.account.service.PointsGoodsSettingService;
|
||||
import com.czg.enums.DeleteEnum;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.validator.ValidatorUtil;
|
||||
import com.czg.validator.group.DefaultGroup;
|
||||
import com.czg.validator.group.InsertGroup;
|
||||
import com.czg.validator.group.UpdateGroup;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 积分商品设置
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-25
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/admin/points/goodsSetting")
|
||||
public class PointsGoodsSettingController {
|
||||
|
||||
private final PointsGoodsSettingService pointsGoodsSettingService;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@GetMapping("page")
|
||||
@OperationLog("积分商品设置-分页")
|
||||
//@SaAdminCheckPermission("pointsGoodsSetting:page")
|
||||
public CzgResult<Page<PointsGoodsSettingDTO>> getPointsGoodsSettingPage(PointsGoodsSettingDTO param) {
|
||||
Page<PointsGoodsSettingDTO> data = pointsGoodsSettingService.getPointsGoodsSettingPage(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("{id}")
|
||||
@OperationLog("积分商品设置-详情")
|
||||
//@SaAdminCheckPermission("pointsGoodsSetting:info")
|
||||
public CzgResult<PointsGoodsSettingDTO> getPointsGoodsSettingById(@PathVariable("id") Long id) {
|
||||
PointsGoodsSetting entity = pointsGoodsSettingService.getById(id);
|
||||
PointsGoodsSettingDTO data = BeanUtil.copyProperties(entity, PointsGoodsSettingDTO.class);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
@PostMapping
|
||||
@OperationLog("积分商品设置-新增")
|
||||
//@SaAdminCheckPermission("pointsGoodsSetting:add")
|
||||
public CzgResult<Boolean> addPointsGoodsSetting(@RequestBody PointsGoodsSettingDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
ValidatorUtil.validateEntity(dto, InsertGroup.class, DefaultGroup.class);
|
||||
PointsGoodsSetting entity = BeanUtil.copyProperties(dto, PointsGoodsSetting.class);
|
||||
boolean ret = pointsGoodsSettingService.save(entity);
|
||||
return CzgResult.success(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*/
|
||||
@PutMapping
|
||||
@OperationLog("积分商品设置-修改")
|
||||
//@SaAdminCheckPermission("pointsGoodsSetting:update")
|
||||
public CzgResult<Boolean> updatePointsGoodsSetting(@RequestBody PointsGoodsSettingDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
ValidatorUtil.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
PointsGoodsSetting entity = new PointsGoodsSetting();
|
||||
BeanUtil.copyProperties(dto, entity, CopyOptions.create().setIgnoreNullValue(false));
|
||||
boolean ret = pointsGoodsSettingService.updateById(entity);
|
||||
return CzgResult.success(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("{id}")
|
||||
@OperationLog("积分商品设置-删除")
|
||||
//@SaAdminCheckPermission("pointsGoodsSetting:delete")
|
||||
public CzgResult<Void> deletePointsGoodsSetting(@PathVariable("id") Long id) {
|
||||
PointsGoodsSetting entity = pointsGoodsSettingService.getById(id);
|
||||
entity.setDelFlag(DeleteEnum.DELETED.value());
|
||||
pointsGoodsSettingService.updateById(entity);
|
||||
return CzgResult.success();
|
||||
}
|
||||
}
|
||||
@@ -7,45 +7,51 @@ import com.czg.market.vo.UMemberConfigVO;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员相关
|
||||
* 会员
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/member")
|
||||
@RequestMapping("/user")
|
||||
public class UMemberController {
|
||||
@Resource
|
||||
private TbMemberConfigService memberConfigService;
|
||||
|
||||
/**
|
||||
* 获取当前店铺会员开通配置信息
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
*/
|
||||
@GetMapping("/config")
|
||||
@GetMapping("/member/config")
|
||||
public CzgResult<UMemberConfigVO> getConfig(@RequestParam Long shopId) {
|
||||
return CzgResult.success(memberConfigService.detail(shopId, StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有已开通的会员
|
||||
*
|
||||
* @return 列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@GetMapping("/member/list")
|
||||
public CzgResult<List<MemberListVO>> getMemberList() {
|
||||
return CzgResult.success(memberConfigService.getMemberList(StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员信息详情
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@GetMapping("/member/detail")
|
||||
public CzgResult<MemberDetailVO> getDetail(@RequestParam Long shopId) {
|
||||
return CzgResult.success(memberConfigService.getUserDetail(StpKit.USER.getLoginIdAsLong(), shopId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
package com.czg.controller.user;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.czg.account.dto.points.OrderDeductionPointsDTO;
|
||||
import com.czg.account.dto.points.PointsBasicSettingDTO;
|
||||
import com.czg.account.entity.MemberPoints;
|
||||
import com.czg.account.entity.PointsBasicSetting;
|
||||
import com.czg.account.param.ConsumeAwardPointsParam;
|
||||
import com.czg.account.param.PayedDeductPointsParam;
|
||||
import com.czg.account.service.MemberPointsService;
|
||||
import com.czg.account.service.PointsBasicSettingService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 支付相关积分接口
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-25
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/user/points/memberPoints")
|
||||
public class UMemberPointsController {
|
||||
|
||||
private final MemberPointsService memberPointsService;
|
||||
|
||||
private final PointsBasicSettingService pointsBasicSettingService;
|
||||
|
||||
/**
|
||||
* 000-积分基本设置详情
|
||||
*/
|
||||
@GetMapping("pointsBasicSetting")
|
||||
public CzgResult<PointsBasicSettingDTO> getPointsBasicSetting() {
|
||||
Long shopId = StpKit.USER.getShopId();
|
||||
PointsBasicSetting entity = pointsBasicSettingService.getById(shopId);
|
||||
PointsBasicSettingDTO data = BeanUtil.copyProperties(entity, PointsBasicSettingDTO.class);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 001-会员积分账户信息
|
||||
*/
|
||||
@GetMapping("myPoints")
|
||||
public CzgResult<MemberPoints> getMemberPoints() {
|
||||
long shopUserId = StpKit.USER.getLoginIdAsLong();
|
||||
MemberPoints data = memberPointsService.getMemberPoints(shopUserId);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 002-获取订单可用积分及抵扣金额(支付页面使用)
|
||||
*
|
||||
* @param shopUserId 用户id
|
||||
* @param orderAmount 订单金额
|
||||
*/
|
||||
@GetMapping("calcUsablePoints")
|
||||
public CzgResult<OrderDeductionPointsDTO> getMemberUsablePoints(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount) {
|
||||
OrderDeductionPointsDTO usablePoints = memberPointsService.getMemberUsablePoints(shopUserId, orderAmount);
|
||||
return CzgResult.success(usablePoints);
|
||||
}
|
||||
|
||||
/**
|
||||
* 004-根据抵扣金额计算所需积分
|
||||
*
|
||||
* @param shopUserId 用户id
|
||||
* @param orderAmount 订单金额
|
||||
* @param deductionAmount 抵扣金额
|
||||
*/
|
||||
@GetMapping("calcUsedPoints")
|
||||
public CzgResult<Integer> calcUsedPoints(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount, @RequestParam BigDecimal deductionAmount) {
|
||||
int points = memberPointsService.calcUsedPoints(shopUserId, orderAmount, deductionAmount);
|
||||
return CzgResult.success(points);
|
||||
}
|
||||
|
||||
/**
|
||||
* 003-根据积分计算可抵扣金额
|
||||
*
|
||||
* @param shopUserId 用户id
|
||||
* @param orderAmount 订单金额
|
||||
* @param points 使用积分
|
||||
*/
|
||||
@GetMapping("calcDeductionAmount")
|
||||
public CzgResult<BigDecimal> calcDeductionAmount(@RequestParam Long shopUserId, @RequestParam BigDecimal orderAmount, @RequestParam Integer points) {
|
||||
BigDecimal deductionAmount = memberPointsService.calcDeductionAmount(shopUserId, orderAmount, points);
|
||||
return CzgResult.success(deductionAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 005-支付完成扣减积分(支付成功回调中使用)
|
||||
*/
|
||||
@PostMapping("payedDeductPoints")
|
||||
public CzgResult<Boolean> deductPoints(@RequestBody PayedDeductPointsParam param) {
|
||||
//boolean ret = memberPointsService.deductPoints(param.getUserId(), param.getPoints(), param.getContent(), param.getOrderId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 006-消费赠送积分(支付成功回调中使用)
|
||||
*/
|
||||
@PostMapping("consumeAwardPoints")
|
||||
public CzgResult<Void> consumeAwardPoints(@RequestBody ConsumeAwardPointsParam param) {
|
||||
//memberPointsService.consumeAwardPoints(param.getUserId(), param.getOrderId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package com.czg.controller.user;
|
||||
|
||||
import com.czg.account.dto.points.PointsExchangeRecordDTO;
|
||||
import com.czg.account.dto.points.PointsGoodsSettingDTO;
|
||||
import com.czg.account.param.PointsExchangeCfParam;
|
||||
import com.czg.account.param.PointsExchangeRecordParam;
|
||||
import com.czg.account.param.PointsOrderCreateParam;
|
||||
import com.czg.account.param.PointsOrderPayParam;
|
||||
import com.czg.account.service.PointsExchangeRecordService;
|
||||
import com.czg.account.service.PointsGoodsSettingService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 积分商城
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-25
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/user/points/mall")
|
||||
public class UPointsMallController {
|
||||
|
||||
private final PointsGoodsSettingService pointsGoodsSettingService;
|
||||
private final PointsExchangeRecordService pointsExchangeRecordService;
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
@GetMapping("/goods/page")
|
||||
public CzgResult<Page<PointsGoodsSettingDTO>> getPointsGoodsSettingPage(PointsGoodsSettingDTO param) {
|
||||
Page<PointsGoodsSettingDTO> data = pointsGoodsSettingService.getPointsGoodsSettingPage(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成订单
|
||||
*/
|
||||
@PostMapping("/order/create")
|
||||
public CzgResult<PointsExchangeRecordDTO> create(@RequestBody PointsOrderCreateParam param) {
|
||||
PointsExchangeRecordDTO data = pointsExchangeRecordService.create(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订单
|
||||
*/
|
||||
@PostMapping("/order/cancel")
|
||||
public CzgResult<Void> cancel(@RequestBody PointsExchangeCfParam param) {
|
||||
pointsExchangeRecordService.cancel(param);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付订单
|
||||
*/
|
||||
@PostMapping("/order/pay")
|
||||
public CzgResult<PointsExchangeRecordDTO> pay(@RequestBody PointsOrderPayParam param) {
|
||||
PointsExchangeRecordDTO data = pointsExchangeRecordService.pay(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请退单
|
||||
*/
|
||||
@PostMapping("/order/refund")
|
||||
public CzgResult<Void> refund(@RequestBody PointsExchangeCfParam param) {
|
||||
pointsExchangeRecordService.refund(param);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的兑换记录
|
||||
*/
|
||||
@GetMapping("/order/page")
|
||||
public CzgResult<Page<PointsExchangeRecordDTO>> getPointsExchangeRecordPage(PointsExchangeRecordParam param) {
|
||||
param.setShopUserId(StpKit.USER.getLoginIdAsLong());
|
||||
Page<PointsExchangeRecordDTO> page = pointsExchangeRecordService.getPointsExchangeRecordPage(param);
|
||||
return CzgResult.success(page);
|
||||
}
|
||||
}
|
||||
@@ -3,18 +3,13 @@ package com.czg.controller.user;
|
||||
import com.czg.account.dto.shopuser.ShopUserAddDTO;
|
||||
import com.czg.account.dto.shopuser.ShopUserDetailDTO;
|
||||
import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
|
||||
import com.czg.account.entity.MemberPointsLog;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.entity.ShopUserFlow;
|
||||
import com.czg.account.service.MemberPointsLogService;
|
||||
import com.czg.account.service.ShopUserFlowService;
|
||||
import com.czg.account.service.UShopUserService;
|
||||
import com.czg.account.vo.MemberPointsLogVO;
|
||||
import com.czg.account.vo.PointsShopListVO;
|
||||
import com.czg.account.vo.ShopUserFlowInfoVO;
|
||||
import com.czg.annotation.Debounce;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.utils.MyQueryWrapper;
|
||||
@@ -25,8 +20,6 @@ import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺会员相关
|
||||
*
|
||||
@@ -39,8 +32,6 @@ public class UShopUserController {
|
||||
private UShopUserService shopUserService;
|
||||
@Resource
|
||||
private ShopUserFlowService shopUserFlowService;
|
||||
@Resource
|
||||
private MemberPointsLogService memberPointsLogService;
|
||||
|
||||
/**
|
||||
* 获取当前店铺会员信息
|
||||
@@ -109,39 +100,4 @@ public class UShopUserController {
|
||||
return CzgResult.success(shopUserFlowService.getOne(new QueryWrapper().eq(ShopUserFlow::getShopId, shopId)
|
||||
.eq(ShopUserFlow::getUserId, StpKit.USER.getLoginIdAsLong()).eq(ShopUserFlow::getId, id)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户所有门店下积分列表
|
||||
*/
|
||||
@GetMapping("/pointsShopList")
|
||||
public CzgResult<List<PointsShopListVO>> getList(@RequestParam(required = false) String shopName) {
|
||||
return CzgResult.success(memberPointsLogService.getList(StpKit.USER.getLoginIdAsLong(), shopName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取积分明细
|
||||
* @return 分页数据
|
||||
*/
|
||||
@GetMapping("/pointsRecord")
|
||||
public CzgResult<Page<MemberPointsLogVO>> getPointsRecord(@RequestParam Long shopId) {
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, StpKit.USER.getLoginIdAsLong());
|
||||
return CzgResult.success(memberPointsLogService.pageAs(PageUtil.buildPage(), new MyQueryWrapper().eq(MemberPointsLog::getShopId, shopId)
|
||||
.eq(MemberPointsLog::getShopUserId, shopUser.getId())
|
||||
.selectAll(MemberPointsLog.class)
|
||||
.select(ShopInfo::getShopName)
|
||||
.leftJoin(ShopInfo.class).on(MemberPointsLog::getShopId, ShopInfo::getId)
|
||||
.orderBy(MemberPointsLog::getId, false), MemberPointsLogVO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取积分明细详情
|
||||
* @param id 明细id
|
||||
* @return 明细数据
|
||||
*/
|
||||
@GetMapping("/pointsRecord/detail")
|
||||
public CzgResult<MemberPointsLog> getPointsRecordDetail(@RequestParam Long id,@RequestParam Long shopId) {
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, StpKit.USER.getLoginIdAsLong());
|
||||
return CzgResult.success(memberPointsLogService.getOne(new QueryWrapper().eq(MemberPointsLog::getShopId, shopId)
|
||||
.eq(MemberPointsLog::getShopUserId, shopUser.getId()).eq(MemberPointsLog::getId, id)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.czg.task;
|
||||
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.PointsExchangeRecordService;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopUserFlowService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 积分商品兑换定时任务
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2025-03-01 15:49
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PointsProductExchangeTask {
|
||||
|
||||
@Resource
|
||||
private PointsExchangeRecordService pointsExchangeRecordService;
|
||||
@Resource
|
||||
private ShopUserFlowService shopUserFlowService;
|
||||
@Resource
|
||||
private ShopInfoService shopInfoService;
|
||||
@Resource
|
||||
private ShopUserService shopUserService;
|
||||
|
||||
/**
|
||||
* order 过期
|
||||
*/
|
||||
@Scheduled(cron = "0 */1 * * * ?")
|
||||
public void run() {
|
||||
pointsExchangeRecordService.authCancel();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.market.dto.MkPointsConfigDTO;
|
||||
import com.czg.market.dto.MkPointsUserDTO;
|
||||
import com.czg.market.entity.MkPointsConfig;
|
||||
import com.czg.market.entity.MkPointsUserRecord;
|
||||
import com.czg.market.service.MkPointsConfigService;
|
||||
import com.czg.market.service.MkPointsUserRecordService;
|
||||
import com.czg.market.service.MkPointsUserService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.utils.CzgStrUtils;
|
||||
import com.czg.validator.ValidatorUtil;
|
||||
import com.czg.validator.group.DefaultGroup;
|
||||
import com.czg.validator.group.InsertGroup;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 积分配置
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/points/")
|
||||
public class PointsConfigController {
|
||||
|
||||
@Resource
|
||||
private MkPointsConfigService pointsConfigService;
|
||||
@Resource
|
||||
private MkPointsUserService pointsUserService;
|
||||
@Resource
|
||||
private MkPointsUserRecordService userRecordService;
|
||||
|
||||
/**
|
||||
* 积分:配置:详情
|
||||
*/
|
||||
@GetMapping("/config")
|
||||
@SaAdminCheckPermission(value = "points:config:info", name = "积分-配置-详情")
|
||||
public CzgResult<MkPointsConfig> getPointsBasicSetting() {
|
||||
MkPointsConfig entity = pointsConfigService.getById(StpKit.USER.getShopId());
|
||||
return CzgResult.success(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分:配置:新增/更新
|
||||
*/
|
||||
@PostMapping("/config")
|
||||
@SaAdminCheckPermission(value = "points:config:up", name = "积分-配置-新增/更新")
|
||||
public CzgResult<Void> savePointsBasicSetting(@RequestBody @Validated MkPointsConfigDTO dto) {
|
||||
Long shopId = StpKit.USER.getShopId();
|
||||
dto.setShopId(shopId);
|
||||
ValidatorUtil.validateEntity(dto, InsertGroup.class, DefaultGroup.class);
|
||||
MkPointsConfig entity = BeanUtil.copyProperties(dto, MkPointsConfig.class);
|
||||
MkPointsConfig record = pointsConfigService.getById(shopId);
|
||||
if (record == null) {
|
||||
pointsConfigService.save(entity);
|
||||
} else {
|
||||
pointsConfigService.saveOrUpdate(entity);
|
||||
}
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分:用户:列表
|
||||
*/
|
||||
@GetMapping("/userPage")
|
||||
@SaAdminCheckPermission(value = "points:user:list", name = "积分-用户-积分列表")
|
||||
public CzgResult<Page<MkPointsUserDTO>> getPointsUserPage(
|
||||
@RequestParam(required = false) @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确") String phone,
|
||||
@RequestParam(required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(required = false, defaultValue = "10") Integer size) {
|
||||
return CzgResult.success(pointsUserService.getPointsUserPage(CzgStrUtils.getStrOrNull(phone), page, size));
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分:用户:积分详情
|
||||
*/
|
||||
@GetMapping("/userRecord")
|
||||
@SaAdminCheckPermission(value = "points:user:record", name = "积分-用户-积分记录")
|
||||
public CzgResult<Page<MkPointsUserRecord>> getPointsUserRecord(@RequestParam(required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(required = false, defaultValue = "10") Integer size,
|
||||
@RequestParam Long id) {
|
||||
return CzgResult.success(userRecordService.pageByPointsUserId(page, size, id));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.czg.BaseQueryParam;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.enums.DeleteEnum;
|
||||
import com.czg.market.dto.MkPointsGoodsDTO;
|
||||
import com.czg.market.entity.MkPointsGoods;
|
||||
import com.czg.market.service.MkPointsGoodsService;
|
||||
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/pointsGoods")
|
||||
public class PointsGoodsController {
|
||||
|
||||
@Resource
|
||||
private MkPointsGoodsService pointsGoodsSettingService;
|
||||
|
||||
/**
|
||||
* 积分:商品:列表
|
||||
*/
|
||||
@GetMapping("page")
|
||||
@SaAdminCheckPermission(value = "points:goods:info", name = "积分-商品-列表")
|
||||
public CzgResult<Page<MkPointsGoods>> getPointsGoodsSettingPage(BaseQueryParam param) {
|
||||
Page<MkPointsGoods> data = pointsGoodsSettingService.getPointsGoodsPage(param, StpKit.USER.getShopId());
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@SaAdminCheckPermission(value = "points:goods:info", name = "积分-商品-列表")
|
||||
public CzgResult<MkPointsGoods> getPointsGoodsSettingById(@PathVariable("id") Long id) {
|
||||
return CzgResult.success(pointsGoodsSettingService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 积分:商品:新增/修改
|
||||
*/
|
||||
@PostMapping
|
||||
@SaAdminCheckPermission(value = "points:goods:up", name = "积分-商品-新增/修改")
|
||||
public CzgResult<Boolean> addPointsGoodsSetting(@RequestBody @Validated MkPointsGoodsDTO dto) {
|
||||
dto.setShopId(StpKit.USER.getShopId());
|
||||
MkPointsGoods entity = BeanUtil.copyProperties(dto, MkPointsGoods.class);
|
||||
boolean ret = pointsGoodsSettingService.saveOrUpdate(entity);
|
||||
return CzgResult.success(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
@SaAdminCheckPermission(value = "points:goods:delete", name = "积分-商品-新增/修改")
|
||||
public CzgResult<Void> deletePointsGoodsSetting(@PathVariable("id") Long id) {
|
||||
MkPointsGoods entity = pointsGoodsSettingService.getById(id);
|
||||
entity.setDelFlag(DeleteEnum.DELETED.value());
|
||||
pointsGoodsSettingService.updateById(entity);
|
||||
return CzgResult.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.czg.controller.user;
|
||||
|
||||
import com.czg.account.vo.PointsShopListVO;
|
||||
import com.czg.market.entity.MkPointsConfig;
|
||||
import com.czg.market.entity.MkPointsUser;
|
||||
import com.czg.market.entity.MkPointsUserRecord;
|
||||
import com.czg.market.service.MkPointsConfigService;
|
||||
import com.czg.market.service.MkPointsUserRecordService;
|
||||
import com.czg.market.service.MkPointsUserService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 积分配置
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/point/")
|
||||
public class UPointsController {
|
||||
|
||||
@Resource
|
||||
private MkPointsConfigService pointsConfigService;
|
||||
@Resource
|
||||
private MkPointsUserService pointsUserService;
|
||||
@Resource
|
||||
private MkPointsUserRecordService pointsUserRecordService;
|
||||
|
||||
/**
|
||||
* 获取配置
|
||||
*/
|
||||
@GetMapping("pointsConfig")
|
||||
public CzgResult<MkPointsConfig> getPointsConfig(@RequestParam(required = false) Long shopId) {
|
||||
if (shopId == null) {
|
||||
shopId = StpKit.USER.getShopId();
|
||||
}
|
||||
return CzgResult.success(pointsConfigService.getById(shopId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户积分 包括配置信息
|
||||
* {
|
||||
* "pointsConfig": 配置信息,
|
||||
* "pointsUser": 用户积分信息
|
||||
* }
|
||||
*/
|
||||
@GetMapping("userPoints")
|
||||
public CzgResult<Map<String, Object>> userPoints(@RequestParam(required = false) Long shopUserId) {
|
||||
Long shopId = StpKit.USER.getShopId();
|
||||
Map<String, Object> result = new HashMap<>(2);
|
||||
MkPointsConfig pointsConfig = pointsConfigService.getById(shopId);
|
||||
MkPointsUser pointsUser = pointsUserService.getOne(QueryWrapper.create().eq(MkPointsUser::getShopId, shopId).eq(MkPointsUser::getUserId, shopUserId));
|
||||
result.put("pointsConfig", pointsConfig == null ? "" : pointsConfig);
|
||||
result.put("pointsUser", pointsUser == null ? "" : pointsUser);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户所有门店下积分列表
|
||||
*/
|
||||
@GetMapping("/shopList")
|
||||
public CzgResult<List<PointsShopListVO>> pointsShopList(@RequestParam(required = false) String shopName) {
|
||||
return CzgResult.success(pointsUserService.pointsShopList(StpKit.USER.getLoginIdAsLong(), shopName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取积分明细
|
||||
*
|
||||
* @return 分页数据
|
||||
*/
|
||||
@GetMapping("/userRecord")
|
||||
public CzgResult<Page<MkPointsUserRecord>> getPointsRecord(@RequestParam(required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(required = false, defaultValue = "10") Integer size,
|
||||
@RequestParam Long id) {
|
||||
return CzgResult.success(pointsUserRecordService.page(Page.of(page, size),
|
||||
QueryWrapper.create().eq(MkPointsUserRecord::getMkPointsUserId, id).orderBy(MkPointsUserRecord::getCreateTime, false)));
|
||||
}
|
||||
}
|
||||
@@ -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