parent
fe920d33c5
commit
7470b83bfb
@ -0,0 +1,89 @@ |
|||||||
|
package com.hfkj.controller; |
||||||
|
|
||||||
|
import com.hfkj.common.exception.ErrorCode; |
||||||
|
import com.hfkj.common.exception.ErrorHelp; |
||||||
|
import com.hfkj.common.exception.SysCode; |
||||||
|
import com.hfkj.common.security.SessionObject; |
||||||
|
import com.hfkj.common.security.UserCenter; |
||||||
|
import com.hfkj.common.utils.DateUtil; |
||||||
|
import com.hfkj.common.utils.ResponseMsgUtil; |
||||||
|
import com.hfkj.entity.BsUser; |
||||||
|
import com.hfkj.entity.BsUserAccount; |
||||||
|
import com.hfkj.model.ResponseData; |
||||||
|
import com.hfkj.model.UserSessionObject; |
||||||
|
import com.hfkj.service.user.BsUserAccountRecordService; |
||||||
|
import com.hfkj.service.user.BsUserAccountService; |
||||||
|
import com.hfkj.service.user.BsUserGradeService; |
||||||
|
import com.hfkj.service.user.BsUserService; |
||||||
|
import com.hfkj.service.user.impl.BsUserServiceImpl; |
||||||
|
import com.hfkj.sysenum.user.UserGradeEnum; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.LinkedHashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @className: ClientController |
||||||
|
* @author: HuRui |
||||||
|
* @date: 2024/9/6 |
||||||
|
**/ |
||||||
|
@Controller |
||||||
|
@RequestMapping(value="/userCount") |
||||||
|
@Api(value="用户统计业务") |
||||||
|
public class UserCountController { |
||||||
|
@Autowired |
||||||
|
private UserCenter userCenter; |
||||||
|
@Resource |
||||||
|
private BsUserAccountRecordService userAccountRecordService; |
||||||
|
@Resource |
||||||
|
private BsUserAccountService userAccountService; |
||||||
|
|
||||||
|
@RequestMapping(value = "/income", method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "收益统计") |
||||||
|
public ResponseData income() { |
||||||
|
try { |
||||||
|
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); |
||||||
|
// 查询用户账户
|
||||||
|
BsUserAccount account = userAccountService.getAccount(userSession.getUser().getId()); |
||||||
|
if (account == null) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户账户"); |
||||||
|
} |
||||||
|
// 今日时间
|
||||||
|
Map<String, Date> todayTime = DateUtil.getTodayTimeObj(); |
||||||
|
// 昨日时间
|
||||||
|
Map<String, Date> yesterdayTime = DateUtil.getYesterdayTimeObj(); |
||||||
|
// 本月时间
|
||||||
|
Map<String, Date> thisMonthTime = DateUtil.getThisMonthTimeObj(); |
||||||
|
// 上月时间
|
||||||
|
Map<String, Date> lastMonthTime = DateUtil.getLastMonthTimeObj(); |
||||||
|
|
||||||
|
Map<String,Object> param = new LinkedHashMap<>(); |
||||||
|
// 当前账户元宝
|
||||||
|
param.put("goldCoin", account.getGoldCoin()); |
||||||
|
// 今日元宝收益
|
||||||
|
param.put("today", userAccountRecordService.getUserTotalProfit(userSession.getUser().getId(), todayTime.get("timeS"), todayTime.get("timeE"))); |
||||||
|
// 昨日元宝收益
|
||||||
|
param.put("yesterday", userAccountRecordService.getUserTotalProfit(userSession.getUser().getId(), yesterdayTime.get("timeS"), yesterdayTime.get("timeE"))); |
||||||
|
// 本月元宝收益
|
||||||
|
param.put("thisMonth", userAccountRecordService.getUserTotalProfit(userSession.getUser().getId(), thisMonthTime.get("timeS"), thisMonthTime.get("timeE"))); |
||||||
|
// 上月元宝收益
|
||||||
|
param.put("lastMonth", userAccountRecordService.getUserTotalProfit(userSession.getUser().getId(), lastMonthTime.get("timeS"), lastMonthTime.get("timeE"))); |
||||||
|
return ResponseMsgUtil.success(param); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue