| | |
| | | public Long createOrder(AddOrderDto addOrderDto) { |
| | | // synchronized(this){ |
| | | MallMember member = LoginUserUtil.getLoginUser(); |
| | | String takeUniqueCode = addOrderDto.getTakeUniqueCode(); |
| | | if(StrUtil.isEmpty(takeUniqueCode)){ |
| | | throw new FebsException("请选择自提点"); |
| | | //验证用户的等级 |
| | | if(AgentLevelEnum.ZERO_LEVEL.name().equals(member.getLevel())){ |
| | | throw new FebsException("请先申请成为代理人"); |
| | | } |
| | | // String takeUniqueCode = addOrderDto.getTakeUniqueCode(); |
| | | // if(StrUtil.isEmpty(takeUniqueCode)){ |
| | | // throw new FebsException("请选择自提点"); |
| | | // } |
| | | |
| | | MallTeamLeader mallTeamLeader = mallTeamLeaderMapper.selectLeaderByUniqueCode(takeUniqueCode); |
| | | if(ObjectUtil.isEmpty(mallTeamLeader)){ |
| | | throw new FebsException("请重新选择团长"); |
| | | } |
| | | // MallTeamLeader mallTeamLeader = mallTeamLeaderMapper.selectLeaderByUniqueCode(takeUniqueCode); |
| | | // if(ObjectUtil.isEmpty(mallTeamLeader)){ |
| | | // throw new FebsException("请重新选择团长"); |
| | | // } |
| | | |
| | | //订单范围内才允许下单 |
| | | MallAddressInfo address = mallAddressInfoMapper.selectAddressInfoByMemberIdAndId(member.getId(), addOrderDto.getAddressId()); |
| | | if(ObjectUtil.isEmpty(address)){ |
| | | throw new FebsException("请重新选择收货地址信息"); |
| | | } |
| | | // MallElectronicFence mallElectronicFence = mallElectronicFenceMapper.selectByTeamLeaderCode(mallTeamLeader.getUniqueCode()); |
| | | // if(ObjectUtil.isNotEmpty(mallElectronicFence)){ |
| | | // String inStr = iMallElectronicFenceService.fenceToLocation(mallElectronicFence.getGKey(), |
| | |
| | | orderInfo.setRemark(addOrderDto.getRemark()); |
| | | orderInfo.setOrderType(addOrderDto.getOrderType()); |
| | | |
| | | orderInfo.setTakeUniqueCode(addOrderDto.getTakeUniqueCode()); |
| | | orderInfo.setDeliveryType(1); |
| | | // orderInfo.setTakeUniqueCode(addOrderDto.getTakeUniqueCode()); |
| | | orderInfo.setDeliveryType(2); |
| | | |
| | | if (CollUtil.isEmpty(addOrderDto.getItems())) { |
| | | throw new FebsException("参数错误"); |
| | |
| | | orderInfo.setCarriage(delivaryAmount); |
| | | } |
| | | orderInfo.setAmount(total); |
| | | |
| | | orderInfo.setAddressId(address.getId()); |
| | | orderInfo.setName(address.getName()); |
| | | orderInfo.setPhone(address.getPhone()); |
| | | orderInfo.setIsHome(addOrderDto.getIsHome()); |
| | | //订单金额大于50,且选择送货上门,订单需要选择地址信息 |
| | | if(1 == addOrderDto.getIsHome()){ |
| | | // if(1 == addOrderDto.getIsHome()){ |
| | | if (StrUtil.isBlank(address.getLatitude())||StrUtil.isBlank(address.getLongitude())) { |
| | | throw new FebsException("请添加地址"); |
| | | } |
| | | orderInfo.setAddress(address.getArea() + address.getAddress()); |
| | | orderInfo.setLatitude(address.getLatitude()); |
| | | orderInfo.setLongitude(address.getLongitude()); |
| | | } |
| | | // } |
| | | this.baseMapper.updateById(orderInfo); |
| | | |
| | | agentProducer.sendOrderCancelDelayMsg(orderInfo.getId(), 15 * 60 * 1000L); |
| | |
| | | orderInfo.setCancelType(MallOrderInfo.CANCEL_BY_SELF); |
| | | this.baseMapper.updateById(orderInfo); |
| | | |
| | | |
| | | |
| | | List<MallOrderItem> mallOrderItemList = mallOrderItemMapper.selectListByOrderId(orderInfo.getId()); |
| | | if(CollUtil.isNotEmpty(mallOrderItemList)){ |
| | | for(MallOrderItem mallOrderItem : mallOrderItemList){ |
| | |
| | | } |
| | | |
| | | MallGoods mallGoods = mallGoodsMapper.selectById(sku.getGoodsId()); |
| | | Integer goodsResult = mallGoodsMapper.upDateStockAndVolumeByGoodsId(mallGoods.getId(), mallOrderItem.getCnt()); |
| | | Integer goodsResult = mallGoodsMapper.updateStockAndVolumeByGoodsId(mallGoods.getId(), mallOrderItem.getCnt()); |
| | | if(1 != goodsResult){ |
| | | throw new FebsException(mallGoods.getGoodsName() + "库存不足"); |
| | | } |
| | | |
| | | Integer skuResult = mallGoodsSkuMapper.upDateStockAndVolumeBySkuId(sku.getId(),mallOrderItem.getCnt()); |
| | | Integer skuResult = mallGoodsSkuMapper.updateStockAndVolumeBySkuId(sku.getId(),mallOrderItem.getCnt()); |
| | | if(1 != skuResult){ |
| | | throw new FebsException(sku.getSkuName() + "库存不足"); |
| | | } |
| | |
| | | IPage<MallOrderInfo> page = new Page<>(orderListDto.getPageNum(), orderListDto.getPageSize()); |
| | | |
| | | orderListDto.setMemberId(member.getId()); |
| | | IPage<MallOrderInfo> mallOrderInfos = this.baseMapper.selectApiOrderListInPage(page, orderListDto); |
| | | // IPage<MallOrderInfo> mallOrderInfos = this.baseMapper.selectApiOrderListInPage(page, orderListDto); |
| | | IPage<MallOrderInfo> mallOrderInfos = this.baseMapper.selectNewApiOrderListInPage(page, orderListDto); |
| | | if (CollUtil.isNotEmpty(mallOrderInfos.getRecords())) { |
| | | mallOrderInfos.getRecords().forEach(item -> { |
| | | item.setItems(mallOrderItemMapper.selectListByOrderId(item.getId())); |
| | |
| | | throw new FebsException("购买商品或sku不存在"); |
| | | } |
| | | |
| | | if (sku.getStock() < mallOrderItem.getCnt()) { |
| | | throw new FebsException(sku.getSkuName() + "库存不足"); |
| | | } |
| | | // if (sku.getStock() < mallOrderItem.getCnt()) { |
| | | // throw new FebsException(sku.getSkuName() + "库存不足"); |
| | | // } |
| | | |
| | | MallGoods mallGoods = mallGoodsMapper.selectById(sku.getGoodsId()); |
| | | Integer goodsResult = mallGoodsMapper.upDateStockAndVolumeByGoodsId(mallGoods.getId(), mallOrderItem.getCnt()); |
| | | Integer goodsResult = mallGoodsMapper.updateStockAndVolumeByGoodsId(mallGoods.getId(), mallOrderItem.getCnt()); |
| | | if(1 != goodsResult){ |
| | | throw new FebsException(mallGoods.getGoodsName() + "库存不足"); |
| | | } |
| | | |
| | | Integer skuResult = mallGoodsSkuMapper.upDateStockAndVolumeBySkuId(sku.getId(),mallOrderItem.getCnt()); |
| | | Integer skuResult = mallGoodsSkuMapper.updateStockAndVolumeBySkuId(sku.getId(),mallOrderItem.getCnt()); |
| | | if(1 != skuResult){ |
| | | throw new FebsException(sku.getSkuName() + "库存不足"); |
| | | } |