From d85af61932a03bd03663daf9da33177af5824a5c Mon Sep 17 00:00:00 2001
From: jyy <935090232@qq.com>
Date: Tue, 20 Apr 2021 14:09:45 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/api_score_meger' into api_score_meger
---
zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopBizUserScoreAction.java | 88 +-------------------------------------------
1 files changed, 2 insertions(+), 86 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopBizUserScoreAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopBizUserScoreAction.java
index 186022e..9e074ae 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopBizUserScoreAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopBizUserScoreAction.java
@@ -1,25 +1,10 @@
package com.matrix.system.shopXcx.action;
-import com.matrix.biz.bean.BizUser;
-import com.matrix.biz.service.BizUserService;
-import com.matrix.core.anotations.RemoveRequestToken;
-import com.matrix.core.anotations.SaveRequestToken;
-import com.matrix.core.constance.MatrixConstance;
-import com.matrix.core.pojo.AjaxResult;
-import com.matrix.core.tools.StringUtils;
-import com.matrix.core.tools.WebUtil;
-import com.matrix.system.common.bean.SysUsers;
-import com.matrix.system.shopXcx.bean.ShopScoreExchange;
+import com.matrix.system.hive.service.SysVipInfoService;
import com.matrix.system.shopXcx.dao.ShopScoreExchangeDao;
-import com.matrix.system.shopXcx.pojo.ExchangeScorePOJO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
-import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.servlet.ModelAndView;
-
-import java.util.Date;
/**
@@ -32,7 +17,7 @@
public class ShopBizUserScoreAction {
@Autowired
- private BizUserService bizUserService;
+ private SysVipInfoService sysVipInfoService;
@Autowired
private ShopScoreExchangeDao shopScoreExchangeDao;
@@ -40,75 +25,6 @@
* 记录编辑前的值Before_Edit_Value
*/
public static final String BEV = "ShopBizUserScore_BEV";
-
-
- /**
- * 进入积分兑换界面
- */
- @SaveRequestToken
- @RequestMapping(value = "/intoExchangePage")
- public ModelAndView exchangeScore(String userId) {
- BizUser bizUser = new BizUser();
- ModelAndView modelAndView = new ModelAndView("admin/shop/user-score-exchange");
- if (StringUtils.isNotBlank(userId)) {
- bizUser = bizUserService.findById(userId);
- if (bizUser.getCurrentScore() == null) {
- bizUser.setCurrentScore(0);
- }
- }
- modelAndView.addObject("obj", bizUser);
- return modelAndView;
- }
-
-
- /**
- * 兑换积分
- */
- @Transactional(rollbackFor = Exception.class)
- @RemoveRequestToken
- @RequestMapping(value = "/exchangeScore")
- public @ResponseBody
- AjaxResult exchangeScore(ExchangeScorePOJO pojo) {
- //校验参数中用户ID和用户兑换积分是否有效
- if (pojo == null || StringUtils.isBlank(pojo.getUserId())
- || pojo.getScore() == null || pojo.getScore() == 0) {
- return new AjaxResult(AjaxResult.STATUS_FAIL, "提交参数有误!");
- }
- //兑换积分用户信息
- BizUser bizUser = bizUserService.findById(pojo.getUserId());
- if (bizUser == null) {
- return new AjaxResult(AjaxResult.STATUS_FAIL, "没有查询到相应用户!");
- }
- if (bizUser.getCurrentScore() == null) {
- bizUser.setCurrentScore(0);
- }
- //如果兑换积分大于用户当前积分
- if (pojo.getScore() > bizUser.getCurrentScore()) {
- return new AjaxResult(AjaxResult.STATUS_FAIL, "兑换积分大于用户当前积分!");
- }
- //剩余积分 = 当前积分 - 兑换积分
- Integer remainScore = bizUser.getCurrentScore() - pojo.getScore();
- //当前操作用户信息
- SysUsers loginUser = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
- //修改用户剩余积分
- BizUser updateModel = new BizUser();
- updateModel.setUserId(bizUser.getUserId());
- updateModel.setCurrentScore(remainScore);
- updateModel.setUpdateBy(loginUser.getSuName());
- updateModel.setUpdateTime(new Date());
- bizUserService.modifyByModel(updateModel);
- //添加积分兑换记录
- ShopScoreExchange insertExchange = new ShopScoreExchange();
- insertExchange.setCreateBy(loginUser.getSuName());
- insertExchange.setUpdateBy(loginUser.getSuName());
- insertExchange.setUserId(bizUser.getOpenId());
- insertExchange.setExchangeScore(pojo.getScore());
- insertExchange.setOperateId(loginUser.getSuId());
- insertExchange.setRemark(pojo.getRemarks());
- shopScoreExchangeDao.insert(insertExchange);
-
- return new AjaxResult(AjaxResult.STATUS_SUCCESS, "兑换成功!");
- }
}
\ No newline at end of file
--
Gitblit v1.9.1