peng
4 天以前 1fdfb56613adca09a0ddf39289b41f96fa335a01
buyer-api/src/main/java/cn/lili/controller/lmk/SupplierController.java
@@ -1,6 +1,7 @@
package cn.lili.controller.lmk;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.security.OperationalJudgment;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.ResultMessage;
@@ -8,16 +9,26 @@
import cn.lili.modules.goods.service.CategoryService;
import cn.lili.modules.member.entity.dos.Clerk;
import cn.lili.modules.member.service.ClerkService;
import cn.lili.modules.member.service.StoreLogisticsService;
import cn.lili.modules.order.order.entity.dto.PartDeliveryParamsDTO;
import cn.lili.modules.order.order.entity.dto.SupplierOrderSearchParams;
import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
import cn.lili.modules.order.order.entity.vo.OrderSimpleXcxVO;
import cn.lili.modules.order.order.service.OrderService;
import cn.lili.modules.store.service.StoreDetailService;
import cn.lili.modules.system.entity.vo.StoreLogisticsVO;
import cn.lili.utils.COSUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Objects;
@@ -37,8 +48,22 @@
     */
    @Autowired
    private StoreDetailService storeDetailService;
    /**
     * 物流公司
     */
    @Autowired
    private StoreLogisticsService storeLogisticsService;
    /**
     * 订单
     */
    @Autowired
    private OrderService orderService;
    @Autowired
    private COSUtil cosUtil;
    @Autowired
    private ClerkService clerkService;
    @ApiOperation(value = "获取店铺经营的分类")
    @GetMapping(value = "/allCategery")
    public ResultMessage<List<CategoryVO>> getListAll() {
@@ -53,4 +78,53 @@
        String goodsManagementCategory = storeDetailService.getStoreDetail(storeId).getGoodsManagementCategory();
        return ResultUtil.data(this.categoryService.getStoreCategory(goodsManagementCategory.split(",")));
    }
    @ApiOperation(value = "查询会员订单列表")
    @GetMapping("/orderList")
    public ResultMessage<IPage<OrderSimpleXcxVO>> orderList(SupplierOrderSearchParams orderSearchParams) {
        String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
        if (StringUtils.isEmpty(storeId)) {
            Clerk clerk = clerkService.getClerkByMemberId(UserContext.getCurrentUserId());
            orderSearchParams.setStoreId(clerk.getStoreId());
        } else {
            orderSearchParams.setStoreId(storeId);
        }
        return ResultUtil.data(orderService.querySupplierOrderParams(orderSearchParams));
    }
    @ApiOperation(value = "订单明细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path")
    })
    @GetMapping(value = "/orderDetail/{orderSn}")
    public ResultMessage<OrderDetailVO> detail(@NotNull @PathVariable String orderSn) {
        OperationalJudgment.judgment(orderService.getBySn(orderSn));
        OrderDetailVO orderDetailVO = orderService.queryDetail(orderSn);
        orderDetailVO.getOrderItems().forEach(orderItem -> {
            String image = orderItem.getImage();
            if (StringUtils.isNotBlank(image) && !image.contains("http")) {
                orderItem.setImage(cosUtil.getPreviewUrl(image));
            }
        });
        return ResultUtil.data(orderDetailVO);
    }
    @ApiOperation(value = "获取商家已选择物流公司列表")
    @GetMapping("/getChecked")
    public ResultMessage<List<StoreLogisticsVO>> getChecked() {
        String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
        return ResultUtil.data(storeLogisticsService.getStoreSelectedLogistics(storeId));
    }
    @ApiOperation(value = "订单包裹发货")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderSn", value = "订单sn", required = true, dataType = "String", paramType = "path"),
            @ApiImplicitParam(name = "logisticsNo", value = "发货单号", required = true, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "logisticsId", value = "物流公司", required = true, dataType = "String", paramType = "query")
    })
    @PostMapping(value = "/{orderSn}/partDelivery")
    public ResultMessage<Object> delivery(@RequestBody PartDeliveryParamsDTO partDeliveryParamsDTO) {
        return ResultUtil.data(orderService.partDelivery(partDeliveryParamsDTO));
    }
}