|
@@ -2252,24 +2252,24 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public R createRewardLiveOrder(LiveOrder liveOrder) {
|
|
public R createRewardLiveOrder(LiveOrder liveOrder) {
|
|
|
- String orderKey= redisCache.getCacheObject("orderKey:"+liveOrder.getOrderKey());
|
|
|
|
|
|
|
+ String orderKey = redisCache.getCacheObject("orderKey:" + liveOrder.getOrderKey());
|
|
|
if (StringUtils.isEmpty(orderKey)) {
|
|
if (StringUtils.isEmpty(orderKey)) {
|
|
|
return R.error("订单已过期");
|
|
return R.error("订单已过期");
|
|
|
}
|
|
}
|
|
|
LiveUserLotteryRecord liveUserLotteryRecord = liveUserLotteryRecordMapper.selectLiveUserLotteryRecordById(liveOrder.getRecordId());
|
|
LiveUserLotteryRecord liveUserLotteryRecord = liveUserLotteryRecordMapper.selectLiveUserLotteryRecordById(liveOrder.getRecordId());
|
|
|
- if(liveUserLotteryRecord == null) return R.error("未查询到中奖记录,请联系管理员处理!");
|
|
|
|
|
- if(liveOrder.getLiveId() == null) return R.error("直播ID不能为空");
|
|
|
|
|
- if(liveOrder.getProductId() == null) return R.error("购物商品ID不能为空");
|
|
|
|
|
- if(liveOrder.getUserName() == null) return R.error("用户名不能为空");
|
|
|
|
|
- if(liveOrder.getUserPhone() == null) return R.error("用户手机号不能为空");
|
|
|
|
|
- if(liveOrder.getUserAddress() == null) return R.error("用户地址不能为空");
|
|
|
|
|
- if(liveOrder.getTotalNum() == null) return R.error("商品数量不能为空");
|
|
|
|
|
|
|
+ if (liveUserLotteryRecord == null) return R.error("未查询到中奖记录,请联系管理员处理!");
|
|
|
|
|
+ if (liveOrder.getLiveId() == null) return R.error("直播ID不能为空");
|
|
|
|
|
+ if (liveOrder.getProductId() == null) return R.error("购物商品ID不能为空");
|
|
|
|
|
+ if (liveOrder.getUserName() == null) return R.error("用户名不能为空");
|
|
|
|
|
+ if (liveOrder.getUserPhone() == null) return R.error("用户手机号不能为空");
|
|
|
|
|
+ if (liveOrder.getUserAddress() == null) return R.error("用户地址不能为空");
|
|
|
|
|
+ if (liveOrder.getTotalNum() == null) return R.error("商品数量不能为空");
|
|
|
|
|
|
|
|
Live live = liveMapper.selectLiveByLiveId(liveOrder.getLiveId());
|
|
Live live = liveMapper.selectLiveByLiveId(liveOrder.getLiveId());
|
|
|
- if(live == null) return R.error("当前直播不存在");
|
|
|
|
|
|
|
+ if (live == null) return R.error("当前直播不存在");
|
|
|
FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreProductById(liveOrder.getProductId());
|
|
FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreProductById(liveOrder.getProductId());
|
|
|
LiveGoods goods = liveGoodsMapper.selectLiveGoodsByProductId(liveOrder.getLiveId(), liveOrder.getProductId());
|
|
LiveGoods goods = liveGoodsMapper.selectLiveGoodsByProductId(liveOrder.getLiveId(), liveOrder.getProductId());
|
|
|
- if(goods == null) return R.error("当前商品不存在");
|
|
|
|
|
|
|
+ if (goods == null) return R.error("当前商品不存在");
|
|
|
FsStoreProductAttrValueScrm attrValue = null;
|
|
FsStoreProductAttrValueScrm attrValue = null;
|
|
|
if (!Objects.isNull(liveOrder.getAttrValueId())) {
|
|
if (!Objects.isNull(liveOrder.getAttrValueId())) {
|
|
|
attrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueById(liveOrder.getAttrValueId());
|
|
attrValue = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueById(liveOrder.getAttrValueId());
|
|
@@ -2281,12 +2281,12 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 更改店铺库存
|
|
// 更改店铺库存
|
|
|
- fsStoreProduct.setStock(fsStoreProduct.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
|
|
- fsStoreProduct.setSales(fsStoreProduct.getSales()+Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
|
|
- fsStoreProductScrmMapper.incStockDecSales(Long.valueOf("-" + liveOrder.getTotalNum()),fsStoreProduct.getProductId());
|
|
|
|
|
|
|
+ fsStoreProduct.setStock(fsStoreProduct.getStock() - Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
|
|
+ fsStoreProduct.setSales(fsStoreProduct.getSales() + Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
|
|
+ fsStoreProductScrmMapper.incStockDecSales(Long.valueOf(liveOrder.getTotalNum()), fsStoreProduct.getProductId());
|
|
|
// 更新直播间库存
|
|
// 更新直播间库存
|
|
|
- goods.setStock(goods.getStock()-Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
|
|
- goods.setSales(goods.getSales()+Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
|
|
|
|
+ goods.setStock(goods.getStock() - Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
|
|
+ goods.setSales(goods.getSales() + Integer.parseInt(liveOrder.getTotalNum()));
|
|
|
liveGoodsMapper.updateLiveGoods(goods);
|
|
liveGoodsMapper.updateLiveGoods(goods);
|
|
|
|
|
|
|
|
//判断是否是三种特定产品
|
|
//判断是否是三种特定产品
|
|
@@ -2303,8 +2303,8 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
liveOrder.setCompanyUserId(liveUserFirstEntry.getCompanyUserId());
|
|
liveOrder.setCompanyUserId(liveUserFirstEntry.getCompanyUserId());
|
|
|
liveOrder.setTuiUserId(liveUserFirstEntry.getCompanyUserId());
|
|
liveOrder.setTuiUserId(liveUserFirstEntry.getCompanyUserId());
|
|
|
|
|
|
|
|
- String orderSn = OrderCodeUtils.getOrderSn();
|
|
|
|
|
- log.info("订单生成:"+orderSn);
|
|
|
|
|
|
|
+ String orderSn = SnowflakeUtil.nextIdStr();
|
|
|
|
|
+ log.info("订单生成:" + orderSn);
|
|
|
liveOrder.setOrderCode(orderSn);
|
|
liveOrder.setOrderCode(orderSn);
|
|
|
BigDecimal totalPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum()));
|
|
BigDecimal totalPrice = fsStoreProduct.getPrice().multiply(new BigDecimal(liveOrder.getTotalNum()));
|
|
|
// 直播不需要服务费 0915 1735 左
|
|
// 直播不需要服务费 0915 1735 左
|
|
@@ -2341,7 +2341,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
liveUserLotteryRecord.setOrderId(liveOrder.getOrderId());
|
|
liveUserLotteryRecord.setOrderId(liveOrder.getOrderId());
|
|
|
liveUserLotteryRecord.setOrderStatus(liveOrder.getStatus());
|
|
liveUserLotteryRecord.setOrderStatus(liveOrder.getStatus());
|
|
|
liveUserLotteryRecordMapper.updateLiveUserLotteryRecord(liveUserLotteryRecord);
|
|
liveUserLotteryRecordMapper.updateLiveUserLotteryRecord(liveUserLotteryRecord);
|
|
|
- LiveOrderItemDTO dto=new LiveOrderItemDTO();
|
|
|
|
|
|
|
+ LiveOrderItemDTO dto = new LiveOrderItemDTO();
|
|
|
dto.setImage(fsStoreProduct.getImage());
|
|
dto.setImage(fsStoreProduct.getImage());
|
|
|
dto.setSku(String.valueOf(fsStoreProduct.getStock()));
|
|
dto.setSku(String.valueOf(fsStoreProduct.getStock()));
|
|
|
if (StringUtils.isEmpty(fsStoreProduct.getBarCode())) {
|
|
if (StringUtils.isEmpty(fsStoreProduct.getBarCode())) {
|
|
@@ -2364,7 +2364,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
liveOrderItem.setJsonInfo(JSON.toJSONString(dto));
|
|
liveOrderItem.setJsonInfo(JSON.toJSONString(dto));
|
|
|
liveOrderItemMapper.insertLiveOrderItem(liveOrderItem);
|
|
liveOrderItemMapper.insertLiveOrderItem(liveOrderItem);
|
|
|
redisCache.deleteObject("orderKey:" + liveOrder.getOrderKey());
|
|
redisCache.deleteObject("orderKey:" + liveOrder.getOrderKey());
|
|
|
- return R.ok("下单成功").put("order",liveOrder);
|
|
|
|
|
|
|
+ return R.ok("下单成功").put("order", liveOrder);
|
|
|
} else {
|
|
} else {
|
|
|
return R.error("订单创建失败");
|
|
return R.error("订单创建失败");
|
|
|
}
|
|
}
|