Commit 1c69cb22 by 吕明尚

订单增加充值和赠送金额

parent 15d84e8e
......@@ -46,7 +46,7 @@ public class GiftAmountLog extends BaseEntity {
* 操作类型
*/
@Excel(name = "操作类型")
private Long operationType;
private Integer operationType;
/**
* 操作时间
......
......@@ -49,7 +49,7 @@ public class RechargeAmountLog extends BaseEntity {
* 操作类型
*/
@Excel(name = "操作类型")
private Long operationType;
private Integer operationType;
/**
* 操作时间
......
......@@ -105,6 +105,12 @@ public class SOrder extends BaseEntity
@Excel(name = "使用余额")
private BigDecimal balance;
@Excel(name = "充值金额")
private BigDecimal rechargeAmount;
@Excel(name = "赠送金额")
private BigDecimal giftAmount;
@Excel(name = "优惠比例")
private BigDecimal discountRatio;
......
......@@ -59,6 +59,10 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
private ISConsumerCouponService consumerCouponService;
@Autowired
private ISysConfigService sysConfigService;
@Autowired
private RechargeAmountLogService rechargeAmountLogService;
@Autowired
private GiftAmountLogService giftAmountLogService;
/**
* 查询会员钱包
......@@ -153,6 +157,26 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
balanceLog.setCreateTime(new Date());
balanceLogService.save(balanceLog);
}
if (consumerWallet.getRechargeAmount().compareTo(new BigDecimal(0)) > 0) {
RechargeAmountLog rechargeAmountLog = new RechargeAmountLog();
rechargeAmountLog.setConsumerId(consumerWallet.getConsumerId());
rechargeAmountLog.setCurrentAmount(new BigDecimal(0));
rechargeAmountLog.setVariableAmount(consumerWallet.getRechargeAmount());
rechargeAmountLog.setOperationType(YesNoEnum.yes.getIndex());
rechargeAmountLog.setOperationTime(new Date());
rechargeAmountLog.setCreateTime(new Date());
rechargeAmountLogService.save(rechargeAmountLog);
}
if (consumerWallet.getGiftAmount().compareTo(new BigDecimal(0)) > 0) {
GiftAmountLog giftAmountLog = new GiftAmountLog();
giftAmountLog.setConsumerId(consumerWallet.getConsumerId());
giftAmountLog.setCurrentAmount(new BigDecimal(0));
giftAmountLog.setVariableAmount(consumerWallet.getGiftAmount());
giftAmountLog.setOperationType(YesNoEnum.yes.getIndex());
giftAmountLog.setOperationTime(new Date());
giftAmountLog.setCreateTime(new Date());
giftAmountLogService.save(giftAmountLog);
}
if (consumerWallet.getRemainingDuration().compareTo(new BigDecimal(0)) > 0) {
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(consumerWallet.getConsumerId());
......@@ -206,6 +230,8 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
public boolean editConsumerWallet(ConsumerWallet consumerWallet, Recharge recharge, ConsumerMember one) {
BigDecimal divide = new BigDecimal(0);
BigDecimal oldBalance = consumerWallet.getBalance();
BigDecimal oldRechargeAmount = consumerWallet.getRechargeAmount();
BigDecimal oldGiftAmount = consumerWallet.getGiftAmount();
BigDecimal oldDuration = consumerWallet.getRemainingDuration();
BigDecimal oldIntegral = consumerWallet.getRemainingIntegral();
String rechargeMembershipExpirationTime = sysConfigService.selectConfigByKey("rechargeMembershipExpirationTime");
......@@ -222,8 +248,10 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
logger.debug("修改会员用户");
consumerWallet.setBalance(consumerWallet.getBalance().add(recharge.getRechargeAmount()));
consumerWallet.setRechargeAmount(consumerWallet.getRechargeAmount().add(recharge.getRechargeAmount()));
if (rechargeConf.getGiveType().contains(GiveTypeEnum.AMOUNT.getIndex())) {
consumerWallet.setBalance(consumerWallet.getBalance().add(recharge.getGiveAmount()));
consumerWallet.setGiftAmount(consumerWallet.getGiftAmount().add(recharge.getGiveAmount()));
}
if (rechargeConf.getGiveType().contains(GiveTypeEnum.DURATION.getIndex())) {
BigDecimal duration = consumerWallet.getRemainingDuration().add(rechargeConf.getGiveDuration());
......@@ -247,6 +275,28 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
balanceLogService.save(balanceLog);
logger.debug("新增余额日志");
}
if (consumerWallet.getRechargeAmount().compareTo(new BigDecimal(0)) > 0) {
RechargeAmountLog rechargeAmountLog = new RechargeAmountLog();
rechargeAmountLog.setConsumerId(consumerWallet.getConsumerId());
rechargeAmountLog.setCurrentAmount(oldRechargeAmount);
rechargeAmountLog.setVariableAmount(consumerWallet.getRechargeAmount().subtract(oldRechargeAmount));
rechargeAmountLog.setOperationType(YesNoEnum.yes.getIndex());
rechargeAmountLog.setOperationTime(new Date());
rechargeAmountLog.setCreateTime(new Date());
rechargeAmountLogService.save(rechargeAmountLog);
logger.debug("新增充值金额日志");
}
if (consumerWallet.getGiftAmount().compareTo(new BigDecimal(0)) > 0) {
GiftAmountLog giftAmountLog = new GiftAmountLog();
giftAmountLog.setConsumerId(consumerWallet.getConsumerId());
giftAmountLog.setCurrentAmount(oldGiftAmount);
giftAmountLog.setVariableAmount(consumerWallet.getGiftAmount().subtract(oldGiftAmount));
giftAmountLog.setOperationType(YesNoEnum.yes.getIndex());
giftAmountLog.setOperationTime(new Date());
giftAmountLog.setCreateTime(new Date());
giftAmountLogService.save(giftAmountLog);
logger.debug("新增赠送金额日志");
}
if (consumerWallet.getRemainingDuration().compareTo(new BigDecimal(0)) > 0) {
DurationLog durationLog = new DurationLog();
durationLog.setConsumerId(consumerWallet.getConsumerId());
......
......@@ -223,9 +223,11 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
ConsumerWallet consumerWallet = new ConsumerWallet();
consumerWallet.setConsumerId(recharge.getConsumerId());
consumerWallet.setBalance(recharge.getRechargeAmount());
consumerWallet.setRechargeAmount(recharge.getRechargeAmount());
if (rechargeConf.getGiveType().contains(GiveTypeEnum.AMOUNT.getIndex())) {
BigDecimal balance = recharge.getRechargeAmount().add(rechargeConf.getGiveAmount());
consumerWallet.setBalance(balance);
consumerWallet.setGiftAmount(rechargeConf.getGiveAmount());
}
if (rechargeConf.getGiveType().contains(GiveTypeEnum.DURATION.getIndex())) {
consumerWallet.setRemainingDuration(rechargeConf.getGiveDuration());
......
......@@ -1135,14 +1135,38 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
if (ObjectUtil.isNotEmpty(sOrder.getBalance()) && sOrder.getBalance().compareTo(BigDecimal.ZERO) > 0) {
BalanceLog balanceLog = new BalanceLog();
RechargeAmountLog rechargeAmountLog = new RechargeAmountLog();
GiftAmountLog giftAmountLog = new GiftAmountLog();
balanceLog.setConsumerId(sOrder.getConsumerId());
balanceLog.setVariableAmount(sOrder.getBalance());
rechargeAmountLog.setConsumerId(sOrder.getConsumerId());
giftAmountLog.setConsumerId(sOrder.getConsumerId());
balanceLog.setCurrentBalance(consumerWallet.getBalance());
rechargeAmountLog.setCurrentAmount(consumerWallet.getRechargeAmount());
giftAmountLog.setCurrentAmount(consumerWallet.getGiftAmount());
balanceLog.setVariableAmount(sOrder.getBalance());
balanceLog.setOperationType(YesNoEnum.no.getIndex());
rechargeAmountLog.setOperationType(YesNoEnum.no.getIndex());
giftAmountLog.setOperationType(YesNoEnum.no.getIndex());
balanceLog.setOperationTime(new Date());
rechargeAmountLog.setOperationTime(new Date());
giftAmountLog.setOperationTime(new Date());
balanceLog.setCreateTime(new Date());
balanceLogService.save(balanceLog);
rechargeAmountLog.setCreateTime(new Date());
giftAmountLog.setCreateTime(new Date());
//计算充值金额和余额的比例
BigDecimal divide = consumerWallet.getRechargeAmount().divide(consumerWallet.getBalance(), 2, RoundingMode.HALF_UP);
//余额乘充值金额比例
BigDecimal oldRechargeAmount = consumerWallet.getBalance().multiply(divide);
BigDecimal oldGiftAmount = consumerWallet.getBalance().subtract(oldRechargeAmount);
rechargeAmountLog.setVariableAmount(oldRechargeAmount);
giftAmountLog.setVariableAmount(oldGiftAmount);
consumerWallet.setBalance(consumerWallet.getBalance().subtract(sOrder.getBalance()));
consumerWallet.setRechargeAmount(consumerWallet.getRechargeAmount().subtract(oldRechargeAmount));
consumerWallet.setGiftAmount(consumerWallet.getGiftAmount().subtract(oldGiftAmount));
sOrder.setRechargeAmount(oldRechargeAmount);
sOrder.setGiftAmount(oldGiftAmount);
balanceLogService.save(balanceLog);
consumerWalletService.updateById(consumerWallet);
}
}
......@@ -1323,14 +1347,30 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
if (ObjectUtil.isNotEmpty(sOrder.getBalance()) && sOrder.getBalance().compareTo(BigDecimal.ZERO) > 0) {
BalanceLog balanceLog = new BalanceLog();
RechargeAmountLog rechargeAmountLog = new RechargeAmountLog();
GiftAmountLog giftAmountLog = new GiftAmountLog();
balanceLog.setConsumerId(sOrder.getConsumerId());
balanceLog.setVariableAmount(sOrder.getBalance());
rechargeAmountLog.setConsumerId(sOrder.getConsumerId());
giftAmountLog.setConsumerId(sOrder.getConsumerId());
balanceLog.setCurrentBalance(consumerWallet.getBalance());
rechargeAmountLog.setCurrentAmount(consumerWallet.getRechargeAmount());
giftAmountLog.setCurrentAmount(consumerWallet.getGiftAmount());
balanceLog.setVariableAmount(sOrder.getBalance());
rechargeAmountLog.setVariableAmount(sOrder.getRechargeAmount());
giftAmountLog.setVariableAmount(sOrder.getGiftAmount());
balanceLog.setOperationType(YesNoEnum.yes.getIndex());
rechargeAmountLog.setOperationType(YesNoEnum.yes.getIndex());
giftAmountLog.setOperationType(YesNoEnum.yes.getIndex());
balanceLog.setOperationTime(new Date());
rechargeAmountLog.setOperationTime(new Date());
giftAmountLog.setOperationTime(new Date());
balanceLog.setCreateTime(new Date());
balanceLogService.save(balanceLog);
rechargeAmountLog.setCreateTime(new Date());
giftAmountLog.setCreateTime(new Date());
consumerWallet.setBalance(consumerWallet.getBalance().add(sOrder.getBalance()));
consumerWallet.setRechargeAmount(consumerWallet.getRechargeAmount().add(sOrder.getRechargeAmount()));
consumerWallet.setGiftAmount(consumerWallet.getGiftAmount().add(sOrder.getGiftAmount()));
balanceLogService.save(balanceLog);
consumerWalletService.updateById(consumerWallet);
}
}
......
......@@ -26,6 +26,8 @@
<result property="totalPrice" column="total_price"/>
<result property="duration" column="duration"/>
<result property="balance" column="balance"/>
<result property="rechargeAmount" column="recharge_amount"/>
<result property="giftAmount" column="gift_amount"/>
<result property="discountRatio" column="discount_ratio"/>
<result property="payPrice" column="pay_price"/>
<result property="payTime" column="pay_time"/>
......@@ -71,6 +73,8 @@
pay_price,
duration,
balance,
recharge_amount,
gift_amount,
discount_ratio,
pay_time,
time_long,
......@@ -116,6 +120,8 @@
pay_price,
duration,
balance,
recharge_amount,
gift_amount,
discount_ratio,
pay_time,
time_long,
......@@ -161,6 +167,8 @@
<if test="payPrice != null and payPrice != ''">and pay_price = #{payPrice}</if>
<if test="duration != null and duration != ''">and duration = #{duration}</if>
<if test="balance != null and balance != ''">and balance = #{balance}</if>
<if test="rechargeAmount != null and rechargeAmount != ''">and recharge_amount = #{rechargeAmount}</if>
<if test="giftAmount != null and giftAmount !=''">and gift_amount = #{giftAmount}</if>
<if test="discountRatio != null and discountRatio != ''">and discount_ratio = #{discountRatio}</if>
<if test="startPayTime != null">
and DATE_FORMAT(pay_time, '%Y-%m-%d') &gt;= DATE_FORMAT(#{startPayTime}, '%Y-%m-%d')
......@@ -233,6 +241,8 @@
s.consumer_phone,
s.duration,
s.balance,
s.recharge_amount,
s.gift_amount,
s.discount_ratio,
s.pack_id,
s.pack_price,
......@@ -283,6 +293,8 @@
s.consumer_phone,
s.duration,
s.balance,
s.recharge_amount,
s.gift_amount,
s.discount_ratio,
s.pack_id,
s.pack_price,
......@@ -496,6 +508,8 @@
<if test="discountRatio != null and discountRatio != ''">discount_ratio,</if>
<if test="duration != null and duration != ''">duration,</if>
<if test="balance != null and balance != '' ">balance,</if>
<if test="rechargeAmount != null and rechargeAmount != ''">recharge_amount,</if>
<if test="giftAmount != null and giftAmount != ''">gift_amount,</if>
<if test="secondaryCardId != null and secondaryCardId != ''">secondary_card_id,</if>
<if test="monthlyCardId != null and monthlyCardId != ''">monthly_card_id,</if>
</trim>
......@@ -535,6 +549,8 @@
<if test="discountRatio != null">#{discountRatio},</if>
<if test="duration != null">#{duration},</if>
<if test="balance != null">#{balance},</if>
<if test="rechargeAmount != null">#{rechargeAmount},</if>
<if test="giftAmount != null">#{giftAmount},</if>
<if test="secondaryCardId != null">#{secondary_card_id},</if>
<if test="monthlyCardId != null">#{monthly_card_id},</if>
</trim>
......@@ -579,6 +595,8 @@
<if test="discountRatio != null">discount_ratio = #{discountRatio},</if>
<if test="duration != null">duration = #{duration},</if>
<if test="balance != null">balance = #{balance},</if>
<if test="rechargeAmount != null">recharge_amount = #{rechargeAmount},</if>
<if test="giftAmount != null">gift_amount = #{giftAmount},</if>
<if test="monthlyCardId != null">monthly_card_id = #{monthlyCardId},</if>
<if test="secondaryCardId != null">secondary_card_id = #{secondaryCardId},</if>
</trim>
......
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