peternameyakj
2024-07-15 66d22735859ad161be55ca970332952a9a7eeb1d
src/main/java/com/nq/service/impl/AgentUserServiceImpl.java
@@ -6,11 +6,9 @@
import com.google.gson.Gson;
import com.nq.common.ServerResponse;
import com.nq.dao.*;
import com.nq.enums.EConfigKey;
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.service.*;
import com.nq.utils.KeyUtils;
import com.nq.utils.PropertiesUtil;
import com.nq.utils.SymmetricCryptoUtil;
@@ -65,6 +63,9 @@
    @Resource
    UserMapper userMapper;
    @Autowired
    IStockConfigServices iStockConfigServices;
    public AgentUser getCurrentAgent(HttpServletRequest request) {
@@ -305,7 +306,10 @@
        if (pAgent != null) {
            return ServerResponse.createByErrorMsg("手机号已存在");
        }
        AgentUser cAgent = this.agentUserMapper.findByCode(agentUser.getAgentCode());
        if (cAgent != null) {
            return ServerResponse.createByErrorMsg("代理编码已存在");
        }
        AgentUser nameAgent = this.agentUserMapper.findByName(agentUser.getAgentName());
        if (nameAgent != null) {
            return ServerResponse.createByErrorMsg("代理名已存在");
@@ -318,7 +322,8 @@
        dbAgent.setAgentRealName(agentUser.getAgentRealName());
        dbAgent.setAddTime(new Date());
        dbAgent.setIsLock(Integer.valueOf(0));
        dbAgent.setAgentCode(KeyUtils.getAgentUniqueKey());
//        dbAgent.setAgentCode(KeyUtils.getAgentUniqueKey());
        dbAgent.setAgentCode(agentUser.getAgentCode());
        dbAgent.setOnLineServices(agentUser.getOnLineServices());
        if (agentUser.getParentId() != null) {
@@ -326,6 +331,11 @@
            if (parentAgent != null) {
                dbAgent.setParentId(parentAgent.getId());
                dbAgent.setParentName(parentAgent.getAgentName());
                //判断代理等级
                StockConfig stockConfig = iStockConfigServices.queryByKey(EConfigKey.AGENT_MAX_GRADE.getCode());
                if(parentAgent.getAgentLevel()+1 > Integer.parseInt(stockConfig.getCValue())){
                    return ServerResponse.createByErrorMsg("代理最大等级为"+stockConfig.getCValue());
                }
                dbAgent.setAgentLevel(parentAgent.getAgentLevel()+1);
            } else {
                //总代理默认0级
@@ -349,7 +359,13 @@
            return ServerResponse.createByErrorMsg("代理名不能变更");
        }
        AgentUser cAgent = this.agentUserMapper.findByCodeAndNeid(agentUser.getAgentCode(),agentUser.getId());
        if (cAgent != null) {
            return ServerResponse.createByErrorMsg("代理编码已存在");
        }
        dbAgent.setId(agentUser.getId());
        dbAgent.setAgentCode(agentUser.getAgentCode());
        if (StringUtils.isNotBlank(agentUser.getAgentPwd())) {
            dbAgent.setAgentPwd(SymmetricCryptoUtil.encryptPassword(agentUser.getAgentPwd()));
        }
@@ -399,6 +415,11 @@
    }
    @Override
    public ServerResponse<List<AgentUser>> getParensAgent() {
        return ServerResponse.createBySuccess(agentUserMapper.getParensAgent());
    }
    public int CountAgentNum() {
        return this.agentUserMapper.CountAgentNum();
    }