diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetMemberServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetMemberServiceImpl.java index a2a90d355..a19879f47 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetMemberServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/fleet/service/impl/FleetMemberServiceImpl.java @@ -310,6 +310,10 @@ public class FleetMemberServiceImpl extends ServiceImpl queryByPageByStoreId(@Param("page") Page page, @Param("integralGiftCategory") IntegralGift integralGift) { IPage integralGiftVOIPage = integralGiftDao.queryAllByLimit(page, integralGift); List records = integralGiftVOIPage.getRecords(); for (IntegralGiftVO record : records) { record.setIfRedemptionIsOnline(integralOrdersService.checkTheRedemptionLimit(record.getId())); + //计算优惠券的领取比例 + extracted(record); } return integralGiftVOIPage; } + private void extracted(IntegralGiftVO coupon) { + // 计算领取的比例并保留两位小数 + double scale = (coupon.getUsedInventory() == null ? 0 : (coupon.getUsedInventory() * 1.0 / coupon.getTotalInventory())) * 100; + scale = Math.round(scale * 100.0) / 100.0; // 保留两位小数 + + //保留小数点两位 + coupon.setReceiveRatio(scale + "%"); + } + @Resource LJGoodsService ljGoodsService; @@ -90,6 +101,7 @@ public class IntegralGiftServiceImpl implements IntegralGiftService { private StockStatisticService stockService; @Autowired private StockTrackService trackService; + /** * 新增数据 * @@ -106,7 +118,7 @@ public class IntegralGiftServiceImpl implements IntegralGiftService { // 增加库存时 从商品拿库存 if ("实物商品".equals(integralGift.getGiftType()) && integralGift.getTotalInventory() > 0) { - ljGoodsService.subtractGoodesStockByLock(integralGift.getGoodsId(),integralGift.getTotalInventory()); + ljGoodsService.subtractGoodesStockByLock(integralGift.getGoodsId(), integralGift.getTotalInventory()); // 添加统计信息 addStockStatistic(integralGift); // 增加库存跟踪信息 @@ -116,6 +128,7 @@ public class IntegralGiftServiceImpl implements IntegralGiftService { this.integralGiftDao.insert(integralGift); return integralGift; } + public boolean addStockStatistic(IntegralGift integralGift) { StockStatistic stock = new StockStatistic(); stock.setGoodsId(integralGift.getGoodsId()); @@ -124,7 +137,7 @@ public class IntegralGiftServiceImpl implements IntegralGiftService { stock.setCostAmount(byId.getBuyingPrice()); int i = stockService.editStockCostAmount(stock); - return i>0; + return i > 0; } @@ -137,8 +150,9 @@ public class IntegralGiftServiceImpl implements IntegralGiftService { stockTrack.setDocument("增加积分商品兑换"); stockTrack.setChangeNumber(-integralGift.getTotalInventory()); int i = trackService.insertStockTrack(stockTrack); - return i>0; + return i > 0; } + /** * 修改数据 * @@ -161,8 +175,8 @@ public class IntegralGiftServiceImpl implements IntegralGiftService { if (ObjectUtil.isNotEmpty(integralGift.getGoodsId())) { LJGoods byId = ljGoodsService.getById(integralGift.getGoodsId()); - if (integralGift.getTotalInventory().compareTo(byId.getStock())>0){ - throw new RuntimeException("该商品库存不足,可用库存“"+byId.getStock()+"”"); + if (integralGift.getTotalInventory().compareTo(byId.getStock()) > 0) { + throw new RuntimeException("该商品库存不足,可用库存“" + byId.getStock() + "”"); } } } @@ -184,24 +198,25 @@ public class IntegralGiftServiceImpl implements IntegralGiftService { /** * 单独修改商品的库存 + * * @param id * @param editInventory * @return */ @Override - public boolean updateInventory(@Param("id") Integer id,@Param("editInventory") Integer editInventory) { + public boolean updateInventory(@Param("id") Integer id, @Param("editInventory") Integer editInventory) { if (ObjectUtil.isEmpty(editInventory)) throw new RuntimeException("输入需要修改的数值"); AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); IntegralGift integralGift1 = this.integralGiftDao.queryById(id); - if (editInventory<0 && integralGift1.getRemainingInventory() < -editInventory) { + if (editInventory < 0 && integralGift1.getRemainingInventory() < -editInventory) { throw new RuntimeException("库存不得少于0"); } - int i = this.integralGiftDao.updateInventory(id,editInventory,nowAccountInfo.getStaffId()); + int i = this.integralGiftDao.updateInventory(id, editInventory, nowAccountInfo.getStaffId()); // 根据id查询积分商品 IntegralGift integralGift = integralGiftDao.queryById(id); if ("实物商品".equals(integralGift.getGiftType()) && ObjectUtil.isNotEmpty(integralGift.getGoodsId())) { LJGoods byId = ljGoodsService.getById(integralGift.getGoodsId()); - if (editInventory>byId.getStock()) { + if (editInventory > byId.getStock()) { // 当增加库存是需要判断商品库存是否足够 throw new RuntimeException("该商品库存不足"); } @@ -216,25 +231,27 @@ public class IntegralGiftServiceImpl implements IntegralGiftService { return true; } + @Resource RedisLock redisLock; + /** * 处理积分商品库存(库存减少) */ @Override - public boolean updateInventoryByLock(@Param("id") Integer id,@Param("editInventory") Integer editInventory) { + public boolean updateInventoryByLock(@Param("id") Integer id, @Param("editInventory") Integer editInventory) { // 根据id加锁 同一时间只能 - String lockKey = "integralGift-"+id; - Boolean isLock = redisLock.tryLock(lockKey,500,5000, TimeUnit.MILLISECONDS); + String lockKey = "integralGift-" + id; + Boolean isLock = redisLock.tryLock(lockKey, 500, 5000, TimeUnit.MILLISECONDS); if (isLock) { try { - IntegralGift integralGift = integralGiftDao.queryById(id); - if (editInventory.compareTo(integralGift.getRemainingInventory())>0) { - throw new RuntimeException("该积分商品库存不足!"); - }else { - integralGiftDao.updateInventoryByLock(id, editInventory); - } - }finally { + IntegralGift integralGift = integralGiftDao.queryById(id); + if (editInventory.compareTo(integralGift.getRemainingInventory()) > 0) { + throw new RuntimeException("该积分商品库存不足!"); + } else { + integralGiftDao.updateInventoryByLock(id, editInventory); + } + } finally { redisLock.unlock(lockKey); } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/vo/IntegralGiftVO.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/vo/IntegralGiftVO.java index 3e2840831..32fa7b13f 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/vo/IntegralGiftVO.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/integral/vo/IntegralGiftVO.java @@ -12,4 +12,6 @@ public class IntegralGiftVO extends IntegralGift { private String storeName; // 商品 // 优惠卷 + //领取比例 + private String receiveRatio; } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponServiceImpl.java index 67f75cd19..617086415 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/marketingActivity/cardCoupon/service/impl/CardCouponServiceImpl.java @@ -97,8 +97,12 @@ public class CardCouponServiceImpl extends ServiceImpl ids = new ArrayList<>(); //循环店铺优惠券 for (CardCouponUniVo coupon : cardCouponUniVos.getRecords()) { + Integer getNum = 0; + if (ObjectUtil.isNotEmpty(coupon.getTfGetNum())){ + getNum = coupon.getTfGetNum(); + } //查询该优惠券是否已到达限制数量 - if ((coupon.getTfGetNum() < coupon.getTfTotal())) { + if ((getNum < coupon.getTfTotal())) { Integer count = 0; if (ObjectUtil.isNotEmpty(cardCouponMap.get(coupon.getId()))){ count = cardCouponMap.get(coupon.getId()); @@ -154,7 +158,7 @@ public class CardCouponServiceImpl extends ServiceImpl - 券已领70% + 券已领{{item.receiveRatio}} diff --git a/gasStation-uni/pagesMy/fleetLimit/index.vue b/gasStation-uni/pagesMy/fleetLimit/index.vue index 5f42fd9a8..43fe322dd 100644 --- a/gasStation-uni/pagesMy/fleetLimit/index.vue +++ b/gasStation-uni/pagesMy/fleetLimit/index.vue @@ -98,7 +98,9 @@ }, methods: { submitFrom() { - if (this.memberInfo.adjustType == '') { + console.log('调整类型',this.memberInfo.adjustType); + console.log('判断',this.memberInfo.adjustType === ''); + if (this.memberInfo.adjustType === '') { uni.showToast({ title: '请选择调整类型', icon: 'none'