KKSU
2024-03-22 2c7890dc25f0cf08b30663eb6c91f83ff29ac24b
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
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
package cc.mrbird.febs.mall.service.impl;
 
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.enumerates.DataDictionaryEnum;
import cc.mrbird.febs.common.enumerates.FlowTypeNewEnum;
import cc.mrbird.febs.common.enumerates.MoneyFlowTypeNewEnum;
import cc.mrbird.febs.common.enumerates.ProductEnum;
import cc.mrbird.febs.common.exception.FebsException;
import cc.mrbird.febs.common.utils.LoginUserUtil;
import cc.mrbird.febs.common.utils.MallUtils;
import cc.mrbird.febs.mall.dto.*;
import cc.mrbird.febs.mall.entity.*;
import cc.mrbird.febs.mall.mapper.*;
import cc.mrbird.febs.mall.service.IApiMallProductService;
import cc.mrbird.febs.mall.service.IMallMoneyFlowService;
import cc.mrbird.febs.mall.vo.*;
import cc.mrbird.febs.rabbit.producter.AgentProducer;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.crypto.SecureUtil;
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 java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
 
@Slf4j
@Service
@RequiredArgsConstructor
public class ApiMallProductServiceImpl extends ServiceImpl<MallProductNftMapper, MallProductNft> implements IApiMallProductService {
 
    private final MallMemberMapper memberMapper;
    private final MallProductBuyMapper mallProductBuyMapper;
    private final MallMemberAmountMapper mallMemberAmountMapper;
    private final IMallMoneyFlowService iMallMoneyFlowService;
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
    private final AgentProducer agentProducer;
    private final MallProductSellMapper mallProductSellMapper;
    private final MallProductSellRecordMapper mallProductSellRecordMapper;
    private final MallProductBuyRecordMapper mallProductBuyRecordMapper;
    private final MallMemberSpeakMapper mallMemberSpeakMapper;
 
