xiaoyong931011
2023-09-15 0537e73efb9aba020fdc8cb48708bb51b46aaf57
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
package cc.mrbird.febs.dapp.service.impl;
 
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.dapp.dto.*;
import cc.mrbird.febs.dapp.entity.*;
import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum;
import cc.mrbird.febs.dapp.mapper.*;
import cc.mrbird.febs.dapp.service.IAdminMallGoodsService;
import cc.mrbird.febs.dapp.vo.AdminMallGoodsCategoryTreeVo;
import cc.mrbird.febs.dapp.vo.AdminMallGoodsCategoryVo;
import cc.mrbird.febs.dapp.vo.AdminMallMoneyFlowVo;
import cc.mrbird.febs.dapp.vo.AdminMallOrderVo;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
 
@Slf4j
@Service
@RequiredArgsConstructor
@Transactional
public class AdminMallGoodsService extends ServiceImpl<MallGoodsMapper, MallGoods> implements IAdminMallGoodsService {
 
    private final MallGoodsMapper mallGoodsMapper;
    private final MallOrderInfoMapper mallOrderInfoMapper;
    private final DappFundFlowDao dappFundFlowDao;
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
    private final MallGoodsCategoryMapper mallGoodsCategoryMapper;
 
    private final PlatformBannerMapper platformBannerMapper;
    private final MallGoodsImagesMapper mallGoodsImagesMapper;
    private final DappMemberDao dappMemberDao;
 
    @Override
    public IPage<MallGoods> getCategoryListInPage(MallGoods mallGoods, QueryRequest request) {
        Page<MallGoods> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<MallGoods> adminMallGoodsVos = this.baseMapper.selectMallGoodsInPage(page, mallGoods);
        return adminMallGoodsVos;
    }
 
    @Override
    @Transactional
    public FebsResponse addMallGoods(AddMallGoodsDto addMallGoodsDto) {
        String goodsName = addMallGoodsDto.getGoodsName();
        Integer mallGoodsByGoodsName = mallGoodsMapper.selectMallGoodsCountByGoodsName(goodsName);
        if (mallGoodsByGoodsName > 0) {
            return new FebsResponse().fail().message("商品名称不能重复");
        }
        String goodsNo = addMallGoodsDto.getGoodsNo();
        Integer mallGoodsByGoodsNo = mallGoodsMapper.selectMallGoodsCountByGoodsNo(goodsNo);
        if (mallGoodsByGoodsNo > 0) {
            return new FebsResponse().fail().message("商品编号不能重复");
        }
        MallGoods mallGoods = new MallGoods();
        //新增商品
        BeanUtil.copyProperties(addMallGoodsDto, mallGoods);
        mallGoods.setIsSale(MallGoods.ISSALE_STATUS_DISABLED);
        mallGoodsMapper.insert(mallGoods);
 
        String thumbs = addMallGoodsDto.getThumbs();
        if (StrUtil.isNotEmpty(thumbs)) {
            List<String> imgs = StrUtil.splitTrim(thumbs, ",");
            if (CollUtil.isNotEmpty(imgs)) {
                int i = 1;
                for (String img : imgs) {
                    MallGoodsImages mallGoodsImages = new MallGoodsImages();
                    mallGoodsImages.setGoodsId(mallGoods.getId());
                    mallGoodsImages.setImageUrl(img);
                    mallGoodsImages.setSeq(i);
                    mallGoodsImagesMapper.insert(mallGoodsImages);
                    i++;
                }
            }
        }
        return new FebsResponse().success().message("操作成功");
    }
 
    @Override
    public FebsResponse upMallGoods(Long id) {
        MallGoods mallGoods = mallGoodsMapper.selectById(id);
        if (ObjectUtil.isEmpty(mallGoods)) {
            return new FebsResponse().fail().message("商品不存在,请刷新当前页面");
        }
        mallGoods.setIsSale(MallGoods.ISSALE_STATUS_ENABLE);
        mallGoodsMapper.updateById(mallGoods);
        return new FebsResponse().success();
    }
 
