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";
/**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;
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<java.lang.Boolean>
**/
@PostMapping("/saveBalance")
@Operation(summary = "创建用户积分(余额)")
@PreAuthorize("@ss.hasPermission('base:customer-balance:create')")
public CommonResult<Boolean> 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<java.lang.Boolean>
// **/
// @PostMapping("/saveBalance")
// @Operation(summary = "创建用户积分(余额)")
// @PreAuthorize("@ss.hasPermission('base:customer-balance:create')")
// public CommonResult<Boolean> saveBalance(@RequestBody CustomerBalanceSaveReqVO createReqVO) {
// customerBalanceService.saveBalance(createReqVO.getCusId(),createReqVO.getOrderId(),createReqVO.getActiveId());
// return success(true);
// }
@PostMapping("/create")
@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.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<CustomerBalance> {
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);
/**
* 更新用户积分余额

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.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<CustomerActiveMapper,
private CustomerCouponService customerCouponService;
@Resource
@Lazy
private CustomerBalanceService balanceService;
@Resource
@Lazy
private RepairOrderInfoService repairOrderInfoService;
/**
* 参与活动
*
@ -123,16 +123,33 @@ public class CustomerActiveServiceImpl extends ServiceImpl<CustomerActiveMapper,
if (null == active.getRuleList() || active.getRuleList().isEmpty()) {
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(),
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、保存参与活动信息*/

View File

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

View File

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

View File

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

View File

@ -28,6 +28,15 @@ public interface RepairOrderInfoService extends IService<RepairOrderInfo> {
**/
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);
/**
* 根据订单编号查询订单数据
* @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.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<RepairOrderInfoMappe
@Resource
private RepairOrderInfoMapper repairOrderInfoMapper;
@Resource
@Lazy
private CustomerBalanceService balanceService;
@Resource
private WechatPayConfig wechatPayConfig;
@ -56,6 +65,26 @@ public class RepairOrderInfoServiceImpl extends ServiceImpl<RepairOrderInfoMappe
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
public void deleteOrderInfo(String id) {
// 删除
@ -68,6 +97,21 @@ public class RepairOrderInfoServiceImpl extends ServiceImpl<RepairOrderInfoMappe
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
public PageResult<RepairOrderInfo> getOrderInfoPage(RepairOrderInfoPageReqVO pageReqVO) {
return null;

View File

@ -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<DlRepairTicketsMappe
// 订单号采用时间戳+工单ID和hash值取余后取3位
repairOrderInfo.setOrderNo(System.currentTimeMillis() + Math.abs(ticketsRespVO.getId().hashCode() % 1000) + "");
repairOrderInfo.setGoodsId(ticketsRespVO.getId());
repairOrderInfo.setTenantName(ORDER_TENANT_NAME);
DictDataRespDTO repairType = dictDataApi.getDictData("repair_type", ticketsRespVO.getRepairType());
if (ObjectUtil.isNotEmpty(repairType)) {
repairOrderInfo.setGoodsTitle(repairType.getLabel());