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/app/customer/admin/CustomerMainApi.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/customer/admin/CustomerMainApi.java index 6995eed1..b69f3648 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/customer/admin/CustomerMainApi.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/app/customer/admin/CustomerMainApi.java @@ -8,9 +8,13 @@ import cn.iocoder.yudao.module.conf.entity.BaseType; import cn.iocoder.yudao.module.custom.entity.CustomerMain; import cn.iocoder.yudao.module.custom.service.CustomerMainService; import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO; +import cn.iocoder.yudao.module.member.entity.MemberLevel; +import cn.iocoder.yudao.module.member.service.MemberLevelService; +import cn.iocoder.yudao.module.member.vo.MemberLevelPageReqVO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -18,6 +22,8 @@ import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; +import java.util.List; + import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; /** @@ -31,6 +37,8 @@ public class CustomerMainApi { @Resource private CustomerMainService customerMainService; + @Resource + private MemberLevelService levelService; /** * 查询当前登录客户信息 @@ -44,6 +52,12 @@ public class CustomerMainApi { return success(customerMainService.getUserCustomer()); } + @GetMapping("/allMember") + @Operation(summary = "获得全部会员") + public CommonResult> getLevelAll(MemberLevelPageReqVO pageReqVO) { + return success(levelService.queryListAll(pageReqVO)); + } + /** * 根据车辆ID反查用户信息 * 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/custom/vo/CustomerMainRespVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerMainRespVO.java index 13ef1dac..c4a3ad32 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerMainRespVO.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerMainRespVO.java @@ -41,6 +41,8 @@ public class CustomerMainRespVO extends CustomerMain { private BigDecimal forzeBalance; /**累计充值额度*/ private BigDecimal allBalance; + /**会员权益*/ + private String userEquity; } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/service/impl/MemberLevelServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/service/impl/MemberLevelServiceImpl.java index b5dd3b83..b078b057 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/service/impl/MemberLevelServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/service/impl/MemberLevelServiceImpl.java @@ -15,7 +15,9 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; /** * 会员等级 Service 实现类 @@ -88,9 +90,8 @@ public class MemberLevelServiceImpl extends ServiceImpl queryListAll(MemberLevelPageReqVO pageReqVO) { QueryWrapper q = new QueryWrapper<>(); - q.eq("status","01"); List memberLevels = this.levelMapper.selectList(q); - return memberLevels; + return memberLevels.stream().sorted(Comparator.comparing(MemberLevel::getSort)).collect(Collectors.toList()); } 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