This commit is contained in:
xiao-fajia 2024-09-21 20:43:29 +08:00
commit 8c430cae91
28 changed files with 404 additions and 73 deletions

View File

@ -73,5 +73,9 @@ public class BaseConstants {
public static final String BALANCE_CHANGE_RULE_JC = "jc";
/**卡券积分变更核销规则-金额*/
public static final String BALANCE_CHANGE_RULE_ME = "je";
/**0否*/
public static final String GENERAL_NO = "0";
/**1是*/
public static final String GENERAL_YES = "1";
}

View File

@ -8,4 +8,6 @@ public interface ErrorCodeConstants {
ErrorCode BASE_WAREHOUSE_EXITS_CHILDREN = new ErrorCode(500, "存在子配置类型,无法删除");
ErrorCode BASE_TYPE_NAME_DUPLICATE = new ErrorCode(500, "同父级下配置类型名称或编码重复");
ErrorCode BASE_WAREHOUSE_NAME_DUPLICATE = new ErrorCode(500, "同父级下仓库区域名称或编码重复");
ErrorCode CUSTOMER_ACTIVE_ONE_COUPON = new ErrorCode(500, "请至少选择一个礼包卡");
ErrorCode CUSTOMER_ACTIVE_NO_RULE = new ErrorCode(500, "当前活动未设置充值规则,请联系管理员设置");
}

View File