    @Override
    public FebsResponse downMallGoods(Long id) {
        MallGoods mallGoods = mallGoodsMapper.selectById(id);
        if (ObjectUtil.isEmpty(mallGoods)) {
            return new FebsResponse().fail().message("商品不存在,请刷新当前页面");
        }
        mallGoods.setIsSale(MallGoods.ISSALE_STATUS_DISABLED);
        mallGoodsMapper.updateById(mallGoods);
        return new FebsResponse().success();
    }
 
    @Override
    @Transactional
    public FebsResponse delMallGoods(Long id) {
        MallGoods mallGoods = mallGoodsMapper.selectById(id);
        if (ObjectUtil.isEmpty(mallGoods)) {
            return new FebsResponse().fail().message("商品不存在,请刷新当前页面");
        }
        Integer isSale = mallGoods.getIsSale();
        if (MallGoods.ISSALE_STATUS_DISABLED != isSale) {
            return new FebsResponse().fail().message("请先下架该商品");
        }
 
        mallGoodsMapper.deleteById(mallGoods);
        return new FebsResponse().success();
    }
 
    @Override
    public MallGoods selectGoodsById(long id) {
        MallGoods mallGoods = mallGoodsMapper.selectById(id);
        List<String> thumbs = mallGoodsImagesMapper.selectByGoodId(mallGoods.getId());
        mallGoods.setImages(thumbs);
        return mallGoods;
    }
 
    @Override
    @Transactional
    public FebsResponse updateMallGoods(MallGoodsUpdateDto mallGoodsUpdateDto) {
        String goodsName = mallGoodsUpdateDto.getGoodsName();
        Integer mallGoodsByGoodsName = mallGoodsMapper.selectMallGoodsCountByGoodsNameAndGoodId(goodsName, mallGoodsUpdateDto.getId());
        if (mallGoodsByGoodsName > 0) {
            return new FebsResponse().fail().message("商品名称不能重复");
        }
        String goodsNo = mallGoodsUpdateDto.getGoodsNo();
        Integer mallGoodsByGoodsNo = mallGoodsMapper.selectMallGoodsCountByGoodsNoAndGoodId(goodsNo, mallGoodsUpdateDto.getId());
        if (mallGoodsByGoodsNo > 0) {
            return new FebsResponse().fail().message("商品编号不能重复");
        }
 
        //新增商品
        MallGoods mallGoods = mallGoodsMapper.selectById(mallGoodsUpdateDto.getId());
 
        BeanUtil.copyProperties(mallGoodsUpdateDto, mallGoods);
        mallGoodsMapper.updateById(mallGoods);
 
        mallGoodsImagesMapper.deleteByGoodsId(mallGoodsUpdateDto.getId());
        String thumbs = mallGoodsUpdateDto.getThumbs();
        if (StrUtil.isNotEmpty(thumbs)) {
            List<String> imgs = StrUtil.splitTrim(thumbs, ",");
            if (CollUtil.isNotEmpty(imgs)) {
                int i = 1;
                for (String img : imgs) {
                    MallGoodsImages mallGoodsImages = new MallGoodsImages();
                    mallGoodsImages.setGoodsId(mallGoods.getId());
                    mallGoodsImages.setImageUrl(img);
                    mallGoodsImages.setSeq(i);
                    mallGoodsImagesMapper.insert(mallGoodsImages);
                    i++;
                }
            }
        }
 
        return new FebsResponse().success().message("操作成功");
    }
 
    @Override
    public IPage<MallOrderInfo> getOrderListInPage(MallOrderInfoDto mallOrderInfo, QueryRequest request) {
        Page<MallOrderInfo> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<MallOrderInfo> adminMallOrderInfoVos = mallGoodsMapper.selectOrderListInPage(page, mallOrderInfo);
        return adminMallOrderInfoVos;
    }
 
    @Override
    public IPage<AdminMallMoneyFlowVo> orderMoneyFlow(QueryRequest request, MallOrderInfo mallOrderInfo) {
        MallOrderInfo mallOrder = mallOrderInfoMapper.selectById(mallOrderInfo.getId());
        Page<AdminMallMoneyFlowVo> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<AdminMallMoneyFlowVo> adminMallMoneyFlowVos = dappFundFlowDao.selectOrderMoneyFlowInPage(page, mallOrder);
        return adminMallMoneyFlowVos;
    }
 
