This commit is contained in:
PQZ 2024-09-24 22:33:44 +08:00
parent f680a54b5c
commit 20e5f46f7f
7 changed files with 163 additions and 65 deletions

View File

@ -87,8 +87,11 @@ public class BaseConstants {
public static final String GENERAL_YES = "1";
/**会员充值*/
public static final String ORDER_HYCZ = "1";
/**维修服务*/
public static final String ORDER_WXFW = "2";
/**维修服务*/
public static final String ORDER_KKYL = "3";
/**订单店铺名称*/
public static final String ORDER_TENANT_NAME = "蓝安集团";

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.custom.service;
import cn.iocoder.yudao.module.custom.entity.CustomerBalanceChange;
import cn.iocoder.yudao.module.custom.vo.CustomerBalanceChangePageReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerBalanceChangeRespVO;
import cn.iocoder.yudao.module.member.entity.MemberCoupon;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
@ -34,8 +35,7 @@ public interface CustomerBalanceChangeService extends IService<CustomerBalanceCh
/**
* 初始化变动记录
* @author PQZ
* @date 10:09 2024/9/21
*
* @param cusId 客户id
* @param userId 用户id
* @param couponId 关联卡券id
@ -46,7 +46,9 @@ public interface CustomerBalanceChangeService extends IService<CustomerBalanceCh
* @param remBalance 变动后剩余积分/次数
* @param reason 变动原因
* @return cn.iocoder.yudao.module.custom.entity.CustomerBalanceChange
**/
* @author PQZ
* @date 10:09 2024/9/21
**/
CustomerBalanceChange initChange(String cusId, Long userId, String couponId, String changeType, String changeMain, String changeRule, BigDecimal changeBalance, BigDecimal remBalance, String reason);
/**
@ -57,6 +59,20 @@ public interface CustomerBalanceChangeService extends IService<CustomerBalanceCh
*/
IPage<CustomerBalanceChangeRespVO> queryListPage(CustomerBalanceChangePageReqVO pageReqVO, Page<CustomerBalanceChangeRespVO> page);
/**
* 转换变动记录
*
* @param cusId 客户id
* @param userId 用户id
* @param activeName 活动名称
* @param couponList 卡券集合
* @return java.util.List<cn.iocoder.yudao.module.custom.entity.CustomerBalanceChange>
* @author PQZ
* @date 21:58 2024/9/24
**/
List<CustomerBalanceChange> transChange(String cusId, Long userId, String activeName, List<MemberCoupon> couponList);
/**
* 通过用户id和卡券id查询积分卡券的变动记录
*

View File

@ -1,13 +1,12 @@
package cn.iocoder.yudao.module.custom.service;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.custom.entity.CustomerCoupon;
import cn.iocoder.yudao.module.custom.vo.CustomerCouponPageReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerCouponRespVO;
import cn.iocoder.yudao.module.custom.vo.CustomerCouponSaveReqVO;
import cn.iocoder.yudao.module.member.entity.MemberCoupon;
import cn.iocoder.yudao.module.order.entity.RepairOrderInfo;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid;
import java.util.List;
/**
@ -27,6 +26,24 @@ public interface CustomerCouponService extends IService<CustomerCoupon> {
**/
void couponVerification(CustomerCouponSaveReqVO saveReqVO);
/**
* 开卡有礼回调
* @author PQZ
* @date 21:50 2024/9/24
* @param orderInfo RepairOrderInfo
**/
void couponCallBack(RepairOrderInfo orderInfo);
/**
* 卡券实体转换
*
* @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);
/**
* 删除用户卡券
*

View File

@ -86,7 +86,7 @@ public class CustomerActiveServiceImpl extends ServiceImpl<CustomerActiveMapper,
//需要保存的参与活动日志
CustomerActive customerActive = new CustomerActive();
//需保保存的用户卡券领取内容
List<CustomerCoupon> customerCouponList;
List<CustomerCoupon> customerCouponList = null;
//需保保存的用户积分余额信息
CustomerBalance balance;
@ -95,10 +95,10 @@ public class CustomerActiveServiceImpl extends ServiceImpl<CustomerActiveMapper,
if (GENERAL_YES.equals(active.getIsPack())) {
/*2.1 打包领取情况*/
List<MemberCoupon> couponList = active.getCouponList();
//换卡券信息
customerCouponList = transCoupon(active.getId(), customer.getId(), customer.getUserId(), couponList);
//换卡券信息
customerCouponList = customerCouponService.transCoupon(active.getId(), customer.getId(), customer.getUserId(), couponList);
//转换日志信息
changeList = transChange(customer.getId(), customer.getUserId(), active.getName(), couponList);
changeList = changeService.transChange(customer.getId(), customer.getUserId(), active.getName(), couponList);
} else {
/*2.2 非打包领取情况*/
//选中卡券校验
@ -107,14 +107,37 @@ public class CustomerActiveServiceImpl extends ServiceImpl<CustomerActiveMapper,
}
//查询出当前选中的卡券及附属卡券
List<String> ids = saveReqVO.getSelectCoupon().stream().map(MemberCoupon::getId).collect(Collectors.toList());
List<MemberCoupon> couponList = couponService.listByIds(ids, true);
//查询选中卡片信息
List<MemberCoupon> couponList = couponService.listByIds(ids, false);
couponList.forEach(item -> {
RepairOrderInfo orderInfo = new RepairOrderInfo();
orderInfo.setOrderNo(System.currentTimeMillis() + Math.abs(item.getId().hashCode() % 1000) + "");
orderInfo.setGoodsId(item.getId());
orderInfo.setActiveId(active.getId());
orderInfo.setGoodsTitle(active.getName());
orderInfo.setTenantName(ORDER_TENANT_NAME);
orderInfo.setGoodsType(ORDER_KKYL);
orderInfo.setUserId(customer.getUserId());
orderInfo.setCusId(customer.getId());
orderInfo.setCusName(customer.getCusName());
orderInfo.setCusPhone(customer.getPhoneNumber());
orderInfo.setGoodsPrice(item.getAmount());
orderInfo.setPayMoney(item.getAmount());
orderInfo.setOrderTime(LocalDateTime.now());
orderInfo.setIsOnline("01");
orderInfo.setOrderStatus("0");
orderInfo.setPayType(saveReqVO.getAccountType());
repairOrderInfoService.save(orderInfo);
});
//转换卡券信息
customerCouponList = transCoupon(active.getId(), customer.getId(), customer.getUserId(), couponList);
//转换日志信息
changeList = transChange(customer.getId(), customer.getUserId(), active.getName(), couponList);
// customerCouponList = transCoupon(active.getId(), customer.getId(), customer.getUserId(), couponList);
//转换日志信息
// changeList = transChange(customer.getId(), customer.getUserId(), active.getName(), couponList);
}
//保存用户卡券
customerCouponService.saveBatch(customerCouponList);
if (null != customerCouponList){
customerCouponService.saveBatch(customerCouponList);
}
}
/*3、活动关联充值规则处理*/
@ -168,54 +191,10 @@ public class CustomerActiveServiceImpl extends ServiceImpl<CustomerActiveMapper,
}
/**
* 卡券实体转换
*
* @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;
}
/**

View File

@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.custom.service.CustomerBalanceChangeService;
import cn.iocoder.yudao.module.custom.vo.CustomerBalanceChangePageReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerBalanceChangeRespVO;
import cn.iocoder.yudao.module.custom.vo.CustomerBalanceChangeSaveReqVO;
import cn.iocoder.yudao.module.member.entity.MemberCoupon;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -18,8 +19,12 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import static cn.iocoder.yudao.common.BaseConstants.BALANCE_CHANGE_MAIN_KQ;
import static cn.iocoder.yudao.common.BaseConstants.BALANCE_CHANGE_TYPE_ZS;
/**
* 用户积分余额卡券变动记录 Service 实现类
*
@ -96,6 +101,29 @@ public class CustomerBalanceChangeServiceImpl extends ServiceImpl<CustomerBalanc
return customerBalanceChangeMapper.queryListPage(pageReqVO, page);
}
/**
* 转换变动记录
*
* @param cusId 客户id
* @param userId 用户id
* @param activeName 活动名称
* @param couponList 卡券集合
* @return java.util.List<cn.iocoder.yudao.module.custom.entity.CustomerBalanceChange>
* @author PQZ
* @date 21:58 2024/9/24
**/
@Override
public List<CustomerBalanceChange> transChange(String cusId, Long userId, String activeName, List<MemberCoupon> couponList) {
List<CustomerBalanceChange> transList = new ArrayList<>();
couponList.forEach(item -> {
CustomerBalanceChange change = 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;
}
/**
* 通过用户id和卡券id查询积分卡券的变动记录
*

View File

@ -10,6 +10,9 @@ import cn.iocoder.yudao.module.custom.service.CustomerCouponService;
import cn.iocoder.yudao.module.custom.vo.CustomerCouponPageReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerCouponRespVO;
import cn.iocoder.yudao.module.custom.vo.CustomerCouponSaveReqVO;
import cn.iocoder.yudao.module.member.entity.MemberCoupon;
import cn.iocoder.yudao.module.member.service.MemberCouponService;
import cn.iocoder.yudao.module.order.entity.RepairOrderInfo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -17,6 +20,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import static cn.iocoder.yudao.common.BaseConstants.*;
@ -34,6 +38,9 @@ public class CustomerCouponServiceImpl extends ServiceImpl<CustomerCouponMapper,
private CustomerCouponMapper customerCouponMapper;
@Resource
private CustomerBalanceChangeService changeService;
@Resource
private MemberCouponService couponService;
/**
@ -68,6 +75,52 @@ public class CustomerCouponServiceImpl extends ServiceImpl<CustomerCouponMapper,
);
}
/**
* 开卡有礼回调
*
* @param orderInfo RepairOrderInfo
* @author PQZ
* @date 21:50 2024/9/24
**/
@Override
public void couponCallBack(RepairOrderInfo orderInfo) {
List<String> ids = new ArrayList<>();
ids.add(orderInfo.getGoodsId());
//查询选中卡片信息
List<MemberCoupon> couponList = couponService.listByIds(ids, true);
List<CustomerCoupon> customerCouponList = transCoupon(orderInfo.getActiveId(), orderInfo.getCusId(), orderInfo.getUserId(), couponList);
List<CustomerBalanceChange> changeList = changeService.transChange(orderInfo.getCusId(), orderInfo.getUserId(), orderInfo.getGoodsTitle(), couponList);
saveBatch(customerCouponList);
changeService.saveBatch(changeList);
}
/**
* 卡券实体转换
*
* @param couponList MemberCoupon集合
* @return java.util.List<cn.iocoder.yudao.module.custom.entity.CustomerCoupon>
* @author PQZ
* @date 11:01 2024/9/21
**/
@Override
public 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;
}
@Override
public void deleteCustomerCoupon(String id) {
// 删除

View File

@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.company.service.CompanyService;
import cn.iocoder.yudao.module.custom.service.CustomerBalanceService;
import cn.iocoder.yudao.module.custom.service.CustomerCouponService;
import cn.iocoder.yudao.module.order.entity.RepairOrderInfo;
import cn.iocoder.yudao.module.order.service.RepairOrderInfoService;
import cn.iocoder.yudao.module.order.vo.RepairOrderInfoMapper;
@ -35,8 +36,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.common.BaseConstants.GENERAL_YES;
import static cn.iocoder.yudao.common.BaseConstants.ORDER_HYCZ;
import static cn.iocoder.yudao.common.BaseConstants.*;
/**
* 维修模块 订单 Service 实现类
@ -52,6 +52,8 @@ public class RepairOrderInfoServiceImpl extends ServiceImpl<RepairOrderInfoMappe
@Resource
@Lazy
private CustomerBalanceService balanceService;
@Resource
private CustomerCouponService couponService;
@Resource
private WechatPayConfig wechatPayConfig;
@ -85,8 +87,8 @@ public class RepairOrderInfoServiceImpl extends ServiceImpl<RepairOrderInfoMappe
if (ORDER_HYCZ.equals(orderInfo.getGoodsType())){
//会员充值回调
balanceService.balanceCallback(orderInfo);
} else {
// TODO: 2024/9/24 维修服务回调
} else if (ORDER_KKYL.equals(orderInfo.getGoodsType())){
couponService.couponCallBack(orderInfo);
}
orderInfo.setOrderStatus(GENERAL_YES);
orderInfo.setPayTime(LocalDateTime.now());