Commit 30b1ef50 by huluobin

update

parent b3dadc5c
......@@ -69,7 +69,8 @@ public class ChargeOrderServiceImpl extends ServiceImpl<ChargeOrderMapper, Charg
Customer customer = customerMapper.selectOne(new LambdaQueryWrapper<Customer>().eq(Customer::getOpenid1, result.getOpenid()));
CustomerBalance customerBalance = customerBalanceMapper.selectOne(new LambdaQueryWrapper<CustomerBalance>().eq(CustomerBalance::getCustomerId, customer.getId()));
CustomerBalance customerBalance = customerBalanceMapper.selectOne(
new LambdaQueryWrapper<CustomerBalance>().eq(CustomerBalance::getCustomerId, customer.getId()));
DiscountConfig discountConfig = discountConfigMapper.selectList(new LambdaQueryWrapper<>())
.stream().filter(config -> config.getChargeAmount() <= result.getTotalFee())
......@@ -80,31 +81,42 @@ public class ChargeOrderServiceImpl extends ServiceImpl<ChargeOrderMapper, Charg
//首次充值
if (customerBalance == null || customerBalance.getBalance() == 0) {
customerBalance = CustomerBalance.builder()
//充值金额+赠送金额
// .balance(result.getTotalFee() + discountConfig.getBestowAmount())
.balance(result.getTotalFee())
if (customerBalance == null) {
customerBalance = CustomerBalance.builder()
//充值金额+赠送金额
.balance(result.getTotalFee())
.customerId(customer.getId())
.currentDiscount(1.00)
.discountRate(0.00)
.firstChargeTime(new Date())
.level(discountConfig.getLevel())
//赠送金额
.totalBestow(0)
//总充值金额
.totalCharge(result.getTotalFee())
.totalExpenditure(0)
.updateTime(new Date())
.version(5)
.build();
} else {
customerBalance.setBalance(result.getTotalFee());
customerBalance.setCurrentDiscount(1.00);
customerBalance.setDiscountRate(0.00);
customerBalance.setFirstChargeTime(new Date());
customerBalance.setLevel(discountConfig.getLevel());
customerBalance.setTotalBestow(0);
customerBalance.setTotalCharge(result.getTotalFee());
customerBalance.setTotalExpenditure(0);
customerBalance.setUpdateTime(new Date());
customerBalance.setVersion(5);
}
.customerId(customer.getId())
.currentDiscount(1.00)
.discountRate(0.00)
.firstChargeTime(new Date())
.level(discountConfig.getLevel())
//赠送金额
// .totalBestow(discountConfig.getBestowAmount())
.totalBestow(0)
//总充值金额
.totalCharge(result.getTotalFee())
.totalExpenditure(0)
.updateTime(new Date())
.version(5)
.build();
//会员卡不存在
if (customerBalance.getId() == null) {
customerBalanceMapper.insert(customerBalance);
}
//会员卡存在
else {
customerBalanceMapper.updateById(customerBalance);
......@@ -117,8 +129,6 @@ public class ChargeOrderServiceImpl extends ServiceImpl<ChargeOrderMapper, Charg
.discount(1.00)
.currentBalance(customerBalance.getBalance())
.bestowAmount(0)
//赠送金额
// .bestowAmount(discountConfig.getBestowAmount())
//首次充值
.type(1)
.customerId(customer.getId())
......@@ -131,12 +141,11 @@ public class ChargeOrderServiceImpl extends ServiceImpl<ChargeOrderMapper, Charg
//充值
else {
//更新用户余额
// customerBalance.setBalance(customerBalance.getBalance() + result.getTotalFee() + discountConfig.getBestowAmount());
customerBalance.setBalance(customerBalance.getBalance() + result.getTotalFee());
customerBalance.setLevel(discountConfig.getLevel());
customerBalance.setUpdateTime(new Date());
//总送
// customerBalance.setTotalBestow(customerBalance.getTotalBestow());
customerBalance.setTotalCharge(customerBalance.getTotalCharge() + result.getTotalFee());
customerBalanceMapper.updateById(customerBalance);
......@@ -147,7 +156,6 @@ public class ChargeOrderServiceImpl extends ServiceImpl<ChargeOrderMapper, Charg
.orderAmount(result.getTotalFee())
.discount(1.00)
.currentBalance(customerBalance.getBalance())
// .bestowAmount(discountConfig.getBestowAmount())
.bestowAmount(0)
//首次充值
.type(1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment