Переглянути джерело

Merge branch 'test' of jishutao/aft into prod

gitadmin 7 роки тому
батько
коміт
13abd01d3e

+ 6 - 2
src/main/java/com/goafanti/common/mapper/DailySalesReportMapper.xml

@@ -179,7 +179,7 @@
 		from admin a left join user_role b
 		on a.id=b.uid left join role c
 		on b.rid=c.id left join department_management d
-		on a.department_id=d.id left join (select aid,count(0) as privateCustomersCount from user where aid is not null and aid != '' group by aid)e
+		on a.department_id=d.id left join (select aid,count(0) as privateCustomersCount from user where aid is not null and aid != '' and share_type=0 and status != 1 group by aid)e
 		on a.id=e.aid left join admin f
 		on d.manager_id=f.id
 		where c.role_name in ('营销员' ,'营销经理','营销管理员')
@@ -257,6 +257,8 @@ from ( select
 			( select aid, count( aid ) as count1
 				from user 
 				where aid is not null and aid !=''
+				and share_type=0
+				and status != 1
 				group by aid
 			) y left join admin z on
 			y.aid = z.id
@@ -348,7 +350,8 @@ from(
 select a.id,sum(e.privateCustomersCount) as privateCustomersCount
 	from admin a left join user_role b
 	on a.id=b.uid left join role c
-	on b.rid=c.id left join (select aid,count(0) as privateCustomersCount from user group by aid)e
+	on b.rid=c.id left join (select aid,count(0) as privateCustomersCount from user where aid is not null and aid !=''
+				and share_type=0 and status != 1 group by aid)e
 	on a.id=e.aid  where c.role_name in ('营销员','营销经理','营销管理员')
 	<if test="depId != null">
 	and a.department_id = #{depId,jdbcType=VARCHAR}
@@ -424,6 +427,7 @@ from ( select
 			( select aid, count( aid ) as count1
 				from user 
 				where aid is not null and aid !=''
+				and share_type=0 and status != 1
 				group by aid
 			) y left join admin z on
 			y.aid = z.id

+ 1 - 1
src/main/java/com/goafanti/common/mapper/UserLockReleaseMapper.xml

@@ -366,7 +366,7 @@
 	left join 
 		(select uid,aid,max(create_time) as last_follow_time from user_follow where aid = #{aid} group by uid)t1
 	on t0.uid = t1.uid 
-	where datediff(ifnull(t1.last_follow_time,now()),t0.lock_time)>30 or datediff(now(),t0.lock_time)>270
+	where datediff(now(),if(t1.t0.lock_time &lt; t1.last_follow_time,t1.last_follow_time,t1.t0.lock_time))>30 or datediff(now(),t0.lock_time)>270
   </select>
   
   <select id="selectWaitReleaseBusiness"  resultType="com.goafanti.customer.bo.LockingReleaseBo">

+ 3 - 3
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -330,15 +330,15 @@
 			dg1.name as province,
 			dg2.name as city, 
 			dg3.name as area,
-			d.name as adminName,
-			e.name as informationMaintainer		
+			a.aid,
+			a.share_type as shareType,
+			a.information_maintainer as mid 		
 		from user a 
 		left join organization_identity b on a.id = b.uid
 		left join district_glossory dg1 on b.location_province = dg1.id
 		left join district_glossory dg2 on b.location_city = dg2.id
 		left join district_glossory dg3 on b.location_area = dg3.id
 		left join admin d on a.aid = d.id 
-		left join admin e on a.information_maintainer=e.id
 		where a.type = 1 and a.status != 1
 		<if test="aid != null and aid !=''">
 			and a.aid = #{aid,jdbcType=VARCHAR}

+ 3 - 4
src/main/java/com/goafanti/common/task/ReleaseUserTask.java

@@ -15,8 +15,8 @@ import com.goafanti.common.model.User;
 import com.goafanti.customer.bo.LockingReleaseBo;
 import com.goafanti.customer.service.CustomerService;
 import com.goafanti.user.service.UserService;
-//@Component
-@Controller
+@Component
+//@Controller
 public class ReleaseUserTask {
 	@Resource
 	private CustomerService customerServiceImpl;
@@ -26,7 +26,7 @@ public class ReleaseUserTask {
 	/**
 	 * 每天凌晨一点释放客户和业务
 	 */
-	@Scheduled(cron = "0 0 1 * * ?") 
+	@Scheduled(cron = "0 0 1  * * ?") 
 //	@RequestMapping(value = "/releaseUser")
 	public void releaseUser(){
 		Date releaseTime = new Date();
@@ -41,7 +41,6 @@ public class ReleaseUserTask {
 			businessTmpList = customerServiceImpl.selectWaitReleaseBusiness(u.getId());
 			lockBusinessList.addAll(businessTmpList);
 		}
-		
 		if(lockUserList.size()>0) customerServiceImpl.updateReleaseLock(lockUserList,releaseTime);
 		if(lockBusinessList.size()>0) customerServiceImpl.updateReleaseLock(lockBusinessList,releaseTime);
 		if(lockUserList.size()>0) userServiceImpl.updateReleaseLock(lockUserList);

+ 20 - 0
src/main/java/com/goafanti/customer/bo/CustomerListOut.java

@@ -46,6 +46,10 @@ public class CustomerListOut extends CustomerListIn{
 	/** 资料所属人 **/
 	private String informationMaintainer;
 	
+	private String shareType;
+	
+	private String mid;
+	
 	public String getAuditOpinion() {
 		return auditOpinion;
 	}
@@ -164,4 +168,20 @@ public class CustomerListOut extends CustomerListIn{
 	public void setInformationMaintainer(String informationMaintainer) {
 		this.informationMaintainer = informationMaintainer;
 	}
+
+	public String getShareType() {
+		return shareType;
+	}
+
+	public void setShareType(String shareType) {
+		this.shareType = shareType;
+	}
+
+	public String getMid() {
+		return mid;
+	}
+
+	public void setMid(String mid) {
+		this.mid = mid;
+	}
 }

+ 5 - 4
src/main/java/com/goafanti/customer/controller/AdminCustomerApiController.java

@@ -177,14 +177,15 @@ public class AdminCustomerApiController extends BaseApiController{
 	 * @throws Exception 
 	 * @throws NumberFormatException **/
 	@RequestMapping(value = "/addCustomer", method = RequestMethod.POST)
-	public Result addCustomer(String name,String contacts,String contactMobile,Integer type,Integer source,String societyTag) throws Exception{
+	public Result addCustomer(String name,String contacts,String contactMobile,Integer type,
+			 Integer province ,Integer city, Integer area,Integer source,String societyTag) throws Exception{
 		Result res = new Result();
 		if(StringUtils.isBlank(name) || StringUtils.isBlank(contacts)
-				|| StringUtils.isBlank(contactMobile) || StringUtils.isBlank(societyTag)){
-			res.getError().add(buildError("","客户名称、联系人、联系电话、社会性质不能为空"));
+				|| StringUtils.isBlank(contactMobile) || StringUtils.isBlank(societyTag)||null==province||null==city||null==area){
+			res.getError().add(buildError("","客户名称、联系人、联系电话、社会性质、地址不能为空"));
 			return res;
 		}
-		customerService.addCustomer(name, contacts, contactMobile,type,source,societyTag);
+		customerService.addCustomer(name, contacts, contactMobile,type,source,societyTag,province,city,area);
 		return res;
 	}
 	

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

@@ -133,9 +133,12 @@ public interface CustomerService {
 	 * @param contactMobile 联系电话
 	 * @param type 客户类型
 	 * @param societyTag 社会属性
+	 * @param area 
+	 * @param city 
+	 * @param province 
 	 * @return
 	 */
-	int addCustomer(String name,String contacts,String contactMobile,Integer type,Integer source,String societyTag)  throws BusinessException;
+	int addCustomer(String name,String contacts,String contactMobile,Integer type,Integer source,String societyTag, Integer province, Integer city, Integer area)  throws BusinessException;
 	
 	
 	/**

+ 32 - 4
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -22,6 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
 import com.goafanti.common.bo.Error;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
+import com.goafanti.common.dao.AdminMapper;
 import com.goafanti.common.dao.BusinessGlossoryMapper;
 import com.goafanti.common.dao.BusinessProjectMapper;
 import com.goafanti.common.dao.OrganizationContactBookMapper;
@@ -93,6 +94,8 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 	private BusinessProjectMapper businessProjectMapper;
 	@Resource
 	private UserLockReleaseMapper userLockReleaseMapper;
+	@Resource
+	private AdminMapper	adminMapper;
 	@SuppressWarnings("unchecked")
 	@Override
 	public Pagination<CustomerListOut> listPrivatePersonalCustomer(CustomerListIn cli, Integer pageNo,Integer pageSize) {
@@ -163,7 +166,16 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 	public Pagination<CustomerListOut> listAllOrganizationCustomer(CustomerListIn cli, Integer pageNo,Integer pageSize) {
 		cli.setType(AFTConstants.USER_TYPE_ORGANIZATION);
 		Map<String,Object> params = disposeParams(cli);
-		return (Pagination<CustomerListOut>) findPage("selectOrganizationCustomerList","selectOrganizationCustomerCount",params,pageNo,pageSize);
+		Pagination<CustomerListOut> p=(Pagination<CustomerListOut>) findPage("selectOrganizationCustomerList","selectOrganizationCustomerCount",params,pageNo,pageSize);
+		List<CustomerListOut> l=(List<CustomerListOut>) p.getList();
+		for (CustomerListOut c : l) {
+			if (null!=c) {
+				if(null!=c.getAid())c.setAdminName(adminMapper.selectNameByid(c.getAid()));
+				if (null!=c.getShareType()&&c.getShareType().equals("1"))c.setAdminName("暂无");
+				if(null!=c.getMid())c.setInformationMaintainer(adminMapper.selectNameByid(c.getMid()));
+			}
+		}
+		return p; 
 	}
 	
 	@Override
@@ -210,7 +222,8 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 
 	@Override
 	@Transactional
-	public int addCustomer(String name, String contacts, String contactMobile, Integer type, Integer source,String societyTag)  throws BusinessException{
+	public int addCustomer(String name, String contacts, String contactMobile, Integer type, Integer source,String societyTag, 
+			Integer province ,Integer city, Integer area)  throws BusinessException{
 		User user = new User();
 		Date now = new Date();
 		String uid = UUID.randomUUID().toString();
@@ -240,6 +253,9 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 			ui.setContacts(contacts);
 			ui.setContactMobile(contactMobile);
 			ui.setUsername(name);
+			ui.setProvince(province);
+			ui.setCity(city);
+			ui.setArea(area);
 			ui.setExpert(AFTConstants.NO);
 			ui.setCelebrity(AFTConstants.NO);
 			ui.setInternational(AFTConstants.NO);
@@ -254,6 +270,9 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 			oi.setUid(uid);
 			oi.setContacts(contacts);
 			oi.setContactMobile(contactMobile);
+			oi.setLocationProvince(province);
+			oi.setLocationCity(city);
+			oi.setLocationArea(area);
 			oi.setHighTechZone(AFTConstants.NO);
 			oi.setInternational(AFTConstants.NO);
 			oi.setListed(AFTConstants.NO);
@@ -1170,9 +1189,18 @@ public class CustomerServiceImpl  extends BaseMybatisDao<UserMapper> implements
 		Long l1,l2;
 		int diff1,diff2;
 		for(CustomerListOut clo: tmpList){
-			s1 = StringUtils.isBlank(clo.getLastFollowTime()) ? clo.getTransferTime() : clo.getLastFollowTime();
-			s2 = StringUtils.isBlank(clo.getLastSignTime()) ? clo.getTransferTime() : clo.getLastSignTime();
+			//s1 = StringUtils.isBlank(clo.getLastFollowTime()) ? clo.getTransferTime() : clo.getLastFollowTime();
 			try {
+			if (StringUtils.isNotBlank(clo.getLastFollowTime())){
+				if(DateUtils.parseDate(clo.getLastFollowTime(), AFTConstants.YYYYMMDDHHMMSS).getTime()>DateUtils.parseDate(clo.getTransferTime(), AFTConstants.YYYYMMDDHHMMSS).getTime()) {
+					s1=clo.getLastFollowTime();
+				}else {
+					s1=clo.getTransferTime();
+				}
+			}else {
+				s1=clo.getTransferTime();
+			}
+			s2 = StringUtils.isBlank(clo.getLastSignTime()) ? clo.getTransferTime() : clo.getLastSignTime();
 				l1 = DateUtils.parseDate(s1, AFTConstants.YYYYMMDDHHMMSS).getTime();
 				l2 = DateUtils.parseDate(s2, AFTConstants.YYYYMMDDHHMMSS).getTime();
 				diff1 = (int)((l1 + AFTConstants.USER_FOLLOW_LIMIT_MS - now.getTime())/(24*3600*1000));