Administrator
2025-07-04 d448834784e996a3c35c90097c4e7b110899bed2
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
package cc.mrbird.febs.mall.controller.clothes;
 
import cc.mrbird.febs.common.annotation.ControllerEndpoint;
import cc.mrbird.febs.common.controller.BaseController;
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.common.enumerates.OrderDeliveryStateEnum;
import cc.mrbird.febs.common.enumerates.OrderStatusEnum;
import cc.mrbird.febs.common.utils.excl.ExcelSheetPO;
import cc.mrbird.febs.common.utils.excl.ExcelUtil;
import cc.mrbird.febs.common.utils.excl.ExcelVersion;
import cc.mrbird.febs.common.utils.excl.ResponseHeadUtil;
import cc.mrbird.febs.mall.dto.DeliverGoodsDto;
import cc.mrbird.febs.mall.dto.clothes.AdminClothesDeliverGoodsDto;
import cc.mrbird.febs.mall.dto.clothes.AdminClothesOrderListDto;
import cc.mrbird.febs.mall.dto.clothes.AdminClothesRefundOrderDto;
import cc.mrbird.febs.mall.dto.clothes.AdminClothesTypeInfoDto;
import cc.mrbird.febs.mall.entity.*;
import cc.mrbird.febs.mall.service.ClothesTypeService;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
 
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/admin/clothesType")
public class AdminClothesTypeController extends BaseController {
 
    private final ClothesTypeService clothesTypeService;
 
    /**
     * 订单列表
     *
     * @param dto
     * @param request
     * @return
     */
    @GetMapping("orderList")
    public FebsResponse getOrderList(AdminClothesOrderListDto dto, QueryRequest request) {
        String startTime = dto.getStartTime();
        String endTime = dto.getEndTime();
        if(StrUtil.isNotBlank(startTime) && StrUtil.isNotBlank(endTime)){
            DateTime dateStartTime= DateUtil.parseDate(startTime);
            DateTime dateEndTime = DateUtil.parseDate(endTime);
            int compare = DateUtil.compare(dateStartTime, dateEndTime);
            if(compare >= 0){
                return new FebsResponse().fail().message("请输入正确的开始时间和结束时间");
            }
        }
        Map<String, Object> data = getDataTable(clothesTypeService.getOrderListInPage(dto, request));
        return new FebsResponse().success().data(data);
    }
 
    /**
     * 订单列表-发货
     */
    @PostMapping("deliverGoods")
    @ControllerEndpoint(operation = "订单列表-发货", exceptionMessage = "操作失败")
    public FebsResponse deliverGoods(AdminClothesDeliverGoodsDto dto) {
 
        return clothesTypeService.deliverGoods(dto);
    }
 
    /**
     * 订单列表-修改物流编号
     */
    @PostMapping("deliverGoodsUpdate")
    @ControllerEndpoint(operation = "订单列表-修改物流编号", exceptionMessage = "操作失败")
    public FebsResponse deliverGoodsUpdate(@Valid AdminClothesDeliverGoodsDto dto) {
 
        return clothesTypeService.deliverGoodsUpdate(dto);
    }
 
    /**
     * 订单列表-仅退款
     */
 
    @GetMapping("refundOrder/{id}")
    @ControllerEndpoint(operation = "订单列表-仅退款", exceptionMessage = "仅退款")
    public FebsResponse refundOrder(@NotNull(message = "{required}") @PathVariable Long id) {
        AdminClothesRefundOrderDto dto = new AdminClothesRefundOrderDto();
        dto.setId(id);
        return clothesTypeService.refundOrder(dto);
    }
 
    @GetMapping("confirmOrder/{ids}")
    @ControllerEndpoint(operation = "订单列表-确认收货", exceptionMessage = "操作失败")
    public FebsResponse confirmOrder(@NotBlank(message = "{required}") @PathVariable String ids){
        List<String> List = StrUtil.splitTrim(ids, ",");
        for(String id : List){
            long orderId = Long.parseLong(id);
            clothesTypeService.confirmOrder(orderId);
        }
        return new FebsResponse().success();
    }
 
    @GetMapping("exportOrderList/{ids}")
    @ControllerEndpoint(operation = "订单列表", exceptionMessage = "导出失败")
    public FebsResponse exportOrderList(@NotBlank(message = "{required}") @PathVariable String ids, HttpServletResponse response) throws IOException {
        List<String> List = StrUtil.splitTrim(ids, ",");
        if(CollUtil.isNotEmpty( List)){
            ArrayList<Long> orderIds = new ArrayList<>();
            for (String id : List){
                long orderId = Long.parseLong(id);
                orderIds.add(orderId);
            }
            if(CollUtil.isNotEmpty(orderIds)){
 
                clothesTypeService.exportOrderList(orderIds,response);
            }
        }
        return null;
    }
 
