Compare commits
No commits in common. "91439621106f1cef41668e018dd1ead028579291" and "94f046d44ca7474f3d3a41f63be4f04c0a9ded41" have entirely different histories.
9143962110
...
94f046d44c
@ -25,21 +25,6 @@ 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);
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建用户积分(余额)")
|
||||
@PreAuthorize("@ss.hasPermission('base:customer-balance:create')")
|
||||
@ -55,6 +40,4 @@ public class CustomerBalanceController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -16,11 +16,9 @@ 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.service.RepairOrderInfoService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mzt.logapi.service.IFunctionService;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -59,11 +57,7 @@ public class CustomerActiveServiceImpl extends ServiceImpl<CustomerActiveMapper,
|
||||
@Resource
|
||||
private CustomerCouponService customerCouponService;
|
||||
@Resource
|
||||
@Lazy
|
||||
private CustomerBalanceService balanceService;
|
||||
@Resource
|
||||
@Lazy
|
||||
private RepairOrderInfoService repairOrderInfoService;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -8,27 +8,13 @@ import cn.iocoder.yudao.module.custom.service.CustomerBalanceService;
|
||||
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
|
||||
import cn.iocoder.yudao.module.custom.vo.CustomerBalanceSaveReqVO;
|
||||
import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO;
|
||||
import cn.iocoder.yudao.module.member.entity.ActiveRule;
|
||||
import cn.iocoder.yudao.module.member.service.ActiveMainService;
|
||||
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;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.common.BaseConstants.GENERAL_YES;
|
||||
|
||||
/**
|
||||
* 用户积分(余额) Service 实现类
|
||||
@ -43,12 +29,6 @@ public class CustomerBalanceServiceImpl extends ServiceImpl<CustomerBalanceMappe
|
||||
private CustomerBalanceMapper customerBalanceMapper;
|
||||
@Resource
|
||||
private CustomerMainService customerMainService;
|
||||
@Resource
|
||||
@Lazy
|
||||
private RepairOrderInfoService orderInfoService;
|
||||
@Resource
|
||||
@Lazy
|
||||
private ActiveMainService activeMainService;
|
||||
|
||||
|
||||
@Override
|
||||
@ -61,7 +41,7 @@ public class CustomerBalanceServiceImpl extends ServiceImpl<CustomerBalanceMappe
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户余额信息(充值完成的回调)
|
||||
* 更新用户余额信息
|
||||
*
|
||||
* @param cusId 用户id
|
||||
* @param orderId 订单id
|
||||
@ -70,58 +50,9 @@ public class CustomerBalanceServiceImpl extends ServiceImpl<CustomerBalanceMappe
|
||||
* @date 21:04 2024/9/23
|
||||
**/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveBalance(String cusId, String orderId, String activeId) {
|
||||
//查询当前登录用户信息
|
||||
CustomerMainRespVO customer = customerMainService.getCustomerById(cusId);
|
||||
//查询订单表数据
|
||||
RepairOrderInfo orderInfo = orderInfoService.getById(orderId);
|
||||
CustomerBalance balance;
|
||||
if (null != activeId) {
|
||||
//获取当前活动信息
|
||||
ActiveMainRespVO active = activeMainService.getActiveMain(activeId, 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换余额
|
||||
*
|
||||
* @param customer 用户信息
|
||||
* @param amount 实际充值金额
|
||||
* @param ruleList 规则
|
||||
* @return cn.iocoder.yudao.module.custom.entity.CustomerBalance
|
||||
* @author PQZ
|
||||
* @date 11:30 2024/9/21
|
||||
**/
|
||||
CustomerBalance transBalance(CustomerMainRespVO customer, BigDecimal amount, List<ActiveRule> ruleList) {
|
||||
CustomerBalance result = new CustomerBalance();
|
||||
result.setCusId(customer.getId());
|
||||
result.setUserId(customer.getUserId());
|
||||
BigDecimal nowChange = amount;
|
||||
if (null != ruleList && !ruleList.isEmpty()) {
|
||||
List<ActiveRule> sortList = ruleList.stream().sorted(Comparator.comparing(ActiveRule::getRechAmount).reversed()).collect(Collectors.toList());
|
||||
for (ActiveRule item : sortList) {
|
||||
//如果规则匹配
|
||||
if (amount.compareTo(item.getRechAmount()) >= 0) {
|
||||
nowChange = amount.add(item.getGiveAmount());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//余额
|
||||
result.setBalance(customer.getBalance().add(nowChange));
|
||||
//累计充值金额
|
||||
result.setAllBalance(customer.getBalance().add(nowChange));
|
||||
//本次变动金额
|
||||
result.setNowChange(nowChange);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -142,7 +73,7 @@ public class CustomerBalanceServiceImpl extends ServiceImpl<CustomerBalanceMappe
|
||||
@Override
|
||||
public void updateByCusId(CustomerBalance balance) {
|
||||
LambdaQueryWrapper<CustomerBalance> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(CustomerBalance::getCusId, balance.getCusId()).eq(BaseDO::getDeleted, '0');
|
||||
lambdaQueryWrapper.eq(CustomerBalance::getCusId,balance.getCusId()).eq(BaseDO::getDeleted,'0');
|
||||
remove(lambdaQueryWrapper);
|
||||
this.save(balance);
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ import java.math.BigDecimal;
|
||||
@Schema(description = "管理后台 - 用户积分(余额)新增/修改 Request VO")
|
||||
@Data
|
||||
public class CustomerBalanceSaveReqVO extends CustomerBalance {
|
||||
private String activeId;
|
||||
private String orderId;
|
||||
|
||||
|
||||
}
|
||||
@ -75,11 +75,11 @@ public class RepairOrderInfo extends TenantBaseDO {
|
||||
/**
|
||||
* 会员优惠金额
|
||||
*/
|
||||
private BigDecimal reduceMoney;
|
||||
private Long reduceMoney;
|
||||
/**
|
||||
* 使用会员储值卡的金额
|
||||
*/
|
||||
private BigDecimal balance;
|
||||
private Long balance;
|
||||
/**
|
||||
* 支付时间
|
||||
*/
|
||||
@ -152,10 +152,6 @@ public class RepairOrderInfo extends TenantBaseDO {
|
||||
* 创建人所在部门
|
||||
*/
|
||||
private Integer deptId;
|
||||
/**
|
||||
* 创建人所在部门
|
||||
*/
|
||||
private String tenantName;
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user