| | |
| | | .one(); |
| | | if (one!=null){ |
| | | if (one.getTotal()-1<0 && lensSeries.getType()==1 ){ |
| | | return ApiResult.failed("库存不足"); |
| | | if (StringUtils.hasLength(orderGood.getRightLens())){ |
| | | orderService.removeById(dto); |
| | | return ApiResult.failed("镜片(R)库存不足,请重新选择"); |
| | | }else{ |
| | | orderService.removeById(dto); |
| | | return ApiResult.failed("镜片(L)库存不足,请重新选择"); |
| | | } |
| | | } |
| | | // 减少对应库存 |
| | | one.setTotal(one.getTotal()-1); |
| | |
| | | lensWarehousingDetailService.save(tLensWarehousingDetail); |
| | | |
| | | }else { |
| | | orderService.removeById(dto); |
| | | return ApiResult.failed("商品库存不足"); |
| | | } |
| | | }else{ |
| | |
| | | .eq(TFrameGoods::getColor, orderGood.getColor()).one(); |
| | | if (one!=null){ |
| | | if (one.getTotal()-1<0){ |
| | | return ApiResult.failed("库存不足"); |
| | | orderService.removeById(dto); |
| | | return ApiResult.failed("镜架库存不足,请重新选择"); |
| | | } |
| | | // 增加对应库存 |
| | | one.setTotal(one.getTotal()-1); |
| | |
| | | frameWarehousingDetailService.save(tFrameWarehousingDetail); |
| | | |
| | | }else{ |
| | | return ApiResult.failed("商品库存不足"); |
| | | orderService.removeById(dto); |
| | | return ApiResult.failed("镜架库存不足,请重新选择"); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (dto.getCouponId()!=null){ |
| | | TCouponReceive couponReceive = couponReceiveService.getById(dto.getCouponId()); |
| | | if (couponReceive==null){ |
| | | orderService.removeById(dto); |
| | | return ApiResult.failed("优惠券不存在"); |
| | | } |
| | | List<TCouponReceive> couponReceives = couponReceiveService.lambdaQuery() |
| | | .eq(TCouponReceive::getUserId, dto.getUserId()) |
| | | .eq(TCouponReceive::getCouponId, couponReceive.getCouponId()) |
| | | .orderByDesc(TCouponReceive::getCreateTime).list(); |
| | | if (couponReceives.isEmpty())return ApiResult.failed("优惠券不存在"); |
| | | if (couponReceives.isEmpty()){ |
| | | orderService.removeById(dto); |
| | | return ApiResult.failed("优惠券不存在"); |
| | | } |
| | | TCouponReceive tCouponReceive = couponReceives.get(0); |
| | | tCouponReceive.setStatus(2); |
| | | tCouponReceive.setUseTime(LocalDateTime.now()); |
| | |
| | | frameGoodsService.updateBatchById(tFrameGoods); |
| | | TAddOptometryVO tAddOptometryVO = new TAddOptometryVO(); |
| | | TTicket tTicket = tTicketService.lambdaQuery().eq(TTicket::getStoreId, dto.getStoreId()) |
| | | .eq(TTicket::getType,1) |
| | | .eq(TTicket::getType,2) |
| | | .eq(TTicket::getStatus, 1).list().stream().findFirst().orElse(null); |
| | | if (tTicket==null){ |
| | | orderService.removeById(dto); |
| | | return ApiResult.failed("当前门店未绑定小票机"); |
| | | } |
| | | tAddOptometryVO.setSn(tTicket.getCloudId()+""); |
| | | tAddOptometryVO.setPhone(dto.getPhone()); |
| | | List<TOrderGoods> orderGoods1 = dto.getOrderGoods(); |
| | | ArrayList<TOrderGoodsPrintVO> tOrderGoodsPrintVOS = new ArrayList<>(); |
| | | // 复制 |
| | | for (TOrderGoods orderGood : orderGoods1) { |
| | | TOrderGoodsPrintVO tOrderGoodsPrintVO = new TOrderGoodsPrintVO(); |
| | | BeanUtils.copyProperties(orderGood,tOrderGoodsPrintVO); |