mitao
2024-04-30 c6889419ea24a8df72b654f30b3851f1172e3499
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
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
package com.sinata.modular.mall.controller;
 
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.enums.SqlLike;
import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.toolkit.CollectionUtils;
import com.google.common.collect.Lists;
import com.sinata.common.enums.EnumCityRole;
import com.sinata.common.enums.EnumMemberGrade;
import com.sinata.common.enums.mall.EnumMallGoodsGroupType;
import com.sinata.common.enums.mall.EnumMallOrderState;
import com.sinata.core.base.controller.BaseController;
import com.sinata.core.common.annotion.BussinessLog;
import com.sinata.core.common.annotion.Permission;
import com.sinata.core.common.constant.factory.PageFactory;
import com.sinata.core.shiro.ShiroKit;
import com.sinata.core.shiro.ShiroUser;
import com.sinata.core.util.DateUtils2;
import com.sinata.core.util.ExcelExportUtil;
import com.sinata.core.util.ExpressApi;
import com.sinata.core.util.PayUtil;
import com.sinata.modular.mall.dto.OrderSearchDto;
import com.sinata.modular.mall.model.*;
import com.sinata.modular.mall.service.*;
import com.sinata.modular.member.model.MemUser;
import com.sinata.modular.member.model.MemUserRelation;
import com.sinata.modular.member.service.IMemUserRelationService;
import com.sinata.modular.member.service.IMemUserService;
import com.sinata.modular.system.model.Role;
import com.sinata.modular.system.service.IMyCouponService;
import com.sinata.modular.system.service.IRoleService;
import java.util.Map;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
 
/**
 * 商品订单控制器
 *
 * @author goku
 */
@Slf4j
@Controller
@RequestMapping("/mallOrder")
public class MallOrderController extends BaseController {
 
    private String PREFIX = "/mall/mallOrder/";
 
    @Resource
    private IMemUserService memUserService;
 
    @Resource
    private IMemUserRelationService userRelationService;
 
    @Resource
    private IMyCouponService myCouponService;
 
    @Autowired
    private IMallOrderService mallOrderService;
 
    @Resource
    private IMallGoodsSetService mallGoodsSetService;
 
    @Resource
    private IMallGoodsService mallGoodsService;
 
    @Resource
    private IMallOrderDetailService mallOrderDetailService;
 
    @Resource
    private IMallExpressCompanyService mallExpressCompanyService;
 
    @Resource
    private IMallOrderDetailGroupSpecService mallOrderDetailGroupSpecService;
    @Resource
    private IRoleService roleService;
    @Resource
    private IMallGoodsSkuService mallGoodsSkuService;
 
    private MallOrder selectById(String orderNo) {
        return this.mallOrderService.selectOne(new EntityWrapper<MallOrder>()
                .eq("order_no", orderNo));
    }
 
    /**
     * 跳转到商品订单首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "mallOrder.html";
    }
 
    /**
     * 跳转到添加商品订单
     */
    @RequestMapping("/mallOrder_add")
    public String mallOrderAdd() {
        return PREFIX + "mallOrder_add.html";
    }
 
    /**
     * 跳转到设置运费
     */
    @RequestMapping("/setFreightAuth/{orderNo}")
    public String mallOrderUpdate(@PathVariable String orderNo, Model model) {
        model.addAttribute("item", selectById(orderNo));
        return PREFIX + "setFreightAuth.html";
    }
 
    /**
     * 退款页面
     */
    @RequestMapping(value = "/deliverAuth/{orderNo}")
    public String deliverAuth(@PathVariable String orderNo, Model model) {
        model.addAttribute("orderNo", orderNo);
        model.addAttribute("expressCompanyList", this.mallExpressCompanyService.selectList(Condition.empty()));
        return PREFIX + "deliverAuth.html";
    }
 
    /**
     * 获取商品订单列表
     */
    @ResponseBody
    @RequestMapping(value = "/list")
    public Object list(OrderSearchDto dto) {
        Page<MallOrder> page = new PageFactory().defaultPage();
 
        Wrapper<?> wrapper = wrapperList(dto);
 
        page = mallOrderService.findPage(page, wrapper);
        return super.packForBT(page);
    }
 
    /**
     * 新增商品订单
     */
    @Permission
    @ResponseBody
    @BussinessLog(value = "新增商品订单")
    @RequestMapping(value = "/add")
    public Object add(MallOrder mallOrder) {
        mallOrderService.insert(mallOrder);
        return SUCCESS_TIP;
    }
 
