Просмотр исходного кода

审核个人用户及团体用户

Antiloveg лет назад: 8
Родитель
Сommit
5315cccb0a

+ 11 - 18
src/main/java/com/goafanti/admin/controller/AdminApiController.java

@@ -370,8 +370,6 @@ public class AdminApiController extends CertifyApiController {
 		return res;
 	}
 
-	
-
 	/**
 	 * 新增用户
 	 */
@@ -465,6 +463,10 @@ public class AdminApiController extends CertifyApiController {
 			return res;
 		}
 
+		if (StringUtils.isBlank(userIdentity.getId())) {
+
+		}
+
 		if (null == userIdentity.getUid()) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
 			return res;
@@ -491,15 +493,11 @@ public class AdminApiController extends CertifyApiController {
 		UserIdentity ui = new UserIdentity();
 		BeanUtils.copyProperties(userIdentity, ui);
 
-		ui.setProcess(IdentityProcess.COMMITTED.getCode());
-		ui.setAuditStatus(IdentityAuditStatus.COMMITTED.getCode());
-
-		if (StringUtils.isBlank(ui.getId())) {
-			ui.setId(UUID.randomUUID().toString());
-			res.setData(userIdentityService.insertByAdmin(ui, null, null, saveSign));
-		} else {
-			res.setData(userIdentityService.updateUserDetail(ui, null, null, saveSign));
+		if (CertifySubmitType.SUBMIT.getCode().equals(saveSign)) {
+			ui.setProcess(IdentityProcess.COMMITTED.getCode());
+			ui.setAuditStatus(IdentityAuditStatus.COMMITTED.getCode());
 		}
+		res.setData(userIdentityService.updateUserDetail(ui, saveSign));
 		return res;
 	}
 
@@ -577,12 +575,7 @@ public class AdminApiController extends CertifyApiController {
 		OrganizationIdentity oi = new OrganizationIdentity();
 		BeanUtils.copyProperties(orgIdentity, oi);
 
-		if (StringUtils.isBlank(oi.getId())) {
-			oi.setId(UUID.randomUUID().toString());
-			res.setData(organizationIdentityService.insertByAdmin(oi, null, null, saveSign));
-		} else {
-			res.setData(organizationIdentityService.updateOrgDetail(oi, null, null, saveSign));
-		}
+		res.setData(organizationIdentityService.updateOrgDetail(oi, saveSign));
 		return res;
 	}
 
@@ -2431,8 +2424,8 @@ public class AdminApiController extends CertifyApiController {
 	 * 高企认定列表
 	 */
 	@RequestMapping(value = "/listCognizance", method = RequestMethod.POST)
-	public Result listCognizance(String contractId, String uid, String unitName, Integer locationProvince, String pageNo,
-			String pageSize) {
+	public Result listCognizance(String contractId, String uid, String unitName, Integer locationProvince,
+			String pageNo, String pageSize) {
 		Result res = new Result();
 		Integer pNo = 1;
 		Integer pSize = 10;

+ 83 - 103
src/main/java/com/goafanti/admin/controller/AdminUserCertifyApiController.java

@@ -1,8 +1,6 @@
 package com.goafanti.admin.controller;
 
-import java.text.ParseException;
 import java.util.Calendar;
-import java.util.UUID;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
@@ -17,7 +15,6 @@ import org.springframework.web.bind.annotation.RestController;
 
 import com.goafanti.admin.service.AdminService;
 import com.goafanti.common.bo.Result;
-import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.CertifyApiController;
 import com.goafanti.common.enums.AttachmentType;
@@ -25,9 +22,9 @@ import com.goafanti.common.enums.IdentityAuditStatus;
 import com.goafanti.common.enums.IdentityProcess;
 import com.goafanti.common.enums.OrganizationIdentityFields;
 import com.goafanti.common.enums.UserIdentityFields;
+import com.goafanti.common.enums.UserLevel;
 import com.goafanti.common.model.OrganizationIdentity;
 import com.goafanti.common.model.UserIdentity;
-import com.goafanti.common.utils.DateUtils;
 import com.goafanti.user.bo.InputOrganizationIdentity;
 import com.goafanti.user.bo.InputUserIdentity;
 import com.goafanti.user.service.OrganizationIdentityService;
@@ -41,24 +38,23 @@ public class AdminUserCertifyApiController extends CertifyApiController {
 	@Resource
 	private OrganizationIdentityService	organizationIdentityService;
 	@Resource
-	private AdminService adminService;
-	
+	private AdminService				adminService;
+
 	/**
 	 * 审核员--获取客户经理下拉
 	 */
 	@RequestMapping(value = "/accountManager", method = RequestMethod.GET)
-	public Result getAccountManager(){
+	public Result getAccountManager() {
 		Result res = new Result();
 		res.setData(adminService.selectAccoutManager());
 		return res;
 	}
-	
+
 	/**
 	 * 审核员--获取业务员(技术员)下拉
-	 * @return
 	 */
 	@RequestMapping(value = "/technician", method = RequestMethod.GET)
-	public Result getTechnician(){
+	public Result getTechnician() {
 		Result res = new Result();
 		res.setData(adminService.selectTechnician());
 		return res;
@@ -66,11 +62,6 @@ public class AdminUserCertifyApiController extends CertifyApiController {
 
 	/**
 	 * 上传认证资料(营业执照图片、组织机构代码证图片、上年度纳税申报表)
-	 * 
-	 * @param req
-	 * @param sign
-	 * @param uid
-	 * @return
 	 */
 	@RequestMapping(value = "/upload", method = RequestMethod.POST)
 	public Result uploadCertify(HttpServletRequest req, String sign, String uid) {
@@ -94,9 +85,6 @@ public class AdminUserCertifyApiController extends CertifyApiController {
 
 	/**
 	 * 审核员--个人用户详情
-	 * 
-	 * @param uid
-	 * @return
 	 */
 	@RequestMapping(value = "/userDetail", method = RequestMethod.GET)
 	public Result userDetail(String uid) {
@@ -111,11 +99,6 @@ public class AdminUserCertifyApiController extends CertifyApiController {
 
 	/**
 	 * 审核员审核个人用户信息
-	 * 
-	 * @param userIdentity
-	 * @param bindingResult
-	 * @param paymentDateFormattedDate
-	 * @return
 	 */
 	@RequestMapping(value = "/updateUserDetail", method = RequestMethod.POST)
 	public Result disposeUser(@Valid InputUserIdentity userIdentity, BindingResult bindingResult,
@@ -127,58 +110,59 @@ public class AdminUserCertifyApiController extends CertifyApiController {
 			return res;
 		}
 
-		if (null == userIdentity.getUid()) {
+		if (StringUtils.isBlank(userIdentity.getId())) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户认证ID", "用户认证ID"));
+			return res;
+		}
+
+		if (StringUtils.isBlank(userIdentity.getUid())) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
 			return res;
 		}
 
-		if (!StringUtils.isBlank(paymentDateFormattedDate)) {
-			try {
-				userIdentity.setPaymentDate(DateUtils.parseDate(paymentDateFormattedDate, AFTConstants.YYYYMMDD));
-			} catch (ParseException e) {
+		if (null == userIdentity.getAuditStatus()) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到审核状态", "审核状态"));
+			return res;
+		}
+
+		if (null == userIdentity.getLevel()) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户等级", "用户等级"));
+			return res;
+		}
+
+		if (!UserLevel.GENERAL.getCode().equals(userIdentity.getLevel())
+				|| IdentityAuditStatus.PASSED.getCode().equals(userIdentity.getAuditStatus())) {
+			if (StringUtils.isBlank(aid)) {
+				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到业务员ID", "业务员ID"));
+				return res;
+			}
+
+			if (StringUtils.isBlank(mid)) {
+				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到客户经理ID", "客户经理ID"));
+				return res;
 			}
 		}
 
 		UserIdentity ui = new UserIdentity();
 		BeanUtils.copyProperties(userIdentity, ui);
-		if (StringUtils.isBlank(ui.getId())) {
-			ui.setId(UUID.randomUUID().toString());
-			ui.setAuditStatus(null == ui.getAuditStatus() ? 0 : ui.getAuditStatus());
-			if (IdentityAuditStatus.UNCOMMITTED.getCode() == ui.getAuditStatus()) {
-				ui.setProcess(IdentityProcess.UNCOMMITTED.getCode());
-			} else if (IdentityAuditStatus.COMMITTED.getCode() == ui.getAuditStatus()
-					|| IdentityAuditStatus.UNPAID.getCode() == ui.getAuditStatus()) {
-				ui.setProcess(IdentityProcess.COMMITTED.getCode());
-			} else if (IdentityAuditStatus.PAID.getCode() == ui.getAuditStatus()) {
-				ui.setProcess(IdentityProcess.FILLIN.getCode());
-			} else if (IdentityAuditStatus.NOTPASSED.getCode() == ui.getAuditStatus()
-					|| IdentityAuditStatus.PASSED.getCode() == ui.getAuditStatus()) {
-				ui.setProcess(IdentityProcess.RESULTS.getCode());
-			}
-			res.setData(userIdentityService.insertByAdmin(ui, aid, mid, null));
-		} else {
-			ui.setAuditStatus(null == ui.getAuditStatus() ? 0 : ui.getAuditStatus());
-			if (IdentityAuditStatus.UNCOMMITTED.getCode() == ui.getAuditStatus()) {
-				ui.setProcess(IdentityProcess.UNCOMMITTED.getCode());
-			} else if (IdentityAuditStatus.COMMITTED.getCode() == ui.getAuditStatus()
-					|| IdentityAuditStatus.UNPAID.getCode() == ui.getAuditStatus()) {
-				ui.setProcess(IdentityProcess.COMMITTED.getCode());
-			} else if (IdentityAuditStatus.PAID.getCode() == ui.getAuditStatus()) {
-				ui.setProcess(IdentityProcess.FILLIN.getCode());
-			} else if (IdentityAuditStatus.NOTPASSED.getCode() == ui.getAuditStatus()
-					|| IdentityAuditStatus.PASSED.getCode() == ui.getAuditStatus()) {
-				ui.setProcess(IdentityProcess.RESULTS.getCode());
-			}
-			res.setData(userIdentityService.updateUserDetail(ui, aid, mid, null));
+
+		if (IdentityAuditStatus.UNCOMMITTED.getCode().equals(ui.getAuditStatus())) {
+			ui.setProcess(IdentityProcess.UNCOMMITTED.getCode());
+		} else if (IdentityAuditStatus.COMMITTED.getCode().equals(ui.getAuditStatus())
+				|| IdentityAuditStatus.UNPAID.getCode().equals(ui.getAuditStatus())) {
+			ui.setProcess(IdentityProcess.COMMITTED.getCode());
+		} else if (IdentityAuditStatus.PAID.getCode().equals(ui.getAuditStatus())) {
+			ui.setProcess(IdentityProcess.FILLIN.getCode());
+		} else if (IdentityAuditStatus.NOTPASSED.getCode().equals(ui.getAuditStatus())
+				|| IdentityAuditStatus.PASSED.getCode().equals(ui.getAuditStatus())) {
+			ui.setProcess(IdentityProcess.RESULTS.getCode());
 		}
+		res.setData(userIdentityService.updateUserDetailByAuditAdmin(ui, aid, mid, userIdentity.getLevel()));
 		return res;
 	}
 
 	/**
 	 * 审核员---团体用户详情
-	 * 
-	 * @param uid
-	 * @return
 	 */
 	@RequestMapping(value = "/orgDetail", method = RequestMethod.GET)
 	public Result orgDetail(String uid) {
@@ -193,11 +177,6 @@ public class AdminUserCertifyApiController extends CertifyApiController {
 
 	/**
 	 * 审核员审核团体用户信息
-	 * 
-	 * @param orgIdentity
-	 * @param bindingResult
-	 * @param paymentDateFormattedDate
-	 * @return
 	 */
 	@RequestMapping(value = "/updateOrgDetail", method = RequestMethod.POST)
 	public Result diposeOrg(@Valid InputOrganizationIdentity orgIdentity, BindingResult bindingResult,
@@ -210,55 +189,56 @@ public class AdminUserCertifyApiController extends CertifyApiController {
 			return res;
 		}
 
-		if (null == orgIdentity.getUid()) {
+		if (StringUtils.isBlank(orgIdentity.getId())) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户认证ID", "用户认证ID"));
+			return res;
+		}
+
+		if (StringUtils.isBlank(orgIdentity.getUid())) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户", "用户"));
 			return res;
 		}
-		if (!StringUtils.isBlank(paymentDateFormattedDate)) {
-			try {
-				orgIdentity.setPaymentDate(DateUtils.parseDate(paymentDateFormattedDate, AFTConstants.YYYYMMDD));
-			} catch (ParseException e) {
+
+		if (null == orgIdentity.getAuditStatus()) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到审核状态", "审核状态"));
+			return res;
+		}
+		
+		if (null == orgIdentity.getLevel()) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到用户等级", "用户等级"));
+			return res;
+		}
+
+		if (!UserLevel.GENERAL.getCode().equals(orgIdentity.getLevel())
+				|| IdentityAuditStatus.PASSED.getCode().equals(orgIdentity.getAuditStatus())) {
+			if (StringUtils.isBlank(aid)) {
+				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到业务员ID", "业务员ID"));
+				return res;
+			}
+
+			if (StringUtils.isBlank(mid)) {
+				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "找不到客户经理ID", "客户经理ID"));
+				return res;
 			}
 		}
 
 		OrganizationIdentity oi = new OrganizationIdentity();
 		BeanUtils.copyProperties(orgIdentity, oi);
 
-		if (StringUtils.isBlank(oi.getId())) {
-			oi.setId(UUID.randomUUID().toString());
-			oi.setIdentityType(null == oi.getIdentityType() ? 0 : oi.getIdentityType());
-			oi.setAuditStatus(null == oi.getAuditStatus() ? 0 : oi.getAuditStatus());
-			if (IdentityAuditStatus.UNCOMMITTED.getCode() == oi.getAuditStatus()) {
-				oi.setProcess(IdentityProcess.UNCOMMITTED.getCode());
-			} else if (IdentityAuditStatus.COMMITTED.getCode() == oi.getAuditStatus()
-					|| IdentityAuditStatus.UNPAID.getCode() == oi.getAuditStatus()) {
-				oi.setProcess(IdentityProcess.COMMITTED.getCode());
-			} else if (IdentityAuditStatus.PAID.getCode() == oi.getAuditStatus()) {
-				oi.setProcess(IdentityProcess.FILLIN.getCode());
-			} else if (IdentityAuditStatus.NOTPASSED.getCode() == oi.getAuditStatus()
-					|| IdentityAuditStatus.PASSED.getCode() == oi.getAuditStatus()) {
-				oi.setProcess(IdentityProcess.RESULTS.getCode());
-			}
-			oi.setListed(null == oi.getListed() ? 0 : oi.getListed());
-			oi.setListedType(null == oi.getListedType() ? 0 : oi.getListedType());
-			res.setData(organizationIdentityService.insertByAdmin(oi, aid, mid, null));
-		} else {
-			oi.setAuditStatus(null == oi.getAuditStatus() ? 0 : oi.getAuditStatus());
-			if (IdentityAuditStatus.UNCOMMITTED.getCode() == oi.getAuditStatus()) {
-				oi.setProcess(IdentityProcess.UNCOMMITTED.getCode());
-			} else if (IdentityAuditStatus.COMMITTED.getCode() == oi.getAuditStatus()
-					|| IdentityAuditStatus.UNPAID.getCode() == oi.getAuditStatus()) {
-				oi.setProcess(IdentityProcess.COMMITTED.getCode());
-			} else if (IdentityAuditStatus.PAID.getCode() == oi.getAuditStatus()) {
-				oi.setProcess(IdentityProcess.FILLIN.getCode());
-			} else if (IdentityAuditStatus.NOTPASSED.getCode() == oi.getAuditStatus()
-					|| IdentityAuditStatus.PASSED.getCode() == oi.getAuditStatus()) {
-				oi.setProcess(IdentityProcess.RESULTS.getCode());
-			}
-			res.setData(organizationIdentityService.updateOrgDetail(oi, aid, mid, null));
+		if (IdentityAuditStatus.UNCOMMITTED.getCode().equals(oi.getAuditStatus())) {
+			oi.setProcess(IdentityProcess.UNCOMMITTED.getCode());
+		} else if (IdentityAuditStatus.COMMITTED.getCode().equals(oi.getAuditStatus())
+				|| IdentityAuditStatus.UNPAID.getCode().equals(oi.getAuditStatus())) {
+			oi.setProcess(IdentityProcess.COMMITTED.getCode());
+		} else if (IdentityAuditStatus.PAID.getCode().equals(oi.getAuditStatus())) {
+			oi.setProcess(IdentityProcess.FILLIN.getCode());
+		} else if (IdentityAuditStatus.NOTPASSED.getCode().equals(oi.getAuditStatus())
+				|| IdentityAuditStatus.PASSED.getCode().equals(oi.getAuditStatus())){
+			oi.setProcess(IdentityProcess.RESULTS.getCode());
 		}
+		res.setData(organizationIdentityService.updateOrgDetailByAuditAdmin(oi, aid, mid, orgIdentity.getLevel()));
 		return res;
 	}
 	
-	
+
 }

+ 195 - 8
src/main/java/com/goafanti/common/mapper/UserMapper.xml

@@ -234,8 +234,8 @@
 	<if test=" number != null">
 		and u.number = #{number,jdbcType=INTEGER}
 	</if>
-	<if test="unitName != null">
-		and i.unit_name like CONCAT('%', #{unitName,jdbcType=VARCHAR}, '%')   
+	<if test="username != null">
+		and i.username like CONCAT('%', #{username,jdbcType=VARCHAR}, '%')   
 	</if>
 	<if test="auditStatus != null">
 		and i.audit_status= #{auditStatus,jdbcType=INTEGER}
@@ -266,8 +266,8 @@
 	<if test="number != null">
 		and u.number = #{number,jdbcType=INTEGER}
 	</if>
-	<if test="aftUsername != null">
-		and i.aft_username = #{aftUsername,jdbcType=VARCHAR}
+	<if test="username != null">
+		and i.username = #{username,jdbcType=VARCHAR}
 	</if>
 	<if test="auditStatus != null">
 		and i.audit_status= #{auditStatus,jdbcType=INTEGER}
@@ -303,8 +303,8 @@
 	<if test=" number != null">
 		and u.number = #{number,jdbcType=INTEGER}
 	</if>
-	<if test="aftUsername != null">
-		and o.aft_username = #{aftUsername,jdbcType=VARCHAR}
+	<if test="unitName != null">
+		and o.unit_name = #{unitName,jdbcType=VARCHAR}
 	</if>
 	<if test="auditStatus != null">
 		and o.audit_status= #{auditStatus,jdbcType=INTEGER}
@@ -338,8 +338,8 @@
 	<if test=" number != null">
 		and u.number = #{number,jdbcType=INTEGER}
 	</if>
-	<if test="aftUsername != null">
-		and o.aft_username = #{aftUsername,jdbcType=VARCHAR}
+	<if test="unitName != null">
+		and o.unit_name = #{unitName,jdbcType=VARCHAR}
 	</if>
 	<if test="auditStatus != null">
 		and o.audit_status= #{auditStatus,jdbcType=INTEGER}
@@ -384,4 +384,191 @@
   		and u.mobile = #{mobile,jdbcType=VARCHAR}
   	</if>
   </select>
+  
+   <select id="findAreaManagerUserListByPage" parameterType="String" resultType="com.goafanti.user.bo.UserListBo">
+  	select u.id ,u.mobile, u.email, u.create_time as createTime, 
+  	       u.number , i.aft_username as aftUsername, i.audit_status as auditStatus, a.name as adminName,
+  	       ad.name as managerName
+    from user u  
+    LEFT JOIN admin a on a.id = u.aid
+    LEFT JOIN admin ad on ad.id = u.mid
+    LEFT JOIN user_identity i 
+    ON u.id = i.uid  where u.type = 0
+    <if test = "mobile != null">
+	    and u.mobile = #{mobile,jdbcType=VARCHAR}
+	</if>
+	<if test = "email != null">
+	    and u.email = #{email,jdbcType=VARCHAR}
+	</if>
+	<if test = "pStart != null" >
+		and u.create_time <![CDATA[ > ]]> #{pStart,jdbcType=TIMESTAMP}
+	</if>
+	<if test = "pEnd != null">
+		and u.create_time <![CDATA[ < ]]> #{pEnd,jdbcType=TIMESTAMP}
+	</if>
+	<if test=" number != null">
+		and u.number = #{number,jdbcType=INTEGER}
+	</if>
+	<if test="username != null">
+		and i.username like CONCAT('%', #{username,jdbcType=VARCHAR}, '%')   
+	</if>
+	<if test="auditStatus != null">
+		and i.audit_status= #{auditStatus,jdbcType=INTEGER}
+	</if>
+	
+	 <if test="provinceList != null">
+	   and  i.province in
+	    <foreach collection="provinceList" item="plist"  open="(" separator="," close=")">
+			#{plist}
+		</foreach>
+	</if>
+	<if test="cityList != null">
+		and i.city in 
+		<foreach collection="cityList" item="clist"  open="(" separator="," close=")">
+			#{clist}
+		</foreach>
+	</if>
+	
+	order by u.number desc
+	<if test="page_sql!=null">
+		${page_sql}
+	</if>
+  </select>
+  
+  <select id="findAreaManagerUserCount" resultType="java.lang.Integer" parameterType="String">
+  	select count(1) 
+    from user u LEFT JOIN user_identity i 
+    ON u.id = i.uid 
+    WHERE u.type = 0
+    <if test = "mobile != null">
+	    and u.mobile = #{mobile,jdbcType=VARCHAR}
+	</if>
+	<if test = "email != null">
+	    and u.email = #{email,jdbcType=VARCHAR}
+	</if>
+	<if test = "pStart != null" >
+		and u.create_time <![CDATA[ > ]]> #{pStart,jdbcType=TIMESTAMP}
+	</if>
+	<if test = "pEnd != null">
+		and u.create_time <![CDATA[ < ]]> #{pEnd,jdbcType=TIMESTAMP}
+	</if>
+	<if test="number != null">
+		and u.number = #{number,jdbcType=INTEGER}
+	</if>
+	<if test="username != null">
+		and i.username = #{username,jdbcType=VARCHAR}
+	</if>
+	<if test="auditStatus != null">
+		and i.audit_status= #{auditStatus,jdbcType=INTEGER}
+	</if>
+	
+	 <if test="provinceList != null">
+	   and  i.province in
+	    <foreach collection="provinceList" item="plist"  open="(" separator="," close=")">
+			#{plist}
+		</foreach>
+	</if>
+	<if test="cityList != null">
+		and i.city in 
+		<foreach collection="cityList" item="clist"  open="(" separator="," close=")">
+			#{clist}
+		</foreach>
+	</if>
+  </select>  
+  
+   <select id="findAreaManagerOrgListByPage" parameterType="String" resultType="com.goafanti.user.bo.OrgListBo">
+  select u.id ,u.mobile, u.email, u.create_time as createTime, 
+  	       u.number , o.aft_username as aftUsername, o.audit_status as auditStatus, a.name as adminName,
+  	       o.unit_name as unitName, ad.name as managerName
+    from user u  
+    LEFT JOIN admin a on a.id = u.aid 
+    LEFT JOIN admin ad on ad.id = u.mid
+	LEFT JOIN organization_identity o 
+    ON u.id = o.uid 
+    WHERE u.type = 1
+   
+    <if test = "mobile != null">
+	    and u.mobile = #{mobile,jdbcType=VARCHAR}
+	</if>
+	<if test = "uid != null">
+	    and u.id = #{uid,jdbcType=VARCHAR}
+	</if>
+	<if test = "email != null">
+	    and u.email = #{email,jdbcType=VARCHAR}
+	</if>
+	<if test = "pStart != null" >
+		and u.create_time <![CDATA[ > ]]> #{pStart,jdbcType=TIMESTAMP}
+	</if>
+	<if test = "pEnd != null">
+		and u.create_time <![CDATA[ < ]]> #{pEnd,jdbcType=TIMESTAMP}
+	</if>
+	<if test=" number != null">
+		and u.number = #{number,jdbcType=INTEGER}
+	</if>
+	<if test="unitName != null">
+		and o.unit_name = #{unitName,jdbcType=VARCHAR}
+	</if>
+	<if test="auditStatus != null">
+		and o.audit_status= #{auditStatus,jdbcType=INTEGER}
+	</if>
+	 <if test="provinceList != null">
+	   and  o.licence_province in
+	    <foreach collection="provinceList" item="plist"  open="(" separator="," close=")">
+			#{plist}
+		</foreach>
+	</if>
+	<if test="cityList != null">
+		and o.licence_city in 
+		<foreach collection="cityList" item="clist"  open="(" separator="," close=")">
+			#{clist}
+		</foreach>
+	</if>
+	order by u.number desc
+	<if test="page_sql!=null">
+		${page_sql}
+	</if>
+  </select>
+  
+  <select id="findAreaManagerOrgCount" resultType="java.lang.Integer" parameterType="String">
+  	select count(1) 
+    from user u LEFT JOIN organization_identity o 
+    ON u.id = o.uid 
+    WHERE u.type = 1
+    <if test = "uid != null">
+	    and u.id = #{uid,jdbcType=VARCHAR}
+	</if>
+    <if test = "mobile != null">
+	    and u.mobile = #{mobile,jdbcType=VARCHAR}
+	</if>
+	<if test = "email != null">
+	    and u.email = #{email,jdbcType=VARCHAR}
+	</if>
+	<if test = "pStart != null" >
+		and u.create_time <![CDATA[ > ]]> #{pStart,jdbcType=TIMESTAMP}
+	</if>
+	<if test = "pEnd != null">
+		and u.create_time <![CDATA[ < ]]> #{pEnd,jdbcType=TIMESTAMP}
+	</if>
+	<if test=" number != null">
+		and u.number = #{number,jdbcType=INTEGER}
+	</if>
+	<if test="unitName != null">
+		and o.unit_name = #{unitName,jdbcType=VARCHAR}
+	</if>
+	<if test="auditStatus != null">
+		and o.audit_status= #{auditStatus,jdbcType=INTEGER}
+	</if>
+	 <if test="provinceList != null">
+	   and  i.province in
+	    <foreach collection="provinceList" item="plist"  open="(" separator="," close=")">
+			#{plist}
+		</foreach>
+	</if>
+	<if test="cityList != null">
+		and i.city in 
+		<foreach collection="cityList" item="clist"  open="(" separator="," close=")">
+			#{clist}
+		</foreach>
+	</if>
+  </select>  
 </mapper>

+ 25 - 0
src/main/java/com/goafanti/user/bo/InputOrganizationIdentity.java

@@ -165,6 +165,10 @@ public class InputOrganizationIdentity {
 
 	@Size(min = 0, max = 36, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String		consultant;
+	
+	@Max(value = 5, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer level;
 
 	public String getId() {
 		return id;
@@ -538,4 +542,25 @@ public class InputOrganizationIdentity {
 		this.consultant = consultant;
 	}
 
+	public Integer getLevel() {
+		return level;
+	}
+
+	public void setLevel(Integer level) {
+		this.level = level;
+	}
+
+	public Integer getLocationProvince() {
+		return locationProvince;
+	}
+
+	public Integer getLocationCity() {
+		return locationCity;
+	}
+
+	public Integer getLocationArea() {
+		return locationArea;
+	}
+	
+	
 }

+ 12 - 0
src/main/java/com/goafanti/user/bo/InputUserIdentity.java

@@ -80,8 +80,20 @@ public class InputUserIdentity {
 	@Max(value = 3, message = "{" + ErrorConstants.PARAM_ERROR + "}")
 	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
 	private Integer		wrongCount;
+	
+	@Max(value = 5, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer level;
 
 	private Date		paymentDate;
+	
+	public Integer getLevel() {
+		return level;
+	}
+
+	public void setLevel(Integer level) {
+		this.level = level;
+	}
 
 	public Date getPaymentDate() {
 		return paymentDate;

+ 2 - 4
src/main/java/com/goafanti/user/service/OrganizationIdentityService.java

@@ -28,11 +28,9 @@ public interface OrganizationIdentityService {
 
 	Map<String, String> selectContactsByUserId(String uid);
 
-
-
 	int saveOrgIndentityProcess(Result res, OrganizationIdentity o, String uid);
 
-	int updateOrgDetail(OrganizationIdentity orgIdentity, String aid, String mid, String saveSign);
+	int updateOrgDetail(OrganizationIdentity orgIdentity, String saveSign);
 
 	OrgBasicInfoBo selectBasicInfo(String uid, int year);
 
@@ -42,7 +40,7 @@ public interface OrganizationIdentityService {
 
 	AuditorOrgIdentityDetailBo selectAuditorOrgIdentityDetailByUserId(String uid);
 
-	OrganizationIdentity insertByAdmin(OrganizationIdentity oi, String aid, String mid, String saveSign);
+	int updateOrgDetailByAuditAdmin(OrganizationIdentity oi, String aid, String mid, Integer level);
 
 
 

+ 4 - 2
src/main/java/com/goafanti/user/service/UserIdentityService.java

@@ -19,12 +19,14 @@ public interface UserIdentityService {
 
 	int  saveUserIdentityProcess(Result res, UserIdentity u, String uid);
 
-	int updateUserDetail(UserIdentity userIdentity, String aid, String mid, String saveSign);
+	int updateUserDetail(UserIdentity userIdentity, String saveSign);
 
-	UserIdentity insertByAdmin(UserIdentity ui, String aid, String mid, String saveSign);
+	UserIdentity insertByAdmin(UserIdentity ui, String saveSign);
 
 	AuditorUserIdentityDetailBo selectAuditorUserIdentityByUserId(String uid);
 
+	int updateUserDetailByAuditAdmin(UserIdentity ui, String aid, String mid, Integer level);
+
 
 
 }

+ 25 - 45
src/main/java/com/goafanti/user/service/impl/OrganizationIdentityServiceImpl.java

@@ -141,16 +141,9 @@ public class OrganizationIdentityServiceImpl extends BaseMybatisDao<Organization
 	}
 
 	@Override
-	public int updateOrgDetail(OrganizationIdentity orgIdentity, String aid, String mid, String saveSign) {
-		if (null != orgIdentity.getAuditStatus() && 5 == orgIdentity.getAuditStatus()
-				&& !StringUtils.isBlank(orgIdentity.getUid())) {
-			User u = new User();
-			u.setId(orgIdentity.getUid());
-			u.setLvl(UserLevel.CERTIFIED.getCode());
-			userMapper.updateByPrimaryKeySelective(u);
-		}
-		Calendar cal = Calendar.getInstance();
+	public int updateOrgDetail(OrganizationIdentity orgIdentity, String saveSign) {
 		if (null != orgIdentity.getLastYearTaxReportUrl()) {
+			Calendar cal = Calendar.getInstance();
 			OrgRatepay rate = orgRatepayMapper.selectRatepayByUidAndYear(orgIdentity.getUid(), Calendar.YEAR - 1);
 			if (null == rate) {
 				OrgRatepay r = new OrgRatepay();
@@ -166,26 +159,35 @@ public class OrganizationIdentityServiceImpl extends BaseMybatisDao<Organization
 			}
 		}
 
-		User user = userMapper.selectByPrimaryKey(orgIdentity.getUid());
-		if (!TokenManager.hasRole(AFTConstants.AUDITORADMIN) && !TokenManager.hasRole(AFTConstants.SUPERADMIN)
-				&& CertifySubmitType.SUBMIT.getCode().equals(saveSign)) {
-			user.setAid(TokenManager.getAdminId());
+		if (CertifySubmitType.SUBMIT.getCode().equals(saveSign)) {
+			User user = userMapper.selectByPrimaryKey(orgIdentity.getUid());
 			createAuditorNotice(user);
-		} else {
-			if (!StringUtils.isBlank(aid)) {
-				user.setAid(aid);
-			}
-			if (!StringUtils.isBlank(mid)) {
-				user.setMid(mid);
-			}
-			createNotice(user, orgIdentity.getAuditStatus());
-		}
-		userMapper.updateByPrimaryKeySelective(user);
+		} 
 		return organizationIdentityMapper.updateByPrimaryKeySelective(orgIdentity);
 
 	}
 
 	@Override
+	public int updateOrgDetailByAuditAdmin(OrganizationIdentity oi, String aid, String mid, Integer level) {
+		User user = userMapper.selectByPrimaryKey(oi.getUid());
+		if (!IdentityAuditStatus.PASSED.getCode().equals(oi.getAuditStatus())) {
+			user.setLvl(UserLevel.GENERAL.getCode());
+			userMapper.updateByPrimaryKeySelective(user);
+			createNotice(user, oi.getAuditStatus());
+		}
+		if (IdentityAuditStatus.PASSED.getCode().equals(oi.getAuditStatus())) {
+			if (UserLevel.GENERAL.getCode().equals(level)) {
+				user.setLvl(UserLevel.CERTIFIED.getCode());
+			}
+			user.setAid(aid);
+			user.setMid(mid);
+			userMapper.updateByPrimaryKeySelective(user);
+			createNotice(user, oi.getAuditStatus());
+		}
+		return organizationIdentityMapper.updateByPrimaryKeySelective(oi);
+	}
+
+	@Override
 	public OrgBasicInfoBo selectBasicInfo(String uid, int year) {
 		return organizationIdentityMapper.selectBasicInfo(uid, year);
 	}
@@ -221,28 +223,6 @@ public class OrganizationIdentityServiceImpl extends BaseMybatisDao<Organization
 		return organizationIdentityMapper.selectAuditorOrgIdentityDetailByUserId(uid);
 	}
 
-	@Override
-	public OrganizationIdentity insertByAdmin(OrganizationIdentity oi, String aid, String mid, String saveSign) {
-		organizationIdentityMapper.insert(oi);
-		User u = userMapper.selectByPrimaryKey(oi.getUid());
-		if (!TokenManager.hasRole(AFTConstants.AUDITORADMIN) && !TokenManager.hasRole(AFTConstants.SUPERADMIN)
-				&& CertifySubmitType.SUBMIT.getCode().equals(saveSign)) {
-			u.setAid(TokenManager.getAdminId());
-			userMapper.updateByPrimaryKeySelective(u);
-			createAuditorNotice(u);
-		}
-		if (TokenManager.hasRole(AFTConstants.AUDITORADMIN) || TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
-			u.setAid(aid);
-			u.setMid(mid);
-			if (IdentityAuditStatus.PASSED.getCode() == oi.getAuditStatus()) {
-				u.setLvl(UserLevel.CERTIFIED.getCode());
-			}
-			userMapper.updateByPrimaryKeySelective(u);
-			createNotice(u, oi.getAuditStatus());
-		}
-		return null;
-	}
-
 	// 给业务员及客户经理发送通知
 	private void createNotice(User u, Integer status) {
 		if (!StringUtils.isBlank(u.getAid())) {

+ 26 - 29
src/main/java/com/goafanti/user/service/impl/UserIdentityServiceImpl.java

@@ -87,33 +87,38 @@ public class UserIdentityServiceImpl implements UserIdentityService {
 	}
 
 	@Override
-	public int updateUserDetail(UserIdentity u, String aid, String mid, String saveSign) {
-		if (null != u.getAuditStatus() && 5 == u.getAuditStatus() && !StringUtils.isBlank(u.getUid())) {
-			User user = new User();
-			user.setId(u.getUid());
-			user.setLvl(UserLevel.CERTIFIED.getCode());
+	public int updateUserDetail(UserIdentity u, String saveSign) {
+		if (CertifySubmitType.SUBMIT.getCode().equals(saveSign)) {
+			User user = userMapper.selectByPrimaryKey(u.getUid());
+			createAuditorNotice(user);
+		}
+		return userIdentityMapper.updateByPrimaryKeySelective(u);
+
+	}
+
+	@Override
+	public int updateUserDetailByAuditAdmin(UserIdentity ui, String aid, String mid, Integer level) {
+		// 审核员UPDATE_USER_DETAIL
+		User user = userMapper.selectByPrimaryKey(ui.getUid());
+		if (!IdentityAuditStatus.PASSED.getCode().equals(ui.getAuditStatus())) {
+			user.setLvl(UserLevel.GENERAL.getCode());
 			userMapper.updateByPrimaryKeySelective(user);
+			createNotice(user, ui.getAuditStatus());
 		}
-		User user = userMapper.selectByPrimaryKey(u.getUid());
-		if (!TokenManager.hasRole(AFTConstants.AUDITORADMIN) && !TokenManager.hasRole(AFTConstants.SUPERADMIN)
-				&& CertifySubmitType.SUBMIT.getCode().equals(saveSign)) {
-			user.setAid(TokenManager.getAdminId());
-			createAuditorNotice(user);
-		} else {
-			if (!StringUtils.isBlank(aid)) {
-				user.setAid(aid);
-			}
-			if (!StringUtils.isBlank(mid)) {
-				user.setMid(mid);
+		if (IdentityAuditStatus.PASSED.getCode().equals(ui.getAuditStatus())) {
+			if (UserLevel.GENERAL.getCode().equals(level)) {
+				user.setLvl(UserLevel.CERTIFIED.getCode());
 			}
-			createNotice(user, u.getAuditStatus());
+			user.setAid(aid);
+			user.setMid(mid);
+			userMapper.updateByPrimaryKeySelective(user);
+			createNotice(user, ui.getAuditStatus());
 		}
-		userMapper.updateByPrimaryKeySelective(user);
-		return userIdentityMapper.updateByPrimaryKeySelective(u);
+		return userIdentityMapper.updateByPrimaryKeySelective(ui);
 	}
 
 	@Override
-	public UserIdentity insertByAdmin(UserIdentity ui, String aid, String mid, String saveSign) {
+	public UserIdentity insertByAdmin(UserIdentity ui, String saveSign) {
 		userIdentityMapper.insert(ui);
 		User u = userMapper.selectByPrimaryKey(ui.getUid());
 		if (!TokenManager.hasRole(AFTConstants.AUDITORADMIN) && !TokenManager.hasRole(AFTConstants.SUPERADMIN)
@@ -122,15 +127,6 @@ public class UserIdentityServiceImpl implements UserIdentityService {
 			userMapper.updateByPrimaryKeySelective(u);
 			createAuditorNotice(u);
 		}
-		if (TokenManager.hasRole(AFTConstants.AUDITORADMIN) || TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
-			u.setAid(aid);
-			u.setMid(mid);
-			if (IdentityAuditStatus.PASSED.getCode() == ui.getAuditStatus()) {
-				u.setLvl(UserLevel.CERTIFIED.getCode());
-			}
-			userMapper.updateByPrimaryKeySelective(u);
-			createNotice(u, ui.getAuditStatus());
-		}
 		return ui;
 	}
 
@@ -212,4 +208,5 @@ public class UserIdentityServiceImpl implements UserIdentityService {
 		noticeMapper.insert(n);
 	}
 
+
 }

+ 39 - 14
src/main/java/com/goafanti/user/service/impl/UserServiceImpl.java

@@ -12,9 +12,11 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.goafanti.common.constant.AFTConstants;
+import com.goafanti.common.dao.AdminLocationMapper;
 import com.goafanti.common.dao.OrganizationIdentityMapper;
 import com.goafanti.common.dao.UserIdentityMapper;
 import com.goafanti.common.dao.UserMapper;
+import com.goafanti.common.enums.UserType;
 import com.goafanti.common.model.OrganizationIdentity;
 import com.goafanti.common.model.User;
 import com.goafanti.common.utils.DateUtils;
@@ -37,11 +39,13 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 	private OrganizationIdentityMapper	organizationIdentityMapper;
 	@Autowired
 	private UserIdentityMapper			userIdentityMapper;
+	@Autowired
+	private AdminLocationMapper			adminLocationMapper;
 
 	@Override
 	public User insertRegister(User user, String contacts, String unitName) {
 		userMapper.insert(user);
-		if (null != user.getType() && 1 == user.getType()) {
+		if (null != user.getType() && UserType.ORGANIZATION.getCode().equals(user.getType())) {
 			if (!StringUtils.isBlank(unitName) || !StringUtils.isBlank(contacts)) {
 				OrganizationIdentity organizationIdentity = new OrganizationIdentity();
 				organizationIdentity.setUid(user.getId());
@@ -98,7 +102,7 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<UserListBo> listUser(String mobile, String email, String[] pDate, Integer number, String unitName,
+	public Pagination<UserListBo> listUser(String mobile, String email, String[] pDate, Integer number, String username,
 			Integer auditStatus, Integer pageNo, Integer pageSize) throws ParseException {
 		Map<String, Object> params = new HashMap<>();
 		Date pStart = null;
@@ -131,8 +135,8 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 			params.put("number", number);
 		}
 
-		if (!StringUtils.isBlank(unitName)) {
-			params.put("unitName", unitName);
+		if (!StringUtils.isBlank(username)) {
+			params.put("username", username);
 		}
 
 		if (null != auditStatus) {
@@ -143,16 +147,32 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 			pageNo = 1;
 		}
 
-		if (pageSize == null || pageSize < 0) {
+		if (pageSize == null || pageSize < 0 || pageSize > 10) {
 			pageSize = 10;
 		}
-		return (Pagination<UserListBo>) findPage("findUserListByPage", "findUserCount", params, pageNo, pageSize);
+
+		if (TokenManager.hasRole(AFTConstants.AREAADMIN) || TokenManager.hasRole(AFTConstants.MANAGERADMIN)) {
+			List<Integer> provinceList = adminLocationMapper
+					.selectProvinceWhereCityIsNullByAdminId(TokenManager.getAdminId());
+			List<Integer> cityList = adminLocationMapper.selectCityByAdminId(TokenManager.getAdminId());
+			provinceList.addAll(cityList);
+			if (null != provinceList && provinceList.size() > 0) {
+				params.put("provinceList", provinceList);
+			}
+			if (null != cityList && cityList.size() > 0) {
+				params.put("cityList", cityList);
+			}
+			return (Pagination<UserListBo>) findPage("findAreaManagerUserListByPage", "findAreaManagerUserCount", params, pageNo, pageSize);
+		} else if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
+			return (Pagination<UserListBo>) findPage("findUserListByPage", "findUserCount", params, pageNo, pageSize);
+		}
+		return null;
 	}
 
 	@SuppressWarnings("unchecked")
 	@Override
 	public Pagination<OrgListBo> listOrg(String uid, String mobile, String email, String[] pDate, Integer number,
-			String aftUsername, Integer auditStatus, Integer pageNo, Integer pageSize) throws ParseException {
+			String unitName, Integer auditStatus, Integer pageNo, Integer pageSize) throws ParseException {
 		Map<String, Object> params = new HashMap<>();
 		Date pStart = null;
 		Date pEnd = null;
@@ -192,8 +212,8 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 			params.put("number", number);
 		}
 
-		if (!StringUtils.isBlank(aftUsername)) {
-			params.put("aftUsername", aftUsername);
+		if (!StringUtils.isBlank(unitName)) {
+			params.put("unitName", unitName);
 		}
 
 		if (null != auditStatus) {
@@ -207,7 +227,13 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 		if (pageSize == null || pageSize < 0) {
 			pageSize = 10;
 		}
-		return (Pagination<OrgListBo>) findPage("findOrgListByPage", "findOrgCount", params, pageNo, pageSize);
+		
+		if (TokenManager.hasRole(AFTConstants.SUPERADMIN)){
+			return (Pagination<OrgListBo>) findPage("findOrgListByPage", "findOrgCount", params, pageNo, pageSize);
+		} else if (TokenManager.hasRole(AFTConstants.AREAADMIN) || TokenManager.hasRole(AFTConstants.MANAGERADMIN)){
+			return (Pagination<OrgListBo>) findPage("findAreaManagerOrgListByPage", "findAreaManagerOrgCount", params, pageNo, pageSize);
+		}
+		return null;
 	}
 
 	@Override
@@ -253,8 +279,8 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 			return disposeAchievementUserOwner(userIdentityMapper.selectAchievementUserOwner(aid, name));
 		}
 	}
-	
-	public List<OrgUnitNames> selectAchievementOrgOwner(String name){
+
+	public List<OrgUnitNames> selectAchievementOrgOwner(String name) {
 		String aid = TokenManager.getAdminId();
 		if (TokenManager.hasRole(AFTConstants.MANAGERADMIN)) {
 			return organizationIdentityMapper.selectManagerAchievementOrgOwner(aid, name);
@@ -269,7 +295,7 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 	private Map<String, String> disposeAchievementUserOwner(List<UserNames> list) {
 		Map<String, String> map = new HashMap<>();
 		if (null != list && list.size() > 0) {
-			for(UserNames u : list){
+			for (UserNames u : list) {
 				map.put(u.getUid(), u.getUsername() + " " + u.getMobile());
 			}
 		}
@@ -285,6 +311,5 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 	public String findOrgNameByNameAndMobile(String name, String mobile) {
 		return userMapper.findOrgByNameAndMobile(name, mobile);
 	}
-	
 
 }