111
This commit is contained in:
parent
16fdfa62e4
commit
1226a2880e
@ -43,7 +43,37 @@ public class CustomerActiveController {
|
||||
@PostMapping("/attendActive")
|
||||
@Operation(summary = "参加活动")
|
||||
public CommonResult<Boolean> attendActive(@RequestBody CustomerActiveSaveReqVO createReqVO) {
|
||||
customerActiveService.attendActive(createReqVO);
|
||||
customerActiveService.attendActiveOrder(createReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新版参加活动
|
||||
*
|
||||
* @param createReqVO CustomerActiveSaveReqVO
|
||||
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.String>
|
||||
* @author PQZ
|
||||
* @date 9:49 2024/9/21
|
||||
**/
|
||||
@PostMapping("/attendActiveOrder")
|
||||
@Operation(summary = "参加活动")
|
||||
public CommonResult<Boolean> attendActiveOrder(@RequestBody CustomerActiveSaveReqVO createReqVO) {
|
||||
customerActiveService.attendActiveOrder(createReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值
|
||||
*
|
||||
* @param createReqVO CustomerActiveSaveReqVO实体
|
||||
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
|
||||
* @author PQZ
|
||||
* @date 16:34 2024/9/28
|
||||
**/
|
||||
@PostMapping("/recharge")
|
||||
@Operation(summary = "充值")
|
||||
public CommonResult<Boolean> recharge(@RequestBody CustomerActiveSaveReqVO createReqVO) {
|
||||
customerActiveService.recharge(createReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -73,11 +103,10 @@ public class CustomerActiveController {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author PQZ
|
||||
* @date 16:12 2024/9/23
|
||||
* @param pageReqVO ActiveMainPageReqVO实体
|
||||
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<com.baomidou.mybatisplus.core.metadata.IPage < ?>>
|
||||
* @author PQZ
|
||||
* @date 16:12 2024/9/23
|
||||
**/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "可参与营销活动")
|
||||
|
@ -31,12 +31,23 @@ public interface CustomerActiveService extends IService<CustomerActive> {
|
||||
|
||||
|
||||
/**
|
||||
* 用户参与活动
|
||||
* 新版参与活动方法
|
||||
* @author PQZ
|
||||
* @date 10:18 2024/9/27
|
||||
* @param saveReqVO CustomerActiveSaveReqVO实体
|
||||
* @date 11:38 2024/9/28
|
||||
* @param saveReqVO CustomerActiveSaveReqVO
|
||||
* @return cn.iocoder.yudao.module.order.entity.RepairOrderInfo
|
||||
**/
|
||||
void cusAttendActive(CustomerActiveSaveReqVO saveReqVO);
|
||||
RepairOrderInfo attendActiveOrder(CustomerActiveSaveReqVO saveReqVO);
|
||||
|
||||
|
||||
/**
|
||||
* 充值
|
||||
* @author PQZ
|
||||
* @date 16:25 2024/9/28
|
||||
* @param saveReqVO CustomerActiveSaveReqVO 实体
|
||||
* @return cn.iocoder.yudao.module.order.entity.RepairOrderInfo
|
||||
**/
|
||||
RepairOrderInfo recharge(CustomerActiveSaveReqVO saveReqVO);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -66,9 +66,8 @@ public class CustomerActiveServiceImpl extends ServiceImpl<CustomerActiveMapper,
|
||||
private RepairOrderInfoService repairOrderInfoService;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 参与活动
|
||||
* 参与活动(临时保留后续作废)
|
||||
*
|
||||
* @param saveReqVO CustomerActiveSaveReqVO实体
|
||||
* @author PQZ
|
||||
@ -205,19 +204,163 @@ public class CustomerActiveServiceImpl extends ServiceImpl<CustomerActiveMapper,
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户参与活动
|
||||
* 新版参与活动方法
|
||||
*
|
||||
* @param saveReqVO CustomerActiveSaveReqVO实体
|
||||
* @param saveReqVO CustomerActiveSaveReqVO
|
||||
* @return cn.iocoder.yudao.module.order.entity.RepairOrderInfo
|
||||
* @author PQZ
|
||||
* @date 10:18 2024/9/27
|
||||
* @date 11:38 2024/9/28
|
||||
**/
|
||||
@Override
|
||||
public void cusAttendActive(CustomerActiveSaveReqVO saveReqVO) {
|
||||
RepairOrderInfo repairOrderInfo = attendActive(saveReqVO);
|
||||
if (null != repairOrderInfo){
|
||||
public RepairOrderInfo attendActiveOrder(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 = null;
|
||||
//需保保存的用户积分余额信息
|
||||
CustomerBalance balance;
|
||||
//要返回的订单数据
|
||||
RepairOrderInfo resultOrder = null;
|
||||
|
||||
/*2、各类型活动处理*/
|
||||
if ("zcyl".equals(active.getType())) {
|
||||
//注册有礼
|
||||
List<MemberCoupon> couponList = active.getCouponList();
|
||||
//转换卡券信息
|
||||
customerCouponList = customerCouponService.transCoupon(active.getId(), customer.getId(), customer.getUserId(), couponList);
|
||||
//转换日志信息
|
||||
changeList = changeService.transChange(customer.getId(), customer.getUserId(), active.getName(), couponList);
|
||||
} else if ("kkyl".equals(active.getType())) {
|
||||
//开卡有礼
|
||||
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, false);
|
||||
if (CollectionUtil.isNotEmpty(couponList)) {
|
||||
//选择的开卡内容设定为单选
|
||||
MemberCoupon item = couponList.get(0);
|
||||
RepairOrderInfo orderInfo = new RepairOrderInfo();
|
||||
orderInfo.setOrderNo(System.currentTimeMillis() + Math.abs(item.getId().hashCode() % 1000) + "");
|
||||
orderInfo.setGoodsId(item.getId());
|
||||
orderInfo.setActiveId(active.getId());
|
||||
orderInfo.setGoodsTitle(item.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.setOrderStatus("0");
|
||||
orderInfo.setPayType(saveReqVO.getAccountType());
|
||||
repairOrderInfoService.save(orderInfo);
|
||||
resultOrder = repairOrderInfoService.getById(orderInfo.getId());
|
||||
}
|
||||
} else if ("czyl".equals(active.getType())) {
|
||||
// 充值有礼
|
||||
if (null == active.getRuleList() || active.getRuleList().isEmpty()) {
|
||||
//校验是否存在充值规则
|
||||
throw exception(CUSTOMER_ACTIVE_NO_RULE);
|
||||
}
|
||||
//记录日志
|
||||
CustomerBalanceChange change = changeService.initChange(customer.getId(),
|
||||
customer.getUserId(), null, BALANCE_CHANGE_TYPE_CZ, BALANCE_CHANGE_MAIN_YE,
|
||||
null, saveReqVO.getTopUpAmount(), new BigDecimal(0), "参加" + active.getName() + "活动充值" + saveReqVO.getTopUpAmount() + "元");
|
||||
changeService.save(change);
|
||||
RepairOrderInfo orderInfo = new RepairOrderInfo();
|
||||
orderInfo.setOrderNo(System.currentTimeMillis() + Math.abs(change.getId().hashCode() % 1000) + "");
|
||||
orderInfo.setGoodsId(change.getId());
|
||||
orderInfo.setActiveId(active.getId());
|
||||
orderInfo.setGoodsTitle(active.getName());
|
||||
orderInfo.setTenantName(ORDER_TENANT_NAME);
|
||||
orderInfo.setGoodsType(ORDER_HYCZ);
|
||||
orderInfo.setUserId(customer.getUserId());
|
||||
orderInfo.setCusId(customer.getId());
|
||||
orderInfo.setCusName(customer.getCusName());
|
||||
orderInfo.setCusPhone(customer.getPhoneNumber());
|
||||
orderInfo.setGoodsPrice(saveReqVO.getTopUpAmount());
|
||||
orderInfo.setPayMoney(saveReqVO.getTopUpAmount());
|
||||
orderInfo.setOrderTime(LocalDateTime.now());
|
||||
orderInfo.setOrderStatus("0");
|
||||
orderInfo.setPayType(saveReqVO.getAccountType());
|
||||
repairOrderInfoService.save(orderInfo);
|
||||
resultOrder = repairOrderInfoService.getById(orderInfo.getId());
|
||||
}
|
||||
|
||||
//保存用户卡券
|
||||
if (null != customerCouponList) {
|
||||
customerCouponService.saveBatch(customerCouponList);
|
||||
}
|
||||
/*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);
|
||||
return resultOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值
|
||||
*
|
||||
* @param saveReqVO CustomerActiveSaveReqVO 实体
|
||||
* @return cn.iocoder.yudao.module.order.entity.RepairOrderInfo
|
||||
* @author PQZ
|
||||
* @date 16:25 2024/9/28
|
||||
**/
|
||||
@Override
|
||||
public RepairOrderInfo recharge(CustomerActiveSaveReqVO saveReqVO) {
|
||||
//当前客户信息
|
||||
CustomerMainRespVO customer = customerMainService.getCustomerById(saveReqVO.getCusId());
|
||||
//变更信息
|
||||
CustomerBalanceChange change = changeService.initChange(customer.getId(),
|
||||
customer.getUserId(), null, BALANCE_CHANGE_TYPE_CZ, BALANCE_CHANGE_MAIN_YE,
|
||||
null, saveReqVO.getTopUpAmount(), new BigDecimal(0), "充值" + saveReqVO.getTopUpAmount() + "元");
|
||||
|
||||
RepairOrderInfo orderInfo = new RepairOrderInfo();
|
||||
orderInfo.setOrderNo(System.currentTimeMillis() + Math.abs(change.getId().hashCode() % 1000) + "");
|
||||
orderInfo.setGoodsId(change.getId());
|
||||
orderInfo.setActiveId(null);
|
||||
orderInfo.setGoodsTitle("用户充值");
|
||||
orderInfo.setTenantName(ORDER_TENANT_NAME);
|
||||
orderInfo.setGoodsType(ORDER_HYCZ);
|
||||
orderInfo.setUserId(customer.getUserId());
|
||||
orderInfo.setCusId(customer.getId());
|
||||
orderInfo.setCusName(customer.getCusName());
|
||||
orderInfo.setCusPhone(customer.getPhoneNumber());
|
||||
orderInfo.setGoodsPrice(saveReqVO.getTopUpAmount());
|
||||
orderInfo.setPayMoney(saveReqVO.getTopUpAmount());
|
||||
orderInfo.setOrderTime(LocalDateTime.now());
|
||||
orderInfo.setIsOnline("01");
|
||||
orderInfo.setOrderStatus("0");
|
||||
orderInfo.setPayType(saveReqVO.getAccountType());
|
||||
//保存变更日志
|
||||
changeService.save(change);
|
||||
//保存订单信息
|
||||
repairOrderInfoService.save(orderInfo);
|
||||
return repairOrderInfoService.getById(orderInfo.getId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user