From 20e5f46f7fff99fbf145c00194db78073aa7fb19 Mon Sep 17 00:00:00 2001 From: PQZ Date: Tue, 24 Sep 2024 22:33:44 +0800 Subject: [PATCH] 1 --- .../iocoder/yudao/common/BaseConstants.java | 3 + .../service/CustomerBalanceChangeService.java | 22 ++++- .../custom/service/CustomerCouponService.java | 23 ++++- .../impl/CustomerActiveServiceImpl.java | 89 +++++++------------ .../CustomerBalanceChangeServiceImpl.java | 28 ++++++ .../impl/CustomerCouponServiceImpl.java | 53 +++++++++++ .../impl/RepairOrderInfoServiceImpl.java | 10 ++- 7 files changed, 163 insertions(+), 65 deletions(-) diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java index 763140e8..f65c46be 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java @@ -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 = "蓝安集团"; diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerBalanceChangeService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerBalanceChangeService.java index ce326e7d..1ad894fa 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerBalanceChangeService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerBalanceChangeService.java @@ -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 queryListPage(CustomerBalanceChangePageReqVO pageReqVO, Page page); + + /** + * 转换变动记录 + * + * @param cusId 客户id + * @param userId 用户id + * @param activeName 活动名称 + * @param couponList 卡券集合 + * @return java.util.List + * @author PQZ + * @date 21:58 2024/9/24 + **/ + List transChange(String cusId, Long userId, String activeName, List couponList); + /** * 通过用户id和卡券id查询积分、卡券的变动记录 * diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerCouponService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerCouponService.java index 55780a9a..1035463d 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerCouponService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerCouponService.java @@ -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 { **/ 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 + * @author PQZ + * @date 11:01 2024/9/21 + **/ + List transCoupon(String activeId, String cusId, Long userId, List couponList); + /** * 删除用户卡券 * diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerActiveServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerActiveServiceImpl.java index 413cdd7b..3a993f84 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerActiveServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerActiveServiceImpl.java @@ -86,7 +86,7 @@ public class CustomerActiveServiceImpl extends ServiceImpl customerCouponList; + List customerCouponList = null; //需保保存的用户积分余额信息 CustomerBalance balance; @@ -95,10 +95,10 @@ public class CustomerActiveServiceImpl extends ServiceImpl 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 ids = saveReqVO.getSelectCoupon().stream().map(MemberCoupon::getId).collect(Collectors.toList()); - List couponList = couponService.listByIds(ids, true); + //查询选中卡片信息 + List 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 - * @author PQZ - * @date 11:01 2024/9/21 - **/ - List transCoupon(String activeId, String cusId, Long userId, List couponList) { - List 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 - * @author PQZ - * @date 11:20 2024/9/21 - **/ - List transChange(String cusId, Long userId, String activeName, List couponList) { - List 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; - } + + /** diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerBalanceChangeServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerBalanceChangeServiceImpl.java index 2f5b30a7..ee359a25 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerBalanceChangeServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerBalanceChangeServiceImpl.java @@ -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 + * @author PQZ + * @date 21:58 2024/9/24 + **/ + @Override + public List transChange(String cusId, Long userId, String activeName, List couponList) { + List 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查询积分、卡券的变动记录 * diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerCouponServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerCouponServiceImpl.java index 703684fd..e290fe55 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerCouponServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerCouponServiceImpl.java @@ -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 ids = new ArrayList<>(); + ids.add(orderInfo.getGoodsId()); + //查询选中卡片信息 + List couponList = couponService.listByIds(ids, true); + List customerCouponList = transCoupon(orderInfo.getActiveId(), orderInfo.getCusId(), orderInfo.getUserId(), couponList); + List changeList = changeService.transChange(orderInfo.getCusId(), orderInfo.getUserId(), orderInfo.getGoodsTitle(), couponList); + saveBatch(customerCouponList); + changeService.saveBatch(changeList); + } + + /** + * 卡券实体转换 + * + * @param couponList MemberCoupon集合 + * @return java.util.List + * @author PQZ + * @date 11:01 2024/9/21 + **/ + @Override + public List transCoupon(String activeId, String cusId, Long userId, List couponList) { + List 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) { // 删除 diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/order/service/impl/RepairOrderInfoServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/order/service/impl/RepairOrderInfoServiceImpl.java index f160712e..a0f133ac 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/order/service/impl/RepairOrderInfoServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/order/service/impl/RepairOrderInfoServiceImpl.java @@ -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