无关风月
2024-12-31 bf765893039bc7968b8160a70bda778526dca98c
manage/src/main/java/com/jilongda/manage/controller/TOrderController.java
@@ -13,6 +13,7 @@
import com.jilongda.manage.query.TOrderQuery;
import com.jilongda.manage.service.*;
import com.jilongda.manage.utils.LoginInfoUtil;
import com.jilongda.manage.utils.OssUploadUtil;
import com.jilongda.manage.vo.TModelVO;
import com.jilongda.manage.vo.TOptometryVO;
import com.jilongda.manage.vo.TOrderListVO;
@@ -24,6 +25,7 @@
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.math.BigDecimal;
import java.util.*;
@@ -68,6 +70,21 @@
    private TBrandService brandService;
    @Autowired
    private TOptometryService optometryService;
    @PostMapping("/obs-upload")
    @ApiOperation(value = "文件上传",tags = "管理后台-文件上传")
    public ApiResult<String> uploadOSS(@RequestPart("file") MultipartFile file) {
        try {
            // 上传并返回访问地址
            String fileName = file.getOriginalFilename();
            String prefix = fileName.substring(fileName.lastIndexOf("."));
            long fileSize = file.getSize();
            String url = OssUploadUtil.ossUpload("eyes/",file);
            return ApiResult.success(url);
        } catch (Exception e) {
            System.err.println("上传文件失败"+e);
            return ApiResult.failed(e.getMessage());
        }
    }
    @ApiOperation(value = "销售订单分页列表")
    @PostMapping(value = "/pageList")
    public ApiResult<PageInfo<TOrderListVO>> pageList(@RequestBody TOrderQuery query) {
@@ -157,7 +174,11 @@
        if(Objects.nonNull(user)){
            dto.setStoreId(user.getStoreId());
        }
        if (dto.getUserId()!=null){
            TAppUser byId = tAppUserService.getById(dto.getUserId());
            dto.setName(byId.getName());
            dto.setPhone(byId.getPhone());
        }
        orderService.save(dto);
        List<TOptometryDetail> optometryDetails = dto.getOptometryDetails();
@@ -175,8 +196,15 @@
            orderGood.setOrderId(dto.getId());
            if (StringUtils.hasLength(orderGood.getSeriesName())){
                // 镜片
                orderGood.setRLens(orderGood.getRightLens());
                orderGood.setLLens(orderGood.getLeftLens());
                String rLens = orderGood.getRLens();
                String[] split = rLens.split(",");
                String[] split = null;
                if(StringUtils.hasLength(rLens)){
                    split = rLens.split(",");
                }else {
                    split = orderGood.getLLens().split(",");
                }
                TBrand one1 = brandService.lambdaQuery().eq(TBrand::getName, orderGood.getBrandName())
                        .eq(TBrand::getType, 2).one();
                TLensSeries one2 = lensSeriesService.lambdaQuery().eq(TLensSeries::getName, orderGood.getSeriesName())
@@ -221,7 +249,7 @@
        orderGoodsService.saveBatch(orderGoods);
        lensGoodsService.updateBatchById(tLensGoods);
        frameGoodsService.updateBatchById(tFrameGoods);
        return ApiResult.success();
        return ApiResult.success(dto.getId());
    }
    @ApiOperation(value = "销售订单详情")