package com.nq.service.impl;
|
|
import com.github.pagehelper.Page;
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
import com.nq.common.ServerResponse;
|
import com.nq.common.lanage.MessageLocaleResolver;
|
import com.nq.dao.*;
|
import com.nq.pojo.*;
|
import com.nq.service.IAgentAgencyFeeService;
|
import com.nq.service.IAgentDistributionUserService;
|
import com.nq.service.IAgentUserService;
|
import com.nq.service.ISiteInfoService;
|
import com.nq.utils.KeyUtils;
|
import com.nq.utils.PropertiesUtil;
|
import com.nq.utils.SymmetricCryptoUtil;
|
import com.nq.utils.redis.CookieUtils;
|
import com.nq.utils.redis.JsonUtil;
|
import com.nq.utils.redis.RedisShardedPoolUtils;
|
import com.nq.vo.admin.AdminCountVO;
|
import com.nq.vo.agent.AgentInfoVO;
|
import com.nq.vo.agent.AgentSecondInfoVO;
|
|
import java.math.BigDecimal;
|
import java.util.Date;
|
import java.util.List;
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
|
import org.apache.commons.lang3.StringUtils;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@Service("iAgentUserService")
|
public class AgentUserServiceImpl implements IAgentUserService {
|
private static final Logger log = LoggerFactory.getLogger(AgentUserServiceImpl.class);
|
|
|
@Autowired
|
AgentUserMapper agentUserMapper;
|
@Autowired
|
SiteTaskLogMapper siteTaskLogMapper;
|
|
|
@Autowired
|
ISiteInfoService iSiteInfoService;
|
|
@Autowired
|
IAgentDistributionUserService iAgentDistributionUserService;
|
|
@Autowired
|
IAgentAgencyFeeService iAgentAgencyFeeService;
|
|
|
@Resource
|
UserRechargeMapper userRechargeMapper;
|
|
@Resource
|
UserWithdrawMapper userWithdrawMapper;
|
|
@Resource
|
UserMapper userMapper;
|
|
|
public AgentUser getCurrentAgent(HttpServletRequest request) {
|
// String loginToken = CookieUtils.readLoginToken(request, PropertiesUtil.getProperty("agent.cookie.name"));
|
String loginToken = request.getHeader(PropertiesUtil.getProperty("agent.cookie.name"));
|
if (StringUtils.isEmpty(loginToken)) {
|
return null;
|
}
|
String agentJson = RedisShardedPoolUtils.get(loginToken);
|
AgentUser agentUser = (AgentUser) JsonUtil.string2Obj(agentJson, AgentUser.class);
|
if (agentUser ==null){
|
return null;
|
}
|
|
return this.agentUserMapper.selectByPrimaryKey(agentUser.getId());
|
}
|
|
|
public AgentUser findByCode(String agentCode) {
|
return this.agentUserMapper.findByCode(agentCode);
|
}
|
|
|
public ServerResponse login(String agentPhone, String agentPwd, String verifyCode, HttpServletRequest request) {
|
// if (StringUtils.isBlank(verifyCode)) {
|
// return ServerResponse.createByErrorMsg("验证码不能为空");
|
// }
|
String original = (String) request.getSession().getAttribute("KAPTCHA_SESSION_KEY");
|
|
// if (!verifyCode.equalsIgnoreCase(original)) {
|
// return ServerResponse.createByErrorMsg("验证码错误");
|
// }
|
|
if (StringUtils.isBlank(agentPhone) || StringUtils.isBlank(agentPwd)) {
|
return ServerResponse.createByErrorMsg("Parameter cannot be empty",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
agentPwd = SymmetricCryptoUtil.encryptPassword(agentPwd);
|
AgentUser agentUser = this.agentUserMapper.login(agentPhone, agentPwd);
|
if (agentUser == null) {
|
return ServerResponse.createByErrorMsg("User password is incorrect",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
if (agentUser.getIsLock().intValue() == 1) {
|
return ServerResponse.createByErrorMsg("Login failed, your account has been locked!",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
return ServerResponse.createBySuccess(agentUser);
|
}
|
|
|
public ServerResponse getAgentInfo(HttpServletRequest request) {
|
String host = "";
|
ServerResponse serverResponse = this.iSiteInfoService.getInfo();
|
if (serverResponse.isSuccess()) {
|
SiteInfo siteInfo = (SiteInfo) serverResponse.getData();
|
if (StringUtils.isBlank(siteInfo.getSiteHost())) {
|
return ServerResponse.createByErrorMsg("info host not set",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
host = siteInfo.getSiteHost();
|
}
|
String loginToken = CookieUtils.readLoginToken(request, PropertiesUtil.getProperty("agent.cookie.name"));
|
String agentJson = RedisShardedPoolUtils.get(loginToken);
|
AgentUser agentUser = (AgentUser) JsonUtil.string2Obj(agentJson, AgentUser.class);
|
if (agentUser ==null){
|
return ServerResponse.createByError("please log in first",null,request.getHeader(MessageLocaleResolver.LANG));
|
}
|
AgentUser dbuser = this.agentUserMapper.selectByPrimaryKey(agentUser.getId());
|
AgentInfoVO agentInfoVO = assembleAgentInfoVO(dbuser, host);
|
return ServerResponse.createBySuccess(agentInfoVO);
|
}
|
|
|
public ServerResponse updatePwd(String oldPwd, String newPwd, HttpServletRequest request) {
|
if (StringUtils.isBlank(oldPwd) || StringUtils.isBlank(newPwd)) {
|
return ServerResponse.createByErrorMsg("Parameter cannot be empty",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
AgentUser agentUser = getCurrentAgent(request);
|
if (agentUser ==null){
|
return ServerResponse.createByError("please log in first",null,request.getHeader(MessageLocaleResolver.LANG));
|
}
|
oldPwd = SymmetricCryptoUtil.encryptPassword(oldPwd);
|
if (!oldPwd.equals(agentUser.getAgentPwd())) {
|
return ServerResponse.createByErrorMsg("wrong password",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
agentUser.setAgentPwd(SymmetricCryptoUtil.encryptPassword(newPwd));
|
int updateCount = this.agentUserMapper.updateByPrimaryKeySelective(agentUser);
|
|
if (updateCount > 0) {
|
return ServerResponse.createBySuccessMsg("Successfully modified",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
return ServerResponse.createByErrorMsg("fail to edit",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
|
public ServerResponse addAgentUser(String agentName, String agentPwd, String agentRealName, String agentPhone, Integer parentId, String poundageScale, String deferredFeesScale, String receiveDividendsScale, HttpServletRequest request) {
|
if (StringUtils.isBlank(agentName) ||
|
StringUtils.isBlank(agentPwd) ||
|
StringUtils.isBlank(agentRealName) ||
|
StringUtils.isBlank(agentPhone)) {
|
return ServerResponse.createByErrorMsg("Add failed, parameter cannot be empty",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
AgentUser dbuser = this.agentUserMapper.findByName(agentName);
|
if (dbuser != null) {
|
return ServerResponse.createByErrorMsg("Add failed, agent name already exists",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
AgentUser dbuser2 = this.agentUserMapper.findByPhone(agentPhone);
|
if (dbuser2 != null) {
|
return ServerResponse.createByErrorMsg("Failed to add, mobile phone number already exists",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
AgentUser agentUser = new AgentUser();
|
agentUser.setAgentName(agentName);
|
agentUser.setAgentPwd(SymmetricCryptoUtil.encryptPassword(agentPwd));
|
agentUser.setAgentCode(KeyUtils.getAgentUniqueKey());
|
agentUser.setAgentRealName(agentRealName);
|
agentUser.setAgentPhone(agentPhone);
|
agentUser.setAddTime(new Date());
|
agentUser.setIsLock(Integer.valueOf(0));
|
agentUser.setPoundageScale(new BigDecimal(poundageScale));
|
agentUser.setDeferredFeesScale(new BigDecimal(deferredFeesScale));
|
agentUser.setReceiveDividendsScale(new BigDecimal(receiveDividendsScale));
|
agentUser.setTotalMoney(new BigDecimal(0));
|
/*AgentUser currentAgent = getCurrentAgent(request);
|
agentUser.setParentId(currentAgent.getId());
|
agentUser.setParentName(currentAgent.getAgentName());*/
|
AgentUser parentAgent = this.agentUserMapper.selectByPrimaryKey(parentId);
|
if (parentId != null && parentId>0) {
|
if (parentAgent != null) {
|
if(parentAgent.getAgentLevel()>=6){
|
return ServerResponse.createByErrorMsg("Level 6 agents cannot add subordinates",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
agentUser.setParentId(parentAgent.getId());
|
agentUser.setParentName(parentAgent.getAgentName());
|
agentUser.setAgentLevel(parentAgent.getAgentLevel()+1);
|
} else {
|
//总代理默认0级
|
agentUser.setAgentLevel(Integer.valueOf(0));
|
agentUser.setParentId(Integer.valueOf(0));
|
}
|
} else {
|
//总代理默认0级
|
agentUser.setAgentLevel(Integer.valueOf(0));
|
agentUser.setParentId(Integer.valueOf(0));
|
}
|
|
int insertCount = 0;
|
try {
|
this.agentUserMapper.insert(agentUser);
|
insertCount = agentUser.getId();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
if (insertCount > 0) {
|
if (parentAgent != null) {
|
//分销用户数据处理
|
recursiveSaveAgentDistributionUser(insertCount,parentId,parentAgent.getAgentLevel());
|
}
|
return ServerResponse.createBySuccessMsg("Save proxy user successfully",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
return ServerResponse.createByErrorMsg("Add failed, please try again",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
//分销代理数据:循环添加
|
public int recursiveSaveAgentDistributionUser(int agentId, int parentId,int level){
|
int k = 0;
|
int pId = parentId;
|
for (int i = level; i >= 0; i--){
|
AgentUser parentAgent = this.agentUserMapper.selectByPrimaryKey(pId);
|
System.out.print("分销代理数据level="+i+"===parentid="+parentAgent.getParentId());
|
//分销用户数据处理
|
AgentDistributionUser agentDistributionUser = new AgentDistributionUser();
|
agentDistributionUser.setAgentId(agentId);
|
agentDistributionUser.setParentId(parentAgent.getId());
|
agentDistributionUser.setParentLevel(parentAgent.getAgentLevel());
|
iAgentDistributionUserService.insert(agentDistributionUser);
|
|
if (parentAgent.getParentId()==null){
|
pId = 0;
|
}else{
|
pId = parentAgent.getParentId();
|
|
}
|
k++;
|
}
|
return k;
|
}
|
|
|
public ServerResponse<PageInfo> getSecondAgent(int pageNum, int pageSize, HttpServletRequest request) {
|
Page<AgentSecondInfoVO> page = PageHelper.startPage(pageNum, pageSize);
|
AgentUser agentUser = getCurrentAgent(request);
|
if (agentUser ==null){
|
return ServerResponse.createByError("please log in first",null,request.getHeader(MessageLocaleResolver.LANG));
|
}
|
//log.info("======test=======" + agentUser.getId().toString());
|
List<AgentUser> agentUsers = this.agentUserMapper.getSecondAgent(agentUser.getId());
|
/*
|
List<AgentSecondInfoVO> agentSecondInfoVOS = Lists.newArrayList();
|
for (AgentUser agentUser1 : agentUsers) {
|
AgentSecondInfoVO agentSecondInfoVO = assembleAgentSecondInfoVO(agentUser1);
|
agentSecondInfoVOS.add(agentSecondInfoVO);
|
}*/
|
PageInfo pageInfo = new PageInfo(page);
|
pageInfo.setList(agentUsers);
|
return ServerResponse.createBySuccess(pageInfo);
|
}
|
|
/*查询代理所有上级*/
|
@Override
|
public List<AgentUser> getAgentSuperiorList(int agentId){
|
return this.agentUserMapper.getAgentSuperiorList(agentId);
|
}
|
|
public ServerResponse<PageInfo> listByAdmin(String realName, String phone, int pageNum, int pageSize, int id, HttpServletRequest request) {
|
Page<AgentUser> page = PageHelper.startPage(pageNum, pageSize);
|
|
this.agentUserMapper.listByAdmin(realName, phone, id);
|
PageInfo pageInfo = new PageInfo(page);
|
|
return ServerResponse.createBySuccess(pageInfo);
|
}
|
|
public ServerResponse add(AgentUser agentUser, HttpServletRequest request) {
|
if (StringUtils.isBlank(agentUser.getAgentName()) ||
|
StringUtils.isBlank(agentUser.getAgentPhone()) ||
|
StringUtils.isBlank(agentUser.getAgentRealName()) ||
|
StringUtils.isBlank(agentUser.getAgentPwd())) {
|
return ServerResponse.createByErrorMsg("Parameter cannot be empty",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
AgentUser pAgent = this.agentUserMapper.findByPhone(agentUser.getAgentPhone());
|
if (pAgent != null) {
|
return ServerResponse.createByErrorMsg("Mobile phone number already exists",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
AgentUser nameAgent = this.agentUserMapper.findByName(agentUser.getAgentName());
|
if (nameAgent != null) {
|
return ServerResponse.createByErrorMsg("Agent name already exists",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
AgentUser dbAgent = new AgentUser();
|
dbAgent.setAgentName(agentUser.getAgentName());
|
dbAgent.setAgentPwd(SymmetricCryptoUtil.encryptPassword(agentUser.getAgentPwd()));
|
dbAgent.setAgentPhone(agentUser.getAgentPhone());
|
dbAgent.setAgentRealName(agentUser.getAgentRealName());
|
dbAgent.setAddTime(new Date());
|
dbAgent.setIsLock(Integer.valueOf(0));
|
dbAgent.setAgentCode(KeyUtils.getAgentUniqueKey());
|
//AgentUser loginAgent = getCurrentAgent(request);
|
if (agentUser.getParentId() != null) {
|
AgentUser parentAgent = this.agentUserMapper.selectByPrimaryKey(agentUser.getParentId());
|
if (parentAgent != null) {
|
dbAgent.setParentId(parentAgent.getId());
|
dbAgent.setParentName(parentAgent.getAgentName());
|
dbAgent.setAgentLevel(parentAgent.getAgentLevel()+1);
|
} else {
|
//总代理默认0级
|
dbAgent.setAgentLevel(Integer.valueOf(0));
|
dbAgent.setParentId(Integer.valueOf(0));
|
}
|
}
|
|
int insertCount = this.agentUserMapper.insert(dbAgent);
|
if (insertCount > 0) {
|
return ServerResponse.createBySuccessMsg("Agent added successfully",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
return ServerResponse.createByErrorMsg("Failed to add proxy",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
|
public ServerResponse update(AgentUser agentUser,HttpServletRequest request) {
|
AgentUser dbAgent = new AgentUser();
|
|
if (StringUtils.isNotBlank(agentUser.getAgentName())) {
|
return ServerResponse.createByErrorMsg("Agent name cannot be changed",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
dbAgent.setId(agentUser.getId());
|
if (StringUtils.isNotBlank(agentUser.getAgentPwd())) {
|
dbAgent.setAgentPwd(SymmetricCryptoUtil.encryptPassword(agentUser.getAgentPwd()));
|
}
|
if (StringUtils.isNotBlank(agentUser.getAgentRealName())) {
|
dbAgent.setAgentRealName(agentUser.getAgentRealName());
|
}
|
if (StringUtils.isNotBlank(agentUser.getSiteLever())) {
|
dbAgent.setSiteLever(agentUser.getSiteLever());
|
}
|
if (StringUtils.isNotBlank(agentUser.getAgentPhone())) {
|
AgentUser phoneAgent = this.agentUserMapper.findByPhone(agentUser.getAgentPhone());
|
|
if (phoneAgent == null || phoneAgent.getId() == agentUser.getId()) {
|
dbAgent.setAgentPhone(agentUser.getAgentPhone());
|
} else {
|
return ServerResponse.createByErrorMsg("The mobile phone number already exists, please change your mobile phone",
|
request.getHeader(request.getHeader(MessageLocaleResolver.LANG)));
|
}
|
}
|
if (agentUser.getIsLock() != null) {
|
dbAgent.setIsLock(agentUser.getIsLock());
|
}
|
|
|
if (agentUser.getParentId() != null) {
|
|
AgentUser parentAgent = this.agentUserMapper.selectByPrimaryKey(agentUser.getParentId());
|
if (parentAgent != null) {
|
dbAgent.setParentId(parentAgent.getId());
|
dbAgent.setParentName(parentAgent.getAgentName());
|
}
|
}
|
|
int updateCount = this.agentUserMapper.updateByPrimaryKeySelective(dbAgent);
|
if (updateCount > 0) {
|
return ServerResponse.createBySuccessMsg("Modify proxy successfully",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
return ServerResponse.createByErrorMsg("Failed to modify proxy",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
public int CountAgentNum() {
|
return this.agentUserMapper.CountAgentNum();
|
}
|
|
|
private AgentSecondInfoVO assembleAgentSecondInfoVO(AgentUser agentUser) {
|
AgentSecondInfoVO agentSecondInfoVO = new AgentSecondInfoVO();
|
agentSecondInfoVO.setId(agentUser.getId());
|
agentSecondInfoVO.setAgentCode(agentUser.getAgentCode());
|
agentSecondInfoVO.setAgentName(agentUser.getAgentName());
|
agentSecondInfoVO.setAgentPhone(agentUser.getAgentPhone());
|
agentSecondInfoVO.setAgentRealName(agentUser.getAgentRealName());
|
return agentSecondInfoVO;
|
}
|
|
private AgentInfoVO assembleAgentInfoVO(AgentUser agentUser, String host) {
|
AgentInfoVO agentInfoVO = new AgentInfoVO();
|
agentInfoVO.setId(agentUser.getId());
|
agentInfoVO.setAgentName(agentUser.getAgentName());
|
agentInfoVO.setAgentRealName(agentUser.getAgentRealName());
|
agentInfoVO.setAgentPhone(agentUser.getAgentPhone());
|
agentInfoVO.setAgentCode(agentUser.getAgentCode());
|
agentInfoVO.setAddTime(agentUser.getAddTime());
|
agentInfoVO.setIsLock(agentUser.getIsLock());
|
agentInfoVO.setParentId(agentUser.getParentId());
|
agentInfoVO.setParentName(agentUser.getParentName());
|
agentInfoVO.setTotalMoney(agentUser.getTotalMoney());
|
|
String pcUrl = host + PropertiesUtil.getProperty("site.pc.reg.url") + agentUser.getAgentCode();
|
agentInfoVO.setPcUrl(pcUrl);
|
String mUrl = host + PropertiesUtil.getProperty("site.m.reg.url") + agentUser.getAgentCode();
|
agentInfoVO.setMUrl(mUrl);
|
return agentInfoVO;
|
}
|
|
/*代理账户扣款*/
|
@Transactional
|
public ServerResponse updateAgentAmt(Integer agentId, Integer amt, Integer direction,HttpServletRequest request) {
|
if (agentId == null || amt == null || direction == null) {
|
return ServerResponse.createByErrorMsg("Parameter cannot be empty",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
AgentUser agentUser = this.agentUserMapper.selectByPrimaryKey(agentId);
|
if (agentUser == null) {
|
return ServerResponse.createByErrorMsg("Agent does not exist",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
BigDecimal totalMoney = agentUser.getTotalMoney();//扣除前金额
|
BigDecimal back_amt = agentUser.getTotalMoney();//扣除后余额
|
BigDecimal deduct_amt = new BigDecimal(amt);//扣除金额
|
if (totalMoney==null){
|
totalMoney = new BigDecimal(0);
|
}
|
if (direction.intValue() == 0) {
|
|
} else if (direction.intValue() == 1) {
|
if (totalMoney.compareTo(new BigDecimal(amt)) < 0) {
|
return ServerResponse.createByErrorMsg("Deduction failed, total funds are insufficient",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
deduct_amt = deduct_amt.multiply(new BigDecimal(-1));
|
back_amt = back_amt.subtract(new BigDecimal(amt));
|
} else {
|
return ServerResponse.createByErrorMsg("This operation does not exist",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
//修改代理账户余额
|
AgentUser user = new AgentUser();
|
user.setId(agentUser.getId());
|
user.setTotalMoney(deduct_amt);
|
agentUserMapper.updateTotalMoney(user);
|
//利润明细增加
|
AgentAgencyFee agentAgencyFee = new AgentAgencyFee();
|
agentAgencyFee.setAgentId(agentUser.getId());
|
agentAgencyFee.setStatus(1);
|
agentAgencyFee.setAymentType(2);
|
agentAgencyFee.setBusinessId(0);
|
agentAgencyFee.setFeeType(0);
|
agentAgencyFee.setTotalMoney(deduct_amt);
|
agentAgencyFee.setProfitMoney(new BigDecimal(amt.intValue()));
|
agentAgencyFee.setRemarks("【提现支出】提现金额:"+amt);
|
iAgentAgencyFeeService.insert(agentAgencyFee);
|
|
|
SiteTaskLog siteTaskLog = new SiteTaskLog();
|
siteTaskLog.setTaskType("管理员修改代理金额");
|
StringBuffer cnt = new StringBuffer();
|
cnt.append("管理员修改代理金额 - ")
|
.append((direction.intValue() == 0) ? "入款" : "扣款")
|
.append(amt).append("元");
|
siteTaskLog.setTaskCnt(cnt.toString());
|
|
StringBuffer target = new StringBuffer();
|
target.append("代理id : ").append(agentUser.getId())
|
.append("修改前 总资金 = ").append(totalMoney)
|
.append("修改后 总资金 = ").append(back_amt);
|
siteTaskLog.setTaskTarget(target.toString());
|
|
siteTaskLog.setIsSuccess(Integer.valueOf(0));
|
siteTaskLog.setAddTime(new Date());
|
|
int insertCount = this.siteTaskLogMapper.insert(siteTaskLog);
|
if (insertCount > 0) {
|
return ServerResponse.createBySuccessMsg("Fund modification successful",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
return ServerResponse.createByErrorMsg("Failed to modify funds",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
/*删除代理*/
|
public ServerResponse delAgent(Integer agentId,HttpServletRequest request) {
|
AgentUser dbAgent = this.agentUserMapper.selectByPrimaryKey(agentId);
|
|
if (dbAgent == null) {
|
return ServerResponse.createByErrorMsg("The agent does not exist, please operate normally!",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
int updateCount = this.agentUserMapper.deleteByPrimaryKey(agentId);
|
if (updateCount > 0) {
|
return ServerResponse.createBySuccessMsg("Delete agent successfully",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
return ServerResponse.createByErrorMsg("Failed to delete agent",request.getHeader(MessageLocaleResolver.LANG));
|
}
|
|
@Override
|
public ServerResponse count(HttpServletRequest request) {
|
String loginToken = CookieUtils.readLoginToken(request, PropertiesUtil.getProperty("agent.cookie.name"));
|
String agentJson = RedisShardedPoolUtils.get(loginToken);
|
AgentUser agentUser = (AgentUser) JsonUtil.string2Obj(agentJson, AgentUser.class);
|
if (agentUser ==null){
|
return ServerResponse.createByError("please log in first",null,request.getHeader(MessageLocaleResolver.LANG));
|
}
|
AdminCountVO adminCountVO = new AdminCountVO();
|
|
|
//累计充值金额
|
BigDecimal charge_sum_amt = userRechargeMapper.agentCountChargeSumAmt(Integer.valueOf(1),agentUser.getId());
|
//今日充值金额
|
BigDecimal charge_today_sum_amt = userRechargeMapper.agentCountTotalRechargeAmountByTime(Integer.valueOf(1),agentUser.getId());
|
|
//累计提现金额
|
BigDecimal sp_withdraw_sum_amt_success =userWithdrawMapper.agentCountSpWithSumAmtByState(Integer.valueOf(1),agentUser.getId());
|
|
//今日提现金额
|
BigDecimal sp_withdraw_sum_today_amt_success = userWithdrawMapper.agentCountSpWithSumAmTodaytByState(Integer.valueOf(1),agentUser.getId());
|
|
/**
|
* 当天注册人数
|
* */
|
int regDayCount = userMapper.querySumTodayRegCount(agentUser.getId());
|
adminCountVO.setToDayRegCount(regDayCount);
|
List<UserRecharge> list = userRechargeMapper.queryDayFrist(agentUser.getId());
|
adminCountVO.setToDayFristRechargeCount(list.size());
|
adminCountVO.setToDayRechargeCount(list.size());
|
|
BigDecimal b = BigDecimal.ZERO;
|
|
for (int i = 0; i < list.size(); i++) {
|
b.add(list.get(i).getPayAmt());
|
}
|
adminCountVO.setToDayFristRechargeMoney(b);
|
adminCountVO.setCharge_sum_amt(charge_sum_amt);
|
adminCountVO.setCharge_today_sum_amt(charge_today_sum_amt);
|
adminCountVO.setSp_withdraw_sum_amt_success(sp_withdraw_sum_amt_success);
|
adminCountVO.setSp_withdraw_sum_today_amt_success(sp_withdraw_sum_today_amt_success);
|
|
return ServerResponse.createBySuccess(adminCountVO);
|
}
|
}
|