    @Override
    public List<ApiMallProductNftVo> productNFTList() {
 
        DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(DateUtil.date()));
        DataDictionaryCustom startTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.YU_YUE_START_TIME.getType(),
                DataDictionaryEnum.YU_YUE_START_TIME.getCode()
        );
        DateTime startTime = DateUtil.parseTime(startTimeDic.getValue());
        DataDictionaryCustom endTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.YU_YUE_END_TIME.getType(),
                DataDictionaryEnum.YU_YUE_END_TIME.getCode()
        );
        DateTime endTime = DateUtil.parseTime(endTimeDic.getValue());
        List<ApiMallProductNftVo> list = this.baseMapper.selectByState(ProductEnum.PRODUCT_NFT_OPEN.getValue());
        if(CollUtil.isNotEmpty(list)){
            for(ApiMallProductNftVo apiMallProductNftVo : list){
                apiMallProductNftVo.setYuYueState(2);
//                if(nowTime.compareTo(startTime) < 0){
//                    apiMallProductNftVo.setYuYueState(1);
//                }
//                if(nowTime.compareTo(startTime) >= 0 && nowTime.compareTo(endTime) <= 0){
//                    apiMallProductNftVo.setYuYueState(2);
//                }
//                if(nowTime.compareTo(endTime) > 0){
//                    apiMallProductNftVo.setYuYueState(3);
//                }
            }
        }
        return list;
    }
 
    @Override
    @Transactional
    public FebsResponse createNFT(ApiCreateNFTDto createNFTDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        MallMember mallMember = memberMapper.selectById(memberId);
        Long productNFTId = createNFTDto.getId();
        String tradePassword = SecureUtil.md5(createNFTDto.getTradePassword());
        /**
         * 预约,验证交易密码、预约产品是否开启状态、该产品是否已经预约、token是否足够
         * 冻结对应的令牌数量、生成预约记录、生成流水记录
         */
        Boolean aBoolean = operationPermissionMemberFrozen(memberId);
        if(aBoolean){
            throw new FebsException("用户已冻结");
        }
 
//        DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(DateUtil.date()));
//        DataDictionaryCustom startTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                DataDictionaryEnum.YU_YUE_START_TIME.getType(),
//                DataDictionaryEnum.YU_YUE_START_TIME.getCode()
//        );
//        DateTime startTime = DateUtil.parseTime(startTimeDic.getValue());
//        DataDictionaryCustom endTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
//                DataDictionaryEnum.YU_YUE_END_TIME.getType(),
//                DataDictionaryEnum.YU_YUE_END_TIME.getCode()
//        );
//        DateTime endTime = DateUtil.parseTime(endTimeDic.getValue());
//        if(!(nowTime.compareTo(startTime) >= 0 && nowTime.compareTo(endTime) <= 0)){
//            throw new FebsException("预约未开始");
//        }
        if(!tradePassword.equals(mallMember.getTradePassword())){
            throw new FebsException("请输入正确的交易密码");
        }
        MallProductNft mallProductNft = this.baseMapper.selectById(productNFTId);
        if(ObjectUtil.isEmpty(mallProductNft)){
            throw new FebsException("网络异常");
        }
        if(ProductEnum.PRODUCT_NFT_OPEN.getValue() != mallProductNft.getState()){
            throw new FebsException("预约超时");
        }
        MallProductBuy mallProductBuy = mallProductBuyMapper.selectMemberIdAndNFTIdAndStateAndMateState(
                memberId,productNFTId,ProductEnum.PRODUCT_BUY_ON_GOING.getValue(),ProductEnum.PRODUCT_BUY_MATE_STATE_FAIL.getValue());
        if(ObjectUtil.isNotEmpty(mallProductBuy)){
            throw new FebsException("不可重复开启");
        }
        QueryWrapper<MallProductBuy> mallProductBuyDone = new QueryWrapper<>();
        mallProductBuyDone.like("CREATED_TIME", DateUtil.today());
        mallProductBuyDone.eq("member_id",memberId);
        Integer selectCount = mallProductBuyMapper.selectCount(mallProductBuyDone);
        if(0 < selectCount){
            throw new FebsException("每日开启一次");
        }
 
        BigDecimal priceToken = mallProductNft.getPriceToken();
        MallMemberAmount mallMemberAmount = mallMemberAmountMapper.selectByMemberId(memberId);
        if(BigDecimal.ZERO.compareTo(mallMemberAmount.getTokenAva()) >= 0
         || priceToken.compareTo(mallMemberAmount.getTokenAva()) > 0){
            throw new FebsException("余额不足");
        }
 
        String orderNo = MallUtils.getOrderNum("YY");
        mallProductBuy = new MallProductBuy();
        mallProductBuy.setMemberId(memberId);
        mallProductBuy.setOrderNo(orderNo);
        mallProductBuy.setProductNftId(mallProductNft.getId());
        mallProductBuy.setState(ProductEnum.PRODUCT_BUY_ON_GOING.getValue());
        mallProductBuy.setMateState(ProductEnum.PRODUCT_BUY_MATE_STATE_FAIL.getValue());
        mallProductBuy.setNftTotal(mallProductNft.getPriceNft());
        mallProductBuy.setNftAva(mallProductNft.getPriceNft());
//        mallProductBuy.setNftAva(BigDecimal.ZERO);
        mallProductBuyMapper.insert(mallProductBuy);
        //令牌 可用减少,冻结增加
        mallMemberAmount.setTokenAva(mallMemberAmount.getTokenAva().subtract(priceToken));
        mallMemberAmount.setTokenFrozen(mallMemberAmount.getTokenFrozen().add(priceToken));
        mallMemberAmountMapper.updateTokenAvaAndTokenFrozenById(mallMemberAmount);
        iMallMoneyFlowService.addMoneyFlow(
                memberId,
                priceToken.negate(),
                MoneyFlowTypeNewEnum.TOKEN_BUY_FROZEN.getValue(),
                orderNo,
                null,
                FlowTypeNewEnum.TOKEN.getValue(),
                MoneyFlowTypeNewEnum.TOKEN_BUY_FROZEN.getDescrition());
        HashMap<String, Long> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("id",productNFTId);
        objectObjectHashMap.put("time",5L);
        return new FebsResponse().success().data(objectObjectHashMap);
    }
 
    @Override
    @Transactional
    public FebsResponse outFcm(ApiOutFcmDto outFcmDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        MallMember mallMember = memberMapper.selectById(memberId);
        String tradePassword = SecureUtil.md5(outFcmDto.getTradePassword());
        /**
         * 实时兑换FCM-to-NFT
         * 验证账户交易密码,fcm余额
         * 计算手续费、减少用户的fcm余额
         * 增加流水
         */
 
        Boolean aBoolean = operationPermissionMemberFrozen(memberId);
        if(aBoolean){
            throw new FebsException("用户已冻结");
        }
        if(!tradePassword.equals(mallMember.getTradePassword())){
            throw new FebsException("请输入正确的交易密码");
        }
        BigDecimal fcmCnt = outFcmDto.getFcmCnt();
        DataDictionaryCustom outFcmMinDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.OUT_FCM_MIN.getType(),
                DataDictionaryEnum.OUT_FCM_MIN.getCode());
        BigDecimal outFcmMin = ObjectUtil.isEmpty(outFcmMinDic) ? new BigDecimal(100) : new BigDecimal(outFcmMinDic.getValue());
        if(outFcmMin.compareTo(fcmCnt) > 0){
            throw new FebsException("最少"+outFcmMin);
        }
        MallMemberAmount mallMemberAmount = mallMemberAmountMapper.selectByMemberId(memberId);
        if(BigDecimal.ZERO.compareTo(mallMemberAmount.getFcmCntAva()) >= 0
                || fcmCnt.compareTo(mallMemberAmount.getTokenAva()) > 0){
            throw new FebsException("余额不足");
        }
        DataDictionaryCustom fcmPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.FCM_PRICE.getType(),
                DataDictionaryEnum.FCM_PRICE.getCode());
        BigDecimal fcmPrice = ObjectUtil.isEmpty(fcmPriceDic) ? new BigDecimal(2) : new BigDecimal(fcmPriceDic.getValue());
        //手续费
        DataDictionaryCustom outFcmFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.OUT_FCM_FEE.getType(),
                DataDictionaryEnum.OUT_FCM_FEE.getCode());
        BigDecimal outFcmFeePercent = ObjectUtil.isEmpty(outFcmFeeDic) ? new BigDecimal(20) : new BigDecimal(outFcmFeeDic.getValue());
        outFcmFeePercent = outFcmFeePercent.divide(new BigDecimal(100),4,BigDecimal.ROUND_DOWN);
        BigDecimal outFcmFee = fcmCnt.multiply(outFcmFeePercent);
        //实际到账数量
        BigDecimal fcmCntReal = fcmCnt.subtract(outFcmFee).setScale(2, BigDecimal.ROUND_DOWN);
 
        BigDecimal nftCnt = fcmCntReal.multiply(fcmPrice);
 
        mallMemberAmount.setFcmCntAva(mallMemberAmount.getFcmCntAva().subtract(fcmCnt));
        mallMemberAmountMapper.updateFcmCntAvaById(mallMemberAmount);
        String orderNo = MallUtils.getOrderNum("DB");
        iMallMoneyFlowService.addMoneyFlow(
                memberId,
                fcmCnt.negate(),
                MoneyFlowTypeNewEnum.FCM_OUT.getValue(),
                orderNo,
                mallMember.getId(),
                FlowTypeNewEnum.FCM_COIN.getValue(),
                MoneyFlowTypeNewEnum.FCM_OUT.getDescrition());
        iMallMoneyFlowService.addMoneyFlow(
                memberId,
                outFcmFee.negate(),
                MoneyFlowTypeNewEnum.FCM_OUT_FEE.getValue(),
                orderNo,
                mallMember.getId(),
                FlowTypeNewEnum.FCM_COIN.getValue(),
                MoneyFlowTypeNewEnum.FCM_OUT_FEE.getDescrition());
 
        MallMemberAmount mallMemberAmountNft = mallMemberAmountMapper.selectByMemberId(memberId);
        mallMemberAmountNft.setTrendsNft(mallMemberAmountNft.getTrendsNft().add(nftCnt));
        mallMemberAmountMapper.updateTrendsNftById(mallMemberAmountNft);
        String orderNoNFT = MallUtils.getOrderNum("NFT");
        iMallMoneyFlowService.addMoneyFlow(
                memberId,
                nftCnt,
                MoneyFlowTypeNewEnum.NFT_IN.getValue(),
                orderNoNFT,
                mallMember.getId(),
                FlowTypeNewEnum.NFT.getValue(),
                MoneyFlowTypeNewEnum.NFT_IN.getDescrition());
 
        agentProducer.sendFcmNFTExchangeMsg(outFcmFee.toString());
        return new FebsResponse().success();
    }
 
    @Override
    @Transactional
    public FebsResponse outNFT(ApiOutNFTDto outNFTDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        MallMember mallMember = memberMapper.selectById(memberId);
        String tradePassword = SecureUtil.md5(outNFTDto.getTradePassword());
        /**
         * 验证数量、交易密码、NFT余额
         * 计算手续费、减少动态NFT、增加冻结NFT
         * 增加流水
         */
 
        Boolean aBoolean = operationPermissionMemberFrozen(memberId);
        if(aBoolean){
            throw new FebsException("用户已冻结");
        }
        if(!tradePassword.equals(mallMember.getTradePassword())){
            throw new FebsException("请输入正确的交易密码");
        }
        BigDecimal nftCnt = outNFTDto.getNftCnt();
        BigDecimal remainder = nftCnt.remainder(BigDecimal.TEN);
        if(remainder.compareTo(BigDecimal.ZERO) != 0){
            throw new FebsException("数量需要为10的倍数");
        }
 
        DataDictionaryCustom nftMinDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.NFT_MIN.getType(),
                DataDictionaryEnum.NFT_MIN.getCode());
        BigDecimal nftMin = ObjectUtil.isEmpty(nftMinDic) ? new BigDecimal(100) : new BigDecimal(nftMinDic.getValue());
        if(nftMin.compareTo(nftCnt) > 0){
            throw new FebsException("最少"+nftMin);
        }
        MallMemberAmount mallMemberAmount = mallMemberAmountMapper.selectByMemberId(memberId);
        if(BigDecimal.ZERO.compareTo(mallMemberAmount.getTrendsNft()) >= 0
                || nftCnt.compareTo(mallMemberAmount.getTrendsNft()) > 0){
            throw new FebsException("余额不足");
        }
        DataDictionaryCustom nftFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.NFT_FEE.getType(),
                DataDictionaryEnum.NFT_FEE.getCode());
        BigDecimal nftFeePercent = ObjectUtil.isEmpty(nftFeeDic) ? new BigDecimal(20) : new BigDecimal(nftFeeDic.getValue());
        nftFeePercent = nftFeePercent.divide(new BigDecimal(100),4,BigDecimal.ROUND_DOWN);
        BigDecimal nftFee = nftCnt.multiply(nftFeePercent);
        DataDictionaryCustom fcmPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.FCM_PRICE.getType(),
                DataDictionaryEnum.FCM_PRICE.getCode());
        BigDecimal fcmPrice = ObjectUtil.isEmpty(fcmPriceDic) ? new BigDecimal(2) : new BigDecimal(fcmPriceDic.getValue());
        BigDecimal fcmFeeCnt = nftFee.divide(fcmPrice, 2, BigDecimal.ROUND_DOWN);
        if(BigDecimal.ZERO.compareTo(mallMemberAmount.getTrendsNft()) >= 0
            || fcmFeeCnt.compareTo(mallMemberAmount.getFcmCntAva()) > 0){
            throw new FebsException("手续费不足");
        }
 
        String orderNo = MallUtils.getOrderNum("NFT");
        MallProductSell mallProductSell = new MallProductSell();
        mallProductSell.setMemberId(memberId);
        mallProductSell.setOrderNo(orderNo);
        mallProductSell.setNftTotal(nftCnt);
        mallProductSell.setNftCnt(nftCnt);
        mallProductSell.setNftCntAva(nftCnt);
        mallProductSell.setNftFee(nftFee);
        mallProductSell.setFcmFee(fcmFeeCnt);
        mallProductSell.setState(ProductEnum.PRODUCT_SELL_ON_GOING.getValue());
        mallProductSellMapper.insert(mallProductSell);
 
        mallMemberAmount.setTrendsNft(mallMemberAmount.getTrendsNft().subtract(nftCnt));
        mallMemberAmountMapper.updateTrendsNftById(mallMemberAmount);
 
        MallMemberAmount mallMemberAmountFcm = mallMemberAmountMapper.selectByMemberId(memberId);
        mallMemberAmountFcm.setFcmCntAva(mallMemberAmountFcm.getFcmCntAva().subtract(fcmFeeCnt));
        mallMemberAmountMapper.updateFcmCntAvaById(mallMemberAmountFcm);
 
        MallMemberAmount mallMemberAmountFrozenNFT = mallMemberAmountMapper.selectByMemberId(memberId);
        mallMemberAmountFrozenNFT.setFrozenNft(mallMemberAmountFrozenNFT.getFrozenNft().add(nftCnt));
        mallMemberAmountMapper.updateFrozenNftById(mallMemberAmountFrozenNFT);
        iMallMoneyFlowService.addMoneyFlow(
                memberId,
                nftCnt.negate(),
                MoneyFlowTypeNewEnum.NFT_OUT.getValue(),
                orderNo,
                mallMember.getId(),
                FlowTypeNewEnum.NFT.getValue(),
                MoneyFlowTypeNewEnum.NFT_OUT.getDescrition());
        iMallMoneyFlowService.addMoneyFlow(
                memberId,
                fcmFeeCnt.negate(),
                MoneyFlowTypeNewEnum.NFT_OUT_FEE_FCM.getValue(),
                orderNo,
                mallMember.getId(),
                FlowTypeNewEnum.FCM_COIN.getValue(),
                MoneyFlowTypeNewEnum.NFT_OUT_FEE_FCM.getDescrition());
        agentProducer.sendFcmNFTExchangeMsg(fcmFeeCnt.toString());
        return new FebsResponse().success();
    }
 
    public static void main(String[] args) {
        DateTime dateTime = DateUtil.parseTime("15:00:00");
        DateTime dateTime2 = DateUtil.parseTime("19:00:00");
        DateTime dateTime1 = DateUtil.parseTime(DateUtil.formatTime(DateUtil.date()));
        System.out.println(dateTime);
        System.out.println(dateTime1);
        System.out.println(dateTime1.compareTo(dateTime));
        System.out.println(dateTime1.compareTo(dateTime2));
        System.out.println(dateTime1.compareTo(dateTime) >= 0 && dateTime1.compareTo(dateTime2) <= 0);
    }
 
    @Override
    public FebsResponse orderList(ApiOrderListDto apiOrderListDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        List<ApiOrderListVo> objects = new ArrayList<>();
        Integer orderType = apiOrderListDto.getOrderType();
        apiOrderListDto.setMemberId(memberId);
        DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(DateUtil.date()));
        DataDictionaryCustom startTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.YU_YUE_START_TIME.getType(),
                DataDictionaryEnum.YU_YUE_START_TIME.getCode()
        );
        DateTime startTime = DateUtil.parseTime(startTimeDic.getValue());
        DataDictionaryCustom endTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.YU_YUE_END_TIME.getType(),
                DataDictionaryEnum.YU_YUE_END_TIME.getCode()
        );
        DateTime endTime = DateUtil.parseTime(endTimeDic.getValue());
        if(nowTime.compareTo(startTime) >= 0 && nowTime.compareTo(endTime) <= 0){
//            //买单
//            if(2 == orderType){
//                IPage<ApiOrderListVo> page = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize());
//                IPage<ApiOrderListVo> apiOrderListVoIPageBuy = mallProductBuyMapper.selectListInPage(page, apiOrderListDto);
//                if(CollUtil.isNotEmpty(apiOrderListVoIPageBuy.getRecords())){
//                    for(ApiOrderListVo apiOrderListVo : apiOrderListVoIPageBuy.getRecords()){
//                        objects.add(apiOrderListVo);
//                    }
//                }
//            }
//            //卖单
//            if(1 == orderType){
//                IPage<ApiOrderListVo> page = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize());
//                IPage<ApiOrderListVo> apiOrderListVoIPageSell = mallProductSellMapper.selectListInPage(page, apiOrderListDto);
//                if(CollUtil.isNotEmpty(apiOrderListVoIPageSell.getRecords())){
//                    for(ApiOrderListVo apiOrderListVo : apiOrderListVoIPageSell.getRecords()){
//                        objects.add(apiOrderListVo);
//                    }
//                }
//            }
 
            IPage<ApiOrderListVo> pageBuy = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize());
            IPage<ApiOrderListVo> apiOrderListVoIPageBuy = mallProductBuyMapper.selectListInPage(pageBuy, apiOrderListDto);
            if(CollUtil.isNotEmpty(apiOrderListVoIPageBuy.getRecords())){
                for(ApiOrderListVo apiOrderListVo : apiOrderListVoIPageBuy.getRecords()){
                    objects.add(apiOrderListVo);
                }
            }
 
 
            IPage<ApiOrderListVo> pageSell = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize());
            IPage<ApiOrderListVo> apiOrderListVoIPageSell = mallProductSellMapper.selectListInPage(pageSell, apiOrderListDto);
            if(CollUtil.isNotEmpty(apiOrderListVoIPageSell.getRecords())){
                for(ApiOrderListVo apiOrderListVo : apiOrderListVoIPageSell.getRecords()){
                    objects.add(apiOrderListVo);
                }
            }
        }
 
        return new FebsResponse().success().data(objects);
    }
 
    @Override
    public FebsResponse orderSell(ApiOrderSellInfoDto apiOrderSellInfoDto) {
        Long productSellId = apiOrderSellInfoDto.getId();
        Long memberId = LoginUserUtil.getLoginUser().getId();
        ApiOrderSellInfoVo apiOrderSellInfoVo = mallProductSellMapper.selectSellInfoById(productSellId);
        if(ObjectUtil.isEmpty(apiOrderSellInfoVo)){
            throw new FebsException("记录不存在");
        }
        List<ApiOrderSellRecordInfoVo> apiOrderSellRecordInfoVos = mallProductSellRecordMapper.selectBySellId(productSellId);
        if(CollUtil.isNotEmpty(apiOrderSellRecordInfoVos)){
            apiOrderSellInfoVo.setApiOrderSellRecordInfoVos(apiOrderSellRecordInfoVos);
        }
        return new FebsResponse().success().data(apiOrderSellInfoVo);
    }
 
    @Override
    public FebsResponse orderBuy(ApiOrderBuyInfoDto apiOrderBuyInfoDto) {
        Long productBuyId = apiOrderBuyInfoDto.getId();
        Long memberId = LoginUserUtil.getLoginUser().getId();
        ApiOrderBuyInfoVo apiOrderBuyInfoVo = mallProductBuyMapper.selectBuyById(productBuyId);
        if(ObjectUtil.isEmpty(apiOrderBuyInfoVo)){
            throw new FebsException("记录不存在");
        }
        List<ApiOrderBuyRecordInfoVo> apiOrderBuyRecordInfoVos = mallProductBuyRecordMapper.selectByBuyId(productBuyId);
        if(CollUtil.isNotEmpty(apiOrderBuyRecordInfoVos)){
            apiOrderBuyInfoVo.setApiOrderBuyRecordInfoVos(apiOrderBuyRecordInfoVos);
        }
        return new FebsResponse().success().data(apiOrderBuyInfoVo);
    }
 
    @Override
    public FebsResponse orderBuyInsure(ApiOrderBuyInsureDto apiOrderBuyInsureDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        MallMember mallMember = memberMapper.selectById(memberId);
        Long buyRecordId = apiOrderBuyInsureDto.getBuyRecordId();
        String nftImg = apiOrderBuyInsureDto.getNftImg();
        Integer type = apiOrderBuyInsureDto.getType();
        String tradePassword = SecureUtil.md5(apiOrderBuyInsureDto.getTradePassword());
        /**
         * 验证订单是否存在
         * 更新买单状态
         * 更新卖单状态
         * 生成流水信息
         */
 
        Boolean aBoolean = operationPermissionMemberFrozen(memberId);
        if(aBoolean){
            throw new FebsException("用户已冻结");
        }
        if(!tradePassword.equals(mallMember.getTradePassword())){
            throw new FebsException("请输入正确的交易密码");
        }
        MallProductBuyRecord mallProductBuyRecord = mallProductBuyRecordMapper.selectById(buyRecordId);
        if(ObjectUtil.isEmpty(mallProductBuyRecord)){
            throw new FebsException("记录不存在");
        }
        Integer state = mallProductBuyRecord.getState();
        if(ProductEnum.PRODUCT_MATE_STATE_WAIT_PAY.getValue() != state){
            throw new FebsException("记录不是待支付状态");
        }
 
        MallProductSellRecord mallProductSellRecord = mallProductSellRecordMapper.selectById(mallProductBuyRecord.getSellRecordId());
        if(ObjectUtil.isEmpty(mallProductSellRecord)){
            throw new FebsException("记录不存在");
        }
        Integer stateSell = mallProductSellRecord.getState();
        if(ProductEnum.PRODUCT_MATE_STATE_WAIT_PAY.getValue() != stateSell){
            throw new FebsException("记录不是待支付状态");
        }
 
        DateTime payTime = DateUtil.date();
        mallProductBuyRecord.setState(ProductEnum.PRODUCT_MATE_STATE_PAY.getValue());
        mallProductBuyRecord.setPayTime(payTime);
        mallProductBuyRecord.setNftImg(nftImg);
        mallProductBuyRecord.setType(type);
        mallProductBuyRecordMapper.updateById(mallProductBuyRecord);
 
        mallProductSellRecord.setState(ProductEnum.PRODUCT_MATE_STATE_PAY.getValue());
        mallProductSellRecord.setPayTime(payTime);
        mallProductSellRecord.setNftImg(nftImg);
        mallProductSellRecord.setType(type);
        mallProductSellRecordMapper.updateById(mallProductSellRecord);
 
        String orderNo = MallUtils.getOrderNum("ZF");
        iMallMoneyFlowService.addMoneyFlow(
                memberId,
                mallProductBuyRecord.getPickNftCnt(),
                MoneyFlowTypeNewEnum.PAY.getValue(),
                orderNo,
                mallMember.getId(),
                FlowTypeNewEnum.NFT.getValue(),
                MoneyFlowTypeNewEnum.PAY.getDescrition());
 
        DataDictionaryCustom insureMinuteDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.INSURE_END_MINUTE.getType(),
                DataDictionaryEnum.INSURE_END_MINUTE.getCode()
        );
        Integer insureMinute = Integer.parseInt(ObjectUtil.isEmpty(insureMinuteDic) ? "60" : insureMinuteDic.getValue());
        Date endTime = DateUtil.offsetMinute(payTime, insureMinute);
        long remainTime = DateUtil.between(payTime, endTime, DateUnit.SECOND, false);
        agentProducer.sendFcmPayBuyTimeTTLMsg(mallProductSellRecord.getId(), remainTime * 1000L);
        return new FebsResponse().success();
    }
 
    @Override
    public FebsResponse orderSellInsure(ApiOrderSellInsureDto apiOrderSellInsureDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        MallMember mallMember = memberMapper.selectById(memberId);
        String tradePassword = SecureUtil.md5(apiOrderSellInsureDto.getTradePassword());
        Long sellRecordId = apiOrderSellInsureDto.getSellRecordId();
        /**
         * 验证订单是否存在
         * 更新买单状态
         * 更新卖单状态
         * 生成流水信息
         */
 
        Boolean aBoolean = operationPermissionMemberFrozen(memberId);
        if(aBoolean){
            throw new FebsException("用户已冻结");
        }
        if(!tradePassword.equals(mallMember.getTradePassword())){
            throw new FebsException("请输入正确的交易密码");
        }
        MallProductSellRecord mallProductSellRecord = mallProductSellRecordMapper.selectById(sellRecordId);
        if(ObjectUtil.isEmpty(mallProductSellRecord)){
            throw new FebsException("记录不存在");
        }
        Integer stateSell = mallProductSellRecord.getState();
        if(ProductEnum.PRODUCT_MATE_STATE_PAY.getValue() != stateSell){
            throw new FebsException("记录不是已支付状态");
        }
 
        MallProductBuyRecord mallProductBuyRecord = mallProductBuyRecordMapper.selectById(mallProductSellRecord.getBuyRecordId());
        if(ObjectUtil.isEmpty(mallProductBuyRecord)){
            throw new FebsException("记录不存在");
        }
        Integer state = mallProductBuyRecord.getState();
        if(ProductEnum.PRODUCT_MATE_STATE_PAY.getValue() != state){
            throw new FebsException("记录不是已支付状态");
        }
 
        mallProductBuyRecord.setState(ProductEnum.PRODUCT_MATE_STATE_CONFIRM.getValue());
        mallProductBuyRecordMapper.updateById(mallProductBuyRecord);
 
        mallProductSellRecord.setState(ProductEnum.PRODUCT_MATE_STATE_CONFIRM.getValue());
        mallProductSellRecordMapper.updateById(mallProductSellRecord);
 
        agentProducer.sendFcmOrderSellInsureMsg(sellRecordId);
        return new FebsResponse().success();
    }
 
    @Override
    public FebsResponse orderBuyList(ApiOrderBuyDto apiOrderBuyDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        IPage<ApiOrderBuyVo> page = new Page<>(apiOrderBuyDto.getPageNum(), apiOrderBuyDto.getPageSize());
        apiOrderBuyDto.setMemberId(memberId);
        IPage<ApiOrderBuyVo> apiOrderBuyVoIPage = mallProductBuyMapper.selectBuyListInPage(page, apiOrderBuyDto);
        return new FebsResponse().success().data(apiOrderBuyVoIPage);
    }
 
    @Override
    public Boolean operationPermissionMemberFrozen(Long memberId) {
        MallMember mallMember = memberMapper.selectById(memberId);
        if(ProductEnum.MEMBER_FROZEN.getValue() == mallMember.getIsFrozen()){
            return true;
        }
        return false;
    }
 
    @Override
    public FebsResponse orderSellComplain(ApiOrderSellComplainDto apiOrderSellComplainDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        Long sellRecordId = apiOrderSellComplainDto.getSellRecordId();
        Integer orderType = apiOrderSellComplainDto.getOrderType();
        String buyOrderNo = null;
        if(orderType == 1){
 
            MallProductSellRecord mallProductSellRecord = mallProductSellRecordMapper.selectById(sellRecordId);
            if(ObjectUtil.isEmpty(mallProductSellRecord)){
                throw new FebsException("记录不存在");
            }
            MallProductBuyRecord mallProductBuyRecord = mallProductBuyRecordMapper.selectById(mallProductSellRecord.getBuyRecordId());
            if(ObjectUtil.isEmpty(mallProductBuyRecord)){
                throw new FebsException("记录不存在");
            }
 
            mallProductBuyRecord.setState(ProductEnum.PRODUCT_MATE_STATE_COMPLAIN.getValue());
            mallProductBuyRecordMapper.updateById(mallProductBuyRecord);
 
            mallProductSellRecord.setState(ProductEnum.PRODUCT_MATE_STATE_COMPLAIN.getValue());
            mallProductSellRecordMapper.updateById(mallProductSellRecord);
            buyOrderNo = mallProductBuyRecord.getBuyOrderNo();
        }
        if(orderType == 2){
            MallProductBuyRecord mallProductBuyRecord = mallProductBuyRecordMapper.selectById(sellRecordId);
            if(ObjectUtil.isEmpty(mallProductBuyRecord)){
                throw new FebsException("记录不存在");
            }
 
            MallProductSellRecord mallProductSellRecord = mallProductSellRecordMapper.selectById(mallProductBuyRecord.getSellRecordId());
            if(ObjectUtil.isEmpty(mallProductSellRecord)){
                throw new FebsException("记录不存在");
            }
 
 
            mallProductBuyRecord.setState(ProductEnum.PRODUCT_MATE_STATE_COMPLAIN.getValue());
            mallProductBuyRecordMapper.updateById(mallProductBuyRecord);
 
            mallProductSellRecord.setState(ProductEnum.PRODUCT_MATE_STATE_COMPLAIN.getValue());
            mallProductSellRecordMapper.updateById(mallProductSellRecord);
            buyOrderNo = mallProductBuyRecord.getBuyOrderNo();
 
        }
 
        MallMemberSpeak mallMemberSpeak = new MallMemberSpeak();
        mallMemberSpeak.setMemberId(memberId);
        mallMemberSpeak.setState(ProductEnum.SPEAK_NO_DEAL.getValue());
        String description = apiOrderSellComplainDto.getDescription();
        mallMemberSpeak.setDescription("编号:"+buyOrderNo+","+description);
        mallMemberSpeakMapper.insert(mallMemberSpeak);
        return new FebsResponse().success();
    }
 
    @Override
    public FebsResponse orderRecordList(ApiOrderRecordListDto apiOrderListDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        List<ApiOrderRecordListVo> objects = new ArrayList<>();
        apiOrderListDto.setMemberId(memberId);
        DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(DateUtil.date()));
        DataDictionaryCustom startTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.YU_YUE_START_TIME.getType(),
                DataDictionaryEnum.YU_YUE_START_TIME.getCode()
        );
        DateTime startTime = DateUtil.parseTime(startTimeDic.getValue());
        DataDictionaryCustom endTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.YU_YUE_END_TIME.getType(),
                DataDictionaryEnum.YU_YUE_END_TIME.getCode()
        );
        DateTime endTime = DateUtil.parseTime(endTimeDic.getValue());
        if(nowTime.compareTo(startTime) >= 0 && nowTime.compareTo(endTime) <= 0){
            IPage<ApiOrderRecordListVo> pageBuy = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize());
            IPage<ApiOrderRecordListVo> apiOrderListVoIPageBuy = mallProductBuyRecordMapper.selectListInPage(pageBuy, apiOrderListDto);
            if(CollUtil.isNotEmpty(apiOrderListVoIPageBuy.getRecords())){
                for(ApiOrderRecordListVo apiOrderListVo : apiOrderListVoIPageBuy.getRecords()){
                    objects.add(apiOrderListVo);
                }
            }
        }
 
