Browse Source

销售来源统计导出百分比处理

anderx 3 years ago
parent
commit
3322e0fd2f

+ 24 - 9
src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java

@@ -3,6 +3,7 @@ package com.goafanti.customer.controller;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Type;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -53,6 +54,8 @@ public class AdminCustomerApiController extends BaseApiController{
 	private AttachmentService aftFileService;
 	@Value(value = "${upload.private.path}")
 	private String	uploadPrivatePath	= null;
+	@Value(value = "${user.receive.max}")
+	private Integer USER_RECEIVE_MAX = null;
 	@Resource
 	private AdminService adminService;
 
@@ -323,7 +326,7 @@ public class AdminCustomerApiController extends BaseApiController{
 			res.getError().add(buildError("","创建客户参数不全"));
 			return res;
 		}
-		if (customerService.checkMax(TokenManager.getAdminId())) {
+		if (customerService.checkMax(null,TokenManager.getAdminId())) {
 			res.getError().add(buildError("","私有客户已达最大限制"));
 			return res;
 		}
@@ -622,24 +625,36 @@ public class AdminCustomerApiController extends BaseApiController{
 		return res;
 	}
 
-	/** 领取客户 **/
+	/**
+	 * 领取客户
+	 * @param uid 客户编号
+	 * @param oldAid 原来的客户归属人
+	 * @return
+	 */
 	@RequestMapping(value = "/receiveCustomer", method = RequestMethod.GET)
-	public Result receiveCustomer(String uid,String oldAid){
+	public Result receiveCustomer(String uid, String oldAid) {
 		Result res = new Result();
-		if(StringUtils.isBlank(uid) || StringUtils.isBlank("oldAid")){
+		if (StringUtils.isBlank(uid) || StringUtils.isBlank("oldAid")) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, ""));
 			return res;
 		}
-		if (customerService.checkMax(TokenManager.getAdminId())) {
-			res.getError().add(buildError("","私有客户已达最大限制"));
+
+		if (customerService.receiveEveryDay(uid)){
+			res.getError().add(buildError(ErrorConstants.CUSTOM_EREXCESS,  USER_RECEIVE_MAX.toString(),USER_RECEIVE_MAX.toString()));
+			return res;
+
+		}
+		if (customerService.checkMax(uid,TokenManager.getAdminId())) {
+			res.getError().add(buildError("", "私有客户已达最大限制"));
 			return res;
 		}
 
 		if (customerService.checkBeforeChannel(uid)) {
-			res.getError().add(buildError("","渠道客户丢失后不可再领取"));
+			res.getError().add(buildError("", "外联客户丢失后不可再领取"));
 			return res;
 		}
-		customerService.updateByOperatorType(uid,null, oldAid,AFTConstants.USER_RECEIVE,null);
+
+		customerService.updateByOperatorType(uid, null, oldAid, AFTConstants.USER_RECEIVE, null);
 		return res;
 	}
 
@@ -873,7 +888,7 @@ public class AdminCustomerApiController extends BaseApiController{
 					operatorType=AFTConstants.USER_TRANSFER_TO_OTHER;
 				}
 		if ((operatorType ==AFTConstants.USER_TRANSFER_TO_OTHER||operatorType ==AFTConstants.USER_RECEIVE)
-				&& customerService.checkMax(aid)) {
+				&& customerService.checkMax(uid,aid)) {
 			res.getError().add(buildError("","对方私有客户已达最大限制"));
 			return res;
 		}

+ 4 - 1
src/main/java/com/goafanti/customer/service/CustomerService.java

@@ -7,6 +7,7 @@ import java.util.Set;
 
 
 import com.goafanti.customer.bo.*;
+import org.apache.poi.hssf.record.BOFRecord;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 import com.goafanti.common.bo.userDaysBo;
@@ -501,7 +502,7 @@ public interface CustomerService {
 	Pagination<FollowListBo> listFollowHistory(Integer pageNo, Integer pageSize,String uid,String businessGlossoryId,Integer type);
 	int pushGuidance(String uid);
 
-	boolean checkMax(String aid);
+	boolean checkMax(String uid,String aid);
 	/**
 	 *
 	 * @param list 释放客户
@@ -543,4 +544,6 @@ public interface CustomerService {
 	Pagination<OutChannelListBo> channelUserList(InputChannelListBo in);
 
     List<?> selectChannelUserList(InputChannelListBo in);
+
+	boolean receiveEveryDay(String uid);
 }

+ 21 - 5
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -63,12 +63,12 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	private OrganizationContactBookMapper organizationContactBookMapper;
 	@Resource(name = "passwordUtil")
 	private PasswordUtil passwordUtil;
-	@Value(value = "${user.receive.max}")
-	private Integer USER_RECEIVE_MAX = null;
 	@Value(value = "${user_remind_days}")
 	private Integer USER_REMIND_DAYS = null;
 	@Value(value = "${user_channel_days}")
 	private Integer USER_CHANNEL_DAYS= null;
+	@Value(value = "${user.receive.max}")
+	private Integer USER_RECEIVE_MAX = null;
 	@Resource
 	private UserFollowMapper userFollowMapper;
 	@Resource
@@ -1163,8 +1163,6 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		int flag = 0;
 		//领取
 		if (AFTConstants.USER_RECEIVE.equals(operatorType)) {
-			if (userMapper.UserReceiveCount(TokenManager.getAdminId()) >= USER_RECEIVE_MAX)
-				throw new BusinessException(new Error(ErrorConstants.CUSTOM_EREXCESS, "" + USER_RECEIVE_MAX, ""));
 			user.setAid(TokenManager.getAdminId());
 			user.setShareType(AFTConstants.USER_SHARE_PRIVATE);
 			user.setInformationMaintainer(TokenManager.getAdminId());
@@ -1235,6 +1233,16 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		return 1;
 	}
 
+	@Override
+	public boolean receiveEveryDay(String uid) {
+		if (uid !=null ){
+			User u=userMapper.selectByPrimaryKey(uid);
+			if (u.getNewChannel()==1)return false;
+		}
+		if (userMapper.UserReceiveCount(TokenManager.getAdminId()) >= USER_RECEIVE_MAX)return  true;
+		return false;
+	}
+
 
 
 	/**
@@ -2083,9 +2091,15 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	}
 
 	@Override
-	public boolean checkMax(String aid) {
+	public boolean checkMax(String uid,String aid) {
 		int y = 0;
 		int i = userMapper.checkUserMax(aid);
+		if (uid !=null){
+			User user =userMapper.selectByPrimaryKey(uid);
+			if (user.getNewChannel()==1){
+				return false;
+			}
+		}
 		List<String > roles=adminMapper.getAdminRoleListByAid(aid);
 		for (String role : roles) {
 			if (role.equals(AFTConstants.SALESMAN_DIRECTOR)){
@@ -2436,6 +2450,8 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		return (List<OutChannelListBo>) findList("channelUserList",params,1,9999);
 	}
 
+
+
 	/**
 	 * 根据您 初始时间、最后跟进时间当前时间计算剩余天数
 	 * @param out