1
This commit is contained in:
parent
9eceda0858
commit
51bc0851f9
@ -483,57 +483,68 @@ public class IntegralOrdersServiceImpl implements IntegralOrdersService {
|
||||
String lockKey = "IntegralOrders" + orderNo;
|
||||
Boolean isLock = redisLock.tryLock(lockKey, 5000, TimeUnit.MILLISECONDS);
|
||||
if (isLock && "paid".equals(listByOrderNo.get(0).getStatus()) && "0".equals(listByOrderNo.get(0).getProcessingStatus())) {
|
||||
// 查询用户信息
|
||||
LJUserVo ljUserVos = ljUserMapper.selectAllInfoById2(listByOrderNo.get(0).getUserId(), listByOrderNo.get(0).getChainStoreId());
|
||||
// 查询用户信息
|
||||
BigDecimal totalPoints = new BigDecimal(0);
|
||||
try {
|
||||
|
||||
for (IntegralOrders integralOrders : listByOrderNo) {
|
||||
// 查询员工信息
|
||||
LJStaff ljStaff = ljStaffMapper.selectById(integralOrders.getStaffId());
|
||||
if (ObjectUtil.isEmpty(integralOrders.getIntegral())) integralOrders.setIntegral(0.0);
|
||||
totalPoints = totalPoints.add(new BigDecimal(integralOrders.getIntegral()));
|
||||
// 加兑换卷和优惠券判断
|
||||
IntegralGift integralGift = integralGiftService.queryById(integralOrders.getGiftId());
|
||||
if (integralGift.getGiftType().equals("电子券")) {
|
||||
// 查询用户信息
|
||||
LJUserVo ljUserVos = ljUserMapper.selectAllInfoById2(listByOrderNo.get(0).getUserId(), listByOrderNo.get(0).getChainStoreId());
|
||||
// 查询用户信息
|
||||
BigDecimal totalPoints = new BigDecimal(0);
|
||||
|
||||
CardCoupon cardCoupon = cardCouponService.selectOneBuId(integralGift.getCouponId());
|
||||
ResponseObject responseObject = cardCouponService.sendCoupon2(new CardCouponUser());
|
||||
for (IntegralOrders integralOrders : listByOrderNo) {
|
||||
// 查询员工信息
|
||||
LJStaff ljStaff = ljStaffMapper.selectById(integralOrders.getStaffId());
|
||||
if (ObjectUtil.isEmpty(integralOrders.getIntegral())) integralOrders.setIntegral(0.0);
|
||||
totalPoints = totalPoints.add(new BigDecimal(integralOrders.getIntegral()));
|
||||
// 加兑换卷和优惠券判断
|
||||
IntegralGift integralGift = integralGiftService.queryById(integralOrders.getGiftId());
|
||||
if (integralGift.getGiftType().equals("电子券")) {
|
||||
|
||||
|
||||
for (int i = 0; i <integralOrders.getExchangeQuantity() ; i++) {
|
||||
CardCouponUser cardCouponUser = new CardCouponUser();
|
||||
cardCouponUser.setMtUserId(ljUserVos.getId());
|
||||
cardCouponUser.setStoreId(integralOrders.getStoreId());
|
||||
cardCouponUser.setCardCouponId(integralGift.getCouponId());
|
||||
ResponseObject responseObject = cardCouponService.sendCoupon2(cardCouponUser);
|
||||
}
|
||||
|
||||
} else if (integralGift.getGiftType().equals("实物商品")) {
|
||||
// 修改商品库存并增加记录
|
||||
LJGoodsDto goods = new LJGoodsDto();
|
||||
goods.setId(integralGift.getGoodsId());
|
||||
goods.setDocument("积分兑换");
|
||||
goods.setNumberOfChanges(-integralOrders.getExchangeQuantity());
|
||||
goods.setGoodsNo(integralOrders.getOrderNumber());
|
||||
ljGoodsService.editGoodsInventory(goods);
|
||||
}
|
||||
|
||||
// 处理积分库存
|
||||
integralGiftService.updateInventoryByLock(integralOrders.getGiftId(), integralOrders.getExchangeQuantity());
|
||||
|
||||
} else if (integralGift.getGiftType().equals("实物商品")) {
|
||||
// 修改商品库存并增加记录
|
||||
LJGoodsDto goods = new LJGoodsDto();
|
||||
goods.setId(integralGift.getGoodsId());
|
||||
goods.setDocument("积分兑换");
|
||||
goods.setNumberOfChanges(-integralOrders.getExchangeQuantity());
|
||||
goods.setGoodsNo(integralOrders.getOrderNumber());
|
||||
ljGoodsService.editGoodsInventory(goods);
|
||||
}
|
||||
|
||||
// 处理积分库存
|
||||
integralGiftService.updateInventoryByLock(integralOrders.getGiftId(), integralOrders.getExchangeQuantity());
|
||||
// 用户积分余额变动
|
||||
if (totalPoints.doubleValue() > 0) {
|
||||
UserBalance userBalance = balanceCalculation(ljUserVos, totalPoints.doubleValue());
|
||||
userBalance.setChainStoreId(listByOrderNo.get(0).getChainStoreId());
|
||||
userBalanceService.updateUserBalance(userBalance);
|
||||
}
|
||||
// 积分表变动
|
||||
if (totalPoints.doubleValue() > 0) {
|
||||
IntegralDetail integralDetail = changesInPoints(totalPoints.doubleValue(), ljUserVos);
|
||||
integralDetail.setStoreId(listByOrderNo.get(0).getStoreId());
|
||||
integralDetail.setChainStoreId(listByOrderNo.get(0).getChainStoreId());
|
||||
integralDetailService.insert2(integralDetail);
|
||||
}
|
||||
|
||||
// 批量修改该
|
||||
integralOrdersDao.updatePaymentType(orderNo);
|
||||
|
||||
redisLock.unlock(lockKey);
|
||||
} catch (Exception e) {
|
||||
redisLock.unlock(lockKey);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 用户积分余额变动
|
||||
if (totalPoints.doubleValue() > 0) {
|
||||
UserBalance userBalance = balanceCalculation(ljUserVos, totalPoints.doubleValue());
|
||||
userBalance.setChainStoreId(listByOrderNo.get(0).getChainStoreId());
|
||||
userBalanceService.updateUserBalance(userBalance);
|
||||
}
|
||||
// 积分表变动
|
||||
if (totalPoints.doubleValue() > 0) {
|
||||
IntegralDetail integralDetail = changesInPoints(totalPoints.doubleValue(), ljUserVos);
|
||||
integralDetail.setStoreId(listByOrderNo.get(0).getStoreId());
|
||||
integralDetail.setChainStoreId(listByOrderNo.get(0).getChainStoreId());
|
||||
integralDetailService.insert2(integralDetail);
|
||||
}
|
||||
|
||||
// 批量修改该
|
||||
integralOrdersDao.updatePaymentType(orderNo);
|
||||
|
||||
redisLock.unlock(lockKey);
|
||||
|
||||
} else {
|
||||
redisLock.unlock(lockKey);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user