lidongdong
2023-08-31 0d15a472f111a8fd73b549ac0247313f32df0214
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
package com.panzhihua.applets.api;
 
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.service.community.CommunityService;
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.common.utlis.StringUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
@Slf4j
@RestController
@RequestMapping("/XmostBeautiful")
@Api(tags = {"小程序志愿者活动"})
public class XmostBeautifulApi extends BaseController
{
 
    @Resource
    private CommunityService communityService;
 
 
    @Resource
    private UserService userService;
 
    /**
     * 查询单个
     * @param Id
     * @return
     */
    @GetMapping("/queryById")
    public R queryById(@RequestParam("id") String Id)
    {
        if(StringUtils.isEmpty(Id))
        {
            return R.fail("id不能为空");
        }
        return communityService.queryById2(Id);
    }
 
 
    /**
     * 分页查询
     * @param name
     * @param unmountType
     * @return
     */
    @GetMapping("/getqueryList")
    public R queryList(@RequestParam("pageNum") int pageNum,
                       @RequestParam("pageSize")int pageSize,
                       @RequestParam(value = "name", required = false) String name,
                       @RequestParam(value = "unmountType", required = false) String unmountType)
    {
        return communityService.queryList(pageNum,pageSize,name,unmountType);
    }
 
 
    /**
     * 查询单个志愿者活动详情
     * @param Id
     * @return
     */
    @GetMapping("/volunteerQueryById")
    public R volunteerQueryById(@RequestParam("id") String Id)
    {
        if(StringUtils.isEmpty(Id))
        {
            return R.fail("id不能为空");
        }
        return communityService.volunteerQueryById(Id);
    }
 
    /***********************************************************************************************************
     *
     *
     *                   订单兑换
     *
     *
     ***********************************************************************************************************/
 