//        IPage<ApiOrderRecordListVo> pageBuy = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize());
//        IPage<ApiOrderRecordListVo> apiOrderListVoIPageBuy = mallProductBuyRecordMapper.selectListInPage(pageBuy, apiOrderListDto);
//        if(CollUtil.isNotEmpty(apiOrderListVoIPageBuy.getRecords())){
//            for(ApiOrderRecordListVo apiOrderListVo : apiOrderListVoIPageBuy.getRecords()){
//                objects.add(apiOrderListVo);
//            }
//        }
        IPage<ApiOrderRecordListVo> pageSell = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize());
        IPage<ApiOrderRecordListVo> apiOrderListVoIPageSell = mallProductSellRecordMapper.selectListInPage(pageSell, apiOrderListDto);
        if(CollUtil.isNotEmpty(apiOrderListVoIPageSell.getRecords())){
            for(ApiOrderRecordListVo apiOrderListVo : apiOrderListVoIPageSell.getRecords()){
                objects.add(apiOrderListVo);
            }
        }
 
        return new FebsResponse().success().data(objects);
    }
 
    @Override
    public FebsResponse orderSellRecord(ApiOrderSellInfoDto apiOrderSellInfoDto) {
        Long productSellRecordId = apiOrderSellInfoDto.getId();
        Long memberId = LoginUserUtil.getLoginUser().getId();
        MallProductSellRecord mallProductSellRecord = mallProductSellRecordMapper.selectById(productSellRecordId);
        if(ObjectUtil.isEmpty(mallProductSellRecord)){
            throw new FebsException("记录不存在");
        }
        ApiOrderSellRecordInfoVo apiOrderSellRecordInfoVo = mallProductSellRecordMapper.selectBySellRecordId(productSellRecordId);
        return new FebsResponse().success().data(apiOrderSellRecordInfoVo);
    }
 
    @Override
    public FebsResponse orderBuyRecord(ApiOrderBuyInfoDto apiOrderBuyInfoDto) {
        Long productBuyRecordId = apiOrderBuyInfoDto.getId();
        Long memberId = LoginUserUtil.getLoginUser().getId();
        MallProductBuyRecord mallProductBuyRecord = mallProductBuyRecordMapper.selectById(productBuyRecordId);
        if(ObjectUtil.isEmpty(mallProductBuyRecord)){
            throw new FebsException("记录不存在");
        }
        ApiOrderBuyRecordInfoVo apiOrderBuyRecordInfoVo = mallProductBuyRecordMapper.selectByBuyRecordId(productBuyRecordId);
        return new FebsResponse().success().data(apiOrderBuyRecordInfoVo);
    }
 
    @Override
    @Transactional
    public FebsResponse transGfd(ApiTransGfdDto transGfdDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        BigDecimal cnt = transGfdDto.getCnt();//兑换数量
 
        MallMember mallMember = memberMapper.selectById(memberId);
        String tradePassword = SecureUtil.md5(transGfdDto.getTradePassword());
        Boolean aBoolean = operationPermissionMemberFrozen(memberId);
        if(aBoolean){
            throw new FebsException("用户已冻结");
        }
        if(!tradePassword.equals(mallMember.getTradePassword())){
            throw new FebsException("请输入正确的交易密码");
        }
        MallMemberAmount mallMemberAmount = mallMemberAmountMapper.selectByMemberId(memberId);
        Integer type = transGfdDto.getType();
        String orderNo = MallUtils.getOrderNum("GSD");
        if(1 == type){//NFT兑换GFD
            BigDecimal trendsNft = mallMemberAmount.getTrendsNft();
            if(BigDecimal.ZERO.compareTo(trendsNft) >= 0){
                throw new FebsException("NFT不足");
            }
            if(cnt.compareTo(trendsNft) > 0){
                throw new FebsException("NFT不足");
            }
            mallMemberAmount.setTrendsNft(trendsNft.subtract(cnt));
            mallMemberAmount.setGsd(mallMemberAmount.getGsd().add(cnt));
            mallMemberAmountMapper.updateTrendsNftAndGsdById(mallMemberAmount);
            iMallMoneyFlowService.addMoneyFlow(
                    memberId,
                    cnt,
                    MoneyFlowTypeNewEnum.NFT_GSD.getValue(),
                    orderNo,
                    mallMember.getId(),
                    FlowTypeNewEnum.GSD.getValue(),
                    MoneyFlowTypeNewEnum.NFT_GSD.getDescrition());
 
        }
        if(2 == type){//GFA兑换GFD
            BigDecimal fcmCntAva = mallMemberAmount.getFcmCntAva();
            if(BigDecimal.ZERO.compareTo(fcmCntAva) >= 0){
                throw new FebsException("代币不足");
            }
            if(cnt.compareTo(fcmCntAva) > 0){
                throw new FebsException("代币不足");
            }
            DataDictionaryCustom fcmPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                    DataDictionaryEnum.FCM_PRICE.getType(),
                    DataDictionaryEnum.FCM_PRICE.getCode());
            BigDecimal fcmPrice = ObjectUtil.isEmpty(fcmPriceDic) ? new BigDecimal(2) : new BigDecimal(fcmPriceDic.getValue());
            BigDecimal gsdCnt = fcmPrice.multiply(cnt);
            mallMemberAmount.setFcmCntAva(fcmCntAva.subtract(cnt));
            mallMemberAmount.setGsd(mallMemberAmount.getGsd().add(gsdCnt));
            mallMemberAmountMapper.updateFcmCntAvaAndGsdById(mallMemberAmount);
            iMallMoneyFlowService.addMoneyFlow(
                    memberId,
                    cnt,
                    MoneyFlowTypeNewEnum.GFA_GSD.getValue(),
                    orderNo,
                    mallMember.getId(),
                    FlowTypeNewEnum.GSD.getValue(),
                    MoneyFlowTypeNewEnum.GFA_GSD.getDescrition());
 
        }
        return new FebsResponse().success();
    }
 
    @Override
    @Transactional
    public FebsResponse gfdTrans(ApiGfdTransDto transGfdDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        BigDecimal cnt = transGfdDto.getCnt();//兑换数量
 
        MallMember mallMember = memberMapper.selectById(memberId);
        String tradePassword = SecureUtil.md5(transGfdDto.getTradePassword());
        Boolean aBoolean = operationPermissionMemberFrozen(memberId);
        if(aBoolean){
            throw new FebsException("用户已冻结");
        }
        if(!tradePassword.equals(mallMember.getTradePassword())){
            throw new FebsException("请输入正确的交易密码");
        }
        MallMemberAmount mallMemberAmount = mallMemberAmountMapper.selectByMemberId(memberId);
        BigDecimal gsd = mallMemberAmount.getGsd();
        if(BigDecimal.ZERO.compareTo(gsd) >= 0){
            throw new FebsException("积分不足");
        }
        if(cnt.compareTo(gsd) > 0){
            throw new FebsException("积分不足");
        }
        Integer type = transGfdDto.getType();
        String orderNo = MallUtils.getOrderNum("GSD");
        if(1 == type){//GFD兑换NFT
            BigDecimal trendsNft = mallMemberAmount.getTrendsNft();
            mallMemberAmount.setTrendsNft(trendsNft.add(cnt));
            mallMemberAmount.setGsd(mallMemberAmount.getGsd().subtract(cnt));
            mallMemberAmountMapper.updateTrendsNftAndGsdById(mallMemberAmount);
            iMallMoneyFlowService.addMoneyFlow(
                    memberId,
                    cnt,
                    MoneyFlowTypeNewEnum.GSD_NFT.getValue(),
                    orderNo,
                    mallMember.getId(),
                    FlowTypeNewEnum.GSD.getValue(),
                    MoneyFlowTypeNewEnum.GSD_NFT.getDescrition());
 
        }
        if(2 == type){//GFD兑换GFA
            BigDecimal fcmCntAva = mallMemberAmount.getFcmCntAva();
            DataDictionaryCustom fcmPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                    DataDictionaryEnum.FCM_PRICE.getType(),
                    DataDictionaryEnum.FCM_PRICE.getCode());
            BigDecimal fcmPrice = ObjectUtil.isEmpty(fcmPriceDic) ? new BigDecimal(2) : new BigDecimal(fcmPriceDic.getValue());
            BigDecimal gsdCnt = cnt.divide(fcmPrice,2,BigDecimal.ROUND_DOWN);
            mallMemberAmount.setFcmCntAva(fcmCntAva.add(gsdCnt));
            mallMemberAmount.setGsd(mallMemberAmount.getGsd().subtract(cnt));
            mallMemberAmountMapper.updateFcmCntAvaAndGsdById(mallMemberAmount);
            iMallMoneyFlowService.addMoneyFlow(
                    memberId,
                    cnt,
                    MoneyFlowTypeNewEnum.GSD_GFA.getValue(),
                    orderNo,
                    mallMember.getId(),
                    FlowTypeNewEnum.GSD.getValue(),
                    MoneyFlowTypeNewEnum.GSD_GFA.getDescrition());
 
        }
        return new FebsResponse().success();
    }
 
    @Override
    public FebsResponse orderSellList(ApiOrderSellDto apiOrderBuyDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        IPage<ApiOrderSellVo> page = new Page<>(apiOrderBuyDto.getPageNum(), apiOrderBuyDto.getPageSize());
        apiOrderBuyDto.setMemberId(memberId);
        IPage<ApiOrderSellVo> apiOrderBuyVoIPage = mallProductBuyMapper.selectSellListInPage(page, apiOrderBuyDto);
        return new FebsResponse().success().data(apiOrderBuyVoIPage);
    }
}