会员积分代码提交
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.entity.MemberPoints;
|
||||
import com.czg.account.param.MemberPointsParam;
|
||||
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.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/member-points")
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
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/member-points-log")
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.czg.account.dto.points.PointsBasicSettingDTO;
|
||||
import com.czg.account.entity.PointsBasicSetting;
|
||||
import com.czg.account.service.PointsBasicSettingService;
|
||||
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.*;
|
||||
|
||||
|
||||
/**
|
||||
* 积分基本设置
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-25
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/admin/points/basic-setting")
|
||||
public class PointsBasicSettingController {
|
||||
|
||||
private final PointsBasicSettingService pointsBasicSettingService;
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@GetMapping()
|
||||
@OperationLog("积分基本设置-详情")
|
||||
//@SaAdminCheckPermission("basicSetting:info")
|
||||
public CzgResult<PointsBasicSettingDTO> getPointsBasicSettingByShopId() {
|
||||
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);
|
||||
PointsBasicSetting entity = BeanUtil.copyProperties(dto, PointsBasicSetting.class);
|
||||
pointsBasicSettingService.saveOrUpdate(entity);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.dto.points.PointsExchangeRecordDTO;
|
||||
import com.czg.account.param.PointsExchangeCfParam;
|
||||
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/exchange-record")
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
@PostMapping("cancel")
|
||||
@OperationLog("积分兑换-取消")
|
||||
//@SaAdminCheckPermission("pointsExchangeRecord:cancel")
|
||||
public CzgResult<Void> cancel(@RequestBody PointsExchangeCfParam param) {
|
||||
pointsExchangeRecordService.cancel(param);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 退单
|
||||
*/
|
||||
@PostMapping("refund")
|
||||
@OperationLog("积分兑换-退单")
|
||||
//@SaAdminCheckPermission("pointsExchangeRecord:refund")
|
||||
public CzgResult<Void> refund(@RequestBody PointsExchangeCfParam param) {
|
||||
pointsExchangeRecordService.refund(param);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计
|
||||
*/
|
||||
@GetMapping("total")
|
||||
@OperationLog("积分兑换-统计")
|
||||
//@SaAdminCheckPermission("pointsExchangeRecord:total")
|
||||
public CzgResult<PointsExchangeSummaryVo> total(PointsExchangeRecordParam param) {
|
||||
PointsExchangeSummaryVo data = pointsExchangeRecordService.total(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
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/goods-setting")
|
||||
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,96 @@
|
||||
package com.czg.controller.user;
|
||||
|
||||
import com.czg.account.dto.points.OrderDeductionPointsDTO;
|
||||
import com.czg.account.entity.MemberPoints;
|
||||
import com.czg.account.param.ConsumeAwardPointsParam;
|
||||
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.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/member-points")
|
||||
public class UMemberPointsController {
|
||||
|
||||
private final MemberPointsService memberPointsService;
|
||||
|
||||
/**
|
||||
* 获取会员积分等信息
|
||||
*/
|
||||
@GetMapping("my-points")
|
||||
@OperationLog("会员积分-获取会员积分等信息")
|
||||
public CzgResult<MemberPoints> getMemberPoints() {
|
||||
long userId = StpKit.USER.getLoginIdAsLong();
|
||||
MemberPoints data = memberPointsService.getMemberPoints(userId);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单可用积分及抵扣金额
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param orderAmount 订单金额
|
||||
*/
|
||||
@GetMapping("calc-usable-points")
|
||||
@OperationLog("获取订单可用积分及抵扣金额")
|
||||
public CzgResult<OrderDeductionPointsDTO> getMemberUsablePoints(@RequestParam Long userId, @RequestParam BigDecimal orderAmount) {
|
||||
OrderDeductionPointsDTO usablePoints = memberPointsService.getMemberUsablePoints(userId, orderAmount);
|
||||
return CzgResult.success(usablePoints);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据抵扣金额计算所需积分
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param orderAmount 订单金额
|
||||
* @param deductionAmount 抵扣金额
|
||||
*/
|
||||
@GetMapping("calc-used-points")
|
||||
@OperationLog("根据抵扣金额计算所需积分")
|
||||
public CzgResult<Integer> calcUsedPoints(@RequestParam Long userId, @RequestParam BigDecimal orderAmount, @RequestParam BigDecimal deductionAmount) {
|
||||
int points = memberPointsService.calcUsedPoints(userId, orderAmount, deductionAmount);
|
||||
return CzgResult.success(points);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据积分计算可抵扣金额
|
||||
*/
|
||||
@GetMapping("calc-deduction-amount")
|
||||
@OperationLog("根据积分计算可抵扣金额")
|
||||
public CzgResult<BigDecimal> calcDeductionAmount(@RequestParam Long memberId, @RequestParam BigDecimal orderAmount, @RequestParam Integer points) {
|
||||
BigDecimal deductionAmount = memberPointsService.calcDeductionAmount(memberId, orderAmount, points);
|
||||
return CzgResult.success(deductionAmount);
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付完成扣减积分(支付成功回调中使用)
|
||||
*/
|
||||
@PostMapping("payed-deduct-points")
|
||||
@OperationLog("支付完成扣减积分(支付成功回调中使用)")
|
||||
public CzgResult<Boolean> deductPoints(@RequestBody PayedDeductPointsParam param) {
|
||||
boolean ret = memberPointsService.deductPoints(param.getUserId(), param.getPoints(), param.getContent(), param.getOrderId());
|
||||
return CzgResult.success(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* 消费赠送积分(支付成功回调中使用)
|
||||
*/
|
||||
@PostMapping("consume-award-points")
|
||||
@OperationLog("消费赠送积分(支付成功回调中使用)")
|
||||
public CzgResult<Void> consumeAwardPoints(@RequestBody ConsumeAwardPointsParam param) {
|
||||
memberPointsService.consumeAwardPoints(param.getUserId(), param.getOrderId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user