lidongdong
2023-11-17 df7a9d5bca908cdb4a3a0984b4c63c4be7a89671
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
package com.panzhihua.service_dangjian.service.impl;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.building.NewFightShoppingOrderVO;
import com.panzhihua.common.utlis.Snowflake;
import com.panzhihua.service_dangjian.dao.NewFightShoppingOrderDao;
import com.panzhihua.service_dangjian.entity.NewFightShopping;
import com.panzhihua.service_dangjian.entity.NewFightShoppingOrder;
import com.panzhihua.service_dangjian.service.NewFightShoppingOrderService;
import com.panzhihua.service_dangjian.service.NewFightShoppingService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.Date;
 
 
@Slf4j
@Service
public class NewFightShoppingOrderServiceImpl extends ServiceImpl<NewFightShoppingOrderDao,
        NewFightShoppingOrder> implements NewFightShoppingOrderService
{
 
    @Resource
    private NewFightShoppingService shoppingService;
 
 
    @Override
    public R getList(int pageNum,int pageSize,String userId,String goodsId,String orderNumber,
                     String goodName,String name,String cancelType,String communityId)
    {
        Page page = new Page<NewFightShopping>(pageNum,pageSize);
        return R.ok(baseMapper.getList(page,userId,goodsId,orderNumber,goodName,name,cancelType,communityId));
    }
 
    @Override
    public NewFightShoppingOrder getDetails(String id,String communityId) {
        return baseMapper.getDetails(id,communityId);
    }
 
 
    @Override
    public R addData(NewFightShoppingOrderVO item)
    {
        item.setOrderNumber(Snowflake.getId()+"");
//        JinhuiCoinGeneralTable generalTable=tableService.getDetails(item.getUserId());
//        NewFightShopping goods=shoppingService.getDetails(item.getGoodsId());
//
//        int allMoney=0;
//        int getMoney=Integer.valueOf(goods.getGoodPrice());
//
//
//        if(generalTable==null)
//        {
//            return R.fail("金汇币不足!");
//        }
//
//        if(!StringUtils.isEmpty(generalTable.getGoldCoin()))
//        {
//            allMoney=Integer.valueOf(generalTable.getGoldCoin());
//        }
//        if(getMoney>allMoney)
//        {
//            return R.fail("金汇币不足!");
//        }
 
        item.setCancelType("0");
//        item.setPalyMoney(goods.getGoodPrice());
        int num= baseMapper.addData(item);
        if(num>0)
        {
            //修改个人金汇币总额
//            allMoney=allMoney-getMoney;
//            JinhuiCoinGeneralTableVO generalTableVO=new JinhuiCoinGeneralTableVO();
//            generalTableVO.setId(generalTable.getId());
//            generalTableVO.setGoldCoin(allMoney+"");
//            tableService.editData(generalTableVO);
//
//            //增加兑换记录
//            JinhuiGoldCoinRecordVO recordVO=new JinhuiGoldCoinRecordVO();
//            recordVO.setTitle("兑换商品");
//            recordVO.setType("2");
//            recordVO.setUserId(item.getUserId());
//            recordVO.setGoldCoin(getMoney+"");
//            goldCoinRecordService.addData(recordVO);
 
            return R.ok();
        }
        return R.fail("添加失败");
    }
 
    @Override
    public R editData(NewFightShoppingOrderVO item) {
        int num= baseMapper.editData(item);
        if(num>0)
        {
            return R.ok();
        }
        return R.fail("添加失败");
    }
 
    @Override
    public R cancelOrder(String orderId,String communityId)
    {
        NewFightShoppingOrder order=baseMapper.getDetails(orderId,communityId);
 
        if(!StringUtils.equals("0",order.getCancelType()))
        {
            return R.fail("订单不是待核销状态");
        }
 
        NewFightShoppingOrderVO orderVO=new NewFightShoppingOrderVO();
        orderVO.setId(orderId);
        orderVO.setCancelType("2");
        orderVO.setAbolishTime(new Date());
        int num=baseMapper.editData(orderVO);
        if(num>0)
        {
//            JinhuiCoinGeneralTable generalTable=tableService.getDetails(order.getUserId());
//
//            int allMoney=0;
//            int getMoney=Integer.valueOf(order.getPalyMoney());
//
//            if(!StringUtils.isEmpty(generalTable.getGoldCoin()))
//            {
//                allMoney=Integer.valueOf(generalTable.getGoldCoin());
//            }
//
//            //修改个人金汇币总额
//            allMoney=allMoney+getMoney;
//            JinhuiCoinGeneralTableVO generalTableVO=new JinhuiCoinGeneralTableVO();
//            generalTableVO.setId(generalTable.getId());
//            generalTableVO.setGoldCoin(allMoney+"");
//            tableService.editData(generalTableVO);
//
//            //增加兑换记录
//            JinhuiGoldCoinRecordVO recordVO=new JinhuiGoldCoinRecordVO();
//            recordVO.setTitle("商品订单取消");
//            recordVO.setType("3");
//            recordVO.setUserId(order.getUserId());
//            recordVO.setGoldCoin(getMoney+"");
//            goldCoinRecordService.addData(recordVO);
 
            return R.ok();
        }
        return R.fail("取消失败");
    }
 
    @Override
    public R expurgateData(String id,String communityId)
    {
        NewFightShoppingOrder order=baseMapper.getDetails(id,communityId);
 
        if(StringUtils.equals("0",order.getCancelType()))
        {
            return R.fail("待核销订单不能删除");
        }
 
        int num= baseMapper.expurgateData(id);
        if(num>0)
        {
            return R.ok();
        }
        return R.fail("添加失败");
    }
}