From 725449edce99acdb3111f36d4b722eebbd22d41a Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 11 Jun 2020 20:14:50 +0800
Subject: [PATCH] finish add agent view
---
src/main/resources/templates/febs/views/modules/agent/agent.html | 312 ++++++++++++++++++++
src/main/java/com/xcong/excoin/modules/agent/entity/MemberEntity.java | 2
src/main/java/com/xcong/excoin/system/mapper/UserMapper.java | 13
src/main/java/com/xcong/excoin/modules/agent/service/IAgentService.java | 16 +
src/main/java/com/xcong/excoin/modules/agent/controller/ViewController.java | 36 ++
src/main/resources/mapper/modules/AgentFriendRelationMapper.xml | 5
src/main/java/com/xcong/excoin/modules/agent/mapper/AgentFriendRelationMapper.java | 11
src/main/java/com/xcong/excoin/system/entity/User.java | 12
src/main/resources/static/febs/lay/modules/febs.js | 3
src/main/java/com/xcong/excoin/modules/agent/mapper/MemberMapper.java | 6
src/main/java/com/xcong/excoin/modules/agent/service/impl/AgentServiceImpl.java | 89 +++++
src/main/resources/mapper/modules/MemberMapper.xml | 10
src/main/resources/templates/febs/views/modules/agent/agentAdd.html | 77 +++++
src/main/java/com/xcong/excoin/modules/agent/controller/MemberController.java | 6
src/main/java/com/xcong/excoin/modules/agent/pojo/AgentUser.java | 92 ++++++
/dev/null | 23 -
src/main/resources/static/febs/lay/modules/validate.js | 8
src/main/java/com/xcong/excoin/modules/agent/service/impl/MemberServiceImpl.java | 10
src/main/java/com/xcong/excoin/modules/agent/entity/AgentFriendRelationEntity.java | 64 ++++
src/main/resources/mapper/system/UserMapper.xml | 34 ++
src/main/java/com/xcong/excoin/modules/agent/service/IMemberService.java | 4
src/main/resources/templates/febs/views/modules/agent/member.html | 0
src/main/java/com/xcong/excoin/common/entity/FebsConstant.java | 8
src/main/java/com/xcong/excoin/modules/agent/controller/AgentController.java | 48 +++
24 files changed, 849 insertions(+), 40 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/common/entity/FebsConstant.java b/src/main/java/com/xcong/excoin/common/entity/FebsConstant.java
index bdcdc91..ad0edd1 100644
--- a/src/main/java/com/xcong/excoin/common/entity/FebsConstant.java
+++ b/src/main/java/com/xcong/excoin/common/entity/FebsConstant.java
@@ -51,4 +51,12 @@
* Windows 操作系统
*/
String SYSTEM_WINDOWS = "windows";
+
+ String USER_TYPE_ADMIN = "admin";
+
+ String USER_TYPE_AGENT = "agent";
+
+ String SYSTEM_AGENT = "agent";
+
+ String DEFAULT_REFERER_ID = "rxadr3";
}
diff --git a/src/main/java/com/xcong/excoin/modules/agent/controller/AgentController.java b/src/main/java/com/xcong/excoin/modules/agent/controller/AgentController.java
new file mode 100644
index 0000000..ddeacb2
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/agent/controller/AgentController.java
@@ -0,0 +1,48 @@
+package com.xcong.excoin.modules.agent.controller;
+
+import com.xcong.excoin.common.controller.BaseController;
+import com.xcong.excoin.common.entity.FebsResponse;
+import com.xcong.excoin.common.entity.QueryRequest;
+import com.xcong.excoin.modules.agent.pojo.AgentUser;
+import com.xcong.excoin.modules.agent.service.IAgentService;
+import com.xcong.excoin.system.entity.User;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.validation.Valid;
+import java.util.Map;
+
+/**
+ * @author wzy
+ * @date 2020-06-11
+ **/
+@Slf4j
+@Validated
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/agent")
+public class AgentController extends BaseController {
+
+ private final IAgentService agentService;
+
+ @GetMapping("getList")
+ @RequiresPermissions("agent:view")
+ public FebsResponse getList(AgentUser agentUser, QueryRequest queryRequest) {
+ Map<String, Object> map = getDataTable(agentService.findAgentList(agentUser, queryRequest));
+ return new FebsResponse().success().data(map);
+ }
+
+ @PostMapping("add")
+ @RequiresPermissions("agent:add")
+ public FebsResponse add(@Valid AgentUser agentUser) {
+ User user = getCurrentUser();
+ agentService.addAgent(agentUser, user);
+ return new FebsResponse().success();
+ }
+}
diff --git a/src/main/java/com/xcong/excoin/modules/member/controller/MemberController.java b/src/main/java/com/xcong/excoin/modules/agent/controller/MemberController.java
similarity index 85%
rename from src/main/java/com/xcong/excoin/modules/member/controller/MemberController.java
rename to src/main/java/com/xcong/excoin/modules/agent/controller/MemberController.java
index d0002ee..70a3d5f 100644
--- a/src/main/java/com/xcong/excoin/modules/member/controller/MemberController.java
+++ b/src/main/java/com/xcong/excoin/modules/agent/controller/MemberController.java
@@ -1,10 +1,10 @@
-package com.xcong.excoin.modules.member.controller;
+package com.xcong.excoin.modules.agent.controller;
import com.xcong.excoin.common.controller.BaseController;
import com.xcong.excoin.common.entity.FebsResponse;
import com.xcong.excoin.common.entity.QueryRequest;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.modules.member.service.IMemberService;
+import com.xcong.excoin.modules.agent.entity.MemberEntity;
+import com.xcong.excoin.modules.agent.service.IMemberService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
diff --git a/src/main/java/com/xcong/excoin/modules/agent/controller/ViewController.java b/src/main/java/com/xcong/excoin/modules/agent/controller/ViewController.java
new file mode 100644
index 0000000..57a68ed
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/agent/controller/ViewController.java
@@ -0,0 +1,36 @@
+package com.xcong.excoin.modules.agent.controller;
+
+import com.xcong.excoin.common.entity.FebsConstant;
+import com.xcong.excoin.common.utils.FebsUtil;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * @author wzy
+ * @date 2020-06-10
+ **/
+@Controller("memberView")
+@RequestMapping(FebsConstant.VIEW_PREFIX + "/agent")
+public class ViewController {
+
+ @GetMapping("member")
+ @RequiresPermissions("amember:view")
+ public String member() {
+ return FebsUtil.view("modules/agent/member");
+ }
+
+
+ @GetMapping("agent")
+ @RequiresPermissions("agent:view")
+ public String agent() {
+ return FebsUtil.view("modules/agent/agent");
+ }
+
+ @GetMapping("agentAdd")
+ @RequiresPermissions("agent:add")
+ public String agentAdd() {
+ return FebsUtil.view("modules/agent/agentAdd");
+ }
+}
diff --git a/src/main/java/com/xcong/excoin/modules/agent/entity/AgentFriendRelationEntity.java b/src/main/java/com/xcong/excoin/modules/agent/entity/AgentFriendRelationEntity.java
new file mode 100644
index 0000000..b690032
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/agent/entity/AgentFriendRelationEntity.java
@@ -0,0 +1,64 @@
+package com.xcong.excoin.modules.agent.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.xcong.excoin.common.entity.BaseEntity;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wzy
+ * @date 2020-06-11
+ **/
+@Slf4j
+@Data
+@TableName("agent_friend_relation")
+public class AgentFriendRelationEntity extends BaseEntity {
+
+ /**
+ * 后台用户ID
+ */
+ private Long userId;
+
+ /**
+ * 会员ID
+ */
+ private Long memberId;
+
+ /**
+ * 邀请码
+ */
+ private String inviteId;
+
+ /**
+ * 上级代理用户ID
+ */
+ private Long refererMemberId;
+
+ /**
+ * 上级代理邀请码
+ */
+ private String refererId;
+
+ /**
+ * 上级邀请码链
+ */
+ private String refererIds;
+
+ /**
+ * 返佣比例
+ */
+ private BigDecimal returnRatio;
+
+ /**
+ * 代理层级
+ */
+ private Integer leverId;
+
+ /**
+ * 手续费是否设置自己
+ */
+ private Integer feeIsSelf;
+
+}
diff --git a/src/main/java/com/xcong/excoin/modules/member/entity/MemberEntity.java b/src/main/java/com/xcong/excoin/modules/agent/entity/MemberEntity.java
similarity index 98%
rename from src/main/java/com/xcong/excoin/modules/member/entity/MemberEntity.java
rename to src/main/java/com/xcong/excoin/modules/agent/entity/MemberEntity.java
index c259a34..0db13c1 100644
--- a/src/main/java/com/xcong/excoin/modules/member/entity/MemberEntity.java
+++ b/src/main/java/com/xcong/excoin/modules/agent/entity/MemberEntity.java
@@ -1,4 +1,4 @@
-package com.xcong.excoin.modules.member.entity;
+package com.xcong.excoin.modules.agent.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
diff --git a/src/main/java/com/xcong/excoin/modules/agent/mapper/AgentFriendRelationMapper.java b/src/main/java/com/xcong/excoin/modules/agent/mapper/AgentFriendRelationMapper.java
new file mode 100644
index 0000000..38b4369
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/agent/mapper/AgentFriendRelationMapper.java
@@ -0,0 +1,11 @@
+package com.xcong.excoin.modules.agent.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xcong.excoin.modules.agent.entity.AgentFriendRelationEntity;
+
+/**
+ * @author helius
+ */
+public interface AgentFriendRelationMapper extends BaseMapper<AgentFriendRelationEntity> {
+}
diff --git a/src/main/java/com/xcong/excoin/modules/member/mapper/MemberMapper.java b/src/main/java/com/xcong/excoin/modules/agent/mapper/MemberMapper.java
similarity index 65%
rename from src/main/java/com/xcong/excoin/modules/member/mapper/MemberMapper.java
rename to src/main/java/com/xcong/excoin/modules/agent/mapper/MemberMapper.java
index 788d97b..b433991 100644
--- a/src/main/java/com/xcong/excoin/modules/member/mapper/MemberMapper.java
+++ b/src/main/java/com/xcong/excoin/modules/agent/mapper/MemberMapper.java
@@ -1,9 +1,9 @@
-package com.xcong.excoin.modules.member.mapper;
+package com.xcong.excoin.modules.agent.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
+import com.xcong.excoin.modules.agent.entity.MemberEntity;
import org.apache.ibatis.annotations.Param;
/**
@@ -13,4 +13,6 @@
public interface MemberMapper extends BaseMapper<MemberEntity> {
IPage<MemberEntity> selectMemberListInPage(Page<MemberEntity> page, @Param("record") MemberEntity memberEntity);
+
+ MemberEntity selectMemberByInviteIdAndRefererId(@Param("inviteId") String inviteId, @Param("refererId") String refererId);
}
diff --git a/src/main/java/com/xcong/excoin/modules/agent/pojo/AgentUser.java b/src/main/java/com/xcong/excoin/modules/agent/pojo/AgentUser.java
new file mode 100644
index 0000000..cc6d289
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/agent/pojo/AgentUser.java
@@ -0,0 +1,92 @@
+package com.xcong.excoin.modules.agent.pojo;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author wzy
+ * @date 2020-06-11
+ **/
+@Data
+public class AgentUser {
+
+ /**
+ * 后台用户主键ID
+ */
+ private Long id;
+
+ /**
+ * 代理姓名
+ */
+ @NotBlank(message = "代理姓名不能为空")
+ private String name;
+
+ /**
+ * 代理账号
+ */
+ @NotBlank(message = "代理账号不能为空")
+ private String account;
+
+ /**
+ * 邀请码
+ */
+ @NotBlank(message = "邀请码不能为空")
+ private String inviteId;
+
+ /**
+ * 手机号
+ */
+ @NotBlank(message = "手机号不能为空")
+ private String telphone;
+
+ /**
+ * 邮箱
+ */
+ private String email;
+
+ /**
+ * 上级邀请码
+ */
+ private String referId;
+
+ /**
+ * 发展代理数
+ */
+ private Integer childCnt;
+
+ /**
+ * 充值总数
+ */
+ private BigDecimal chargeTotal;
+
+ /**
+ * 提现总数
+ */
+ private BigDecimal cashOutTotal;
+
+ /**
+ * 佣金返现
+ */
+ private BigDecimal returnTotal;
+
+ /**
+ * 返佣比例
+ */
+ @NotNull(message = "返佣比例不能为空")
+ private BigDecimal returnRatio;
+
+ /**
+ * 状态
+ */
+ private Integer status;
+
+ /**
+ * 创建时间
+ */
+ private Date createTime;
+
+}
diff --git a/src/main/java/com/xcong/excoin/modules/agent/service/IAgentService.java b/src/main/java/com/xcong/excoin/modules/agent/service/IAgentService.java
new file mode 100644
index 0000000..330391d
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/agent/service/IAgentService.java
@@ -0,0 +1,16 @@
+package com.xcong.excoin.modules.agent.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.xcong.excoin.common.entity.QueryRequest;
+import com.xcong.excoin.modules.agent.pojo.AgentUser;
+import com.xcong.excoin.system.entity.User;
+
+/**
+ * @author helius
+ */
+public interface IAgentService {
+
+ IPage<AgentUser> findAgentList(AgentUser agentUser, QueryRequest request);
+
+ void addAgent(AgentUser agentUser, User user);
+}
diff --git a/src/main/java/com/xcong/excoin/modules/member/service/IMemberService.java b/src/main/java/com/xcong/excoin/modules/agent/service/IMemberService.java
similarity index 76%
rename from src/main/java/com/xcong/excoin/modules/member/service/IMemberService.java
rename to src/main/java/com/xcong/excoin/modules/agent/service/IMemberService.java
index 4b0a602..820e9af 100644
--- a/src/main/java/com/xcong/excoin/modules/member/service/IMemberService.java
+++ b/src/main/java/com/xcong/excoin/modules/agent/service/IMemberService.java
@@ -1,9 +1,9 @@
-package com.xcong.excoin.modules.member.service;
+package com.xcong.excoin.modules.agent.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xcong.excoin.common.entity.QueryRequest;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
+import com.xcong.excoin.modules.agent.entity.MemberEntity;
/**
* @author helius
diff --git a/src/main/java/com/xcong/excoin/modules/agent/service/impl/AgentServiceImpl.java b/src/main/java/com/xcong/excoin/modules/agent/service/impl/AgentServiceImpl.java
new file mode 100644
index 0000000..c54e672
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/agent/service/impl/AgentServiceImpl.java
@@ -0,0 +1,89 @@
+package com.xcong.excoin.modules.agent.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.xcong.excoin.common.entity.FebsConstant;
+import com.xcong.excoin.common.entity.QueryRequest;
+import com.xcong.excoin.common.exception.FebsException;
+import com.xcong.excoin.common.utils.Md5Util;
+import com.xcong.excoin.modules.agent.entity.AgentFriendRelationEntity;
+import com.xcong.excoin.modules.agent.entity.MemberEntity;
+import com.xcong.excoin.modules.agent.mapper.AgentFriendRelationMapper;
+import com.xcong.excoin.modules.agent.mapper.MemberMapper;
+import com.xcong.excoin.modules.agent.pojo.AgentUser;
+import com.xcong.excoin.modules.agent.service.IAgentService;
+import com.xcong.excoin.system.entity.User;
+import com.xcong.excoin.system.mapper.UserMapper;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+
+/**
+ * @author wzy
+ * @date 2020-06-11
+ **/
+@Slf4j
+@RequiredArgsConstructor
+@Service
+public class AgentServiceImpl implements IAgentService {
+
+ private final UserMapper userMapper;
+
+ private final MemberMapper memberMapper;
+
+ private final AgentFriendRelationMapper agentFriendRelationMapper;
+
+ @Override
+ public IPage<AgentUser> findAgentList(AgentUser agentUser, QueryRequest request) {
+ Page<AgentUser> page = new Page<>(request.getPageNum(), request.getPageSize());
+ return userMapper.selectAgentUserList(page, agentUser);
+ }
+
+ @Override
+ public void addAgent(AgentUser agentUser, User user) {
+ AgentFriendRelationEntity agentFriendRelation = new AgentFriendRelationEntity();
+ String refererId = "";
+ if (FebsConstant.USER_TYPE_ADMIN.equals(user.getType())) {
+ refererId = FebsConstant.DEFAULT_REFERER_ID;
+ } else {
+ refererId = user.getInviteId();
+ }
+ MemberEntity memberEntity = memberMapper.selectMemberByInviteIdAndRefererId(agentUser.getInviteId(), refererId);
+ if (memberEntity == null) {
+ throw new FebsException("UID不存在或不是本用户下级代理");
+ }
+
+ User exsit = userMapper.selectUserByInviteId(agentUser.getInviteId());
+ if (exsit != null) {
+ throw new FebsException("该用户已存在");
+ }
+
+ User addUser = new User();
+ addUser.setUsername(agentUser.getAccount());
+ addUser.setStatus(User.STATUS_VALID);
+ addUser.setAvatar(User.DEFAULT_AVATAR);
+ addUser.setTheme(User.THEME_WHITE);
+ addUser.setIsTab(User.TAB_OPEN);
+ addUser.setType(FebsConstant.USER_TYPE_AGENT);
+ addUser.setSystem(FebsConstant.SYSTEM_AGENT);
+ addUser.setCreateTime(new Date());
+ addUser.setInviteId(agentUser.getInviteId());
+ addUser.setAgentName(agentUser.getName());
+ addUser.setPassword(Md5Util.encrypt(user.getUsername(), User.DEFAULT_PASSWORD));
+ userMapper.insert(user);
+
+ agentFriendRelation.setInviteId(agentUser.getInviteId());
+ agentFriendRelation.setRefererId(refererId);
+ agentFriendRelation.setRefererIds(memberEntity.getRefererIds());
+ agentFriendRelation.setMemberId(memberEntity.getId());
+ agentFriendRelation.setReturnRatio(agentUser.getReturnRatio());
+ agentFriendRelation.setUserId(user.getUserId());
+ agentFriendRelation.setCreateBy(user.getUsername());
+ agentFriendRelation.setCreateTime(new Date());
+ agentFriendRelation.setUpdateBy(user.getUsername());
+ agentFriendRelation.setUpdateTime(new Date());
+ agentFriendRelationMapper.insert(agentFriendRelation);
+ }
+}
diff --git a/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java b/src/main/java/com/xcong/excoin/modules/agent/service/impl/MemberServiceImpl.java
similarity index 74%
rename from src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java
rename to src/main/java/com/xcong/excoin/modules/agent/service/impl/MemberServiceImpl.java
index 332c400..a9de188 100644
--- a/src/main/java/com/xcong/excoin/modules/member/service/impl/MemberServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/agent/service/impl/MemberServiceImpl.java
@@ -1,15 +1,13 @@
-package com.xcong.excoin.modules.member.service.impl;
+package com.xcong.excoin.modules.agent.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcong.excoin.common.entity.QueryRequest;
-import com.xcong.excoin.modules.member.entity.MemberEntity;
-import com.xcong.excoin.modules.member.mapper.MemberMapper;
-import com.xcong.excoin.modules.member.service.IMemberService;
+import com.xcong.excoin.modules.agent.entity.MemberEntity;
+import com.xcong.excoin.modules.agent.mapper.MemberMapper;
+import com.xcong.excoin.modules.agent.service.IMemberService;
import org.springframework.stereotype.Service;
-
-import java.util.Map;
/**
* @author wzy
diff --git a/src/main/java/com/xcong/excoin/modules/member/controller/ViewController.java b/src/main/java/com/xcong/excoin/modules/member/controller/ViewController.java
deleted file mode 100644
index c7e9b55..0000000
--- a/src/main/java/com/xcong/excoin/modules/member/controller/ViewController.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.xcong.excoin.modules.member.controller;
-
-import com.xcong.excoin.common.entity.FebsConstant;
-import com.xcong.excoin.common.utils.FebsUtil;
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-/**
- * @author wzy
- * @date 2020-06-10
- **/
-@Controller("memberView")
-@RequestMapping(FebsConstant.VIEW_PREFIX + "modules/member")
-public class ViewController {
-
- @GetMapping("member")
- @RequiresPermissions("member:view")
- public String member() {
- return FebsUtil.view("modules/member/member");
- }
-}
diff --git a/src/main/java/com/xcong/excoin/system/entity/User.java b/src/main/java/com/xcong/excoin/system/entity/User.java
index e612617..c68b9ec 100644
--- a/src/main/java/com/xcong/excoin/system/entity/User.java
+++ b/src/main/java/com/xcong/excoin/system/entity/User.java
@@ -183,6 +183,18 @@
@ExcelField(value = "个人描述")
private String description;
+ @TableField("SYSTEM")
+ private String system;
+
+ @TableField("TYPE")
+ private String type;
+
+ @TableField("INVITE_ID")
+ private String inviteId;
+
+ @TableField("AGENT_NAME")
+ private String agentName;
+
/**
* 部门名称
*/
diff --git a/src/main/java/com/xcong/excoin/system/mapper/UserMapper.java b/src/main/java/com/xcong/excoin/system/mapper/UserMapper.java
index 71c75b4..0fb90e2 100644
--- a/src/main/java/com/xcong/excoin/system/mapper/UserMapper.java
+++ b/src/main/java/com/xcong/excoin/system/mapper/UserMapper.java
@@ -1,5 +1,6 @@
package com.xcong.excoin.system.mapper;
+import com.xcong.excoin.modules.agent.pojo.AgentUser;
import com.xcong.excoin.system.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -40,4 +41,16 @@
*/
List<User> findUserDetail(@Param("user") User user);
+ /**
+ * 获取代理商列表
+ *
+ * @param page
+ * @param agentUser
+ * @param <T>
+ * @return
+ */
+ IPage<AgentUser> selectAgentUserList(Page<AgentUser> page,@Param("record") AgentUser agentUser);
+
+ User selectUserByInviteId(@Param("inviteId") String inviteId);
+
}
diff --git a/src/main/resources/mapper/modules/AgentFriendRelationMapper.xml b/src/main/resources/mapper/modules/AgentFriendRelationMapper.xml
new file mode 100644
index 0000000..a86b18c
--- /dev/null
+++ b/src/main/resources/mapper/modules/AgentFriendRelationMapper.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.xcong.excoin.modules.agent.mapper.AgentFriendRelationMapper">
+
+</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/modules/MemberMapper.xml b/src/main/resources/mapper/modules/MemberMapper.xml
index 380a747..99a3e52 100644
--- a/src/main/resources/mapper/modules/MemberMapper.xml
+++ b/src/main/resources/mapper/modules/MemberMapper.xml
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.xcong.excoin.modules.member.mapper.MemberMapper">
+<mapper namespace="com.xcong.excoin.modules.agent.mapper.MemberMapper">
- <select id="selectMemberListInPage" resultType="com.xcong.excoin.modules.member.entity.MemberEntity">
+ <select id="selectMemberListInPage" resultType="com.xcong.excoin.modules.agent.entity.MemberEntity">
select * from member
<where>
<if test="record != null" >
@@ -30,4 +30,10 @@
order by create_time desc
</select>
+
+ <select id="selectMemberByInviteIdAndRefererId" resultType="com.xcong.excoin.modules.agent.entity.MemberEntity">
+ select * from member
+ where invite_id=#{inviteId} and referer_id=#{refererId}
+ </select>
+
</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/system/UserMapper.xml b/src/main/resources/mapper/system/UserMapper.xml
index b7838c0..363a17d 100644
--- a/src/main/resources/mapper/system/UserMapper.xml
+++ b/src/main/resources/mapper/system/UserMapper.xml
@@ -44,6 +44,10 @@
u.modify_time modifyTime,
u.description,
u.avatar,
+ u.invite_id,
+ u.system,
+ u.type,
+ u.agent_name,
d.dept_name deptName,
GROUP_CONCAT(r.role_id) roleId,
GROUP_CONCAT(r.ROLE_NAME) roleName
@@ -86,7 +90,11 @@
u.last_login_time,
u.modify_time,
u.description,
- u.avatar
+ u.avatar,
+ u.invite_id,
+ u.system,
+ u.type,
+ u.agent_name,
</sql>
<select id="countUserDetail" parameterType="user" resultType="long">
@@ -116,6 +124,10 @@
u.modify_time modifyTime,
u.description,
u.avatar,
+ u.invite_id,
+ u.system,
+ u.type,
+ u.agent_name,
u.theme,
u.is_tab isTab,
d.dept_name deptName,
@@ -141,6 +153,10 @@
u.modify_time,
u.description,
u.avatar,
+ u.invite_id,
+ u.system,
+ u.type,
+ u.agent_name,
u.theme,
u.is_tab
</select>
@@ -149,4 +165,20 @@
select user_id userId, dept_id deptId from t_user_data_permission
where user_id = #{userId}
</select>
+
+ <select id="selectAgentUserList" resultType="com.xcong.excoin.modules.agent.pojo.AgentUser">
+ select *
+ from t_user a
+ inner join agent_friend_relation b on a.user_id = b.user_id
+ inner join member c on b.member_id = c.id
+ <if test="record != null">
+ <where>
+
+ </where>
+ </if>
+ </select>
+
+ <select id="selectUserByInviteId" resultType="user">
+ select * from t_user where invite_id=#{inviteId}
+ </select>
</mapper>
diff --git a/src/main/resources/static/febs/lay/modules/febs.js b/src/main/resources/static/febs/lay/modules/febs.js
index bbac870..9aaee98 100644
--- a/src/main/resources/static/febs/lay/modules/febs.js
+++ b/src/main/resources/static/febs/lay/modules/febs.js
@@ -540,6 +540,9 @@
"count": res.data.total,
"data": res.data.rows
}
+ },
+ done: function(res, curr, count) {
+ count || this.elem.next('.layui-table-view').find('.layui-table-header').css('overflow', 'auto');
}
};
return layuiTable.render(
diff --git a/src/main/resources/static/febs/lay/modules/validate.js b/src/main/resources/static/febs/lay/modules/validate.js
index 452e8a5..c86ad1e 100644
--- a/src/main/resources/static/febs/lay/modules/validate.js
+++ b/src/main/resources/static/febs/lay/modules/validate.js
@@ -78,6 +78,14 @@
return '长度范围 ' + minlength + ' ~ ' + maxlength + ' 个字符';
}
}
+ },
+ slot: function (value) {
+ if (!isEmpty(value)) {
+ console.log(new RegExp("^0\\.\\d{2}$").test(value))
+ if (!new RegExp("^0\\.\\d{2}$").test(value)) {
+ return '保留两位小数';
+ }
+ }
}
});
diff --git a/src/main/resources/templates/febs/views/modules/agent/agent.html b/src/main/resources/templates/febs/views/modules/agent/agent.html
new file mode 100644
index 0000000..db21149
--- /dev/null
+++ b/src/main/resources/templates/febs/views/modules/agent/agent.html
@@ -0,0 +1,312 @@
+<div class="layui-fluid layui-anim febs-anim" id="febs-user" lay-title="代理商列表">
+ <div class="layui-row febs-container">
+ <div class="layui-col-md12">
+ <div class="layui-card">
+ <div class="layui-card-body febs-table-full">
+ <form class="layui-form layui-table-form" lay-filter="user-table-form">
+ <div class="layui-row">
+ <div class="layui-col-md10">
+ <div class="layui-form-item">
+ <div class="layui-inline">
+ <div class="layui-input-inline">
+ <input type="text" placeholder="手机号/邮箱/邀请码" name="account" autocomplete="off" class="layui-input">
+ </div>
+ </div>
+ <div class="layui-inline">
+ <label class="layui-form-label layui-form-label-sm">创建时间</label>
+ <div class="layui-input-inline">
+ <input type="text" name="createTime" id="user-createTime" class="layui-input">
+ </div>
+ </div>
+ <div class="layui-inline">
+ <label class="layui-form-label layui-form-label-sm">账号类型</label>
+ <div class="layui-input-inline">
+ <select name="accountType">
+ <option value=""></option>
+ <option value="1">测试账号</option>
+ <option value="2">正常账号</option>
+ </select>
+ </div>
+ </div>
+ <div class="layui-inline">
+ <label class="layui-form-label layui-form-label-sm">账号状态</label>
+ <div class="layui-input-inline">
+ <select name="accountStatus">
+ <option value=""></option>
+ <option value="0">禁用</option>
+ <option value="1">正常</option>
+ </select>
+ </div>
+ </div>
+ <div class="layui-inline">
+ <label class="layui-form-label layui-form-label-sm">实名状态</label>
+ <div class="layui-input-inline">
+ <select name="certifyStatus">
+ <option value=""></option>
+ <option value="0">未通过</option>
+ <option value="1">审核中</option>
+ <option value="2">审核通过</option>
+ <option value="2">未实名</option>
+ </select>
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area">
+ <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query">
+ <i class="layui-icon"></i>
+ </div>
+ <div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset">
+ <i class="layui-icon"></i>
+ </div>
+ <div class="layui-btn layui-btn-sm layui-btn-primary table-action action-more"
+ shiro:hasAnyPermissions="user:add,user:update,user:password:reset,user:export">
+ <i class="layui-icon"></i>
+ </div>
+ </div>
+ </div>
+ </form>
+ <table lay-filter="userTable" lay-data="{id: 'userTable'}"></table>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+<!-- 表格字段状态格式化 start -->
+<script type="text/html" id="certify-status">
+ {{#
+ var certifyStatus = {
+ 0: {title: '未通过', color: 'red'},
+ 1: {title: '审核中', color: 'blue'},
+ 2: {title: '审核通过', color: 'green'},
+ 3: {title: '未实名', color: 'cyan'}
+ }[d.certifyStatus];
+ }}
+ <span class="layui-badge febs-tag-{{certifyStatus.color}}">{{ certifyStatus.title }}</span>
+</script>
+<script type="text/html" id="account-status">
+ {{#
+ var accountStatus = {
+ 1: {title: '正常', color : 'blue'},
+ 0: {title: '禁用', color : 'red'}
+ }[d.status];
+ }}
+ <span class="layui-badge febs-bg-{{accountStatus.color}}">{{ accountStatus.title }}</span>
+</script>
+<!-- 表格字段状态格式化 start -->
+
+<!-- 表格操作栏 start -->
+<script type="text/html" id="user-option">
+ <span shiro:lacksPermission="agent:view,agent:edit,agent:del">
+ <span class="layui-badge-dot febs-bg-orange"></span> 无权限
+ </span>
+ <a lay-event="detail" shiro:hasPermission="agent:view"><i
+ class="layui-icon febs-edit-area febs-green"></i></a>
+ <a lay-event="edit" shiro:hasPermission="agent:edit"><i
+ class="layui-icon febs-edit-area febs-blue"></i></a>
+ <a lay-event="del" shiro:hasPermission="agent:del"><i class="layui-icon febs-edit-area febs-red"></i></a>
+</script>
+<!-- 表格操作栏 end -->
+<script data-th-inline="none" type="text/javascript">
+ // 引入组件并初始化
+ layui.use(['dropdown', 'jquery', 'laydate', 'form', 'table', 'febs', 'treeSelect'], function () {
+ var $ = layui.jquery,
+ laydate = layui.laydate,
+ febs = layui.febs,
+ form = layui.form,
+ table = layui.table,
+ treeSelect = layui.treeSelect,
+ dropdown = layui.dropdown,
+ $view = $('#febs-user'),
+ $query = $view.find('#query'),
+ $reset = $view.find('#reset'),
+ $searchForm = $view.find('form'),
+ sortObject = {field: 'createTime', type: null},
+ tableIns,
+ createTimeFrom,
+ createTimeTo;
+
+ form.render();
+
+ // 表格初始化
+ initTable();
+
+ // 时间组件
+ laydate.render({
+ elem: '#user-createTime',
+ range: true,
+ trigger: 'click'
+ });
+
+ // 新增下拉组件
+ dropdown.render({
+ elem: $view.find('.action-more'),
+ click: function (name, elem, event) {
+ var checkStatus = table.checkStatus('userTable');
+ if (name === 'add') {
+ febs.modal.open('新增用户', 'agent/agentAdd', {
+ btn: ['提交', '重置'],
+ area: $(window).width() <= 750 ? '95%' : '50%',
+ offset: '30px',
+ yes: function (index, layero) {
+ $('#user-add').find('#submit').trigger('click');
+ },
+ btn2: function () {
+ $('#user-add').find('#reset').trigger('click');
+ return false;
+ }
+ });
+ }
+ if (name === 'delete') {
+ if (!checkStatus.data.length) {
+ febs.alert.warn('请选择需要删除的用户');
+ } else {
+ febs.modal.confirm('删除用户', '确定删除该用户?', function () {
+ var userIds = [];
+ layui.each(checkStatus.data, function (key, item) {
+ userIds.push(item.userId)
+ });
+ deleteUsers(userIds.join(','));
+ });
+ }
+ }
+ if (name === 'reset') {
+ if (!checkStatus.data.length) {
+ febs.alert.warn('请选择需要重置密码的用户');
+ } else {
+ var usernames = [];
+ layui.each(checkStatus.data, function (key, item) {
+ usernames.push(item.username)
+ });
+ febs.post(ctx + 'user/password/reset/' + usernames.join(','), null, function () {
+ febs.alert.success('所选用户密码已重置为1234qwer');
+ });
+ }
+ }
+ },
+ options: [{
+ name: 'add',
+ title: '新增代理商',
+ perms: 'agent:add'
+ }, {
+ name: 'delete',
+ title: '删除代理商',
+ perms: 'agent:del'
+ }, {
+ name: 'reset',
+ title: '密码重置',
+ perms: 'agent:password:reset'
+ }]
+ });
+
+ // 下拉框选择器
+ treeSelect.render({
+ elem: $view.find('#dept'),
+ type: 'get',
+ data: ctx + 'dept/select/tree',
+ placeholder: '请选择',
+ search: false
+ });
+
+ // 初始化表格操作栏各个按钮功能
+ table.on('tool(userTable)', function (obj) {
+ var data = obj.data,
+ layEvent = obj.event;
+ if (layEvent === 'detail') {
+ febs.modal.view('用户信息', 'system/user/detail/' + data.username, {
+ area: $(window).width() <= 750 ? '95%' : '660px'
+ });
+ }
+ if (layEvent === 'del') {
+ febs.modal.confirm('删除用户', '确定删除该用户?', function () {
+ deleteUsers(data.userId);
+ });
+ }
+ if (layEvent === 'edit') {
+ febs.modal.open('修改用户', 'system/user/update/' + data.username, {
+ area: $(window).width() <= 750 ? '90%' : '50%',
+ offset: '30px',
+ btn: ['提交', '取消'],
+ yes: function (index, layero) {
+ $('#user-update').find('#submit').trigger('click');
+ },
+ btn2: function () {
+ layer.closeAll();
+ }
+ });
+ }
+ });
+
+ // 查询按钮
+ $query.on('click', function () {
+ var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type});
+ tableIns.reload({where: params, page: {curr: 1}});
+ });
+
+ // 刷新按钮
+ $reset.on('click', function () {
+ $searchForm[0].reset();
+ treeSelect.revokeNode('dept');
+ sortObject.type = 'null';
+ createTimeTo = null;
+ createTimeFrom = null;
+ tableIns.reload({where: getQueryParams(), page: {curr: 1}, initSort: sortObject});
+ });
+
+ function initTable() {
+ tableIns = febs.table.init({
+ elem: $view.find('table'),
+ id: 'userTable',
+ url: ctx + 'agent/getList',
+ cols: [[
+ {type: 'checkbox'},
+ {field: 'name', title: '代理姓名', minWidth: 100, align: 'center'},
+ {field: 'account', title: '代理账号', minWidth: 100, align: 'center'},
+ {field: 'inviteId', title: '代理UID', minWidth: 100, align: 'center'},
+ {field: 'phone', title: '手机号', minWidth: 100, align: 'center'},
+ {field: 'email', title: '邮箱', minWidth: 100, align: 'center'},
+ {field: 'referId', title: '上级UID', minWidth: 100, align: 'center'},
+ {title: '是否实名', templet: '#certify-status', minWidth: 100, align: 'center'},
+ {field: 'childCnt', title: '发展代理数', minWidth: 100, align: 'center'},
+ {field: 'chargeTotal', title: '充值总额', minWidth: 100, align: 'center'},
+ {field: 'cashOutTotal', title: '提现总额', minWidth: 100, align: 'center'},
+ {field: 'returnTotal', title: '佣金返现', minWidth: 100, align: 'center'},
+ {field: 'returnRatio', title: '返佣比例', minWidth: 100, align: 'center'},
+ {title: '状态', templet: '#account-status', align: 'center'},
+ {field: 'createTime', title: '创建时间', minWidth: 140, align: 'center'},
+ {title: '操作', toolbar: '#user-option', minWidth: 140, fixed : 'right', align: 'center'}
+ ]]
+ });
+ }
+
+ // 获取查询参数
+ function getQueryParams() {
+ var createTime = $searchForm.find('input[name="createTime"]').val();
+ if (createTime) {
+ createTimeFrom = createTime.split(' - ')[0];
+ createTimeTo = createTime.split(' - ')[1];
+ }
+ return {
+ startTime: createTimeFrom,
+ endTime: createTimeTo,
+ account: $searchForm.find('input[name="account"]').val().trim(),
+ accountStatus: $searchForm.find("select[name='accountStatus']").val(),
+ accountType: $searchForm.find("select[name='accountType']").val(),
+ certifyStatus: $searchForm.find("select[name='certifyStatus']").val(),
+ invalidate_ie_cache: new Date()
+ };
+ }
+
+ function deleteUsers(userIds) {
+ var currentUserId = currentUser.userId + '';
+ if (('' + userIds).split(',').indexOf(currentUserId) !== -1) {
+ febs.alert.warn('所选用户包含当前登录用户,无法删除');
+ return;
+ }
+ febs.get(ctx + 'user/delete/' + userIds, null, function () {
+ febs.alert.success('删除用户成功');
+ $query.click();
+ });
+ }
+ })
+</script>
\ No newline at end of file
diff --git a/src/main/resources/templates/febs/views/modules/agent/agentAdd.html b/src/main/resources/templates/febs/views/modules/agent/agentAdd.html
new file mode 100644
index 0000000..5b4f8ce
--- /dev/null
+++ b/src/main/resources/templates/febs/views/modules/agent/agentAdd.html
@@ -0,0 +1,77 @@
+<style>
+ #user-add {
+ padding: 20px 25px 25px 0;
+ }
+ #user-add .layui-treeSelect .ztree li a, .ztree li span {
+ margin: 0 0 2px 3px !important;
+ }
+ #user-add #data-permission-tree-block {
+ border: 1px solid #eee;
+ border-radius: 2px;
+ padding: 3px 0;
+ }
+ #user-add .layui-treeSelect .ztree li span.button.switch {
+ top: 1px;
+ left: 3px;
+ }
+</style>
+<div class="layui-fluid" id="user-add">
+ <form class="layui-form" action="" lay-filter="user-add-form">
+ <div class="layui-form-item">
+ <label class="layui-form-label febs-form-item-require">用户名:</label>
+ <div class="layui-input-block">
+ <input type="text" name="account" lay-verify="required" autocomplete="off" class="layui-input">
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <label class="layui-form-label febs-form-item-require">代理姓名:</label>
+ <div class="layui-input-block">
+ <input type="text" name="name" minlength="2" maxlength="25" lay-verify="range" autocomplete="off" class="layui-input">
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <label class="layui-form-label febs-form-item-require">联系电话:</label>
+ <div class="layui-input-block">
+ <input type="tel" name="telphone" lay-verify="phone" autocomplete="off" class="layui-input">
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <label class="layui-form-label febs-form-item-require">代理UID:</label>
+ <div class="layui-input-block">
+ <input type="text" name="inviteId" lay-verify="required" autocomplete="off" class="layui-input">
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <label class="layui-form-label febs-form-item-require">返佣比例:</label>
+ <div class="layui-input-block">
+ <input type="text" name="returnRatio" lay-verify="slot" autocomplete="off" class="layui-input">
+ </div>
+ </div>
+ <div class="layui-form-item febs-hide">
+ <button class="layui-btn" lay-submit="" lay-filter="user-add-form-submit" id="submit"></button>
+ <button type="reset" class="layui-btn" id="reset"></button>
+ </div>
+ </form>
+</div>
+
+<script>
+ layui.use(['febs', 'form', 'validate'], function () {
+ var $ = layui.$,
+ febs = layui.febs,
+ layer = layui.layer,
+ form = layui.form,
+ validate = layui.validate;
+
+ form.verify(validate);
+ form.render();
+
+ form.on('submit(user-add-form-submit)', function (data) {
+ febs.post(ctx + 'agent/add', data.field, function () {
+ layer.closeAll();
+ febs.alert.success('新增用户成功,初始密码为 1234qwer');
+ $('#febs-user').find('#query').click();
+ });
+ return false;
+ });
+ });
+</script>
\ No newline at end of file
diff --git a/src/main/resources/templates/febs/views/modules/member/member.html b/src/main/resources/templates/febs/views/modules/agent/member.html
similarity index 100%
rename from src/main/resources/templates/febs/views/modules/member/member.html
rename to src/main/resources/templates/febs/views/modules/agent/member.html
--
Gitblit v1.9.1