无关风月
2025-02-28 2f8e70ad2884d2b6b7443dfae0af11ae9cfc8b99
manage/src/main/java/com/jilongda/manage/controller/TOrderController.java
@@ -235,7 +235,13 @@
                        .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);
@@ -274,6 +280,7 @@
                    lensWarehousingDetailService.save(tLensWarehousingDetail);
                }else {
                    orderService.removeById(dto);
                    return ApiResult.failed("商品库存不足");
                }
            }else{
@@ -286,7 +293,8 @@
                        .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);
@@ -323,7 +331,8 @@
                    frameWarehousingDetailService.save(tFrameWarehousingDetail);
                }else{
                    return ApiResult.failed("商品库存不足");
                    orderService.removeById(dto);
                    return ApiResult.failed("镜架库存不足,请重新选择");
                }
            }
        }
@@ -331,13 +340,17 @@
            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());
@@ -377,16 +390,16 @@
        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);