积分
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.czg.controller.user;
|
||||
|
||||
import com.czg.market.service.TbMemberConfigService;
|
||||
import com.czg.market.vo.MemberDetailVO;
|
||||
import com.czg.market.vo.MemberListVO;
|
||||
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.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")
|
||||
public class UMemberController {
|
||||
@Resource
|
||||
private TbMemberConfigService memberConfigService;
|
||||
|
||||
/**
|
||||
* 获取当前店铺会员开通配置信息
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
*/
|
||||
@GetMapping("/member/config")
|
||||
public CzgResult<UMemberConfigVO> getConfig(@RequestParam Long shopId) {
|
||||
return CzgResult.success(memberConfigService.detail(shopId, StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有已开通的会员
|
||||
*
|
||||
* @return 列表
|
||||
*/
|
||||
@GetMapping("/member/list")
|
||||
public CzgResult<List<MemberListVO>> getMemberList() {
|
||||
return CzgResult.success(memberConfigService.getMemberList(StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会员信息详情
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
*/
|
||||
@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();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user