    @Override
    public List<DataDictionaryCustom> findDataDicByType(String type) {
        return dataDictionaryCustomMapper.selectDicByType(type);
    }
 
    @Override
    public void bonusSystemSetting(Map<String, Object> map) {
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            if (entry.getValue() instanceof String) {
                dataDictionaryCustomMapper.updateDicValueByTypeAndCode(null, entry.getKey(), (String) entry.getValue());
            } else {
                List<LinkedHashMap<String, Object>> value = (List<LinkedHashMap<String, Object>>) entry.getValue();
 
                for (LinkedHashMap<String, Object> dic : value) {
                    String type = (String) dic.get("type");
                    String code = (String) dic.get("code");
                    String dataValue = (String) dic.get("value");
                    dataDictionaryCustomMapper.updateDicValueByTypeAndCode(type, code, dataValue);
                }
            }
        }
    }
 
    @Override
    public void hlmBasicPerk(HlmBasicPerkDto hlmBasicPerkDto) {
        updateDataDic(DataDictionaryEnum.DONATE_SCORE_PERCENT.getType(),
                DataDictionaryEnum.DONATE_SCORE_PERCENT.getCode(),
                hlmBasicPerkDto.getDonateScorePercent());
        updateDataDic(DataDictionaryEnum.STATIC_RELEASE.getType(),
                DataDictionaryEnum.STATIC_RELEASE.getCode(),
                hlmBasicPerkDto.getStaticRelease());
        updateDataDic(DataDictionaryEnum.DIRECT_RELEASE.getType(),
                DataDictionaryEnum.DIRECT_RELEASE.getCode(),
                hlmBasicPerkDto.getDirectRelease());
        updateDataDic(DataDictionaryEnum.MAX_RELEASE.getType(),
                DataDictionaryEnum.MAX_RELEASE.getCode(),
                hlmBasicPerkDto.getMaxRelease());
        updateDataDic(DataDictionaryEnum.USDT_ORDER_PERCENT.getType(),
                DataDictionaryEnum.USDT_ORDER_PERCENT.getCode(),
                hlmBasicPerkDto.getUsdtOrderRelease());
        updateDataDic(DataDictionaryEnum.TEAM_PERK_LEVEL_EQUALS.getType(),
                DataDictionaryEnum.TEAM_PERK_LEVEL_EQUALS.getCode(),
                hlmBasicPerkDto.getTeamPerkLevelEquals());
        updateDataDic(DataDictionaryEnum.MEMBER_BUY_MAX_AMOUNT.getType(),
                DataDictionaryEnum.MEMBER_BUY_MAX_AMOUNT.getCode(),
                hlmBasicPerkDto.getMemberBuyMaxAmount());
        updateDataDic(DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getType(),
                DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getCode(),
                hlmBasicPerkDto.getPackageTotalScore());
        updateDataDic(DataDictionaryEnum.PACKAGE_SCORE_PRICE.getType(),
                DataDictionaryEnum.PACKAGE_SCORE_PRICE.getCode(),
                hlmBasicPerkDto.getPackageScorePrice());
        updateDataDic(DataDictionaryEnum.PACKAGE_SALE_TO_POOR_PERCENT.getType(),
                DataDictionaryEnum.PACKAGE_SALE_TO_POOR_PERCENT.getCode(),
                hlmBasicPerkDto.getPackageSaleToPoorPercent());
        updateDataDic(DataDictionaryEnum.PACKAGE_POOR.getType(),
                DataDictionaryEnum.PACKAGE_POOR.getCode(),
                hlmBasicPerkDto.getPackagePoor());
        updateDataDic(DataDictionaryEnum.WITHDRAW_FEE.getType(),
                DataDictionaryEnum.WITHDRAW_FEE.getCode(),
                hlmBasicPerkDto.getWithDrawFee());
        updateDataDic(DataDictionaryEnum.MIN_WITHDRAW_AMOUNT.getType(),
                DataDictionaryEnum.MIN_WITHDRAW_AMOUNT.getCode(),
                hlmBasicPerkDto.getMinWithdraw());
        updateDataDic(DataDictionaryEnum.MAX_WITHDRAW_AMOUNT.getType(),
                DataDictionaryEnum.MAX_WITHDRAW_AMOUNT.getCode(),
                hlmBasicPerkDto.getMaxWithdraw());
    }
 
    @Override
    public IPage<MallGoodsCategory> getCategoryList(MallGoodsCategory mallGoodsCategory, QueryRequest request) {
        Page<MallGoodsCategory> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<MallGoodsCategory> mallGoodsCategorys = mallGoodsCategoryMapper.selectCategoryListInPage(page, mallGoodsCategory);
        return mallGoodsCategorys;
    }
 
    @Override
    public FebsResponse addCategory(MallGoodsCategory mallGoodsCategory) {
        String name = mallGoodsCategory.getName();
        if(StrUtil.isEmpty(name)){
            return new FebsResponse().fail().message("分类名称不能为空");
        }
        List<MallGoodsCategory> categorys = mallGoodsCategoryMapper.selectCategoryByName(name);
        if(CollUtil.isNotEmpty(categorys)){
            return new FebsResponse().fail().message("分类名称不能重复");
        }
        Long parentIdParam = mallGoodsCategory.getParentId() == null ? 0L:mallGoodsCategory.getParentId();
        Integer isRecommendParam = mallGoodsCategory.getIsRecommend();
        if(parentIdParam > 0 && isRecommendParam == 1){
            return new FebsResponse().fail().message("子分类不能选择【是否推荐】为【是】");
        }
 
        MallGoodsCategory goodsCategory = new MallGoodsCategory();
        goodsCategory.setName(name);
        goodsCategory.setImage(mallGoodsCategory.getImage());
        if(ObjectUtil.isNotEmpty(mallGoodsCategory.getParentId())){
            Long parentId = mallGoodsCategory.getParentId();
            MallGoodsCategory mallGoodsCategoryParent = mallGoodsCategoryMapper.selectById(parentId);
            goodsCategory.setParentId(mallGoodsCategory.getParentId());
            if(StrUtil.isNotEmpty(mallGoodsCategoryParent.getParentIds())){
                goodsCategory.setParentIds(mallGoodsCategoryParent.getParentIds()+","+mallGoodsCategory.getParentId()+",");
            }else{
                goodsCategory.setParentIds(mallGoodsCategory.getParentId()+",");
            }
            goodsCategory.setIsRecommend(0);
        }else{
            goodsCategory.setParentId(0L);
            goodsCategory.setIsRecommend(mallGoodsCategory.getIsRecommend());
        }
        mallGoodsCategoryMapper.insert(goodsCategory);
        return new FebsResponse().success();
    }
 
    @Override
    public FebsResponse updateCategory(MallGoodsCategory mallGoodsCategoryParam) {
        String name = mallGoodsCategoryParam.getName();
        if(StrUtil.isEmpty(name)){
            return new FebsResponse().fail().message("名称不能为空");
        }
        Long parentIdParam = mallGoodsCategoryParam.getParentId() == null ? 0L:mallGoodsCategoryParam.getParentId();
        Integer isRecommendParam = mallGoodsCategoryParam.getIsRecommend();
        if(parentIdParam > 0 && isRecommendParam == 1){
            return new FebsResponse().fail().message("子分类不能选择【是否推荐】为【是】");
        }
 
        Long id = mallGoodsCategoryParam.getId();
        MallGoodsCategory mallGoodsCategory = mallGoodsCategoryMapper.selectById(id);
        mallGoodsCategory.setName(mallGoodsCategoryParam.getName());
        mallGoodsCategory.setImage(mallGoodsCategoryParam.getImage());
        mallGoodsCategory.setIndexNum(mallGoodsCategoryParam.getIndexNum());
        if(ObjectUtil.isNotEmpty(mallGoodsCategoryParam.getParentId())){
            Long parentId = mallGoodsCategoryParam.getParentId();
            MallGoodsCategory mallGoodsCategoryParent = mallGoodsCategoryMapper.selectById(parentId);
            mallGoodsCategory.setParentId(mallGoodsCategoryParam.getParentId());
            if(StrUtil.isNotEmpty(mallGoodsCategoryParent.getParentIds())){
                mallGoodsCategory.setParentIds(mallGoodsCategoryParent.getParentIds()+","+mallGoodsCategory.getParentId()+",");
            }else{
                mallGoodsCategory.setParentIds(mallGoodsCategory.getParentId()+",");
            }
            mallGoodsCategory.setIsRecommend(0);
        }else{
            mallGoodsCategory.setParentId(0L);
            mallGoodsCategory.setIsRecommend(mallGoodsCategoryParam.getIsRecommend());
        }
        mallGoodsCategoryMapper.updateById(mallGoodsCategory);
 
        return new FebsResponse().success();
    }
 
    @Override
    public FebsResponse delCategary(Long id) {
        MallGoodsCategory mallGoodsCategory = mallGoodsCategoryMapper.selectById(id);
        if(ObjectUtil.isEmpty(mallGoodsCategory)){
            return new FebsResponse().fail().message("系统繁忙,请刷新页面重试");
        }
        List<MallGoodsCategory> childCategarys = mallGoodsCategoryMapper.selectChildCategaryById(id);
        if(CollUtil.isNotEmpty(childCategarys)){
            for(MallGoodsCategory childCategary : childCategarys){
                Long childCategaryId = childCategary.getId();
                List<MallGoods> mallChildGoods = mallGoodsMapper.selectMallGoodsByCategaryId(childCategaryId);
                if(CollUtil.isNotEmpty(mallChildGoods)){
                    return new FebsResponse().fail().message("该分类下的子类【"+childCategary.getName()+"】还有商品,请先删除商品或者修改商品分类");
                }
            }
        }
 
        if(CollUtil.isNotEmpty(childCategarys)){
            return new FebsResponse().fail().message("该分类下还有子类,请先删除子类");
        }
 
        List<MallGoods> mallGoods = mallGoodsMapper.selectMallGoodsByCategaryId(id);
        if(CollUtil.isNotEmpty(mallGoods)){
            return new FebsResponse().fail().message("该分类下还有商品,请先删除商品或者修改商品分类");
        }
        mallGoodsCategoryMapper.deleteById(mallGoodsCategory);
        return new FebsResponse().success();
    }
 
    @Override
    public AdminMallGoodsCategoryVo getMallGoodsCategoryInfoById(long id) {
        return mallGoodsCategoryMapper.getMallGoodsCategoryInfoById(id);
    }
 
    @Override
    public List<AdminMallGoodsCategoryTreeVo> getParentCategorys() {
        List<AdminMallGoodsCategoryTreeVo> adminMallGoodsCategoryTreeVos = mallGoodsCategoryMapper.getParentCategorys();
        return adminMallGoodsCategoryTreeVos;
    }
 
    @Override
    public IPage<PlatformBanner> findPlatformBannerInPage(PlatformBanner platformBannerEntity,
                                                          QueryRequest request) {
        Page<PlatformBanner> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<PlatformBanner> platformBannerEntitys = platformBannerMapper.findPlatformBannerInPage(page, platformBannerEntity);
        return platformBannerEntitys;
    }
 
    @Override
    public PlatformBanner selectPlatformBannerById(long id) {
        PlatformBanner platformBannerEntity = platformBannerMapper.selectById(id);
        return platformBannerEntity;
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public FebsResponse platformBannerConfirm(@Valid PlatformBanner platformBannerEntity) {
        platformBannerMapper.updateById(platformBannerEntity);
        return new FebsResponse().success();
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public FebsResponse platformBannerDelete(@NotNull(message = "{required}") Long id) {
        platformBannerMapper.deleteById(id);
        return new FebsResponse().success();
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void platformBannerAdd(@Valid PlatformBanner platformBannerEntity) {
        PlatformBanner platformBannerEntityAdd = new PlatformBanner();
        platformBannerEntityAdd.setImageUrl(platformBannerEntity.getImageUrl());
        platformBannerEntityAdd.setIsInside(platformBannerEntity.getIsInside());
        platformBannerEntityAdd.setIsJump(platformBannerEntity.getIsJump());
        platformBannerEntityAdd.setIsTop(platformBannerEntity.getIsTop());
        platformBannerEntityAdd.setJumpUrl(platformBannerEntity.getJumpUrl());
        platformBannerEntityAdd.setName(platformBannerEntity.getName());
        platformBannerEntityAdd.setShowPort(platformBannerEntity.getShowPort());
        platformBannerEntityAdd.setSort(platformBannerEntity.getSort());
        platformBannerMapper.insert(platformBannerEntityAdd);
 
    }
 
    @Override
    public AdminMallOrderVo getMallOrderInfoById(long id) {
        return this.baseMapper.getMallOrderInfoById(id);
    }
 
    public void updateDataDic(String type, String code, String value) {
        DataDictionaryCustom dic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(type, code);
        if (dic != null) {
            dic.setValue(value);
            dataDictionaryCustomMapper.updateById(dic);
        }
    }
 
    @Override
    public FebsResponse deliverGoods(DeliverGoodsDto deliverGoodsDto) {
        MallOrderInfo mallOrderInfo = mallOrderInfoMapper.selectById(deliverGoodsDto.getId());
        if(ObjectUtil.isEmpty(mallOrderInfo)){
            return new FebsResponse().fail().message("订单不存在,刷新后重试");
        }
        Integer status = mallOrderInfo.getStatus();
        if(2 != status){
            return new FebsResponse().fail().message("订单不是已完成状态");
        }
        Integer deliverState = mallOrderInfo.getDeliverState();
        if(1 != deliverState){
            return new FebsResponse().fail().message("订单不是待发货状态");
        }
        String expressNo = deliverGoodsDto.getExpressNo();
        if(StrUtil.isEmpty(expressNo)){
            return new FebsResponse().fail().message("请输入物流单号");
        }
        String expressCom = deliverGoodsDto.getExpressCom();
        if(StrUtil.isEmpty(expressCom)){
            return new FebsResponse().fail().message("请输入物流公司");
        }
        mallOrderInfo.setDeliverState(2);
        mallOrderInfo.setDeliverName(expressCom);
        mallOrderInfo.setDeliverCode(expressNo);
        mallOrderInfoMapper.updateById(mallOrderInfo);
        return new FebsResponse().success();
    }
 
    @Override
    public FebsResponse delOrder(Long id) {
        MallOrderInfo mallOrderInfo = mallOrderInfoMapper.selectById(id);
        if(ObjectUtil.isEmpty(mallOrderInfo)){
            return new FebsResponse().fail().message("订单不存在,请刷新重试");
        }
        mallOrderInfoMapper.deleteById(id);
        dappMemberDao.deleteByOrderId(id);
        return new FebsResponse().success();
    }
 
    @Override
    public void deliverGoodsByOrderNo(DeliverGoodsDto deliverGoods) {
 
        MallOrderInfo mallOrderInfo = dappMemberDao.selectOrderByOrderNo(deliverGoods.getOrderNo());
        if(ObjectUtil.isEmpty(mallOrderInfo)){
            return;
        }
        Integer status = mallOrderInfo.getStatus();
        if(2 != status){
            return;
        }
        Integer deliverState = mallOrderInfo.getDeliverState();
        if(1 != deliverState){
            return;
        }
        String expressNo = deliverGoods.getExpressNo();
        if(StrUtil.isEmpty(expressNo)){
            return;
        }
        String expressCom = deliverGoods.getExpressCom();
        if(StrUtil.isEmpty(expressCom)){
            return;
        }
        mallOrderInfo.setDeliverState(2);
        mallOrderInfo.setDeliverName(expressCom);
        mallOrderInfo.setDeliverCode(expressNo);
        mallOrderInfoMapper.updateById(mallOrderInfo);
    }
 
}