From 3186867fb0728c54c6225f6cc01e417e2de1480c Mon Sep 17 00:00:00 2001 From: PQZ Date: Mon, 23 Sep 2024 22:50:05 +0800 Subject: [PATCH] 1 --- .../iocoder/yudao/common/BaseConstants.java | 6 +++ .../admin/CustomerBalanceController.java | 32 ++++++++------ .../service/CustomerBalanceService.java | 11 +++-- .../impl/CustomerActiveServiceImpl.java | 33 ++++++++++---- .../impl/CustomerBalanceServiceImpl.java | 20 +++------ .../custom/vo/CustomerBalanceSaveReqVO.java | 2 +- .../module/order/entity/RepairOrderInfo.java | 6 ++- .../order/service/RepairOrderInfoService.java | 18 ++++++++ .../impl/RepairOrderInfoServiceImpl.java | 44 +++++++++++++++++++ .../impl/DlRepairTicketsServiceImpl.java | 2 + 10 files changed, 129 insertions(+), 45 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 2f6d2861..60b04b6b 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 @@ -77,5 +77,11 @@ public class BaseConstants { public static final String GENERAL_NO = "0"; /**1是*/ 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_TENANT_NAME = "蓝安集团"; } diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerBalanceController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerBalanceController.java index 07e4092f..5fa0ced0 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerBalanceController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerBalanceController.java @@ -1,7 +1,10 @@ package cn.iocoder.yudao.module.custom.controller.admin; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.custom.entity.CustomerActive; import cn.iocoder.yudao.module.custom.service.CustomerBalanceService; +import cn.iocoder.yudao.module.custom.vo.CustomerActiveRespVO; import cn.iocoder.yudao.module.custom.vo.CustomerBalanceSaveReqVO; import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO; import io.swagger.v3.oas.annotations.Operation; @@ -25,20 +28,21 @@ public class CustomerBalanceController { @Resource private CustomerBalanceService customerBalanceService; - /** - * 更新用户余额信息(充值完成的回调) - * @author PQZ - * @date 21:42 2024/9/23 - * @param createReqVO CustomerBalanceSaveReqVO - * @return cn.iocoder.yudao.framework.common.pojo.CommonResult - **/ - @PostMapping("/saveBalance") - @Operation(summary = "创建用户积分(余额)") - @PreAuthorize("@ss.hasPermission('base:customer-balance:create')") - public CommonResult saveBalance(@RequestBody CustomerBalanceSaveReqVO createReqVO) { - customerBalanceService.saveBalance(createReqVO.getCusId(),createReqVO.getOrderId(),createReqVO.getActiveId()); - return success(true); - } +// /** +// * 更新用户余额信息(充值完成的回调) +// * @author PQZ +// * @date 21:42 2024/9/23 +// * @param createReqVO CustomerBalanceSaveReqVO +// * @return cn.iocoder.yudao.framework.common.pojo.CommonResult +// **/ +// @PostMapping("/saveBalance") +// @Operation(summary = "创建用户积分(余额)") +// @PreAuthorize("@ss.hasPermission('base:customer-balance:create')") +// public CommonResult saveBalance(@RequestBody CustomerBalanceSaveReqVO createReqVO) { +// customerBalanceService.saveBalance(createReqVO.getCusId(),createReqVO.getOrderId(),createReqVO.getActiveId()); +// return success(true); +// } + @PostMapping("/create") @Operation(summary = "创建用户积分(余额)") diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerBalanceService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerBalanceService.java index 12c03a0d..4749485b 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerBalanceService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CustomerBalanceService.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.custom.service; import cn.iocoder.yudao.module.custom.entity.CustomerBalance; import cn.iocoder.yudao.module.custom.vo.CustomerBalanceSaveReqVO; +import cn.iocoder.yudao.module.order.entity.RepairOrderInfo; import com.baomidou.mybatisplus.extension.service.IService; import javax.validation.Valid; @@ -22,15 +23,13 @@ public interface CustomerBalanceService extends IService { String createCustomerBalance(@Valid CustomerBalanceSaveReqVO createReqVO); /** - * 更新用户余额信息 + * 更新用户余额信息(充值完成的回调) * - * @param cusId 用户id - * @param orderId 订单id - * @param activeId 活动id + * @param orderInfo 订单信息 * @author PQZ - * @date 21:04 2024/9/23 + * @date 22:10 2024/9/23 **/ - void saveBalance(String cusId, String orderId, String activeId); + void balanceCallback(RepairOrderInfo orderInfo); /** * 更新用户积分(余额) 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 0fecd296..a1994ab7 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 @@ -16,6 +16,7 @@ import cn.iocoder.yudao.module.member.service.ActiveMainService; import cn.iocoder.yudao.module.member.service.MemberCouponService; import cn.iocoder.yudao.module.member.vo.ActiveMainPageReqVO; import cn.iocoder.yudao.module.member.vo.ActiveMainRespVO; +import cn.iocoder.yudao.module.order.entity.RepairOrderInfo; import cn.iocoder.yudao.module.order.service.RepairOrderInfoService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -27,6 +28,7 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.math.BigDecimal; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -60,12 +62,10 @@ public class CustomerActiveServiceImpl extends ServiceImpl ruleList = active.getRuleList(); +// List ruleList = active.getRuleList(); //转换余额信息 - balance = transBalance(customer, saveReqVO.getTopUpAmount(), ruleList); +// 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); + 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.setIsOnline("01"); + orderInfo.setOrderStatus("0"); + repairOrderInfoService.save(orderInfo); //保存余额信息 - balanceService.updateByCusId(balance); +// balanceService.updateByCusId(balance); } /*4、保存参与活动信息*/ diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerBalanceServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerBalanceServiceImpl.java index b1cd7156..8b41f54b 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerBalanceServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CustomerBalanceServiceImpl.java @@ -45,9 +45,6 @@ public class CustomerBalanceServiceImpl extends ServiceImpl { **/ void saveOrderInfo(RepairOrderInfoSaveReqVO saveReqVO); + + /** + * 充值完成回调接口 + * @author PQZ + * @date 22:19 2024/9/23 + * @param orderNo 订单编号 + **/ + void rechargeCallback(String orderNo); + /** * 删除维修模块 订单 * @@ -43,6 +52,15 @@ public interface RepairOrderInfoService extends IService { */ RepairOrderInfo getOrderInfo(String id); + /** + * 根据订单编号查询订单数据 + * @author PQZ + * @date 22:12 2024/9/23 + * @param orderNo 订单编号 + * @return cn.iocoder.yudao.module.order.entity.RepairOrderInfo + **/ + RepairOrderInfo getOrderByOrderNo(String orderNo); + /** * 获得维修模块 订单分页 * 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 234afe7f..8ade533c 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 @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.order.service.impl; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.custom.service.CustomerBalanceService; import cn.iocoder.yudao.module.order.entity.RepairOrderInfo; import cn.iocoder.yudao.module.order.service.RepairOrderInfoService; import cn.iocoder.yudao.module.order.vo.RepairOrderInfoMapper; @@ -14,6 +16,7 @@ import cn.iocoder.yudao.util.WechatPayRequest; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -26,6 +29,9 @@ import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map; +import static cn.iocoder.yudao.common.BaseConstants.GENERAL_YES; +import static cn.iocoder.yudao.common.BaseConstants.ORDER_HYCZ; + /** * 维修模块 订单 Service 实现类 * @@ -37,6 +43,9 @@ public class RepairOrderInfoServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(RepairOrderInfo::getOrderNo,orderNo).eq(BaseDO::getDeleted,'0'); + return getOne(lambdaQueryWrapper); + } + @Override public PageResult getOrderInfoPage(RepairOrderInfoPageReqVO pageReqVO) { return null; diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java index 72f0e601..2a4519b7 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java @@ -41,6 +41,7 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import static cn.iocoder.yudao.common.BaseConstants.ORDER_TENANT_NAME; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; /** @@ -126,6 +127,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl