xuhy
2025-01-10 d1632e46b772d691e55b4013585bfe61164b8bde
manage/src/main/java/com/jilongda/manage/controller/TOrderController.java
@@ -81,6 +81,8 @@
    private TSupplierService supplierService;
    @Autowired
    private TMaterialService materialService;
    @Autowired
    private TLineUpService lineUpService;
    @PostMapping("/obs-upload")
    @ApiOperation(value = "文件上传",tags = "管理后台-文件上传")
@@ -211,10 +213,10 @@
                }else {
                    split = orderGood.getLLens().split(",");
                }
                TBrand one1 = brandService.lambdaQuery().eq(TBrand::getName, orderGood.getBrandName())
                TBrand brand = brandService.lambdaQuery().eq(TBrand::getName, orderGood.getBrandName())
                        .eq(TBrand::getType, 2).one();
                TLensSeries lensSeries = lensSeriesService.lambdaQuery().eq(TLensSeries::getName, orderGood.getSeriesName())
                        .eq(TLensSeries::getBrandId, one1.getId()).one();
                        .eq(TLensSeries::getBrandId, brand.getId()).one();
                TLensGoods one = lensGoodsService.lambdaQuery()
                        .eq(StringUtils.hasLength(orderGood.getSeriesName()),TLensGoods::getSeriesId, lensSeries.getId())
                        .eq(StringUtils.hasLength(orderGood.getRefractiveIndex()),TLensGoods::getRefractiveIndex, orderGood.getRefractiveIndex())
@@ -229,38 +231,38 @@
                    // 减少对应库存
                    one.setTotal(one.getTotal()-1);
                    tLensGoods.add(one);
                    // 生成销售订单主表
                    TWarehousing tWarehousing = new TWarehousing();
                    tWarehousing.setStatus(5);
                    tWarehousing.setType(2);
                    tWarehousing.setStoreId(dto.getStoreId());
                    tWarehousing.setRemark("销售订单-镜片");
                    tWarehousing.setOrderNum(dto.getId()+"");
                    warehousingService.save(tWarehousing);
                    // 生成明细记录
                    TLensWarehousingDetail tLensWarehousingDetail = new TLensWarehousingDetail();
                    tLensWarehousingDetail.setBrand(orderGood.getBrandName());
                    TSupplier supplier = supplierService.getById(lensSeries.getSupplierId());
                    if (supplier!=null){
                        tLensWarehousingDetail.setSupplier(supplier.getName());
                    }
                    tLensWarehousingDetail.setSeries(lensSeries.getName());
                    tLensWarehousingDetail.setRefractiveIndex(orderGood.getRefractiveIndex());
                    if (StringUtils.hasLength(orderGood.getLLens())){
                        tLensWarehousingDetail.setBallMirror(orderGood.getLLens().split(",")[0]);
                        tLensWarehousingDetail.setColumnMirror(orderGood.getLLens().split(",")[0]);
                    }
                    if (StringUtils.hasLength(orderGood.getRLens())){
                        tLensWarehousingDetail.setBallMirror(orderGood.getRLens().split(",")[0]);
                        tLensWarehousingDetail.setColumnMirror(orderGood.getRLens().split(",")[0]);
                    }
                    tLensWarehousingDetail.setType(orderGood.getType());
                    tLensWarehousingDetail.setTotal(1);
                    tLensWarehousingDetail.setSeriesId(lensSeries.getId());
                    tLensWarehousingDetail.setWarehousingId(tWarehousing.getId());
                    tLensWarehousingDetail.setOrderId(dto.getId());
                    lensWarehousingDetailService.save(tLensWarehousingDetail);
//                    // 生成销售订单主表
//
//                    TWarehousing tWarehousing = new TWarehousing();
//                    tWarehousing.setStatus(5);
//                    tWarehousing.setType(2);
//                    tWarehousing.setStoreId(dto.getStoreId());
//                    tWarehousing.setRemark("销售订单-镜片");
//                    tWarehousing.setOrderNum(dto.getId()+"");
//                    warehousingService.save(tWarehousing);
//                    // 生成明细记录
//                    TLensWarehousingDetail tLensWarehousingDetail = new TLensWarehousingDetail();
//                    tLensWarehousingDetail.setBrand(orderGood.getBrandName());
//                    TSupplier supplier = supplierService.getById(lensSeries.getSupplierId());
//                    if (supplier!=null){
//                        tLensWarehousingDetail.setSupplier(supplier.getName());
//                    }
//                    tLensWarehousingDetail.setSeries(lensSeries.getName());
//                    tLensWarehousingDetail.setRefractiveIndex(orderGood.getRefractiveIndex());
//                    if (StringUtils.hasLength(orderGood.getLLens())){
//                        tLensWarehousingDetail.setBallMirror(orderGood.getLLens().split(",")[0]);
//                        tLensWarehousingDetail.setColumnMirror(orderGood.getLLens().split(",")[0]);
//                    }
//                    if (StringUtils.hasLength(orderGood.getRLens())){
//                        tLensWarehousingDetail.setBallMirror(orderGood.getRLens().split(",")[0]);
//                        tLensWarehousingDetail.setColumnMirror(orderGood.getRLens().split(",")[0]);
//                    }
//                    tLensWarehousingDetail.setType(orderGood.getType());
//                    tLensWarehousingDetail.setTotal(1);
//                    tLensWarehousingDetail.setSeriesId(lensSeries.getId());
//                    tLensWarehousingDetail.setWarehousingId(tWarehousing.getId());
//                    tLensWarehousingDetail.setOrderId(dto.getId());
//                    lensWarehousingDetailService.save(tLensWarehousingDetail);
                }else {
                    return ApiResult.failed("商品库存不足");
@@ -318,8 +320,13 @@
        }
        if (dto.getUserId()!=null){
            if (dto.getCouponId()!=null){
                List<TCouponReceive> couponReceives = couponReceiveService.lambdaQuery().eq(TCouponReceive::getUserId, dto.getUserId())
                        .eq(TCouponReceive::getCouponId, dto.getCouponId())
                TCouponReceive couponReceive = couponReceiveService.getById(dto.getCouponId());
                if (couponReceive==null){
                    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("优惠券不存在");
                TCouponReceive tCouponReceive = couponReceives.get(0);
@@ -330,8 +337,29 @@
        }
        List<TOptometryDetail> optometryDetails = dto.getOptometryDetails();
        if (!CollectionUtils.isEmpty(optometryDetails)){
            int temp =0;
            if (dto.getUserId()!=null){
                TOptometry optometry = new TOptometry();
                long count = lineUpService.count(Wrappers.lambdaQuery(TLineUp.class)
                        .eq(TLineUp::getStoreId, dto.getStoreId()));
                optometry.setCode(""+(count+1));
                optometry.setUserId(dto.getUserId());
                optometry.setAge(dto.getAge());
                optometry.setGender(dto.getGender());
                optometry.setRealName(dto.getRealName());
                optometry.setPhone(dto.getPhone());
                optometry.setStoreId(dto.getStoreId());
                optometry.setStatus(3);
                optometryService.save(optometry);
                temp = optometry.getId();
            }
            for (TOptometryDetail optometryDetail : optometryDetails) {
                optometryDetail.setOrderId(dto.getId());
                if (dto.getUserId()!=null){
                    optometryDetail.setOptometryId(temp);
                }
            }
            optometryDetailService.saveBatch(optometryDetails);
        }