更新10.8

This commit is contained in:
许允枞 2024-10-08 14:09:45 +08:00
parent 23e9d78e8c
commit 95a0ce60f9
6 changed files with 55 additions and 26 deletions

View File

@ -310,6 +310,10 @@ public class FleetMemberServiceImpl extends ServiceImpl<FleetMemberMapper, Fleet
fleetMember.setSecondaryCardLimit(fleetMember1.getSecondaryCardLimit() + fleetMember.getAdjustLimit()); fleetMember.setSecondaryCardLimit(fleetMember1.getSecondaryCardLimit() + fleetMember.getAdjustLimit());
fleetMember.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() + fleetMember.getAdjustLimit()); fleetMember.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() + fleetMember.getAdjustLimit());
} else { } else {
//判断被扣除的用户余额是否还够
if (fleetMember1.getRemainingCreditLimit() < fleetMember.getAdjustLimit()) {
return 5;
}
fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() - fleetMember.getAdjustLimit()); fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() - fleetMember.getAdjustLimit());
fleetMember.setSecondaryCardLimit(fleetMember1.getSecondaryCardLimit() - fleetMember.getAdjustLimit()); fleetMember.setSecondaryCardLimit(fleetMember1.getSecondaryCardLimit() - fleetMember.getAdjustLimit());
fleetMember.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() - fleetMember.getAdjustLimit()); fleetMember.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() - fleetMember.getAdjustLimit());

View File

