会员管理

This commit is contained in:
PQZ 2024-09-19 22:54:12 +08:00
parent c65ea8d58f
commit 05780dd983
27 changed files with 343 additions and 622 deletions

View File

@ -53,4 +53,6 @@ public class BaseConstants {
public static final String PROPERTY_EXPIRED = "property_expired";
/** 档案分类字典 */
public static final String ARCHIVES_TYPE = "archives_type";
/**卡片关联关系主表*/
public static final String ACTIVE_RULE_COUPON_ACTIVE = "dl_active_main";
}

View File

@ -1,31 +1,9 @@
package cn.iocoder.yudao.module.member.controller.admin;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.member.entity.ActiveRule;
import cn.iocoder.yudao.module.member.service.ActiveRuleService;
import cn.iocoder.yudao.module.member.vo.ActiveRulePageReqVO;
import cn.iocoder.yudao.module.member.vo.ActiveRuleRespVO;
import cn.iocoder.yudao.module.member.vo.ActiveRuleSaveReqVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "管理后台 - 营销活动规则")
@RestController
@ -33,61 +11,5 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
public class ActiveRuleController {
@Resource
private ActiveRuleService activeRuleService;
@PostMapping("/create")
@Operation(summary = "创建营销活动规则")
@PreAuthorize("@ss.hasPermission('member:active-rule:create')")
public CommonResult<String> createActiveRule(@Valid @RequestBody ActiveRuleSaveReqVO createReqVO) {
return success(activeRuleService.createActiveRule(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新营销活动规则")
@PreAuthorize("@ss.hasPermission('member:active-rule:update')")
public CommonResult<Boolean> updateActiveRule(@Valid @RequestBody ActiveRuleSaveReqVO updateReqVO) {
activeRuleService.updateActiveRule(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除营销活动规则")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('member:active-rule:delete')")
public CommonResult<Boolean> deleteActiveRule(@RequestParam("id") String id) {
activeRuleService.deleteActiveRule(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得营销活动规则")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('member:active-rule:query')")
public CommonResult<ActiveRuleRespVO> getActiveRule(@RequestParam("id") String id) {
ActiveRule activeRule = activeRuleService.getActiveRule(id);
return success(BeanUtils.toBean(activeRule, ActiveRuleRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得营销活动规则分页")
@PreAuthorize("@ss.hasPermission('member:active-rule:query')")
public CommonResult<PageResult<ActiveRuleRespVO>> getActiveRulePage(@Valid ActiveRulePageReqVO pageReqVO) {
PageResult<ActiveRule> pageResult = activeRuleService.getActiveRulePage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ActiveRuleRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出营销活动规则 Excel")
@PreAuthorize("@ss.hasPermission('member:active-rule:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportActiveRuleExcel(@Valid ActiveRulePageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ActiveRule> list = activeRuleService.getActiveRulePage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "营销活动规则.xls", "数据", ActiveRuleRespVO.class,
BeanUtils.toBean(list, ActiveRuleRespVO.class));
}
}

View File

@ -1,31 +1,9 @@
package cn.iocoder.yudao.module.member.controller.admin;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.member.entity.ActiveRuleCoupon;
import cn.iocoder.yudao.module.member.service.ActiveRuleCouponService;
import cn.iocoder.yudao.module.member.vo.ActiveRuleCouponPageReqVO;
import cn.iocoder.yudao.module.member.vo.ActiveRuleCouponRespVO;
import cn.iocoder.yudao.module.member.vo.ActiveRuleCouponSaveReqVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.List;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Tag(name = "管理后台 - 营销活动、规则及会员等级与基础卡券关联关系")
@RestController
@ -33,61 +11,5 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated
public class ActiveRuleCouponController {
@Resource
private ActiveRuleCouponService activeRuleCouponService;
@PostMapping("/create")
@Operation(summary = "创建营销活动、规则及会员等级与基础卡券关联关系")
@PreAuthorize("@ss.hasPermission('member:active-rule-coupon:create')")
public CommonResult<String> createActiveRuleCoupon(@Valid @RequestBody ActiveRuleCouponSaveReqVO createReqVO) {
return success(activeRuleCouponService.createActiveRuleCoupon(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新营销活动、规则及会员等级与基础卡券关联关系")
@PreAuthorize("@ss.hasPermission('member:active-rule-coupon:update')")
public CommonResult<Boolean> updateActiveRuleCoupon(@Valid @RequestBody ActiveRuleCouponSaveReqVO updateReqVO) {
activeRuleCouponService.updateActiveRuleCoupon(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除营销活动、规则及会员等级与基础卡券关联关系")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('member:active-rule-coupon:delete')")
public CommonResult<Boolean> deleteActiveRuleCoupon(@RequestParam("id") String id) {
activeRuleCouponService.deleteActiveRuleCoupon(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得营销活动、规则及会员等级与基础卡券关联关系")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('member:active-rule-coupon:query')")
public CommonResult<ActiveRuleCouponRespVO> getActiveRuleCoupon(@RequestParam("id") String id) {
ActiveRuleCoupon activeRuleCoupon = activeRuleCouponService.getActiveRuleCoupon(id);
return success(BeanUtils.toBean(activeRuleCoupon, ActiveRuleCouponRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得营销活动、规则及会员等级与基础卡券关联关系分页")
@PreAuthorize("@ss.hasPermission('member:active-rule-coupon:query')")
public CommonResult<PageResult<ActiveRuleCouponRespVO>> getActiveRuleCouponPage(@Valid ActiveRuleCouponPageReqVO pageReqVO) {
PageResult<ActiveRuleCoupon> pageResult = activeRuleCouponService.getActiveRuleCouponPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ActiveRuleCouponRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出营销活动、规则及会员等级与基础卡券关联关系 Excel")
@PreAuthorize("@ss.hasPermission('member:active-rule-coupon:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportActiveRuleCouponExcel(@Valid ActiveRuleCouponPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<ActiveRuleCoupon> list = activeRuleCouponService.getActiveRuleCouponPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "营销活动、规则及会员等级与基础卡券关联关系.xls", "数据", ActiveRuleCouponRespVO.class,
BeanUtils.toBean(list, ActiveRuleCouponRespVO.class));
}
}

View File

@ -71,6 +71,22 @@ public class MemberCouponController {
return success(true);
}
/**
* 复制附属权益
*
* @param saveReqVO MemberCouponSaveReqVO实体
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
* @author PQZ
* @date 21:34 2024/9/19
**/
@PostMapping("/copy")
@Operation(summary = "复制附属权益")
@PreAuthorize("@ss.hasPermission('member:coupon:update')")
public CommonResult<Boolean> copyCoupon(@Valid @RequestBody MemberCouponSaveReqVO saveReqVO) {
couponService.copyMemberCoupon(saveReqVO);
return success(true);
}
/**
* 删除基础卡券
*
@ -101,8 +117,7 @@ public class MemberCouponController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('member:coupon:query')")
public CommonResult<MemberCouponRespVO> getCoupon(@RequestParam("id") String id) {
MemberCoupon coupon = couponService.getCoupon(id);
return success(BeanUtils.toBean(coupon, MemberCouponRespVO.class));
return success(couponService.getCoupon(id));
}
/**

View File

@ -54,8 +54,12 @@ public class ActiveMain extends TenantBaseDO {
*/
private String remark;
/**
* 是否区分会员等级
* 是否有充值规则
*/
private String isMember;
private String isRechRule;
/**优惠券是否打包(打包则参加活动关联优惠券全部赠与,非打包则选择赠与)*/
private String isPack;
/**是否关联卡券*/
private String isCoupon;
}

View File

@ -24,7 +24,6 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
@NoArgsConstructor
@AllArgsConstructor
public class MemberCoupon extends TenantBaseDO {
/**
* 主键标识
*/
@ -60,6 +59,8 @@ public class MemberCoupon extends TenantBaseDO {
private BigDecimal amount;
/**单价*/
private BigDecimal unitPrice;
/**附属权益id*/
private String parentId;
/**
* 效果图片
*/
@ -72,5 +73,4 @@ public class MemberCoupon extends TenantBaseDO {
* 核销规则记次核销面额核销一次性核销
*/
private String outRule;
}

View File

@ -34,12 +34,13 @@ public interface ActiveMainService extends IService<ActiveMain> {
void deleteActiveMain(String id);
/**
* 获得营销活动
*
* @param id 编号
* @return 营销活动
*/
ActiveMain getActiveMain(String id);
* 根据营销活动获取详情
* @author PQZ
* @date 18:23 2024/9/19
* @param id 营销活动id
* @return cn.iocoder.yudao.module.member.vo.ActiveMainRespVO
**/
ActiveMainRespVO getActiveMain(String id);
/**
* 分页查询营销活动

View File

@ -1,12 +1,10 @@
package cn.iocoder.yudao.module.member.service;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.entity.ActiveRuleCoupon;
import cn.iocoder.yudao.module.member.vo.ActiveRuleCouponPageReqVO;
import cn.iocoder.yudao.module.member.vo.ActiveRuleCouponSaveReqVO;
import cn.iocoder.yudao.module.member.entity.MemberCoupon;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
import java.util.List;
/**
* 营销活动规则及会员等级与基础卡券关联关系 Service 接口
@ -16,41 +14,33 @@ import javax.validation.Valid;
public interface ActiveRuleCouponService extends IService<ActiveRuleCoupon> {
/**
* 创建营销活动规则及会员等级与基础卡券关联关系
* 根据主表id删除关联关系
*
* @param createReqVO 创建信息
* @return 编号
*/
String createActiveRuleCoupon(@Valid ActiveRuleCouponSaveReqVO createReqVO);
* @param id 主表id
* @author PQZ
* @date 17:56 2024/9/19
**/
void deleteByMainId(String id);
/**
* 更新营销活动规则及会员等级与基础卡券关联关系
* 保存关联关系
*
* @param updateReqVO 更新信息
*/
void updateActiveRuleCoupon(@Valid ActiveRuleCouponSaveReqVO updateReqVO);
* @param list 卡券id集合
* @param mainId 主表id
* @param mainTable 主表名称
* @author PQZ
* @date 17:57 2024/9/19
**/
void saveActiveRuleCoupon(List<MemberCoupon> list, String mainId, String mainTable);
/**
* 删除营销活动规则及会员等级与基础卡券关联关系
* 根据主表id查询关联关系
*
* @param id 编号
*/
void deleteActiveRuleCoupon(String id);
/**
* 获得营销活动规则及会员等级与基础卡券关联关系
*
* @param id 编号
* @return 营销活动规则及会员等级与基础卡券关联关系
*/
ActiveRuleCoupon getActiveRuleCoupon(String id);
/**
* 获得营销活动规则及会员等级与基础卡券关联关系分页
*
* @param pageReqVO 分页查询
* @return 营销活动规则及会员等级与基础卡券关联关系分页
*/
PageResult<ActiveRuleCoupon> getActiveRuleCouponPage(ActiveRuleCouponPageReqVO pageReqVO);
* @param id 主表id
* @return java.util.List<cn.iocoder.yudao.module.member.entity.ActiveRuleCoupon>
* @author PQZ
* @date 17:59 2024/9/19
**/
List<MemberCoupon> queryByMainId(String id);
}

View File

@ -1,12 +1,9 @@
package cn.iocoder.yudao.module.member.service;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.entity.ActiveRule;
import cn.iocoder.yudao.module.member.vo.ActiveRulePageReqVO;
import cn.iocoder.yudao.module.member.vo.ActiveRuleSaveReqVO;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
import java.util.List;
/**
* 营销活动规则 Service 接口
@ -16,41 +13,30 @@ import javax.validation.Valid;
public interface ActiveRuleService extends IService<ActiveRule> {
/**
* 创建营销活动规则
* 保存活动规则
*
* @param createReqVO 创建信息
* @return 编号
*/
String createActiveRule(@Valid ActiveRuleSaveReqVO createReqVO);
* @param list 活动规则集合
* @param activeId 活动id
* @author PQZ
* @date 18:15 2024/9/19
**/
void saveActiveRule(List<ActiveRule> list, String activeId);
/**
* 更新营销活动规则
*
* @param updateReqVO 更新信息
*/
void updateActiveRule(@Valid ActiveRuleSaveReqVO updateReqVO);
* 根据活动id删除活动规则
* @author PQZ
* @date 18:16 2024/9/19
* @param activeId 活动id
**/
void deleteByActiveId(String activeId);
/**
* 删除营销活动规则
*
* @param id 编号
*/
void deleteActiveRule(String id);
/**
* 获得营销活动规则
*
* @param id 编号
* @return 营销活动规则
*/
ActiveRule getActiveRule(String id);
/**
* 获得营销活动规则分页
*
* @param pageReqVO 分页查询
* @return 营销活动规则分页
*/
PageResult<ActiveRule> getActiveRulePage(ActiveRulePageReqVO pageReqVO);
* 根据活动id查询活动规则
* @author PQZ
* @date 18:17 2024/9/19
* @param activeId 活动id
* @return java.util.List<cn.iocoder.yudao.module.member.entity.ActiveRule>
**/
List<ActiveRule> listByActiveId(String activeId);
}

View File

@ -35,12 +35,13 @@ public interface MemberCouponService extends IService<MemberCoupon> {
void deleteCoupon(String id);
/**
* 获得基础卡券
*
* @param id 编号
* @return 基础卡券
*/
MemberCoupon getCoupon(String id);
* 查询基础卡券及附属信息
* @author PQZ
* @date 21:55 2024/9/19
* @param id 卡券id
* @return cn.iocoder.yudao.module.member.vo.MemberCouponRespVO
**/
MemberCouponRespVO getCoupon(String id);
/**
* 分页查询基础卡券信息
@ -53,4 +54,12 @@ public interface MemberCouponService extends IService<MemberCoupon> {
**/
IPage<MemberCouponRespVO> queryListPage(MemberCouponPageReqVO pageReqVO, Page<MemberCouponRespVO> page);
/**
* 复制卡券附属权益
* @author PQZ
* @date 21:25 2024/9/19
* @param saveReqVO MemberCouponSaveReqVO
**/
void copyMemberCoupon(MemberCouponSaveReqVO saveReqVO);
}

View File

@ -1,10 +1,13 @@
package cn.iocoder.yudao.module.member.service.impl;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.entity.ActiveMain;
import cn.iocoder.yudao.module.member.entity.ActiveRule;
import cn.iocoder.yudao.module.member.entity.MemberCoupon;
import cn.iocoder.yudao.module.member.mapper.ActiveMainMapper;
import cn.iocoder.yudao.module.member.service.ActiveMainService;
import cn.iocoder.yudao.module.member.service.ActiveRuleCouponService;
import cn.iocoder.yudao.module.member.service.ActiveRuleService;
import cn.iocoder.yudao.module.member.vo.ActiveMainPageReqVO;
import cn.iocoder.yudao.module.member.vo.ActiveMainRespVO;
import cn.iocoder.yudao.module.member.vo.ActiveMainSaveReqVO;
@ -15,6 +18,9 @@ import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.common.BaseConstants.ACTIVE_RULE_COUPON_ACTIVE;
/**
* 营销活动 Service 实现类
@ -27,6 +33,10 @@ public class ActiveMainServiceImpl extends ServiceImpl<ActiveMainMapper, ActiveM
@Resource
private ActiveMainMapper activeMainMapper;
@Resource
private ActiveRuleService ruleService;
@Resource
private ActiveRuleCouponService activeRuleCouponService;
/**
@ -38,10 +48,24 @@ public class ActiveMainServiceImpl extends ServiceImpl<ActiveMainMapper, ActiveM
**/
@Override
public void saveActiveMain(ActiveMainSaveReqVO saveReqVO) {
ActiveMain activeMain = BeanUtils.toBean(saveReqVO,ActiveMain.class);
//保存活动
ActiveMain activeMain = BeanUtils.toBean(saveReqVO, ActiveMain.class);
saveOrUpdate(activeMain);
//保存规则
if (!saveReqVO.getRuleList().isEmpty()){
ruleService.saveActiveRule(saveReqVO.getRuleList(),activeMain.getId());
}
//保存卡券关联关系
activeRuleCouponService.saveActiveRuleCoupon(saveReqVO.getCouponList(),activeMain.getId(),ACTIVE_RULE_COUPON_ACTIVE);
}
/**
* 删除活动
*
* @param id 活动id
* @author PQZ
* @date 18:27 2024/9/19
**/
@Override
public void deleteActiveMain(String id) {
// 删除
@ -49,10 +73,25 @@ public class ActiveMainServiceImpl extends ServiceImpl<ActiveMainMapper, ActiveM
}
/**
* 根据营销活动获取详情
*
* @param id 营销活动id
* @return cn.iocoder.yudao.module.member.vo.ActiveMainRespVO
* @author PQZ
* @date 18:23 2024/9/19
**/
@Override
public ActiveMain getActiveMain(String id) {
return activeMainMapper.selectById(id);
public ActiveMainRespVO getActiveMain(String id) {
ActiveMain activeMain = activeMainMapper.selectById(id);
ActiveMainRespVO result = BeanUtils.toBean(activeMain, ActiveMainRespVO.class);
//查询关联规则
List<ActiveRule> ruleList = ruleService.listByActiveId(id);
//删除关联卡券
List<MemberCoupon> couponList = activeRuleCouponService.queryByMainId(id);
result.setRuleList(ruleList);
result.setCouponList(couponList);
return result;
}
/**
@ -66,7 +105,7 @@ public class ActiveMainServiceImpl extends ServiceImpl<ActiveMainMapper, ActiveM
**/
@Override
public IPage<ActiveMainRespVO> queryListPage(ActiveMainPageReqVO pageReqVO, Page<ActiveMainRespVO> page) {
return activeMainMapper.selectListPage(pageReqVO,page);
return activeMainMapper.selectListPage(pageReqVO, page);
}

View File

@ -1,17 +1,19 @@
package cn.iocoder.yudao.module.member.service.impl;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.entity.ActiveRuleCoupon;
import cn.iocoder.yudao.module.member.entity.MemberCoupon;
import cn.iocoder.yudao.module.member.mapper.ActiveRuleCouponMapper;
import cn.iocoder.yudao.module.member.service.ActiveRuleCouponService;
import cn.iocoder.yudao.module.member.vo.ActiveRuleCouponPageReqVO;
import cn.iocoder.yudao.module.member.vo.ActiveRuleCouponSaveReqVO;
import cn.iocoder.yudao.module.member.service.MemberCouponService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 营销活动规则及会员等级与基础卡券关联关系 Service 实现类
@ -23,42 +25,70 @@ import javax.annotation.Resource;
public class ActiveRuleCouponServiceImpl extends ServiceImpl<ActiveRuleCouponMapper, ActiveRuleCoupon> implements ActiveRuleCouponService {
@Resource
private ActiveRuleCouponMapper activeRuleCouponMapper;
private MemberCouponService couponService;
/**
* 根据主表id删除关联关系
*
* @param id 主表id
* @author PQZ
* @date 17:56 2024/9/19
**/
@Override
public String createActiveRuleCoupon(ActiveRuleCouponSaveReqVO createReqVO) {
// 插入
ActiveRuleCoupon activeRuleCoupon = BeanUtils.toBean(createReqVO, ActiveRuleCoupon.class);
activeRuleCouponMapper.insert(activeRuleCoupon);
// 返回
return activeRuleCoupon.getId();
public void deleteByMainId(String id) {
LambdaQueryWrapper<ActiveRuleCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ActiveRuleCoupon::getMainId,id);
remove(lambdaQueryWrapper);
}
/**
* 保存关联关系
*
* @param list 卡券id集合
* @param mainId 主表id
* @param mainTable 主表名称
* @author PQZ
* @date 17:57 2024/9/19
**/
@Override
public void updateActiveRuleCoupon(ActiveRuleCouponSaveReqVO updateReqVO) {
// 校验存在
// 更新
ActiveRuleCoupon updateObj = BeanUtils.toBean(updateReqVO, ActiveRuleCoupon.class);
activeRuleCouponMapper.updateById(updateObj);
public void saveActiveRuleCoupon(List<MemberCoupon> list, String mainId, String mainTable) {
//删除原有关联关系
deleteByMainId(mainId);
List<ActiveRuleCoupon> couponList = new ArrayList<>();
//组装现有关联关系
list.forEach(item -> {
ActiveRuleCoupon couponItem = new ActiveRuleCoupon();
couponItem.setCouponId(item.getId());
couponItem.setMainTable(mainTable);
couponItem.setMainId(mainId);
couponList.add(couponItem);
});
saveBatch(couponList);
}
/**
* 根据主表id查询关联关系
*
* @param id 主表id
* @return java.util.List<cn.iocoder.yudao.module.member.entity.ActiveRuleCoupon>
* @author PQZ
* @date 17:59 2024/9/19
**/
@Override
public void deleteActiveRuleCoupon(String id) {
// 校验存在
// 删除
activeRuleCouponMapper.deleteById(id);
public List<MemberCoupon> queryByMainId(String id) {
//查询关联关系
LambdaQueryWrapper<ActiveRuleCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ActiveRuleCoupon::getMainId,id).eq(ActiveRuleCoupon::getDeleted,"0");
List<ActiveRuleCoupon> list = list(lambdaQueryWrapper);
List<String> idList = list.stream().map(ActiveRuleCoupon::getCouponId).collect(Collectors.toList());
//查询关联卡券信息
List<MemberCoupon> result = new ArrayList<>();
if (!idList.isEmpty()){
LambdaQueryWrapper<MemberCoupon> couponLambdaQueryWrapper = new LambdaQueryWrapper<>();
couponLambdaQueryWrapper.in(MemberCoupon::getId,idList).eq(MemberCoupon::getDeleted,"0");
result = couponService.list(couponLambdaQueryWrapper);
}
return result;
}
@Override
public ActiveRuleCoupon getActiveRuleCoupon(String id) {
return activeRuleCouponMapper.selectById(id);
}
@Override
public PageResult<ActiveRuleCoupon> getActiveRuleCouponPage(ActiveRuleCouponPageReqVO pageReqVO) {
return null;
}
}

View File

@ -1,17 +1,15 @@
package cn.iocoder.yudao.module.member.service.impl;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.member.entity.ActiveRule;
import cn.iocoder.yudao.module.member.mapper.ActiveRuleMapper;
import cn.iocoder.yudao.module.member.service.ActiveRuleService;
import cn.iocoder.yudao.module.member.vo.ActiveRulePageReqVO;
import cn.iocoder.yudao.module.member.vo.ActiveRuleSaveReqVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.List;
/**
* 营销活动规则 Service 实现类
@ -22,41 +20,53 @@ import javax.annotation.Resource;
@Validated
public class ActiveRuleServiceImpl extends ServiceImpl<ActiveRuleMapper, ActiveRule> implements ActiveRuleService {
@Resource
private ActiveRuleMapper activeRuleMapper;
/**
* 保存活动规则
*
* @param list 活动规则集合
* @param activeId 活动id
* @author PQZ
* @date 18:15 2024/9/19
**/
@Override
public String createActiveRule(ActiveRuleSaveReqVO createReqVO) {
// 插入
ActiveRule activeRule = BeanUtils.toBean(createReqVO, ActiveRule.class);
activeRuleMapper.insert(activeRule);
// 返回
return activeRule.getId();
public void saveActiveRule(List<ActiveRule> list, String activeId) {
//根据活动id删除活动规则
deleteByActiveId(activeId);
//保存
list.forEach(item -> {
item.setId(null);
item.setActiveId(activeId);
});
saveBatch(list);
}
/**
* 根据活动id删除活动规则
*
* @param activeId 活动id
* @author PQZ
* @date 18:16 2024/9/19
**/
@Override
public void updateActiveRule(ActiveRuleSaveReqVO updateReqVO) {
// 更新
ActiveRule updateObj = BeanUtils.toBean(updateReqVO, ActiveRule.class);
activeRuleMapper.updateById(updateObj);
public void deleteByActiveId(String activeId) {
LambdaQueryWrapper<ActiveRule> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ActiveRule::getActiveId,activeId);
remove(lambdaQueryWrapper);
}
/**
* 根据活动id查询活动规则
*
* @param activeId 活动id
* @return java.util.List<cn.iocoder.yudao.module.member.entity.ActiveRule>
* @author PQZ
* @date 18:17 2024/9/19
**/
@Override
public void deleteActiveRule(String id) {
// 删除
activeRuleMapper.deleteById(id);
public List<ActiveRule> listByActiveId(String activeId) {
LambdaQueryWrapper<ActiveRule> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ActiveRule::getActiveId,activeId).eq(BaseDO::getDeleted,'0');
return list(lambdaQueryWrapper);
}
@Override
public ActiveRule getActiveRule(String id) {
return activeRuleMapper.selectById(id);
}
@Override
public PageResult<ActiveRule> getActiveRulePage(ActiveRulePageReqVO pageReqVO) {
return null;
}
}

View File

@ -2,19 +2,25 @@ package cn.iocoder.yudao.module.member.service.impl;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.member.entity.MemberCoupon;
import cn.iocoder.yudao.module.member.mapper.MemberCouponMapper;
import cn.iocoder.yudao.module.member.service.MemberCouponService;
import cn.iocoder.yudao.module.member.vo.MemberCouponPageReqVO;
import cn.iocoder.yudao.module.member.vo.MemberCouponRespVO;
import cn.iocoder.yudao.module.member.vo.MemberCouponSaveReqVO;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* 基础卡券 Service 实现类
@ -39,7 +45,7 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
**/
@Override
public void saveCoupon(MemberCouponSaveReqVO saveReqVO) {
MemberCoupon memberCoupon = BeanUtils.toBean(saveReqVO,MemberCoupon.class);
MemberCoupon memberCoupon = BeanUtils.toBean(saveReqVO, MemberCoupon.class);
saveOrUpdate(memberCoupon);
}
@ -49,11 +55,24 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
couponMapper.deleteById(id);
}
/**
* 查询基础卡券及附属信息
* @author PQZ
* @date 21:55 2024/9/19
* @param id 卡券id
* @return cn.iocoder.yudao.module.member.vo.MemberCouponRespVO
**/
@Override
public MemberCoupon getCoupon(String id) {
return couponMapper.selectById(id);
public MemberCouponRespVO getCoupon(String id) {
//查询本身数据
MemberCoupon memberCoupon = getById(id);
MemberCouponRespVO result = BeanUtils.toBean(memberCoupon,MemberCouponRespVO.class);
//查询附属权益
LambdaQueryWrapper<MemberCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(MemberCoupon::getParentId,id).eq(BaseDO::getDeleted,'0');
List<MemberCoupon> list = list(lambdaQueryWrapper);
result.setCouponList(list);
return result;
}
/**
@ -67,7 +86,46 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
**/
@Override
public IPage<MemberCouponRespVO> queryListPage(MemberCouponPageReqVO pageReqVO, Page<MemberCouponRespVO> page) {
return couponMapper.selectListPage(pageReqVO,page);
return couponMapper.selectListPage(pageReqVO, page);
}
/**
* 复制卡券附属权益
*
* @param saveReqVO MemberCouponSaveReqVO
* @author PQZ
* @date 21:25 2024/9/19
**/
@Override
@Transactional(rollbackFor = Exception.class)
public void copyMemberCoupon(MemberCouponSaveReqVO saveReqVO) {
//原始数据
LambdaQueryWrapper<MemberCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(MemberCoupon::getParentId, saveReqVO.getId()).eq(BaseDO::getDeleted, '0');
List<MemberCoupon> oldList = list(lambdaQueryWrapper);
//组装复制数据
if (!oldList.isEmpty()) {
//要保存的数据集合
List<MemberCoupon> saveList = new ArrayList<>();
//选中的目标数据
List<MemberCoupon> targetList = saveReqVO.getCouponList();
if (targetList != null && !targetList.isEmpty()) {
targetList.forEach(targetItem -> {
//深拷贝
MemberCoupon target = BeanUtils.toBean(targetItem,MemberCoupon.class);
oldList.forEach(oldItem -> {
//深拷贝
MemberCoupon saveItem = BeanUtils.toBean(oldItem,MemberCoupon.class);
saveItem.setId(null);
saveItem.setParentId(target.getId());
saveItem.setCreateTime(null);
saveItem.setCreator(null);
saveList.add(saveItem);
});
});
}
saveBatch(saveList);
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.member.vo;
import cn.iocoder.yudao.module.member.entity.ActiveMain;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
@ -13,33 +14,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ActiveMainPageReqVO extends PageParam {
@Schema(description = "活动名称", example = "王五")
private String name;
@Schema(description = "活动类型(充值有礼;注册有礼;开卡有礼)", example = "1")
private String type;
@Schema(description = "活动开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] beginTime;
@Schema(description = "活动结束时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] endTime;
@Schema(description = "活动状态", example = "1")
private String status;
@Schema(description = "活动描述", example = "随便")
private String remark;
@Schema(description = "是否区分会员等级")
private String isMember;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
public class ActiveMainPageReqVO extends ActiveMain {
}

View File

@ -1,5 +1,8 @@
package cn.iocoder.yudao.module.member.vo;
import cn.iocoder.yudao.module.member.entity.ActiveMain;
import cn.iocoder.yudao.module.member.entity.ActiveRule;
import cn.iocoder.yudao.module.member.entity.MemberCoupon;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -10,42 +13,10 @@ import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 营销活动 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ActiveMainRespVO {
@Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "10407")
@ExcelProperty("主键标识")
private String id;
@Schema(description = "活动名称", example = "王五")
@ExcelProperty("活动名称")
private String name;
@Schema(description = "活动类型(充值有礼;注册有礼;开卡有礼)", example = "1")
@ExcelProperty("活动类型(充值有礼;注册有礼;开卡有礼)")
private String type;
@Schema(description = "活动开始时间")
@ExcelProperty("活动开始时间")
private LocalDateTime beginTime;
@Schema(description = "活动结束时间")
@ExcelProperty("活动结束时间")
private LocalDateTime endTime;
@Schema(description = "活动状态", example = "1")
@ExcelProperty("活动状态")
private String status;
@Schema(description = "活动描述", example = "随便")
@ExcelProperty("活动描述")
private String remark;
@Schema(description = "是否区分会员等级")
@ExcelProperty("是否区分会员等级")
private String isMember;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
public class ActiveMainRespVO extends ActiveMain {
/**活动关联卡券*/
private List<MemberCoupon> couponList;
/**活动关联规则*/
private List<ActiveRule> ruleList;
}

View File

@ -1,5 +1,8 @@
package cn.iocoder.yudao.module.member.vo;
import cn.iocoder.yudao.module.member.entity.ActiveMain;
import cn.iocoder.yudao.module.member.entity.ActiveRule;
import cn.iocoder.yudao.module.member.entity.MemberCoupon;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
@ -9,30 +12,12 @@ import java.time.LocalDateTime;
@Schema(description = "管理后台 - 营销活动新增/修改 Request VO")
@Data
public class ActiveMainSaveReqVO {
public class ActiveMainSaveReqVO extends ActiveMain {
@Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "10407")
private String id;
/**活动关联卡券*/
private List<MemberCoupon> couponList;
/**活动关联规则*/
private List<ActiveRule> ruleList;
@Schema(description = "活动名称", example = "王五")
private String name;
@Schema(description = "活动类型(充值有礼;注册有礼;开卡有礼)", example = "1")
private String type;
@Schema(description = "活动开始时间")
private LocalDateTime beginTime;
@Schema(description = "活动结束时间")
private LocalDateTime endTime;
@Schema(description = "活动状态", example = "1")
private String status;
@Schema(description = "活动描述", example = "随便")
private String remark;
@Schema(description = "是否区分会员等级")
private String isMember;
}

View File

@ -1,32 +0,0 @@
package cn.iocoder.yudao.module.member.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 营销活动、规则及会员等级与基础卡券关联关系分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ActiveRuleCouponPageReqVO extends PageParam {
@Schema(description = "基础卡券表id", example = "780")
private String couponId;
@Schema(description = "营销活动、规则、会员等级表id", example = "19295")
private String mainId;
@Schema(description = "主表名称")
private String mainTable;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -1,36 +0,0 @@
package cn.iocoder.yudao.module.member.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 营销活动、规则及会员等级与基础卡券关联关系 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ActiveRuleCouponRespVO {
@Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "26827")
@ExcelProperty("主键标识")
private String id;
@Schema(description = "基础卡券表id", example = "780")
@ExcelProperty("基础卡券表id")
private String couponId;
@Schema(description = "营销活动、规则、会员等级表id", example = "19295")
@ExcelProperty("营销活动、规则、会员等级表id")
private String mainId;
@Schema(description = "主表名称")
@ExcelProperty("主表名称")
private String mainTable;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -1,25 +0,0 @@
package cn.iocoder.yudao.module.member.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 营销活动、规则及会员等级与基础卡券关联关系新增/修改 Request VO")
@Data
public class ActiveRuleCouponSaveReqVO {
@Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "26827")
private String id;
@Schema(description = "基础卡券表id", example = "780")
private String couponId;
@Schema(description = "营销活动、规则、会员等级表id", example = "19295")
private String mainId;
@Schema(description = "主表名称")
private String mainTable;
}

View File

@ -1,39 +0,0 @@
package cn.iocoder.yudao.module.member.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 营销活动规则分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ActiveRulePageReqVO extends PageParam {
@Schema(description = "活动id", example = "2412")
private String activeId;
@Schema(description = "规则名称", example = "王五")
private String name;
@Schema(description = "会员等级")
private String memberLevel;
@Schema(description = "充值金额")
private BigDecimal rechAmount;
@Schema(description = "赠送金额")
private String giveAmount;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -1,45 +0,0 @@
package cn.iocoder.yudao.module.member.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 营销活动规则 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ActiveRuleRespVO {
@Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "20194")
@ExcelProperty("主键标识")
private String id;
@Schema(description = "活动id", example = "2412")
@ExcelProperty("活动id")
private String activeId;
@Schema(description = "规则名称", example = "王五")
@ExcelProperty("规则名称")
private String name;
@Schema(description = "会员等级")
@ExcelProperty("会员等级")
private String memberLevel;
@Schema(description = "充值金额")
@ExcelProperty("充值金额")
private BigDecimal rechAmount;
@Schema(description = "赠送金额")
@ExcelProperty("赠送金额")
private String giveAmount;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -1,32 +0,0 @@
package cn.iocoder.yudao.module.member.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 营销活动规则新增/修改 Request VO")
@Data
public class ActiveRuleSaveReqVO {
@Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "20194")
private String id;
@Schema(description = "活动id", example = "2412")
private String activeId;
@Schema(description = "规则名称", example = "王五")
private String name;
@Schema(description = "会员等级")
private String memberLevel;
@Schema(description = "充值金额")
private BigDecimal rechAmount;
@Schema(description = "赠送金额")
private String giveAmount;
}

View File

@ -6,10 +6,14 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Schema(description = "管理后台 - 基础卡券 Response VO")
@Data
@ExcelIgnoreUnannotated
public class MemberCouponRespVO extends MemberCoupon {
/**附属权益集合*/
private List<MemberCoupon> couponList;
}

View File

@ -13,5 +13,7 @@ import java.time.LocalDateTime;
@Schema(description = "管理后台 - 基础卡券新增/修改 Request VO")
@Data
public class MemberCouponSaveReqVO extends MemberCoupon {
/**基础卡券集合*/
private List<MemberCoupon> couponList;
}

View File

@ -16,6 +16,12 @@
dl_member_coupon dmc
<where>
dmc.deleted = 0
<if test="entity.parentId == null">
and dmc.parent_id is null
</if>
<if test="entity.parentId != null and entity.parentId != ''">
and dmc.parent_id like concat('%', #{entity.parentId}, '%')
</if>
<if test="entity.name != null and entity.name != ''">
and dmc.name like concat('%', #{entity.name}, '%')
</if>

View File

@ -68,7 +68,7 @@ import static cn.iocoder.yudao.module.rescue.utils.RescueSysLoginService.generat
*/
@RestController
@Slf4j
@RequestMapping("/rescue")
@RequestMapping("/rescue/login")
public class SysLoginController {
@Resource
private AdminAuthService loginService;