This commit is contained in:
PQZ 2024-09-23 22:50:05 +08:00
parent 9143962110
commit 3186867fb0
10 changed files with 129 additions and 45 deletions

View File

@ -77,5 +77,11 @@ public class BaseConstants {
public static final String GENERAL_NO = "0"; public static final String GENERAL_NO = "0";
/**1是*/ /**1是*/
public static final String GENERAL_YES = "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 = "蓝安集团";
} }

View File

@ -1,7 +1,10 @@
package cn.iocoder.yudao.module.custom.controller.admin; package cn.iocoder.yudao.module.custom.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; 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.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.CustomerBalanceSaveReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO; import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -25,20 +28,21 @@ public class CustomerBalanceController {
@Resource @Resource
private CustomerBalanceService customerBalanceService; private CustomerBalanceService customerBalanceService;
/** // /**
* 更新用户余额信息(充值完成的回调) // * 更新用户余额信息(充值完成的回调)
* @author PQZ // * @author PQZ
* @date 21:42 2024/9/23 // * @date 21:42 2024/9/23
* @param createReqVO CustomerBalanceSaveReqVO // * @param createReqVO CustomerBalanceSaveReqVO
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean> // * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<java.lang.Boolean>
**/ // **/
@PostMapping("/saveBalance") // @PostMapping("/saveBalance")
@Operation(summary = "创建用户积分(余额)") // @Operation(summary = "创建用户积分(余额)")
@PreAuthorize("@ss.hasPermission('base:customer-balance:create')") // @PreAuthorize("@ss.hasPermission('base:customer-balance:create')")
public CommonResult<Boolean> saveBalance(@RequestBody CustomerBalanceSaveReqVO createReqVO) { // public CommonResult<Boolean> saveBalance(@RequestBody CustomerBalanceSaveReqVO createReqVO) {
customerBalanceService.saveBalance(createReqVO.getCusId(),createReqVO.getOrderId(),createReqVO.getActiveId()); // customerBalanceService.saveBalance(createReqVO.getCusId(),createReqVO.getOrderId(),createReqVO.getActiveId());
return success(true); // return success(true);
} // }
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建用户积分(余额)") @Operation(summary = "创建用户积分(余额)")

View File

@ -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.entity.CustomerBalance;
import cn.iocoder.yudao.module.custom.vo.CustomerBalanceSaveReqVO; import cn.iocoder.yudao.module.custom.vo.CustomerBalanceSaveReqVO;
import cn.iocoder.yudao.module.order.entity.RepairOrderInfo;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import javax.validation.Valid; import javax.validation.Valid;
@ -22,15 +23,13 @@ public interface CustomerBalanceService extends IService<CustomerBalance> {
String createCustomerBalance(@Valid CustomerBalanceSaveReqVO createReqVO); String createCustomerBalance(@Valid CustomerBalanceSaveReqVO createReqVO);
/** /**
* 更新用户余额信息 * 更新用户余额信息(充值完成的回调)
* *
* @param cusId 用户id * @param orderInfo 订单信息
* @param orderId 订单id
* @param activeId 活动id
* @author PQZ * @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);
/** /**
* 更新用户积分余额 * 更新用户积分余额

View File

@ -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.service.MemberCouponService;
import cn.iocoder.yudao.module.member.vo.ActiveMainPageReqVO; import cn.iocoder.yudao.module.member.vo.ActiveMainPageReqVO;
import cn.iocoder.yudao.module.member.vo.ActiveMainRespVO; 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 cn.iocoder.yudao.module.order.service.RepairOrderInfoService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -27,6 +28,7 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -60,12 +62,10 @@ public class CustomerActiveServiceImpl extends ServiceImpl<CustomerActiveMapper,
private CustomerCouponService customerCouponService; private CustomerCouponService customerCouponService;
@Resource @Resource
@Lazy @Lazy
private CustomerBalanceService balanceService;
@Resource
@Lazy
private RepairOrderInfoService repairOrderInfoService; private RepairOrderInfoService repairOrderInfoService;
/** /**
* 参与活动 * 参与活动
* *
@ -123,16 +123,33 @@ public class CustomerActiveServiceImpl extends ServiceImpl<CustomerActiveMapper,
if (null == active.getRuleList() || active.getRuleList().isEmpty()) { if (null == active.getRuleList() || active.getRuleList().isEmpty()) {
throw exception(CUSTOMER_ACTIVE_NO_RULE); throw exception(CUSTOMER_ACTIVE_NO_RULE);
} }
List<ActiveRule> ruleList = active.getRuleList(); // List<ActiveRule> ruleList = active.getRuleList();
//转换余额信息 //转换余额信息
balance = transBalance(customer, saveReqVO.getTopUpAmount(), ruleList); // balance = transBalance(customer, saveReqVO.getTopUpAmount(), ruleList);
//记录日志 //记录日志
CustomerBalanceChange change = changeService.initChange(customer.getId(), CustomerBalanceChange change = changeService.initChange(customer.getId(),
customer.getUserId(), null, BALANCE_CHANGE_TYPE_CZ, BALANCE_CHANGE_MAIN_YE, customer.getUserId(), null, BALANCE_CHANGE_TYPE_CZ, BALANCE_CHANGE_MAIN_YE,
null, balance.getNowChange(), balance.getBalance(), "参加" + active.getName() + "活动"); null, saveReqVO.getTopUpAmount(), new BigDecimal(0), "参加" + active.getName() + "活动充值" + saveReqVO.getTopUpAmount() + "");
changeList.add(change); 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、保存参与活动信息*/ /*4、保存参与活动信息*/

View File

@ -45,9 +45,6 @@ public class CustomerBalanceServiceImpl extends ServiceImpl<CustomerBalanceMappe
private CustomerMainService customerMainService; private CustomerMainService customerMainService;
@Resource @Resource
@Lazy @Lazy
private RepairOrderInfoService orderInfoService;
@Resource
@Lazy
private ActiveMainService activeMainService; private ActiveMainService activeMainService;
@ -63,30 +60,23 @@ public class CustomerBalanceServiceImpl extends ServiceImpl<CustomerBalanceMappe
/** /**
* 更新用户余额信息(充值完成的回调) * 更新用户余额信息(充值完成的回调)
* *
* @param cusId 用户id * @param orderInfo 用户订单信息
* @param orderId 订单id
* @param activeId 活动id
* @author PQZ * @author PQZ
* @date 21:04 2024/9/23 * @date 21:04 2024/9/23
**/ **/
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void saveBalance(String cusId, String orderId, String activeId) { public void balanceCallback(RepairOrderInfo orderInfo) {
//查询当前登录用户信息 //查询当前登录用户信息
CustomerMainRespVO customer = customerMainService.getCustomerById(cusId); CustomerMainRespVO customer = customerMainService.getCustomerById(orderInfo.getCusId());
//查询订单表数据
RepairOrderInfo orderInfo = orderInfoService.getById(orderId);
CustomerBalance balance; CustomerBalance balance;
if (null != activeId) { if (null != orderInfo.getActiveId()) {
//获取当前活动信息 //获取当前活动信息
ActiveMainRespVO active = activeMainService.getActiveMain(activeId, true); ActiveMainRespVO active = activeMainService.getActiveMain(orderInfo.getActiveId(), true);
balance = transBalance(customer, orderInfo.getPayMoney(), active.getRuleList()); balance = transBalance(customer, orderInfo.getPayMoney(), active.getRuleList());
} else { } else {
balance = transBalance(customer, orderInfo.getPayMoney(), null); balance = transBalance(customer, orderInfo.getPayMoney(), null);
} }
orderInfo.setOrderStatus(GENERAL_YES);
orderInfo.setPayTime(LocalDateTime.now());
orderInfoService.updateById(orderInfo);
updateByCusId(balance); updateByCusId(balance);
} }

View File

@ -10,7 +10,7 @@ import java.math.BigDecimal;
@Schema(description = "管理后台 - 用户积分(余额)新增/修改 Request VO") @Schema(description = "管理后台 - 用户积分(余额)新增/修改 Request VO")
@Data @Data
public class CustomerBalanceSaveReqVO extends CustomerBalance { public class CustomerBalanceSaveReqVO extends CustomerBalance {
private String activeId;
private String orderId; private String orderId;
} }

View File

@ -47,7 +47,7 @@ public class RepairOrderInfo extends TenantBaseDO {
/** /**
* 用户id * 用户id
*/ */
private Integer userId; private Long userId;
/** /**
* 客户id * 客户id
*/ */
@ -156,6 +156,10 @@ public class RepairOrderInfo extends TenantBaseDO {
* 创建人所在部门 * 创建人所在部门
*/ */
private String tenantName; private String tenantName;
/**
* 活动id
*/
private String activeId;
} }

View File

@ -28,6 +28,15 @@ public interface RepairOrderInfoService extends IService<RepairOrderInfo> {
**/ **/
void saveOrderInfo(RepairOrderInfoSaveReqVO saveReqVO); 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> {
*/ */
RepairOrderInfo getOrderInfo(String id); 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);
/** /**
* 获得维修模块 订单分页 * 获得维修模块 订单分页
* *

View File

@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.order.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; 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.entity.RepairOrderInfo;
import cn.iocoder.yudao.module.order.service.RepairOrderInfoService; import cn.iocoder.yudao.module.order.service.RepairOrderInfoService;
import cn.iocoder.yudao.module.order.vo.RepairOrderInfoMapper; 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.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -26,6 +29,9 @@ import java.time.LocalDateTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static cn.iocoder.yudao.common.BaseConstants.GENERAL_YES;
import static cn.iocoder.yudao.common.BaseConstants.ORDER_HYCZ;
/** /**
* 维修模块 订单 Service 实现类 * 维修模块 订单 Service 实现类
* *
@ -37,6 +43,9 @@ public class RepairOrderInfoServiceImpl extends ServiceImpl<RepairOrderInfoMappe
@Resource @Resource
private RepairOrderInfoMapper repairOrderInfoMapper; private RepairOrderInfoMapper repairOrderInfoMapper;
@Resource
@Lazy
private CustomerBalanceService balanceService;
@Resource @Resource
private WechatPayConfig wechatPayConfig; private WechatPayConfig wechatPayConfig;
@ -56,6 +65,26 @@ public class RepairOrderInfoServiceImpl extends ServiceImpl<RepairOrderInfoMappe
saveOrUpdate(save); saveOrUpdate(save);
} }
/**
* 充值完成回调接口
*
* @param orderNo 订单编号
* @author PQZ
* @date 22:19 2024/9/23
**/
@Override
public void rechargeCallback(String orderNo) {
RepairOrderInfo orderInfo = getOrderByOrderNo(orderNo);
if (ORDER_HYCZ.equals(orderInfo.getGoodsType())){
balanceService.balanceCallback(orderInfo);
} else {
}
orderInfo.setOrderStatus(GENERAL_YES);
orderInfo.setPayTime(LocalDateTime.now());
updateById(orderInfo);
}
@Override @Override
public void deleteOrderInfo(String id) { public void deleteOrderInfo(String id) {
// 删除 // 删除
@ -68,6 +97,21 @@ public class RepairOrderInfoServiceImpl extends ServiceImpl<RepairOrderInfoMappe
return repairOrderInfoMapper.selectById(id); return repairOrderInfoMapper.selectById(id);
} }
/**
* 根据订单编号查询订单数据
*
* @param orderNo 订单编号
* @return cn.iocoder.yudao.module.order.entity.RepairOrderInfo
* @author PQZ
* @date 22:12 2024/9/23
**/
@Override
public RepairOrderInfo getOrderByOrderNo(String orderNo) {
LambdaQueryWrapper<RepairOrderInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(RepairOrderInfo::getOrderNo,orderNo).eq(BaseDO::getDeleted,'0');
return getOne(lambdaQueryWrapper);
}
@Override @Override
public PageResult<RepairOrderInfo> getOrderInfoPage(RepairOrderInfoPageReqVO pageReqVO) { public PageResult<RepairOrderInfo> getOrderInfoPage(RepairOrderInfoPageReqVO pageReqVO) {
return null; return null;

View File

@ -41,6 +41,7 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; 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; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
/** /**
@ -126,6 +127,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 订单号采用时间戳+工单ID和hash值取余后取3位 // 订单号采用时间戳+工单ID和hash值取余后取3位
repairOrderInfo.setOrderNo(System.currentTimeMillis() + Math.abs(ticketsRespVO.getId().hashCode() % 1000) + ""); repairOrderInfo.setOrderNo(System.currentTimeMillis() + Math.abs(ticketsRespVO.getId().hashCode() % 1000) + "");
repairOrderInfo.setGoodsId(ticketsRespVO.getId()); repairOrderInfo.setGoodsId(ticketsRespVO.getId());
repairOrderInfo.setTenantName(ORDER_TENANT_NAME);
DictDataRespDTO repairType = dictDataApi.getDictData("repair_type", ticketsRespVO.getRepairType()); DictDataRespDTO repairType = dictDataApi.getDictData("repair_type", ticketsRespVO.getRepairType());
if (ObjectUtil.isNotEmpty(repairType)) { if (ObjectUtil.isNotEmpty(repairType)) {
repairOrderInfo.setGoodsTitle(repairType.getLabel()); repairOrderInfo.setGoodsTitle(repairType.getLabel());