    /**
     * 删除/批量删除
     */
    @Permission
    @ResponseBody
    @BussinessLog(value = "删除商品订单")
    @RequestMapping(value = "/delete")
    public Object delete(@RequestParam String orderNo) {
        // 逻辑删除
        mallOrderService.updateForSet("cms_delete = 1", new EntityWrapper<MallOrder>().in("order_no", orderNo));
        return SUCCESS_TIP;
    }
 
    /**
     * 修改商品订单
     */
    @Permission
    @ResponseBody
    @BussinessLog(value = "修改商品订单")
    @RequestMapping(value = "/update")
    public Object update(MallOrder mallOrder) {
        mallOrderService.updateById(mallOrder);
        return SUCCESS_TIP;
    }
 
    /**
     * 修改商品订单状态
     */
    @ResponseBody
    @BussinessLog(value = "修改商品订单状态")
    @RequestMapping(value = "/updateState")
    public Object updateState(Integer mallOrderId, Integer state) {
        mallOrderService.updateForSet("state = " + state, new EntityWrapper<MallOrder>().eq("id", mallOrderId));
        return SUCCESS_TIP;
    }
 
    /**
     * 跳转物流详情
     */
    @RequestMapping(value = "/logisticsAuth/{orderNo}")
    public Object logisticsAuth(@PathVariable("orderNo") String orderNo, Model model) {
        model.addAttribute("item", this.mallOrderService.selectById(orderNo));
        return PREFIX + "mallOrder_express.html";
    }
 