    @PostMapping(value = "/importDeliver")
    @ControllerEndpoint(operation = "导入发货", exceptionMessage = "导入失败")
    public FebsResponse importDeliver(@RequestBody MultipartFile file) throws IOException {
        if (file.isEmpty()) {
            return new FebsResponse().fail();
        }
 
        String fileName = file.getOriginalFilename();
        String dirPath = "/home/javaweb/webresource/clothes/";
 
        File saveFile = new File(new File(dirPath).getAbsolutePath() + File.separator + fileName);
        if (!saveFile.exists()) {
            if (!saveFile.getParentFile().exists()) {
                saveFile.getParentFile().mkdirs();
            }
        }
 
        file.transferTo(saveFile);
 
        List<ExcelSheetPO> data = ExcelUtil.readExcel(saveFile, null, null);
        if (CollUtil.isEmpty(data)) {
            return new FebsResponse().fail();
        }
 
        List<List<Object>> dataList = data.get(0).getDataList();
 
        int orderIdNoIndex = -1;
        int expressNoIndex = -1;
        int expressComIndex = -1;
        int expressCodeIndex = -1;
        for (int i = 1; i < dataList.size(); i++) {
            List<Object> objects = dataList.get(i);
 
            String orderId = "";
            String expressNo = "";
            String expressCode = "";
            String expressCom = "";
            for (int j = 0; j < objects.size(); j++) {
                Object obj = objects.get(j);
                if ("订单ID".equals(obj)) {
                    orderIdNoIndex = j;
                }
                if ("物流单号".equals(obj)) {
                    expressNoIndex = j;
                }
 
                if ("物流公司".equals(obj)) {
                    expressComIndex = j;
                }
 
                if ("物流公司码".equals(obj)) {
                    expressCodeIndex = j;
                }
 
                if (j == orderIdNoIndex) {
                    orderId = (String) objects.get(j);
                }
 
 
                if (j == expressNoIndex) {
                    expressNo = (String) objects.get(j);
                }
 
                if (j == expressComIndex) {
                    expressCom = (String) objects.get(j);
                }
 
                if (j == expressCodeIndex) {
                    expressCode = (String) objects.get(j);;
                }
 
            }
 
            if (StrUtil.isNotBlank(expressNo) && StrUtil.isNotBlank(expressCode) && StrUtil.isNotBlank(expressCom)) {
                AdminClothesDeliverGoodsDto dto = new AdminClothesDeliverGoodsDto();
                dto.setId(Long.parseLong(orderId));
                dto.setExpressCom(expressCom);
                dto.setExpressCode(expressCode);
                dto.setExpressNo(expressNo);
                clothesTypeService.deliverGoodsImport(dto);
            }
        }
        return new FebsResponse().success();
    }
 
