mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
package com.panzhihua.service_community.api;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.VolunteerCreditsExchangeVO;
import com.panzhihua.common.model.vos.community.VolunteerIntegralMerchantVO;
import com.panzhihua.common.utlis.StringUtils;
import com.panzhihua.service_community.entity.VolunteerIntegralMerchant;
import com.panzhihua.service_community.service.VolunteerCreditsExchangeService;
import com.panzhihua.service_community.service.VolunteerIntegralMerchantService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
 
/**
 * 商品内容逻辑
 */
@Slf4j
@RestController
@RequestMapping("/VolunteerIntegralMerchant")
public class VolunteerIntegralMerchantApi  extends BaseController
{
    @Resource
    private VolunteerIntegralMerchantService merchantService;
 
    /**
     * 获取单个详情
     * @param id
     * @return
     */
    @GetMapping("/queryById")
    public R VolunteerIntegralMerchantQueryById(@RequestParam("id") String id)
    {
        return R.ok(merchantService.queryById(id));
    }
 
    /**
     * 分页查询
     * @param
     * @return
     */
    @GetMapping("/queryList")
    public R VolunteerIntegralMerchantQueryList(@RequestParam("pageNum") int pageNum,
                                                @RequestParam("pageSize")  int pageSize,
                                                @RequestParam(value = "name", required = false) String name,
                                                @RequestParam(value = "state", required = false) String state,
                                                @RequestParam(value = "goodType", required = false) String goodType,
                                                @RequestParam(value = "merchantId", required = false) String merchantId)
    {
        Page page=new Page<VolunteerIntegralMerchant>(pageNum,pageSize);
        return R.ok(merchantService.queryList(page,name,state,goodType,merchantId));
    }
 
    /**
     * 新增
     * @param
     * @return
     */
    @PostMapping("/insertVolunteer")
    public R VolunteerIntegralMerchantInsertVolunteer(@RequestBody VolunteerIntegralMerchantVO vimVO)
    {
        if(vimVO==null)
        {
            return R.fail("参数不能为空");
        }
 
        if(StringUtils.isEmpty(vimVO.getCommunityId()))
        {
            vimVO.setCommunityId(getCommunityId()+"");
        }
 
        if(StringUtils.isEmpty(vimVO.getName()))
        {
            return R.fail("商品名称不能为空");
        }
 
 
        if(StringUtils.isEmpty(vimVO.getIntegral()))
        {
            return R.fail("商品所需积分不能为空");
        }
 
 
 
        int num= merchantService.insertVolunteer(vimVO);
        if(num>0)
        {
            return R.ok();
        }
        return R.fail("操作失败");
    }
 
    @PostMapping("/updateById")
    public R  VolunteerIntegralMerchantUpdateById(@RequestBody VolunteerIntegralMerchantVO vimVO)
    {
 
        if(vimVO==null)
        {
            return R.fail("参数不能为空");
        }
 
        VolunteerIntegralMerchant vim= merchantService.queryById(vimVO.getId());
        if(StringUtils.equals("1",vim.getState()))
        {
            return R.fail("商品必须下架才能编辑");
        }
 
        if(StringUtils.isEmpty(vimVO.getCommunityId()))
        {
            vimVO.setCommunityId(getCommunityId()+"");
        }
 
        if(StringUtils.isEmpty(vimVO.getIntegral()))
        {
            return R.fail("商品所需积分不能为空");
        }
 
        int num= merchantService.updateById(vimVO);
        if(num>0)
        {
            return R.ok();
        }
        return R.fail("操作失败");
    }
 
 
    @PostMapping("/unmount")
    public R  VolunteerIntegralMerchantUnmount(@RequestBody VolunteerIntegralMerchantVO vimVO)
    {
 
        if(vimVO==null)
        {
            return R.fail("参数不能为空");
        }
 
        if(StringUtils.isEmpty(vimVO.getId()))
        {
            return R.fail("上下架商品id不能为空");
        }
 
        if(StringUtils.isEmpty(vimVO.getState()))
        {
            vimVO.setState("1");
        }
 
        if(StringUtils.isEmpty(vimVO.getCommunityId()))
        {
            vimVO.setCommunityId(getCommunityId()+"");
        }
 
        int num= merchantService.updateById(vimVO);
        if(num>0)
        {
            return R.ok();
        }
        return R.fail("操作失败");
    }
 
 
    @DeleteMapping("/deleteById")
    public R  VolunteerIntegralMerchantDeleteById(@RequestParam("id") String id)
    {
        int num= merchantService.deleteById(id);
        if(num>0)
        {
            return R.ok();
        }
        return R.fail("操作失败");
    }
 