    /**
     * 物流信息
     */
    @ResponseBody
    @RequestMapping(value = "/express")
    public Object express(String expressNo) {
        return ExpressApi.query(expressNo, null);
    }
 
 
    /**
     * 跳转商品订单详情
     */
    @RequestMapping(value = "/detail")
    public Object detail(String orderNo, Integer orderType, Model model) {
        Page<MallOrder> page = new PageFactory().defaultPage(1, 0);
 
        Wrapper<?> wrapper = new EntityWrapper<MallOrder>()
                .eq("o.order_no", orderNo);
        MallOrder mallOrder = mallOrderService.findPage(page, wrapper).getRecords().get(0);
 
        // 订单详情
        List<MallOrderDetail> orderDetailList = this.mallOrderDetailService.selectList(new EntityWrapper<MallOrderDetail>().eq("order_no", orderNo));
        
        // 订单详情-商品信息
        List<Integer> goodsIdList = orderDetailList.stream().map(MallOrderDetail::getGoodsId).collect(Collectors.toList());
 
        // 订单详情套餐规格组商品
        List<MallOrderDetailGroupSpec> mallOrderDetailGroupSpecList = mallOrderDetailGroupSpecService.selectList(new EntityWrapper<MallOrderDetailGroupSpec>().eq("order_no", mallOrder.getOrderNo()));
        if (CollUtil.isNotEmpty(mallOrderDetailGroupSpecList)) {
            List<Integer> mallOrderDetailGroupSpecGroupSpecGoodsIds = mallOrderDetailGroupSpecList.stream().map(MallOrderDetailGroupSpec::getGroupSpecGoodsId).collect(Collectors.toList());
            goodsIdList.addAll(mallOrderDetailGroupSpecGroupSpecGoodsIds);
        }
        
        List<MallGoods> goodsList = mallGoodsService.selectList(new EntityWrapper<MallGoods>().in("id", goodsIdList));
 
        // 封装商品信息
        mallOrder.setOrderDetails(
                orderDetailList.stream().map(o -> {
                    String goodsNo = "";
                    for (MallGoods g : goodsList) {
                        if (g.getId().equals(o.getGoodsId())) {
                            goodsNo = g.getGoodsNo();
                            o.setGoodsName(g.getGoodsName());
                        }
                    }
                    o.setGoodsNo(goodsNo);
                    return o;
                }).collect(Collectors.toList())
        );
        MemUser memUser = this.memUserService.selectById(mallOrder.getUserId());
        if (memUser != null) {
            mallOrder.setUserShowId(memUser.getShowId());
            mallOrder.setUserPhone(memUser.getPhone());
            mallOrder.setUserNickname(memUser.getNickName());
        }
        //mallOrder.setUseList(useService.getUseList(mallOrder.getOrderNo()));
        mallOrder.setUseOrderDetailGroupSpecList(mallOrderDetailGroupSpecService.getUseOrderDetailGroupSpec(mallOrder.getOrderNo()));
        model.addAttribute("item", mallOrder);
 
        String v4ShowId = "", v4Team = "", v5ShowId = "", v5Team = "";
 
        // 计算订单业绩
        BigDecimal saleGoodsMoney = BigDecimal.ZERO;
        try {
            if (mallOrder.getSaleUserId() != null && mallOrder.getSaleUserId() != 0 && mallOrder.getGoodsId() != null) {
                MemUser saleUser = memUserService.selectById(mallOrder.getSaleUserId());
                MallGoodsSet goodsSet = mallGoodsSetService.selectById(mallOrder.getGoodsId());
                if (saleUser.getMemberGradeId() == EnumMemberGrade.G_3.index) {
                    saleGoodsMoney = mallOrder.getPayMoney().multiply(goodsSet.getV3BuyCoef());
                }
                if (saleUser.getMemberGradeId() == EnumMemberGrade.G_4.index) {
                    saleGoodsMoney = mallOrder.getPayMoney().multiply(goodsSet.getV4BuyCoef());
                }
                if (saleUser.getMemberGradeId() == EnumMemberGrade.G_5.index) {
                    saleGoodsMoney = mallOrder.getPayMoney().multiply(goodsSet.getV5BuyCoef());
                }
 
                // 获取合伙人、市场总监
                MemUserRelation saleUserRelation = userRelationService.selectById(mallOrder.getSaleUserId());
                Integer saleUserMemberGradeId = saleUser.getMemberGradeId();
                MemUser[] parentV4V5User = userRelationService.getParentV4V5ByRelationPath(null, null, saleUserRelation.getRelationPath(), saleUserMemberGradeId);
                if (parentV4V5User[0] != null) {
                    v4ShowId = parentV4V5User[0].getShowId();
                    v4Team = parentV4V5User[0].getRealName();
                }
                if (parentV4V5User[1] != null) {
                    v5ShowId = parentV4V5User[1].getShowId();
                    v5Team = parentV4V5User[1].getRealName();
                }
 
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        model.addAttribute("v4ShowId", v4ShowId);
        model.addAttribute("v4Team", v4Team);
        model.addAttribute("v5ShowId", v5ShowId);
        model.addAttribute("v5Team", v5Team);
 
        model.addAttribute("saleGoodsMoney", saleGoodsMoney.setScale(2, BigDecimal.ROUND_HALF_UP));
 
        model.addAttribute("orderType", orderType);
        if (orderType == null || orderType == EnumMallGoodsGroupType.GOODS.index) {
            // 普通商品
            return PREFIX + "mallOrder_detail.html";
        } else {
            model.addAttribute("mallOrderDetailGroupSpecList", mallOrderDetailGroupSpecList.stream()
                            .map(o -> {
                                JSONObject json = JSONUtil.parseObj(o);
 
                                for (MallGoods g : goodsList) {
                                    if (g.getId().equals(o.getGroupSpecGoodsId())) {
                                        json.set("groupSpecGoodsName", g.getGoodsName());
                                        json.set("groupSpecGoodsNo", g.getGoodsNo());
                                        json.set("groupSpecGoodsImage", g.getGoodsImage());
                                    }
                                }
 
                                return json;
                            })
                    .collect(Collectors.toList()));
 
            // 套餐商品
            return PREFIX + "mallOrder_detail_group.html";
        }
    }
 
    /**
     * 跳转商品订单详情
     */
    @RequestMapping(value = "/goodsDetails/{orderNo}")
    public Object goodsDetails(@PathVariable("orderNo") String orderNo, Model model) {
        MallOrder mallOrder = mallOrderService.selectById(orderNo);
 
        mallOrder.setOrderDetails(this.mallOrderDetailService.selectList(new EntityWrapper<MallOrderDetail>()
                .eq("order_no", orderNo)));
        MemUser memUser = this.memUserService.selectById(mallOrder.getUserId());
        if (memUser != null) {
            mallOrder.setUserShowId(memUser.getShowId());
            mallOrder.setUserPhone(memUser.getPhone());
            mallOrder.setUserNickname(memUser.getNickName());
        }
 
        model.addAttribute("item", mallOrder);
        return PREFIX + "mallOrder_goods.html";
    }
 
    /**
     * 获取订单商品
     *
     * @param orderNo
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/getOrderGoods")
    public Object updateState(Integer orderNo) {
        return this.mallOrderDetailService.selectList(new EntityWrapper<MallOrderDetail>()
                .eq("order_no", orderNo));
    }
 
    public Wrapper wrapperList(OrderSearchDto dto) {
        Wrapper<?> wrapper = new EntityWrapper<MallOrder>()
                .orderBy("o.create_time", false)
                .ge(StrUtil.isNotBlank(dto.getBeginTime()), "o.create_time", dto.getBeginTime())
                .le(StrUtil.isNotBlank(dto.getEndTime()), "o.create_time", dto.getEndTime() + " 23:59:59")
                .eq(StrUtil.isNotBlank(dto.getOrderNo()), "o.order_no", dto.getOrderNo())
                .eq(StrUtil.isNotBlank(dto.getUserShowId()), "u.show_id", dto.getUserShowId())
                .eq(StrUtil.isNotBlank(dto.getUserPhone()), "u.phone", dto.getUserPhone())
                //.like(StrUtil.isNotBlank(dto.getUserNickname()), "user.nick_name", dto.getUserNickname());
                .like(StrUtil.isNotBlank(dto.getUserNickname()), "o.take_name", dto.getUserNickname())
                .like(StrUtil.isNotBlank(dto.getGoodsName()), "order_goods.goods_name", dto.getGoodsName());
 
        try {
            // 【城市管理员】数据查询
            ShiroUser shiroUser = ShiroKit.getUser();
            List<Integer> roleList = shiroUser.getRoleList();
            List<Integer> cityRoleList = roleService.selectList(
                            new EntityWrapper<Role>().in("id", roleList)).stream().map(Role::getCityRole)
                    .collect(
                            Collectors.toList());
            if (cityRoleList.contains(EnumCityRole.CITY_ROLE.index)) {
                // 市级城市管理员
                wrapper.like("o.city_code", shiroUser.getCityCode().substring(0, 4), SqlLike.RIGHT);
            }
            else if (cityRoleList.contains(EnumCityRole.PROVINCE_ROLE.index)) {
                // 省级城市管理员
                wrapper.like("o.city_code", shiroUser.getCityCode().substring(0, 2), SqlLike.RIGHT);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
 
        if (null != dto.getState()) {
            if (dto.getState().equals(1)) {
                wrapper.in("o.state", Lists.newArrayList(1, 2));
            } else {
                wrapper.eq("o.state", dto.getState());
            }
        }
        return wrapper;
    }
 
 
    @ResponseBody
    @RequestMapping(value = "/export")
    public void exportOrder(OrderSearchDto dto, HttpServletResponse response) throws IOException {
        Wrapper wrapper = wrapperList(dto);
        List<MallOrder> orders = this.mallOrderService.findList(wrapper);
 
        List<List<Object>> dataList = new ArrayList<>();
        List<Object> titles = CollUtil.newArrayList(
                "营销员工号",
                "营销员姓名",
                "营销业绩",
                "下单时间",
                "订单编号",
                "订单来源",
                "订单类型",
                "商品名称",
                "规格组",
                "购买数量",
                "客户姓名",
                "下单用户手机",
                "预约门店",
                "核销次数",
                "订单金额",
                "优惠金额",
                "实付款",
                "订单状态",
                "退款时间"
        );
        dataList.add(titles);
 
        for (MallOrder order : orders) {
            dataList.add(
                    CollUtil.newArrayList(
                            order.getSaleShowId(),
                            order.getSaleUserName(),
                            order.getGoodsMoney(),
                            DateUtils2.format(order.getCreateTime(), "YYYY-MM-dd HH:mm:ss"),
                            order.getOrderNo(),
                            Objects.nonNull(order.getSaleShowId()) ? "推广链接" : "自然",
                            getOrderType(order.getOrderType()),
                            order.getGoodsName(),
                            order.getGrepName(),
                            order.getGoodsNum(),
                            order.getTakeName(),
                            order.getUserPhone(),
                            order.getMerchantName(),
                            order.getUseNum(),
                            order.getGoodsMoney(),
                            order.getGoodsMoney().subtract(order.getPayMoney()),
                            order.getPayMoney(),
                            order.getStateName(),
                            Objects.nonNull(order.getRefundTime()) ? DateUtils2.format(order.getRefundTime(), "YYYY-MM-dd HH:mm:ss") : ""
                    ));
        }
        ExcelExportUtil.easySheet("导出数据" + DateUtils2.formatDate(new Date(), "YYYYMMddHHmmSS"), "导出数据", dataList, response);
    }
 
    private String getOrderType(int key) {
        String value = "普通商品";
        if (key == 1) {
            value = "黄金套餐";
        } else if (key == 2) {
            value = "钻石套餐";
        }
        return value;
    }
 
    /**
     * 取消订单
     *
     * @param orderNo
     */
    @ResponseBody
    @RequestMapping(value = "/cancelOrder")
    public Object cancelOrder(String orderNo) {
        this.mallOrderService.cancelOrder(orderNo);
        return SUCCESS_TIP;
    }
 
 
    /**
     * 退款操作
     */
    @ResponseBody
    @RequestMapping(value = "/orderShip")
    @Transactional(rollbackFor = Exception.class)
    public Object orderShip(String orderNo, Integer expressCompany) {
        MallOrder order = this.mallOrderService.selectOne(
                new EntityWrapper<MallOrder>()
                        .eq("order_no", orderNo)
                        .last("for update")
        );
 
        if (expressCompany.equals(0)) {
            order.setState(EnumMallOrderState.WAIT_CHECK.index);
        } else {
            // 取消订单扣积分
            memUserService.subIntegralCancelOrder(orderNo);
 
            if (order.getCouponId() != null && order.getCouponId() != 0) {
                // 退还优惠券
                myCouponService.updateUseCoupon(order.getUserId(), order.getCouponId(), 0);
            }
 
            order.setState(EnumMallOrderState.REFUNDED.index);
            BigDecimal refundPrice = order.getPayMoney();
            PayUtil.wechatRefund("T".concat(order.getOrderNo()), order.getTransactionNo(), order.getOutTradeNo(),
                    order.getPayTotalFee(),
                    refundPrice.multiply(Convert.toBigDecimal(100)),
                    "用户申请退款", "rest/mall/pay/notify/wx"
            );
            order.setRefundPrice(refundPrice);
            order.setRefundTime(new Date());
            //退回库存
            List<MallOrderDetail> orderDetailList = this.mallOrderDetailService.selectList(new EntityWrapper<MallOrderDetail>().eq("order_no", orderNo));
            log.info("----------------------------处理退款回退库存--------------------------");
            log.info("orderDetailList:{}", JSON.toJSONString(orderDetailList));
            if (CollectionUtils.isNotEmpty(orderDetailList)) {
                Map<Integer, MallOrderDetail> orderDetailMap = orderDetailList.stream()
                        .collect(Collectors.toMap(MallOrderDetail::getSkuId, e -> e));
                Set<Integer> skuIdList = orderDetailList.stream().map(MallOrderDetail::getSkuId)
                        .collect(Collectors.toSet());
                List<MallGoodsSku> skuList = mallGoodsSkuService.selectList(
                        new EntityWrapper<MallGoodsSku>().in("id", skuIdList));
                for (MallGoodsSku mallGoodsSku : skuList) {
                    MallOrderDetail mallOrderDetail = orderDetailMap.get(mallGoodsSku.getId());
                    mallGoodsSku.setStock(mallGoodsSku.getStock() + mallOrderDetail.getGoodsNum());
                    mallGoodsSkuService.updateById(mallGoodsSku);
                }
                //退销量
                Set<Integer> goodsIdList = orderDetailList.stream().map(MallOrderDetail::getGoodsId)
                        .collect(Collectors.toSet());
                Wrapper<MallGoods> wrapper = new EntityWrapper<MallGoods>().in("id", goodsIdList);
                List<MallGoods> mallGoods = mallGoodsService.selectList(wrapper);
                Map<Integer, MallOrderDetail> orderDetailMap2 = orderDetailList.stream()
                        .collect(Collectors.toMap(MallOrderDetail::getGoodsId, e -> e));
                if (CollectionUtils.isNotEmpty(mallGoods)) {
                    for (MallGoods mallGoods1 : mallGoods) {
                        MallOrderDetail mallOrderDetail1 = orderDetailMap2.get(mallGoods1.getId());
                        if (Objects.nonNull(mallOrderDetail1)) {
                            log.info("----------------------------处理退款回退销量--------------------------");
                            log.info("mallGoods1:{}", JSON.toJSONString(mallGoods1));
                            mallGoods1.setBuyCount(mallGoods1.getBuyCount() - mallOrderDetail1.getGoodsNum());
                            mallGoodsService.updateById(mallGoods1);
                        }
                    }
                }
 
            }
 
 
        }
 
        this.mallOrderService.updateById(order);
 
        return SUCCESS_TIP;
    }
}