    /**
     * 分类列表
     * @return
     */
    @GetMapping("typeList")
    public FebsResponse typeList(ClothesType dto, QueryRequest request) {
 
        Map<String, Object> data = getDataTable(clothesTypeService.adminTypeList(dto, request));
        return new FebsResponse().success().data(data);
    }
    /**
     * 分类-新增
     */
    @PostMapping("typeAdd")
    @ControllerEndpoint(operation = " 分类-新增", exceptionMessage = "操作失败")
    public FebsResponse typeAdd(@RequestBody @Valid ClothesType dto) {
 
        return clothesTypeService.typeAdd(dto);
    }
    /**
     * 分类-更新
     */
    @PostMapping("typeUpdate")
    @ControllerEndpoint(operation = "分类-更新", exceptionMessage = "操作失败")
    public FebsResponse typeUpdate(@RequestBody @Valid ClothesType dto) {
 
        return clothesTypeService.typeUpdate(dto);
    }
    /**
     * 分类-状态操作
     */
    @GetMapping("changeState/{id}/{type}/{state}")
    @ControllerEndpoint(operation = "分类-状态操作", exceptionMessage = "操作失败")
    public FebsResponse changeState(
            @NotNull(message = "{required}") @PathVariable Long id,
            @NotNull(message = "{required}") @PathVariable Integer type,
            @NotNull(message = "{required}") @PathVariable Integer state
    ) {
 
        return clothesTypeService.changeState(id,type,state);
    }
    /**
     * 尺码列表
     * @return
     */
    @GetMapping("sizeList")
    public FebsResponse sizeList(ClothesSize dto, QueryRequest request) {
 
        Map<String, Object> data = getDataTable(clothesTypeService.adminSizeList(dto, request));
        return new FebsResponse().success().data(data);
    }
    /**
     * 尺码-新增
     */
    @PostMapping("sizeAdd")
    @ControllerEndpoint(operation = "新增", exceptionMessage = "操作失败")
    public FebsResponse sizeAdd(@RequestBody @Valid ClothesSize dto) {
 
        return clothesTypeService.sizeAdd(dto);
    }
    /**
     * 尺码-更新
     */
    @PostMapping("sizeUpdate")
    @ControllerEndpoint(operation = "分类-更新", exceptionMessage = "操作失败")
    public FebsResponse sizeUpdate(@RequestBody @Valid ClothesSize dto) {
 
        return clothesTypeService.sizeUpdate(dto);
    }
    /**
     * 图案列表
     * @return
     */
    @GetMapping("patternList")
    public FebsResponse patternList(ClothesPattern dto, QueryRequest request) {
 
        Map<String, Object> data = getDataTable(clothesTypeService.adminPatternList(dto, request));
        return new FebsResponse().success().data(data);
    }
    /**
     * 图案-新增
     */
    @PostMapping("patternAdd")
    @ControllerEndpoint(operation = "新增", exceptionMessage = "操作失败")
    public FebsResponse patternAdd(@RequestBody @Valid ClothesPattern dto) {
 
        return clothesTypeService.patternAdd(dto);
    }
    /**
     * 图案-更新
     */
    @PostMapping("patternUpdate")
    @ControllerEndpoint(operation = "分类-更新", exceptionMessage = "操作失败")
    public FebsResponse patternUpdate(@RequestBody @Valid ClothesPattern dto) {
 
        return clothesTypeService.patternUpdate(dto);
    }
 
 
    /**
     * 位置列表
     * @return
     */
    @GetMapping("locationList")
    public FebsResponse locationList(ClothesLocation dto, QueryRequest request) {
 
        Map<String, Object> data = getDataTable(clothesTypeService.adminLocationList(dto, request));
        return new FebsResponse().success().data(data);
    }
    /**
     * 位置-新增
     */
    @PostMapping("locationAdd")
    @ControllerEndpoint(operation = "新增", exceptionMessage = "操作失败")
    public FebsResponse locationAdd(@RequestBody @Valid ClothesLocation dto) {
 
        return clothesTypeService.locationAdd(dto);
    }
    /**
     * 位置-更新
     */
    @PostMapping("locationUpdate")
    @ControllerEndpoint(operation = "分类-更新", exceptionMessage = "操作失败")
    public FebsResponse locationUpdate(@RequestBody @Valid ClothesLocation dto) {
 
        return clothesTypeService.locationUpdate(dto);
    }
 
 
    /**
     * 布料列表
     * @return
     */
    @GetMapping("clothList")
    public FebsResponse clothList(ClothesCloth dto, QueryRequest request) {
 
        Map<String, Object> data = getDataTable(clothesTypeService.adminClothList(dto, request));
        return new FebsResponse().success().data(data);
    }
    /**
     * 布料-新增
     */
    @PostMapping("clothAdd")
    @ControllerEndpoint(operation = "新增", exceptionMessage = "操作失败")
    public FebsResponse clothAdd(@RequestBody @Valid ClothesCloth dto) {
 
        return clothesTypeService.clothAdd(dto);
    }
    /**
     * 布料-更新
     */
    @PostMapping("clothUpdate")
    @ControllerEndpoint(operation = "分类-更新", exceptionMessage = "操作失败")
    public FebsResponse clothUpdate(@RequestBody @Valid ClothesCloth dto) {
 
        return clothesTypeService.clothUpdate(dto);
    }
 
 
    /**
     * 工艺列表
     * @return
     */
    @GetMapping("artList")
    public FebsResponse artList(ClothesArt dto, QueryRequest request) {
 
        Map<String, Object> data = getDataTable(clothesTypeService.adminArtList(dto, request));
        return new FebsResponse().success().data(data);
    }
    /**
     * 工艺-新增
     */
    @PostMapping("artAdd")
    @ControllerEndpoint(operation = "新增", exceptionMessage = "操作失败")
    public FebsResponse artAdd(@RequestBody @Valid ClothesArt dto) {
 
        return clothesTypeService.artAdd(dto);
    }
    /**
     * 工艺-更新
     */
    @PostMapping("artUpdate")
    @ControllerEndpoint(operation = "分类-更新", exceptionMessage = "操作失败")
    public FebsResponse artUpdate(@RequestBody @Valid ClothesArt dto) {
 
        return clothesTypeService.artUpdate(dto);
    }
 
    @PostMapping("artSet")
    @ControllerEndpoint(operation = "设置", exceptionMessage = "操作失败")
    public FebsResponse artSet(@RequestBody @Valid AdminClothesTypeInfoDto dto) {
 
        return clothesTypeService.artSet(dto);
    }
 
    @PostMapping("sizeSet")
    @ControllerEndpoint(operation = "设置", exceptionMessage = "操作失败")
    public FebsResponse sizeSet(@RequestBody @Valid AdminClothesTypeInfoDto dto) {
 
        return clothesTypeService.sizeSet(dto);
    }
 
    @PostMapping("clothSet")
    @ControllerEndpoint(operation = "设置", exceptionMessage = "操作失败")
    public FebsResponse clothSet(@RequestBody @Valid AdminClothesTypeInfoDto dto) {
 
        return clothesTypeService.clothSet(dto);
    }
 
    @PostMapping("patternSet")
    @ControllerEndpoint(operation = "设置", exceptionMessage = "操作失败")
    public FebsResponse patternSet(@RequestBody @Valid AdminClothesTypeInfoDto dto) {
 
        return clothesTypeService.patternSet(dto);
    }
 
    @PostMapping("locationSet")
    @ControllerEndpoint(operation = "设置", exceptionMessage = "操作失败")
    public FebsResponse locationSet(@RequestBody @Valid AdminClothesTypeInfoDto dto) {
 
        return clothesTypeService.locationSet(dto);
    }
 
}