@ -29,21 +29,22 @@ public class CustomerActiveController {
@Resource
private CustomerActiveService customerActiveService;
@PostMapping("/create")
@Operation(summary = "创建用户参与活动记录")
@PreAuthorize("@ss.hasPermission('base:customer-active:create')")
public CommonResult<String> createCustomerActive(@Valid @RequestBody CustomerActiveSaveReqVO createReqVO) {
return success(customerActiveService.createCustomerActive(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新用户参与活动记录")
@PreAuthorize("@ss.hasPermission('base:customer-active:update')")
public CommonResult<Boolean> updateCustomerActive(@Valid @RequestBody CustomerActiveSaveReqVO updateReqVO) {
customerActiveService.updateCustomerActive(updateReqVO);
/**
* 参加活动
*
* @param createReqVO CustomerActiveSaveReqVO
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.String>
* @author PQZ
* @date 9:49 2024/9/21
**/
@PostMapping("/attendActive")
@Operation(summary = "参加活动")
public CommonResult<Boolean> attendActive(@RequestBody CustomerActiveSaveReqVO createReqVO) {
customerActiveService.attendActive(createReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除用户参与活动记录")
@Parameter(name = "id", description = "编号", required = true)

View File

@ -47,7 +47,7 @@ public class CustomerCouponController {
/**
* 删除用户卡券
* @author PQZ
* @date 22:57 2024/9/20
* @date 23:01 2024/9/20
* @param id TODO
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
**/

View File

@ -32,7 +32,7 @@ public class CustomerActive extends TenantBaseDO {
/**
* 用户id
*/
private Integer userId;
private Long userId;
/**
* 参加活动id
*/

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.custom.entity;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
@ -34,7 +35,7 @@ public class CustomerBalance extends TenantBaseDO {
/**
* 用户id
*/
private Integer userId;
private Long userId;
/**
* 积分余额
*/
@ -47,5 +48,7 @@ public class CustomerBalance extends TenantBaseDO {
* 累计充值额度
*/
private BigDecimal allBalance;
@TableField(exist = false)
private BigDecimal nowChange;
}

View File

@ -34,7 +34,7 @@ public class CustomerBalanceChange extends TenantBaseDO {
/**
* 用户id
*/
private Integer userId;
private Long userId;
/**
* 关联卡券id
*/

View File

@ -39,7 +39,7 @@ public class CustomerCoupon extends TenantBaseDO {
/**
* 用户id
*/
private Integer userId;
private Long userId;
/**
* 卡券id
*/

View File

@ -15,20 +15,17 @@ import javax.validation.Valid;
*/
public interface CustomerActiveService extends IService<CustomerActive> {
/**
* 创建用户参与活动记录
*
* @param createReqVO 创建信息
* @return 编号
*/
String createCustomerActive(@Valid CustomerActiveSaveReqVO createReqVO);
/**
* 更新用户参与活动记录
* 参与活动
*
* @param updateReqVO 更新信息
*/
void updateCustomerActive(@Valid CustomerActiveSaveReqVO updateReqVO);
* @param saveReqVO CustomerActiveSaveReqVO实体
* @author PQZ
* @date 9:57 2024/9/21
**/
void attendActive(CustomerActiveSaveReqVO saveReqVO);
/**
* 删除用户参与活动记录

View File

@ -30,8 +30,24 @@ public interface CustomerBalanceChangeService extends IService<CustomerBalanceCh
* @author PQZ
* @date 21:54 2024/9/20
**/
void saveChange(String cusId, Integer userId, String couponId, String changeType, String changeMain, String changeRule, BigDecimal changeBalance, BigDecimal remBalance, String reason);
void saveChange(String cusId, Long userId, String couponId, String changeType, String changeMain, String changeRule, BigDecimal changeBalance, BigDecimal remBalance, String reason);
/**
* 初始化变动记录
* @author PQZ
* @date 10:09 2024/9/21
* @param cusId 客户id
* @param userId 用户id
* @param couponId 关联卡券id
* @param changeType 变动类型
* @param changeMain 变动主体
* @param changeRule 变动规则
* @param changeBalance 变动积分/次数
* @param remBalance 变动后剩余积分/次数
* @param reason 变动原因
* @return cn.iocoder.yudao.module.custom.entity.CustomerBalanceChange
**/
CustomerBalanceChange initChange(String cusId, Long userId, String couponId, String changeType, String changeMain, String changeRule, BigDecimal changeBalance, BigDecimal remBalance, String reason);
/**
* 获得用户积分余额卡券变动记录分页

View File

@ -28,5 +28,14 @@ public interface CustomerBalanceService extends IService<CustomerBalance> {
*/
void updateCustomerBalance(@Valid CustomerBalanceSaveReqVO updateReqVO);
/**
* 根据用户id更新用户余额表
* @author PQZ
* @date 11:56 2024/9/21
* @param balance CustomerBalance
* @return void
**/
void updateByCusId(CustomerBalance balance);
}

View File

@ -48,6 +48,7 @@ public interface CustomerCouponService extends IService<CustomerCoupon> {
**/
CustomerCouponRespVO getCustomerCoupon(String id);
/**
* 获得用户卡券分页
*

View File

@ -2,16 +2,35 @@ package cn.iocoder.yudao.module.custom.service.impl;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.custom.entity.CustomerActive;
import cn.iocoder.yudao.module.custom.entity.*;
import cn.iocoder.yudao.module.custom.mapper.CustomerActiveMapper;
import cn.iocoder.yudao.module.custom.service.CustomerActiveService;
import cn.iocoder.yudao.module.custom.service.*;
import cn.iocoder.yudao.module.custom.vo.CustomerActivePageReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerActiveSaveReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
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.service.ActiveMainService;
import cn.iocoder.yudao.module.member.service.MemberCouponService;
import cn.iocoder.yudao.module.member.vo.ActiveMainRespVO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mzt.logapi.service.IFunctionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.common.BaseConstants.*;
import static cn.iocoder.yudao.common.ErrorCodeConstants.CUSTOMER_ACTIVE_NO_RULE;
import static cn.iocoder.yudao.common.ErrorCodeConstants.CUSTOMER_ACTIVE_ONE_COUPON;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
/**
* 用户参与活动记录 Service 实现类
@ -24,23 +43,185 @@ public class CustomerActiveServiceImpl extends ServiceImpl<CustomerActiveMapper,
@Resource
private CustomerActiveMapper customerActiveMapper;
@Resource
private ActiveMainService activeMainService;
@Resource
private CustomerMainService customerMainService;
@Resource
private MemberCouponService couponService;
@Resource
private CustomerBalanceChangeService changeService;
@Resource
private CustomerCouponService customerCouponService;
@Resource
private CustomerBalanceService balanceService;
/**
* 参与活动
*
* @param saveReqVO CustomerActiveSaveReqVO实体
* @author PQZ
* @date 9:57 2024/9/21
**/
@Override
public String createCustomerActive(CustomerActiveSaveReqVO createReqVO) {
// 插入
CustomerActive customerActive = BeanUtils.toBean(createReqVO, CustomerActive.class);
customerActiveMapper.insert(customerActive);
// 返回
return customerActive.getId();
@Transactional(rollbackFor = Exception.class)
public void attendActive(CustomerActiveSaveReqVO saveReqVO) {
/*1、基础数据初始化*/
//当前客户信息
CustomerMainRespVO customer = customerMainService.getCustomerById(saveReqVO.getCusId());
//获取当前活动信息
ActiveMainRespVO active = activeMainService.getActiveMain(saveReqVO.getActiveId(), true);
//需要保存的变动日志集合
List<CustomerBalanceChange> changeList = new ArrayList<>();
//需要保存的参与活动日志
CustomerActive customerActive = new CustomerActive();
//需保保存的用户卡券领取内容
List<CustomerCoupon> customerCouponList;
//需保保存的用户积分余额信息
CustomerBalance balance;
/*2、活动关联卡券处理*/
if (GENERAL_YES.equals(active.getIsCoupon())) {
if (GENERAL_YES.equals(active.getIsPack())) {
/*2.1 打包领取情况*/
List<MemberCoupon> couponList = active.getCouponList();
//抓换卡券信息
customerCouponList = transCoupon(active.getId(), customer.getId(), customer.getUserId(), couponList);
//转换日志信息
changeList = transChange(customer.getId(), customer.getUserId(), active.getName(), couponList);
} else {
/*2.2 非打包领取情况*/
//选中卡券校验
if (null == saveReqVO.getSelectCoupon() || saveReqVO.getSelectCoupon().isEmpty()) {
throw exception(CUSTOMER_ACTIVE_ONE_COUPON);
}
//查询出当前选中的卡券及附属卡券
List<String> ids = saveReqVO.getSelectCoupon().stream().map(MemberCoupon::getId).collect(Collectors.toList());
List<MemberCoupon> couponList = couponService.listByIds(ids, true);
//转换卡券信息
customerCouponList = transCoupon(active.getId(), customer.getId(), customer.getUserId(), couponList);
//转换日志信息
changeList = transChange(customer.getId(), customer.getUserId(), active.getName(), couponList);
}
//保存用户卡券
customerCouponService.saveBatch(customerCouponList);
}
/*3、活动关联充值规则处理*/
if (GENERAL_YES.equals(active.getIsRechRule())) {
//校验是否存在充值规则
if (null == active.getRuleList() || active.getRuleList().isEmpty()) {
throw exception(CUSTOMER_ACTIVE_NO_RULE);
}
List<ActiveRule> ruleList = active.getRuleList();
//转换余额信息
balance = transBalance(customer,saveReqVO.getTopUpAmount(),ruleList);
//记录日志
CustomerBalanceChange change = changeService.initChange(customer.getId(),
customer.getUserId(), null, BALANCE_CHANGE_TYPE_CZ, BALANCE_CHANGE_MAIN_YE,
null, balance.getNowChange(), balance.getBalance(), "参加" + active.getName() + "活动");
changeList.add(change);
//保存余额信息
balanceService.updateByCusId(balance);
}
/*4、保存参与活动信息*/
customerActive.setActiveId(active.getId());
customerActive.setUserId(customer.getUserId());
customerActive.setCusId(customer.getId());
customerActive.setActiveName(active.getName());
customerActive.setActiveType(active.getType());
customerActive.setRemark(active.getRemark());
save(customerActive);
/*5、保存变动日志*/
//保存变动日志
changeService.saveBatch(changeList);
}
@Override
public void updateCustomerActive(CustomerActiveSaveReqVO updateReqVO) {
// 更新
CustomerActive updateObj = BeanUtils.toBean(updateReqVO, CustomerActive.class);
customerActiveMapper.updateById(updateObj);
/**
* 卡券实体转换
*
* @param couponList MemberCoupon集合
* @return java.util.List<cn.iocoder.yudao.module.custom.entity.CustomerCoupon>
* @author PQZ
* @date 11:01 2024/9/21
**/
List<CustomerCoupon> transCoupon(String activeId, String cusId, Long userId, List<MemberCoupon> couponList) {
List<CustomerCoupon> transList = new ArrayList<>();
couponList.forEach(item -> {
CustomerCoupon coupon = new CustomerCoupon();
coupon.setCusId(cusId);
coupon.setUserId(userId);
coupon.setActiveId(activeId);
coupon.setCouponId(item.getId());
coupon.setAmount(item.getAmount());
coupon.setBalance(item.getAmount());
coupon.setUnitPrice(item.getUnitPrice());
coupon.setOutRule(item.getOutRule());
coupon.setIsValid(GENERAL_YES);
transList.add(coupon);
});
return transList;
}
/**
* 卡券转换记录
*
* @param cusId 客户id
* @param userId 用户id
* @param activeName 活动名称
* @param couponList 卡券集合
* @return java.util.List<cn.iocoder.yudao.module.custom.entity.CustomerBalanceChange>
* @author PQZ
* @date 11:20 2024/9/21
**/
List<CustomerBalanceChange> transChange(String cusId, Long userId, String activeName, List<MemberCoupon> couponList) {
List<CustomerBalanceChange> transList = new ArrayList<>();
couponList.forEach(item -> {
CustomerBalanceChange change = changeService.initChange(cusId,
userId, item.getId(), BALANCE_CHANGE_TYPE_ZS, BALANCE_CHANGE_MAIN_KQ,
item.getOutRule(), item.getAmount(), item.getAmount(), "参加" + activeName + "活动领取");
transList.add(change);
});
return transList;
}
/**
* 转换余额
*
* @param customer 用户信息
* @param amount 实际充值金额
* @param ruleList 规则
* @return cn.iocoder.yudao.module.custom.entity.CustomerBalance
* @author PQZ
* @date 11:30 2024/9/21
**/
CustomerBalance transBalance(CustomerMainRespVO customer, BigDecimal amount, List<ActiveRule> ruleList) {
CustomerBalance result = new CustomerBalance();
result.setCusId(customer.getId());
result.setUserId(customer.getUserId());
List<ActiveRule> sortList = ruleList.stream().sorted(Comparator.comparing(ActiveRule::getRechAmount).reversed()).collect(Collectors.toList());
for (ActiveRule item : sortList) {
if (amount.compareTo(item.getRechAmount()) >= 0) {
BigDecimal nowChange = amount.add(item.getGiveAmount());
//余额
result.setBalance(customer.getBalance().add(nowChange));
//累计充值金额
result.setAllBalance(customer.getBalance().add(nowChange));
result.setNowChange(nowChange);
break;
}
}
return result;
}
@Override
public void deleteCustomerActive(String id) {
// 删除
@ -48,7 +229,6 @@ public class CustomerActiveServiceImpl extends ServiceImpl<CustomerActiveMapper,
}
@Override
public CustomerActive getCustomerActive(String id) {
return customerActiveMapper.selectById(id);

View File

@ -47,7 +47,29 @@ public class CustomerBalanceChangeServiceImpl extends ServiceImpl<CustomerBalanc
* @date 21:54 2024/9/20
**/
@Override
public void saveChange(String cusId, Integer userId, String couponId, String changeType, String changeMain, String changeRule, BigDecimal changeBalance, BigDecimal remBalance, String reason) {
public void saveChange(String cusId, Long userId, String couponId, String changeType, String changeMain, String changeRule, BigDecimal changeBalance, BigDecimal remBalance, String reason) {
CustomerBalanceChange change = initChange(cusId,userId,couponId,changeType,changeMain,changeRule,changeBalance,remBalance,reason);
save(change);
}
/**
* 初始化变动记录
*
* @param cusId 客户id
* @param userId 用户id
* @param couponId 关联卡券id
* @param changeType 变动类型
* @param changeMain 变动主体
* @param changeRule 变动规则
* @param changeBalance 变动积分/次数
* @param remBalance 变动后剩余积分/次数
* @param reason 变动原因
* @return cn.iocoder.yudao.module.custom.entity.CustomerBalanceChange
* @author PQZ
* @date 10:09 2024/9/21
**/
@Override
public CustomerBalanceChange initChange(String cusId, Long userId, String couponId, String changeType, String changeMain, String changeRule, BigDecimal changeBalance, BigDecimal remBalance, String reason) {
CustomerBalanceChange change = new CustomerBalanceChange();
change.setCusId(cusId);
change.setUserId(userId);
@ -58,9 +80,10 @@ public class CustomerBalanceChangeServiceImpl extends ServiceImpl<CustomerBalanc
change.setChangeBalance(changeBalance);
change.setRemBalance(remBalance);
change.setReason(reason);
save(change);
return change;
}
/**
* 获得用户积分余额卡券变动记录分页
*

View File

@ -1,15 +1,18 @@
package cn.iocoder.yudao.module.custom.service.impl;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.custom.entity.CustomerBalance;
import cn.iocoder.yudao.module.custom.mapper.CustomerBalanceMapper;
import cn.iocoder.yudao.module.custom.service.CustomerBalanceService;
import cn.iocoder.yudao.module.custom.vo.CustomerBalanceSaveReqVO;
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 实现类
@ -39,6 +42,21 @@ public class CustomerBalanceServiceImpl extends ServiceImpl<CustomerBalanceMappe
customerBalanceMapper.updateById(updateObj);
}
/**
* 根据用户id更新用户余额表
*
* @param balance CustomerBalance
* @return void
* @author PQZ
* @date 11:56 2024/9/21
**/
@Override
public void updateByCusId(CustomerBalance balance) {
LambdaQueryWrapper<CustomerBalance> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CustomerBalance::getCusId,balance.getCusId()).eq(BaseDO::getDeleted,'0');
remove(lambdaQueryWrapper);
this.save(balance);
}
}

View File

@ -1,15 +1,19 @@
package cn.iocoder.yudao.module.custom.vo;
import cn.iocoder.yudao.module.custom.entity.CustomerActive;
import cn.iocoder.yudao.module.member.entity.MemberCoupon;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.math.BigDecimal;
import java.util.*;
import javax.validation.constraints.*;
@Schema(description = "管理后台 - 用户参与活动记录新增/修改 Request VO")
@Data
public class CustomerActiveSaveReqVO extends CustomerActive {
/**充值金额*/
private BigDecimal topUpAmount;
/**选中的优惠券*/
private List<MemberCoupon> selectCoupon;
}

View File

@ -92,7 +92,7 @@ public class ActiveMainController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('member:active-main:query')")
public CommonResult<ActiveMainRespVO> getActiveMain(@RequestParam("id") String id) {
ActiveMain activeMain = activeMainService.getActiveMain(id);
ActiveMain activeMain = activeMainService.getActiveMain(id,false);
return success(BeanUtils.toBean(activeMain, ActiveMainRespVO.class));
}

View File

@ -47,6 +47,6 @@ public class ActiveRule extends TenantBaseDO {
/**
* 赠送金额
*/
private String giveAmount;
private BigDecimal giveAmount;
}

View File

@ -35,12 +35,14 @@ public interface ActiveMainService extends IService<ActiveMain> {
/**
* 根据营销活动获取详情
*
* @param id 营销活动id
* @param isChild 是否查询出关联的附属卡券信息
* @return cn.iocoder.yudao.module.member.vo.ActiveMainRespVO
* @author PQZ
* @date 18:23 2024/9/19
* @param id 营销活动id
* @return cn.iocoder.yudao.module.member.vo.ActiveMainRespVO
**/
ActiveMainRespVO getActiveMain(String id);
**/
ActiveMainRespVO getActiveMain(String id, boolean isChild);
/**
* 分页查询营销活动

View File

@ -36,11 +36,12 @@ public interface ActiveRuleCouponService extends IService<ActiveRuleCoupon> {
/**
* 根据主表id查询关联关系
*
* @param id 主表id
* @param id 主表id
* @param isChild 是否查询出关联的附属卡券信息
* @return java.util.List<cn.iocoder.yudao.module.member.entity.ActiveRuleCoupon>
* @author PQZ
* @date 17:59 2024/9/19
**/
List<MemberCoupon> queryByMainId(String id);
List<MemberCoupon> queryByMainId(String id, boolean isChild);
}

View File

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
import java.util.List;
/**
* 基础卡券 Service 接口
@ -27,6 +28,17 @@ public interface MemberCouponService extends IService<MemberCoupon> {
**/
void saveCoupon(@Valid MemberCouponSaveReqVO saveReqVO);
/**
* 通过id集合查询卡券信息
*
* @param ids id集合
* @param isChild 是否查询出关联的卡券信息
* @return java.util.List<cn.iocoder.yudao.module.member.entity.MemberCoupon>
* @author PQZ
* @date 10:47 2024/9/21
**/
List<MemberCoupon> listByIds(List<String> ids, boolean isChild);
/**
* 删除基础卡券
*
@ -36,11 +48,12 @@ public interface MemberCouponService extends IService<MemberCoupon> {
/**
* 查询基础卡券及附属信息
* @author PQZ
* @date 21:55 2024/9/19
*
* @param id 卡券id
* @return cn.iocoder.yudao.module.member.vo.MemberCouponRespVO
**/
* @author PQZ
* @date 21:55 2024/9/19
**/
MemberCouponRespVO getCoupon(String id);
/**
@ -56,10 +69,11 @@ public interface MemberCouponService extends IService<MemberCoupon> {
/**
* 复制卡券附属权益
*
* @param saveReqVO MemberCouponSaveReqVO
* @author PQZ
* @date 21:25 2024/9/19
* @param saveReqVO MemberCouponSaveReqVO
**/
**/
void copyMemberCoupon(MemberCouponSaveReqVO saveReqVO);
}

View File

@ -82,13 +82,13 @@ public class ActiveMainServiceImpl extends ServiceImpl<ActiveMainMapper, ActiveM
* @date 18:23 2024/9/19
**/
@Override
public ActiveMainRespVO getActiveMain(String id) {
public ActiveMainRespVO getActiveMain(String id,boolean isChild) {
ActiveMain activeMain = activeMainMapper.selectById(id);
ActiveMainRespVO result = BeanUtils.toBean(activeMain, ActiveMainRespVO.class);
//查询关联规则
List<ActiveRule> ruleList = ruleService.listByActiveId(id);
//删除关联卡券
List<MemberCoupon> couponList = activeRuleCouponService.queryByMainId(id);
//查询关联卡券
List<MemberCoupon> couponList = activeRuleCouponService.queryByMainId(id,isChild);
result.setRuleList(ruleList);
result.setCouponList(couponList);
return result;

View File

@ -38,7 +38,7 @@ public class ActiveRuleCouponServiceImpl extends ServiceImpl<ActiveRuleCouponMap
@Override
public void deleteByMainId(String id) {
LambdaQueryWrapper<ActiveRuleCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ActiveRuleCoupon::getMainId,id);
lambdaQueryWrapper.eq(ActiveRuleCoupon::getMainId, id);
remove(lambdaQueryWrapper);
}
@ -70,24 +70,23 @@ public class ActiveRuleCouponServiceImpl extends ServiceImpl<ActiveRuleCouponMap
/**
* 根据主表id查询关联关系
*
* @param id 主表id
* @param id 主表id
* @param isChild 是否查询出关联的附属卡券信息
* @return java.util.List<cn.iocoder.yudao.module.member.entity.ActiveRuleCoupon>
* @author PQZ
* @date 17:59 2024/9/19
**/
@Override
public List<MemberCoupon> queryByMainId(String id) {
public List<MemberCoupon> queryByMainId(String id, boolean isChild) {
//查询关联关系
LambdaQueryWrapper<ActiveRuleCoupon> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ActiveRuleCoupon::getMainId,id).eq(ActiveRuleCoupon::getDeleted,"0");
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);
if (!idList.isEmpty()) {
result = couponService.listByIds(idList,isChild);
}
return result;
}

View File

@ -21,6 +21,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 基础卡券 Service 实现类
@ -49,6 +50,35 @@ public class MemberCouponServiceImpl extends ServiceImpl<MemberCouponMapper, Mem
saveOrUpdate(memberCoupon);
}
/**
* 通过id集合查询卡券信息
*
* @param ids id集合
* @param isChild 是否查询出关联的卡券信息
* @return java.util.List<cn.iocoder.yudao.module.member.entity.MemberCoupon>
* @author PQZ
* @date 10:47 2024/9/21
**/
@Override
public List<MemberCoupon> listByIds(List<String> ids, boolean isChild) {
List<MemberCoupon> couponList = new ArrayList<>();
if (!ids.isEmpty()) {
LambdaQueryWrapper<MemberCoupon> couponLambdaQueryWrapper = new LambdaQueryWrapper<>();
couponLambdaQueryWrapper.in(MemberCoupon::getId, ids).eq(MemberCoupon::getDeleted, "0");
couponList = list(couponLambdaQueryWrapper);
}
List<MemberCoupon> result = new ArrayList<>(couponList);
if (isChild){
//查询附属卡片
List<String> parentIds = couponList.stream().map(MemberCoupon::getId).collect(Collectors.toList());
LambdaQueryWrapper<MemberCoupon> couponLambdaQueryWrapper = new LambdaQueryWrapper<>();
couponLambdaQueryWrapper.in(MemberCoupon::getParentId, parentIds).eq(MemberCoupon::getDeleted, "0");
List<MemberCoupon> childList = list(couponLambdaQueryWrapper);
result.addAll(childList);
}
return result;
}
@Override
public void deleteCoupon(String id) {
// 删除

View File

@ -187,4 +187,7 @@ public class RescueInfo extends TenantBaseDO
@TableField(exist = false)
private List<String> roadIds;
@TableField(exist = false)
private List<Long> deptList;
}

View File

@ -55,7 +55,7 @@ public interface RescueInfoMapper extends BaseMapper<RescueInfo>
void dealOverTimeRescue();
List<RescueInfo> getOverTimeRescue();
Map<String,Object> getRescueStatistics(RescueInfo rescueInfo);
Map<String,Object> getRescueStatisticsByAdmin(RescueInfo rescueInfo);
Map<String,Object> getRescueStatisticsByAdmin(@Param("map") RescueInfo rescueInfo);
void deleteOtherInfo1(@Param("rescueId") Long rescueId);
void deleteOtherInfo2(@Param("rescueId") Long rescueId);

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.rescue.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
@ -234,8 +235,15 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
@Override
public IPage<RescueInfo> selectRescueInfoListByAdmin(RescueInfo rescueInfo, Page<RescueInfo> page) {
LoginUser user = getLoginUser();
AdminUserRespDTO adminUser = userService.getUser(user.getId());
List<DeptRespDTO> childDeptList = deptService.getChildDeptList(adminUser.getDeptId());
List<Long> deptList = childDeptList.stream().map(DeptRespDTO::getId).collect(Collectors.toList());
deptList.add(adminUser.getDeptId());
rescueInfo.setDeptList(deptList);
IPage<RescueInfo> rescueInfos = baseMapper.selectRescueInfoList(rescueInfo, page);
for (RescueInfo info : rescueInfos.getRecords()) {
String dljy_type = dictDataService.getDictDataLabel("dljy_type", info.getRescueType());
info.setRescueTypeStr(dljy_type);
@ -821,6 +829,12 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
@Override
public Map<String, Object> getRescueStatisticsByAdmin(RescueInfo rescueInfo) {
LoginUser user = getLoginUser();
AdminUserRespDTO adminUser = userService.getUser(user.getId());
List<DeptRespDTO> childDeptList = deptService.getChildDeptList(adminUser.getDeptId());
List<Long> deptList = childDeptList.stream().map(DeptRespDTO::getId).collect(Collectors.toList());
deptList.add(adminUser.getDeptId());
rescueInfo.setDeptList(deptList);
Map<String, Object> res = baseMapper.getRescueStatisticsByAdmin(rescueInfo);
return res;

View File

@ -48,6 +48,11 @@
<if test="map.licenseNum != null">
and ri.license_num like concat('%', #{map.licenseNum}, '%')
</if>
<if test="map.deptList != null and map.deptList.size()>0">
and ri.dept_id in <foreach collection="map.deptList" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
</where>
order by ri.create_time desc
</select>
@ -341,6 +346,11 @@
FROM rescue_info ri
left join rescue_order_info roi on roi.rescue_info_id = ri.id
where 1 = 1
<if test="map.deptList != null and map.deptList.size()>0">
and ri.dept_id in <foreach collection="map.deptList" separator="," item="item" open="(" close=")">
#{item}
</foreach>
</if>
</select>
<delete id="deleteOtherInfo1">
DELETE