@ -16,6 +16,7 @@ import com.fuint.business.integral.mapper.IntegralGiftMapper;
import com.fuint.business.integral.service.IntegralGiftService; import com.fuint.business.integral.service.IntegralGiftService;
import com.fuint.business.integral.service.IntegralOrdersService; import com.fuint.business.integral.service.IntegralOrdersService;
import com.fuint.business.integral.vo.IntegralGiftVO; import com.fuint.business.integral.vo.IntegralGiftVO;
import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponUniVo;
import com.fuint.common.dto.AccountInfo; import com.fuint.common.dto.AccountInfo;
import com.fuint.common.util.RedisLock; import com.fuint.common.util.RedisLock;
import com.fuint.common.util.TokenUtil; import com.fuint.common.util.TokenUtil;
@ -43,6 +44,7 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
@Autowired @Autowired
@Lazy @Lazy
private IntegralOrdersService integralOrdersService; private IntegralOrdersService integralOrdersService;
/** /**
* 通过ID查询单条数据 * 通过ID查询单条数据
* *
@ -55,7 +57,6 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
} }
/** /**
* 分页查询 * 分页查询
* *
@ -71,17 +72,27 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
} }
@Override @Override
public IPage<IntegralGiftVO> queryByPageByStoreId(@Param("page") Page page, @Param("integralGiftCategory") IntegralGift integralGift) { public IPage<IntegralGiftVO> queryByPageByStoreId(@Param("page") Page page, @Param("integralGiftCategory") IntegralGift integralGift) {
IPage<IntegralGiftVO> integralGiftVOIPage = integralGiftDao.queryAllByLimit(page, integralGift); IPage<IntegralGiftVO> integralGiftVOIPage = integralGiftDao.queryAllByLimit(page, integralGift);
List<IntegralGiftVO> records = integralGiftVOIPage.getRecords(); List<IntegralGiftVO> records = integralGiftVOIPage.getRecords();
for (IntegralGiftVO record : records) { for (IntegralGiftVO record : records) {
record.setIfRedemptionIsOnline(integralOrdersService.checkTheRedemptionLimit(record.getId())); record.setIfRedemptionIsOnline(integralOrdersService.checkTheRedemptionLimit(record.getId()));
//计算优惠券的领取比例
extracted(record);
} }
return integralGiftVOIPage; 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 @Resource
LJGoodsService ljGoodsService; LJGoodsService ljGoodsService;
@ -90,6 +101,7 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
private StockStatisticService stockService; private StockStatisticService stockService;
@Autowired @Autowired
private StockTrackService trackService; private StockTrackService trackService;
/** /**
* 新增数据 * 新增数据
* *
@ -106,7 +118,7 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
// 增加库存时 从商品拿库存 // 增加库存时 从商品拿库存
if ("实物商品".equals(integralGift.getGiftType()) && integralGift.getTotalInventory() > 0) { if ("实物商品".equals(integralGift.getGiftType()) && integralGift.getTotalInventory() > 0) {
ljGoodsService.subtractGoodesStockByLock(integralGift.getGoodsId(),integralGift.getTotalInventory()); ljGoodsService.subtractGoodesStockByLock(integralGift.getGoodsId(), integralGift.getTotalInventory());
// 添加统计信息 // 添加统计信息
addStockStatistic(integralGift); addStockStatistic(integralGift);
// 增加库存跟踪信息 // 增加库存跟踪信息
@ -116,6 +128,7 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
this.integralGiftDao.insert(integralGift); this.integralGiftDao.insert(integralGift);
return integralGift; return integralGift;
} }
public boolean addStockStatistic(IntegralGift integralGift) { public boolean addStockStatistic(IntegralGift integralGift) {
StockStatistic stock = new StockStatistic(); StockStatistic stock = new StockStatistic();
stock.setGoodsId(integralGift.getGoodsId()); stock.setGoodsId(integralGift.getGoodsId());
@ -124,7 +137,7 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
stock.setCostAmount(byId.getBuyingPrice()); stock.setCostAmount(byId.getBuyingPrice());
int i = stockService.editStockCostAmount(stock); int i = stockService.editStockCostAmount(stock);
return i>0; return i > 0;
} }
@ -137,8 +150,9 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
stockTrack.setDocument("增加积分商品兑换"); stockTrack.setDocument("增加积分商品兑换");
stockTrack.setChangeNumber(-integralGift.getTotalInventory()); stockTrack.setChangeNumber(-integralGift.getTotalInventory());
int i = trackService.insertStockTrack(stockTrack); 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())) { if (ObjectUtil.isNotEmpty(integralGift.getGoodsId())) {
LJGoods byId = ljGoodsService.getById(integralGift.getGoodsId()); LJGoods byId = ljGoodsService.getById(integralGift.getGoodsId());
if (integralGift.getTotalInventory().compareTo(byId.getStock())>0){ if (integralGift.getTotalInventory().compareTo(byId.getStock()) > 0) {
throw new RuntimeException("该商品库存不足,可用库存“"+byId.getStock()+""); throw new RuntimeException("该商品库存不足,可用库存“" + byId.getStock() + "");
} }
} }
} }
@ -184,24 +198,25 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
/** /**
* 单独修改商品的库存 * 单独修改商品的库存
*
* @param id * @param id
* @param editInventory * @param editInventory
* @return * @return
*/ */
@Override @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("输入需要修改的数值"); if (ObjectUtil.isEmpty(editInventory)) throw new RuntimeException("输入需要修改的数值");
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
IntegralGift integralGift1 = this.integralGiftDao.queryById(id); IntegralGift integralGift1 = this.integralGiftDao.queryById(id);
if (editInventory<0 && integralGift1.getRemainingInventory() < -editInventory) { if (editInventory < 0 && integralGift1.getRemainingInventory() < -editInventory) {
throw new RuntimeException("库存不得少于0"); throw new RuntimeException("库存不得少于0");
} }
int i = this.integralGiftDao.updateInventory(id,editInventory,nowAccountInfo.getStaffId()); int i = this.integralGiftDao.updateInventory(id, editInventory, nowAccountInfo.getStaffId());
// 根据id查询积分商品 // 根据id查询积分商品
IntegralGift integralGift = integralGiftDao.queryById(id); IntegralGift integralGift = integralGiftDao.queryById(id);
if ("实物商品".equals(integralGift.getGiftType()) && ObjectUtil.isNotEmpty(integralGift.getGoodsId())) { if ("实物商品".equals(integralGift.getGiftType()) && ObjectUtil.isNotEmpty(integralGift.getGoodsId())) {
LJGoods byId = ljGoodsService.getById(integralGift.getGoodsId()); LJGoods byId = ljGoodsService.getById(integralGift.getGoodsId());
if (editInventory>byId.getStock()) { if (editInventory > byId.getStock()) {
// 当增加库存是需要判断商品库存是否足够 // 当增加库存是需要判断商品库存是否足够
throw new RuntimeException("该商品库存不足"); throw new RuntimeException("该商品库存不足");
} }
@ -216,25 +231,27 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
return true; return true;
} }
@Resource @Resource
RedisLock redisLock; RedisLock redisLock;
/** /**
* 处理积分商品库存(库存减少) * 处理积分商品库存(库存减少)
*/ */
@Override @Override
public boolean updateInventoryByLock(@Param("id") Integer id,@Param("editInventory") Integer editInventory) { public boolean updateInventoryByLock(@Param("id") Integer id, @Param("editInventory") Integer editInventory) {
// 根据id加锁 同一时间只能 // 根据id加锁 同一时间只能
String lockKey = "integralGift-"+id; String lockKey = "integralGift-" + id;
Boolean isLock = redisLock.tryLock(lockKey,500,5000, TimeUnit.MILLISECONDS); Boolean isLock = redisLock.tryLock(lockKey, 500, 5000, TimeUnit.MILLISECONDS);
if (isLock) { if (isLock) {
try { try {
IntegralGift integralGift = integralGiftDao.queryById(id); IntegralGift integralGift = integralGiftDao.queryById(id);
if (editInventory.compareTo(integralGift.getRemainingInventory())>0) { if (editInventory.compareTo(integralGift.getRemainingInventory()) > 0) {
throw new RuntimeException("该积分商品库存不足!"); throw new RuntimeException("该积分商品库存不足!");
}else { } else {
integralGiftDao.updateInventoryByLock(id, editInventory); integralGiftDao.updateInventoryByLock(id, editInventory);
} }
}finally { } finally {
redisLock.unlock(lockKey); redisLock.unlock(lockKey);
} }
} }

View File

@ -12,4 +12,6 @@ public class IntegralGiftVO extends IntegralGift {
private String storeName; private String storeName;
// 商品 // 商品
// 优惠卷 // 优惠卷
//领取比例
private String receiveRatio;
} }

View File

@ -97,8 +97,12 @@ public class CardCouponServiceImpl extends ServiceImpl<CardCouponMapper, CardCou
List<Integer> ids = new ArrayList<>(); List<Integer> ids = new ArrayList<>();
//循环店铺优惠券 //循环店铺优惠券
for (CardCouponUniVo coupon : cardCouponUniVos.getRecords()) { 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; Integer count = 0;
if (ObjectUtil.isNotEmpty(cardCouponMap.get(coupon.getId()))){ if (ObjectUtil.isNotEmpty(cardCouponMap.get(coupon.getId()))){
count = cardCouponMap.get(coupon.getId()); count = cardCouponMap.get(coupon.getId());
@ -154,7 +158,7 @@ public class CardCouponServiceImpl extends ServiceImpl<CardCouponMapper, CardCou
private static void extracted(CardCouponUniVo coupon) { private static void extracted(CardCouponUniVo coupon) {
//计算领取的比例 //计算领取的比例
double scale = (coupon.getTfGetNum() * 1.0 / coupon.getTfTotal()) * 100; double scale = (coupon.getTfGetNum() == null ? 0 : coupon.getTfGetNum() * 1.0 / coupon.getTfTotal()) * 100;
coupon.setScale(scale + "%"); coupon.setScale(scale + "%");
} }
} }

View File

@ -24,7 +24,7 @@
</view> </view>
<u-line-progress :percentage="50" :showText="false" height="6" <u-line-progress :percentage="50" :showText="false" height="6"
activeColor="#FA6400"></u-line-progress> activeColor="#FA6400"></u-line-progress>
<view class="hui_">券已领70%</view> <view class="hui_">券已领{{item.receiveRatio}}</view>
</view> </view>
</view> </view>

View File

@ -98,7 +98,9 @@
}, },
methods: { methods: {
submitFrom() { submitFrom() {
if (this.memberInfo.adjustType == '') { console.log('调整类型',this.memberInfo.adjustType);
console.log('判断',this.memberInfo.adjustType === '');
if (this.memberInfo.adjustType === '') {
uni.showToast({ uni.showToast({
title: '请选择调整类型', title: '请选择调整类型',
icon: 'none' icon: 'none'