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;
|
}
|
|
}
|