更新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.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() + fleetMember.getAdjustLimit());
} else {
//判断被扣除的用户余额是否还够
if (fleetMember1.getRemainingCreditLimit() < fleetMember.getAdjustLimit()) {
return 5;
}
fleetLinesChange.setRemainingCreditLimit(fleetMember1.getRemainingCreditLimit() - fleetMember.getAdjustLimit());
fleetMember.setSecondaryCardLimit(fleetMember1.getSecondaryCardLimit() - 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.IntegralOrdersService;
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.util.RedisLock;
import com.fuint.common.util.TokenUtil;
@ -43,6 +44,7 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
@Autowired
@Lazy
private IntegralOrdersService integralOrdersService;
/**
* 通过ID查询单条数据
*
@ -55,12 +57,11 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
}
/**
* 分页查询
*
* @param integralGift 筛选条件
* @param page 分页对象
* @param page 分页对象
* @return 查询结果
*/
@Override
@ -71,17 +72,27 @@ public class IntegralGiftServiceImpl implements IntegralGiftService {
}
@Override
public IPage<IntegralGiftVO> queryByPageByStoreId(@Param("page") Page page, @Param("integralGiftCategory") IntegralGift integralGift) {
IPage<IntegralGiftVO> integralGiftVOIPage = integralGiftDao.queryAllByLimit(page, integralGift);
List<IntegralGiftVO> 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);
}
}

View File

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

View File

@ -97,8 +97,12 @@ public class CardCouponServiceImpl extends ServiceImpl<CardCouponMapper, CardCou
List<Integer> 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<CardCouponMapper, CardCou
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 + "%");
}
}

View File

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

View File

@ -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'