wzy
2021-01-10 16da0ad1fda1dffa3019425a6887d38ed4217f44
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
package com.matrix.system.shopXcx.api.action;
 
import com.matrix.biz.bean.BizUser;
import com.matrix.biz.service.BizUserService;
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.system.shopXcx.bean.ShopScoreExchange;
import com.matrix.system.shopXcx.bean.ShopScoreRecord;
import com.matrix.system.shopXcx.dao.ShopScoreExchangeDao;
import com.matrix.system.shopXcx.dao.ShopScoreRecordDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import java.util.List;
 
/**
 * @description 用户积分控制器
 * @author jyy
 * @date 2019-08-09 15:10
 */
@Controller
@RequestMapping(value="/wxapi/shopScoreRecord")
@CrossOrigin(origins = "*", maxAge = 3600)
public class WxShopScoreAction {
 
    @Autowired
    private ShopScoreRecordDao shopScoreRecordDao;
    @Autowired
    private ShopScoreExchangeDao shopScoreExchangeDao;
    @Autowired
    private RedisUserLoginUtils redisUserLoginUtils;
    @Autowired
    private BizUserService bizUserService;
 
 
    /**
     * 查询我的获得积分列表
     * @return
     */
    @RequestMapping(value = "/getRecordList")
    @ResponseBody
    public AjaxResult getRecordList(@RequestBody PaginationVO pageVo) {
 
        pageVo.setSort("create_time");
        pageVo.setOrder("desc");
        BizUser loginBizUser = redisUserLoginUtils.getLoginUser(BizUser.class);
        ShopScoreRecord params = new ShopScoreRecord();
        params.setBeneficiaryId(loginBizUser.getOpenId());
        List<ShopScoreRecord> dataList = shopScoreRecordDao.selectInPage(params, pageVo);
        int total = shopScoreRecordDao.selectTotalRecord(params);
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, total);
        //查询用户总积分
        BizUser user = bizUserService.findById(loginBizUser.getUserId());
        Integer totalScore = 0;
        if (user != null && user.getTotalScore() != null) {
            totalScore = user.getTotalScore();
        }
        result.putInMap("totalScore", totalScore);
        //查询下级总人数
        BizUser peopleSumParams = new BizUser();
        peopleSumParams.setParentOpenId(loginBizUser.getOpenId());
        int peopleSum = bizUserService.findTotal(peopleSumParams);
        result.putInMap("peopleSum", peopleSum);
        return result;
    }
 
 
    /**
     * 查询我的积分兑换列表
     * @return
     */
    @RequestMapping(value = "/getChangeRecordList")
    @ResponseBody
    public AjaxResult getChangeRecordList(@RequestBody PaginationVO pageVo) {
 
        //不分页
        pageVo.setOffset(null);
        pageVo.setLimit(null);
        //按生成时间倒序排列
        pageVo.setSort("create_time");
        pageVo.setOrder("desc");
        BizUser loginBizUser = redisUserLoginUtils.getLoginUser(BizUser.class);
        ShopScoreExchange params = new ShopScoreExchange();
        params.setUserId(loginBizUser.getOpenId());
        List<ShopScoreExchange> dataList = shopScoreExchangeDao.selectInPage(params, pageVo);
        int total = shopScoreExchangeDao.selectTotalRecord(params);
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList, total);
        //查询用户当前积分
        BizUser user = bizUserService.findById(loginBizUser.getUserId());
        Integer currentScore = 0;
        if (user != null && user.getCurrentScore() != null) {
            currentScore = user.getCurrentScore();
        }
        result.putInMap("currentScore", currentScore);
        return result;
    }
  
}