    /***********************************************************************************************************
     *
     *
     *                   订单兑换
     *
     *
     ***********************************************************************************************************/
    @Resource
    private VolunteerCreditsExchangeService vceService;
 
    /**
     * 分页查询
     * @param
     * @return
     */
    @GetMapping("/order/getList")
    public R getList(@RequestParam("pageNum") int pageNum,
                     @RequestParam("pageSize")  int pageSize,
                     @RequestParam(value = "goodsId", required = false) String goodsId,
                     @RequestParam(value = "orderNumber", required = false) String orderNumber,
                     @RequestParam(value = "goodsName", required = false) String goodsName,
                     @RequestParam(value = "condition", required = false) String condition,
                     @RequestParam(value = "userName", required = false) String userName,
                     @RequestParam(value = "communityId", required = false) String communityId,
                     @RequestParam(value = "userId", required = false) String userId,
                     @RequestParam(value = "orderType", required = false) String orderType,
                     @RequestParam(value = "merchantId", required = false) String merchantId)
    {
        return vceService.getList(pageNum,pageSize,goodsId,orderNumber,goodsName,
                condition,userName,communityId,userId,orderType,merchantId);
    }
 
    /**
     * 查询详情
     * @param id
     * @return
     */
    @GetMapping("/order/getData")
    public R getData(@RequestParam("id") String id)
    {
        if(StringUtils.isEmpty(id))
        {
            return R.fail("订单id不能为空");
        }
        return vceService.getData(id);
    }
 
    /**
     * 新增
     * @param
     * @return
     */
    @PostMapping("/order/insertData")
    public R insertData(@RequestBody VolunteerCreditsExchangeVO item)
    {
        LoginUserInfoVO userInfoVO= getLoginUserInfo();
        if(StringUtils.isEmpty(item.getCommunityId()))
        {
            item.setCommunityId(userInfoVO.getCommunityId()+"");
        }
 
        item.setUserId(userInfoVO.getUserId()+"");
        return vceService.insertData(item);
    }
 
    /**
     * 新增用户购买商家商品记录
     * @param
     * @return
     */
    @PostMapping("/order/insertMerchantData")
    public R insertMerchantData(@RequestBody VolunteerCreditsExchangeVO item)
    {
        LoginUserInfoVO userInfoVO= getLoginUserInfo();
        if(StringUtils.isEmpty(item.getCommunityId()))
        {
            item.setCommunityId(userInfoVO.getCommunityId()+"");
        }
 
        item.setUserId(userInfoVO.getUserId()+"");
        return vceService.insertMerchantData(item);
    }
 
    /**
     * 更新
     * @param item
     * @return
     */
    @PostMapping("/order/update")
    public R update(@RequestBody VolunteerCreditsExchangeVO item)
    {
        return vceService.update(item);
    }
 
    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/order/delete")
    public R delete(@RequestParam("id") String id)
    {
        if(StringUtils.isEmpty(id))
        {
            return R.fail("订单id不能为空");
        }
        return vceService.delete(id);
    }
 
    /**
     * 核销
     * @param id
     * @return
     */
    @GetMapping("/order/conditionData")
    public R conditionData(@RequestParam("id") String id)
    {
        if(StringUtils.isEmpty(id))
        {
            return R.fail("订单id不能为空");
        }
        return vceService.conditionData(id);
    }
 
 
 
    /**
     * 社区取消订单
     * @param id
     * @return
     */
    @GetMapping("/order/communityCancellation")
    public R communityCancellation(@RequestParam("id") String id)
    {
        if(StringUtils.isEmpty(id))
        {
            return R.fail("订单id不能为空");
        }
        return vceService.communityCancellation(id);
    }
 
 
}