This commit is contained in:
2025-12-09 18:41:30 +08:00
parent 82efd1886f
commit 76b93cf8b2
93 changed files with 2131 additions and 3112 deletions

View File

@@ -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));
}
}

View File

@@ -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();
}
}

View File

@@ -1,51 +0,0 @@
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.*;
import java.util.List;
/**
* 会员相关
*
* @author Administrator
*/
@RestController
@RequestMapping("/user/member")
public class UMemberController {
@Resource
private TbMemberConfigService memberConfigService;
/**
* 获取当前店铺会员开通配置信息
* @param shopId 店铺id
*/
@GetMapping("/config")
public CzgResult<UMemberConfigVO> getConfig(@RequestParam Long shopId) {
return CzgResult.success(memberConfigService.detail(shopId, StpKit.USER.getLoginIdAsLong()));
}
/**
* 获取所有已开通的会员
* @return 列表
*/
@GetMapping("/list")
public CzgResult<List<MemberListVO>> getMemberList() {
return CzgResult.success(memberConfigService.getMemberList(StpKit.USER.getLoginIdAsLong()));
}
/**
* 获取会员信息详情
* @param shopId 店铺id
*/
@GetMapping("/detail")
public CzgResult<MemberDetailVO> getDetail(@RequestParam Long shopId) {
return CzgResult.success(memberConfigService.getUserDetail(StpKit.USER.getLoginIdAsLong(), shopId));
}
}

View File

@@ -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)));
}
}