From 28d72ff38688eed22fd374949df0194b6092fe9e Mon Sep 17 00:00:00 2001 From: sw <17615834396@163.com> Date: Thu, 14 Nov 2024 09:16:39 +0800 Subject: [PATCH] 11.14 --- .../fuint/business/order/entity/OilOrder.java | 4 + .../service/impl/OilOrderServiceImpl.java | 59 +++- .../business/userManager/dto/LJUserDto.java | 24 ++ .../userManager/dto/LJUserStaticesDto.java | 40 +++ .../userManager/mapper/LJUserMapper.java | 6 + .../userManager/mapper/xml/LJUserMapper.xml | 30 +- .../userManager/service/LJUserService.java | 6 +- .../service/UserBalanceService.java | 1 + .../service/impl/LJUserServiceImpl.java | 273 +++++++++--------- .../views/cashier/NewComponents/newHome.vue | 13 +- 10 files changed, 309 insertions(+), 147 deletions(-) create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/dto/LJUserDto.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/dto/LJUserStaticesDto.java diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/OilOrder.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/OilOrder.java index 992d5e691..86c655981 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/OilOrder.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/OilOrder.java @@ -185,5 +185,9 @@ public class OilOrder extends BaseEntity implements Serializable { private Long deptId; @TableField(exist = false) private List storeIds; + /** + * 储值卡赠送金额消费 + */ + private Double balanceGiftAmount; } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java index f76d3bf76..5ff761625 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/OilOrderServiceImpl.java @@ -636,7 +636,7 @@ public class OilOrderServiceImpl extends ServiceImpl i order.setBalanceAmount(Double.valueOf(balanceAmount)); order.setOilCardAmount(Double.valueOf(oilCardAmount)); order.setActiveAmount(activeAmount); - + order.setBalanceGiftAmount( this.countCardBalance(Double.valueOf(balanceAmount), userId, storeId, orderNo)); order.setStoreId(storeId); order.setUserId(userId); order.setStaffId(staffId); @@ -1935,20 +1935,35 @@ public class OilOrderServiceImpl extends ServiceImpl i LJStore store = storeService.selectStoreByStoreId(storeId); UserBalance balance = userBalanceService.selectUserBalance(userId, store.getChainStoreId()); if (ObjectUtil.isNotEmpty(balance)) { - // 修改余额信息 - Double beforeBalance = balance.getCardBalance(); - Double afterBalance = beforeBalance - amount; - if ((beforeBalance - amount) < 0.0) { + + + //计算余额 + //消费金额 + BigDecimal num1 = new BigDecimal(amount.toString()); + //总余额 + BigDecimal num2 = new BigDecimal(balance.getCardBalance().toString()); + //赠送余额 + BigDecimal num3 = new BigDecimal(balance.getGiveAmount().toString()); + //总本金 + BigDecimal num4 = num2.subtract(num3); + //赠送余额比例金额 + BigDecimal num5 =num3.divide(num4,2,BigDecimal.ROUND_DOWN).multiply(num1).setScale(2,BigDecimal.ROUND_DOWN); + //剩余赠送余额 + BigDecimal num6 =num3.subtract(num5); + //修改余额信息 + BigDecimal num7 =num2.subtract(num1); + + if (num7.doubleValue() < 0.0) { return false; } - cardBalanceChange.setAfterTheChange(afterBalance); - balance.setCardBalance(afterBalance); + cardBalanceChange.setAfterTheChange(num7.doubleValue()); + balance.setCardBalance(num7.doubleValue()); + balance.setGiveAmount(num6.doubleValue()); // 修改加油次数 Integer consumeNum = balance.getConsumeNum(); balance.setConsumeNum(consumeNum + 1); userBalanceService.updateUserBalance(balance); } - // 添加余额记录信息 cardBalanceChange.setUserId(userId); cardBalanceChange.setChangeType("0"); @@ -1956,7 +1971,6 @@ public class OilOrderServiceImpl extends ServiceImpl i cardBalanceChange.setBalance(amount); cardBalanceChange.setOrderNo(orderNo); cardBalanceChange.setStoreId(storeId); - cardBalanceChangeService.insertCardBalance(cardBalanceChange); return true; } @@ -2416,4 +2430,31 @@ public class OilOrderServiceImpl extends ServiceImpl i } return baseMapper.selectList(queryWrapper); } + + + /** + * 计算储值赠送金额的话费 + * + * @param amount + * @param userId + * @param storeId + */ + private Double countCardBalance(Double amount, Integer userId, Integer storeId, String orderNo) { + // 根据用户id查询用户余额信息 + LJStore store = storeService.selectStoreByStoreId(storeId); + UserBalance balance = userBalanceService.selectUserBalance(userId, store.getChainStoreId()); + + //消费金额 + BigDecimal num1 = new BigDecimal(amount.toString()); + //总余额 + BigDecimal num2 = new BigDecimal(balance.getCardBalance().toString()); + //赠送余额 + BigDecimal num3 = new BigDecimal(balance.getGiveAmount().toString()); + //总本金 + BigDecimal num4 = num2.subtract(num3); + //赠送余额比例金额 + BigDecimal num5 = num3.divide(num4, 2, BigDecimal.ROUND_DOWN).multiply(num1).setScale(2, BigDecimal.ROUND_DOWN); + + return num5.doubleValue(); + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/dto/LJUserDto.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/dto/LJUserDto.java new file mode 100644 index 000000000..9f00c2c4c --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/dto/LJUserDto.java @@ -0,0 +1,24 @@ +package com.fuint.business.userManager.dto; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class LJUserDto implements Serializable { + private static final long serialVersionUID = 1L; + + + //会员人数 + private Integer userNum ; + // 注销会员人数 + private Integer logOffUserNum ; + // 会员总积分 + private Integer allPoints ; + // 消耗积分 + private Integer consumePoints ; + // 会员累计充值 + private Double accumulateRecharge ; + // 会员总余额 + private Double allBalance ; +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/dto/LJUserStaticesDto.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/dto/LJUserStaticesDto.java new file mode 100644 index 000000000..dd6fc87ac --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/dto/LJUserStaticesDto.java @@ -0,0 +1,40 @@ +package com.fuint.business.userManager.dto; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class LJUserStaticesDto implements Serializable { + private static final long serialVersionUID = 1L; + // 充值总额 + private Double rechargeAmount; + // 充值本金 + private Double rechargePrincipal; + // 充值赠送 + private Double rechargeGive; + // 消费总额 + private Double consumeAmount; + // 消费本金 + private Double consumePrincipal ; + // 消费赠送 + private Double consumeGive; + // 退款总额 + private Double refundAmount; + // 退款本金 + private Double refundPrincipal; + // 退款赠送 + private Double refundGive0; + // 注销总额 + private Double logOffAmount; + // 注销本金 + private Double logOffPrincipal; + // 注销赠送 + private Double logOffGive; + // 会员总余额 + private Double userBalance; + // 剩余本金 + private Double residuePrincipal; + // 剩余赠送 + private Double residueGive; +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/LJUserMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/LJUserMapper.java index c6f69d87b..8bbe7d023 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/LJUserMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/LJUserMapper.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.userGroup.entity.UserGroup; +import com.fuint.business.userManager.dto.LJUserDto; +import com.fuint.business.userManager.dto.LJUserStaticesDto; import com.fuint.business.userManager.entity.LJUser; import com.fuint.business.userManager.vo.LJUserVo; import org.apache.ibatis.annotations.Param; @@ -112,4 +114,8 @@ public interface LJUserMapper extends BaseMapper { Integer selectUserCountByChainStoreId(@Param("chainStoreId") Integer chainStoreId); List findUserList(@Param("user") LJUserVo user); + + LJUserDto queryUserMsg(@Param("storeId") Integer storeId); + + LJUserStaticesDto selectAmountStatistics(@Param("storeId") Integer storeId); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserMapper.xml index 02d6be572..c741c37cd 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserMapper.xml +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/userManager/mapper/xml/LJUserMapper.xml @@ -310,7 +310,8 @@ mub.card_balance cardBalance, mub.points, mub.growth_value growthValue, - mub.refuel_money refuelMoney + mub.refuel_money refuelMoney, + mub.give_amount giveAmount from mt_user mu left join mt_user_balance mub on mu.id = mub.mt_user_id where mu.id = #{userId} @@ -419,6 +420,33 @@ + + + + +