|
@@ -1,18 +1,18 @@
|
|
|
package com.txz.cif.web;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import com.txz.cif.core.AbstractApiController;
|
|
|
-import com.txz.cif.core.Result;
|
|
|
-import com.txz.cif.core.ResultCode;
|
|
|
-import com.txz.cif.core.ResultGenerator;
|
|
|
+import com.txz.cif.core.*;
|
|
|
import com.txz.cif.model.Account;
|
|
|
import com.txz.cif.model.AccountFlow;
|
|
|
import com.txz.cif.model.User;
|
|
|
import com.txz.cif.service.AccountFlowService;
|
|
|
import com.txz.cif.service.AccountService;
|
|
|
+import com.txz.cif.service.RedEnvelopeService;
|
|
|
import com.txz.cif.service.UserService;
|
|
|
import com.txz.cif.web.bo.AccountFlowBO;
|
|
|
+import com.txz.cif.web.bo.AccountInfoBO;
|
|
|
import com.txz.cif.web.bo.IndexCollectBO;
|
|
|
+import com.txz.cif.web.bo.UserInfoBO;
|
|
|
import com.txz.cif.web.para.AccountFlowParam;
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
@@ -27,11 +27,10 @@ import tk.mybatis.mapper.entity.Condition;
|
|
|
import tk.mybatis.mapper.entity.Example.Criteria;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -51,12 +50,47 @@ public class AccountApiController extends AbstractApiController {
|
|
|
@Resource
|
|
|
private AccountService accountService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private RedEnvelopeService redEnvelopeService;
|
|
|
+
|
|
|
|
|
|
@Resource
|
|
|
private UserService userService;
|
|
|
+ @Resource
|
|
|
+ private AuthService authService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询账号信息", notes = "",httpMethod = "GET")
|
|
|
+ @GetMapping("/getAccountInfo")
|
|
|
+ public Result<AccountInfoBO> getAccountInfo(HttpServletRequest request) {
|
|
|
+ Long userId = authService.getTokenUserId(request);
|
|
|
+ if (userId == null ){
|
|
|
+ ResultGenerator.genFailResult(ResultCode.USERID_IS_NULL);
|
|
|
+ }
|
|
|
+ User user = userService.findById(userId);
|
|
|
+ if (user == null ){
|
|
|
+ ResultGenerator.genFailResult(ResultCode.USER_IS_NULL);
|
|
|
+ }
|
|
|
+ Account wallet = accountService.getAccount(userId, 1);
|
|
|
+ Account earnings = accountService.getAccount(userId, 2);
|
|
|
+ AccountInfoBO bo = new AccountInfoBO();
|
|
|
+ bo.setBalance(wallet.getBalance().add(earnings.getBalance()));
|
|
|
+ bo.setSettledAmount(earnings.getTotalInamount());
|
|
|
+ BigDecimal pendingAmount = redEnvelopeService.sumWithDay(null,userId,1);
|
|
|
+ bo.setPendingAmount(pendingAmount);
|
|
|
+
|
|
|
+ BigDecimal tDEamings = redEnvelopeService.sumWithDay(1,userId,3);
|
|
|
+ bo.setTDEamings(tDEamings);
|
|
|
+ BigDecimal yDEamings = redEnvelopeService.sumWithDay(2,userId,3);
|
|
|
+ bo.setTDEamings(yDEamings.subtract(tDEamings));
|
|
|
+ Integer day = DateUtil.thisDayOfMonth();
|
|
|
+ BigDecimal mTDEamings = redEnvelopeService.sumWithDay(day,userId,3);
|
|
|
+ bo.setTDEamings(mTDEamings);
|
|
|
+
|
|
|
+ return ResultGenerator.genSuccessResult(bo);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- @PostMapping("/accountFlowList")
|
|
|
+ @PostMapping("/accountFlowList")
|
|
|
@ApiOperation(value = "出入流水",httpMethod = "POST")
|
|
|
public Result<AccountFlowBO> accountFlowList(@RequestBody AccountFlowParam param, @RequestHeader(value = X_CLIENT_TOKEN_USERID, required = false) Long userId)
|
|
|
{
|