peng
10 天以前 923c8e406c7ab57a728911683f0196a6bb732084
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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;
import cn.lili.modules.goods.entity.vos.CategoryVO;
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.*;
 
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Objects;
 
@Validated
@RequiredArgsConstructor
@Api(value = "小程序商户端接口", tags = "小程序商户端接口")
@RestController
@RequestMapping("/buyer/lmk/supplier")
public class SupplierController {
    /**
     * 分类
     */
    @Autowired
    private CategoryService categoryService;
    /**
     * 店铺详情
     */
    @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() {
 
        String storeId = Objects.requireNonNull(UserContext.getCurrentUser()).getStoreId();
        if (StringUtils.isEmpty(storeId)) {
            Clerk clerk = clerkService.getClerkByMemberId(UserContext.getCurrentUserId());
            storeId = clerk.getStoreId();
        }
 
        //获取店铺经营范围
        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));
    }
 
}