    /**
     * 分页查询
     * @param
     * @return
     */
    @GetMapping("/order/getList")
    public R orderMerchantGetList(@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 = "orderType", required = false) String orderType)
    {
        if(StringUtils.isEmpty(communityId))
        {
            communityId=getCommunityId()+"";
        }
        return communityService.getList(pageNum,pageSize,goodsId,orderNumber,goodsName,
                condition,userName,communityId,getUserId()+"",orderType);
    }
 
    /**
     * 新增用户购买商家商品记录
     * @param
     * @return
     */
    @PostMapping("/order/insertMerchantData")
    public R insertMerchantData(@RequestBody VolunteerCreditsExchangeVO item)
    {
 
        if(StringUtils.isEmpty(item.getPalyIntegral()))
        {
            return R.fail("请输入兑换积分");
        }
 
        LoginUserInfoVO userInfoVO= getLoginUserInfo();
        if(StringUtils.isEmpty(item.getCommunityId()))
        {
            item.setCommunityId(userInfoVO.getCommunityId()+"");
        }
        item.setOrderType("2");
        item.setUserId(userInfoVO.getUserId()+"");
        item.setNeedScore(userInfoVO.getLoveIntegral());
        return communityService.insertMerchantData(item);
    }
 
 
 
    /**
     * 更新商家
     * @param item
     * @return
     */
    @PostMapping("/order/MerchantUpdate")
    public R orderMerchantUpdate(@RequestBody VolunteerCreditsExchangeVO item)
    {
        item.setOrderType("2");
        return communityService.update(item);
    }
 
    /**
     * 查询详情
     * @param id
     * @return
     */
    @GetMapping("order/getData")
    public R getData(@RequestParam("id") String id)
    {
        if(StringUtils.isEmpty(id))
        {
            return R.fail("订单id不能为空");
        }
        return communityService.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.setOrderType("1");
        item.setUserId(userInfoVO.getUserId()+"");
        item.setNeedScore(userInfoVO.getLoveIntegral());
        return communityService.insertData(item);
    }
 
    /**
     * 更新社区
     * @param item
     * @return
     */
    @PostMapping("/order/update")
    public R update(@RequestBody VolunteerCreditsExchangeVO item)
    {
        item.setOrderType("1");
        return communityService.update(item);
    }
 
    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/order/delete")
    public R delete(@RequestParam("id") String id)
    {
        if(StringUtils.isEmpty(id))
        {
            return R.fail("订单id不能为空");
        }
        return communityService.delete(id);
    }
 
    /**
     * 核销社区
     * @param id
     * @return
     */
    @GetMapping("/order/conditionData")
    public R conditionData(@RequestParam("id") String id)
    {
        if(StringUtils.isEmpty(id))
        {
            return R.fail("订单id不能为空");
        }
        return communityService.conditionData(id);
    }
 
    /*************************************************************************************
     *
     *      路北社区商家模块
     *
     **************************************************************************************/
    /**
     * 分页查询
     * @param
     * @return
     */
    @GetMapping("/getList")
    public R volunteerMerchantGetList(@RequestParam("pageNum") int pageNum,
                                      @RequestParam("pageSize") int pageSize,
                                      @RequestParam(value = "merchantState", required = false) String merchantState,
                                      @RequestParam(value = "merchantType", required = false) String merchantType,
                                      @RequestParam(value = "name", required = false) String name)
    {
        return communityService.volunteerMerchantGetList(pageNum, pageSize,merchantState,merchantType,name,getCommunityId()+"");
    }
 
    /**
     * 分页查询商家分类
     * @param
     * @return
     */
    @GetMapping("/VolunteerMerchant/getList")
    public R merchantvolunteerTypeGetList(@RequestParam("pageNum")  int pageNum,
                                          @RequestParam("pageSize")  int pageSize)
    {
        return communityService.volunteerTypeGetList(pageNum,pageSize,"2");
    }
 
 
    /**
     * 获取商家详情
     * @param id
     * @return
     */
    @GetMapping("/VolunteerMerchant/getById")
    public R volunteerMerchantGetById(@RequestParam("id") String id)
    {
        return communityService.volunteerMerchantGetById(id);
    }
 
 
    /**
     * 是否是商家
     * @return
     */
    @GetMapping("/VolunteerMerchant/isMerchant")
    public R isMerchant(@RequestParam("userId") String userId)
    {
        return communityService.isMerchant(userId);
    }
 
 
    /**
     * 社区取消订单
     * @param id
     * @return
     */
    @GetMapping("/order/communityCancellation")
    public R communityCancellation(@RequestParam("id") String id)
    {
        return communityService.communityCancellation(id);
    }
 
    /**
     * 用户设置积分支付密码
     * @param userId
     * @param pwd
     * @return
     */
    @GetMapping("/setUserPlayPwd")
    public R setUserPlayPwd(@RequestParam("userId") String userId,@RequestParam("pwd") String pwd)
    {
        if (StringUtils.isEmpty(userId))
        {
            return R.fail("userId不能为空");
        }
 
        if(StringUtils.isEmpty(pwd))
        {
            return R.fail("密码不能为空");
        }
 
        LoginUserInfoVO loginUserInfoVO=new LoginUserInfoVO();
        loginUserInfoVO.setUserId(Long.valueOf(userId));
        loginUserInfoVO.setPlayPwd(pwd);
        return userService.putUser(loginUserInfoVO);
    }
 
 
    /**
     * 判断密码是否正确
     * @param userId
     * @param pwd
     * @return
     */
    @GetMapping("/passwordIsCorrect")
    public R passwordIsCorrect(@RequestParam("userId") String userId,@RequestParam("pwd") String pwd)
    {
        if (StringUtils.isEmpty(userId))
        {
            return R.fail("userId不能为空");
        }
 
        if(StringUtils.isEmpty(pwd))
        {
            return R.fail("密码不能为空");
        }
        LoginUserInfoVO loginUserInfoVO=userService.getUserInfoByUserId(userId).getData();
        if(StringUtils.equals(pwd,loginUserInfoVO.getPlayPwd()))
        {
            return R.ok();
        }
        return R.fail("密码错误");
    }
 
 
}