Преглед изворни кода

营销客户统计相关接口修改

anderx пре 2 година
родитељ
комит
3ae40b6da6

+ 2 - 1
src/main/java/com/goafanti/common/dao/PublicReleaseMapper.java

@@ -2,7 +2,6 @@ package com.goafanti.common.dao;
 
 import com.goafanti.common.model.OutPublicReleaseCount;
 import com.goafanti.common.model.PublicRelease;
-import com.goafanti.common.model.PublicReleaseCount;
 import com.goafanti.weChat.bo.OutPublicRelease;
 import com.goafanti.weChat.bo.OutPublicReleaseAndDetails;
 import org.apache.ibatis.annotations.Param;
@@ -50,4 +49,6 @@ public interface PublicReleaseMapper {
     void updateStatusByMainId(@Param("status") Integer status, @Param("type") Integer type,@Param("mainId") Integer mainId,@Param("aid") String aid);
 
     OutPublicReleaseAndDetails selectDtailsByFid(@Param("ufid")String ufid);
+
+    int selectByaidAndDate(@Param("aid") String aid, @Param("startTime") String startTime, @Param("endTime") String endTime);
 }

+ 2 - 1
src/main/java/com/goafanti/common/dao/UserFollowMapper.java

@@ -58,4 +58,5 @@ public interface UserFollowMapper {
 	List<UserFollow> selectbyUid(@Param("uid")String uid, @Param("aid")String aid);
 
 
-}
+    int selectByaidAndDate(@Param("aid") String aid, @Param("startTime") String startTime, @Param("endTime") String endTime);
+}

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

@@ -851,7 +851,8 @@
       and aid= #{aid}
     </if>
   </select>
-  <update id="updateStatusByMainId">
+
+    <update id="updateStatusByMainId">
     update public_release set status= #{status}
     where main_id= #{mainId}
     <if test="type !=null">
@@ -861,4 +862,13 @@
       and aid= #{aid}
     </if>
   </update>
+
+  <select id="selectByaidAndDate" resultType="java.lang.Integer">
+    select count(*)publicReleaseCount
+    from (select aid
+          from public_release a left join public_release_details b on a.id=b.prid
+          where status =2 and aid= #{aid}
+            and a.release_start BETWEEN #{startTime} and #{endTime} )x
+    group by aid
+  </select>
 </mapper>

+ 7 - 0
src/main/java/com/goafanti/common/mapper/UserFollowMapper.xml

@@ -377,4 +377,11 @@
         </foreach>
       </if>
 	</select>
+    <select id="selectByaidAndDate" resultType="java.lang.Integer">
+      select count(*)followCount
+      from (select aid
+        from user_follow where aid= #{aid}
+        and create_time BETWEEN #{startTime} and #{endTime})a
+      group by aid
+    </select>
 </mapper>

+ 43 - 17
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -748,7 +748,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	@Transactional
 	public int addFollow(FollowBusinessBo fbb,String ufid,Integer mainStatus) throws BusinessException {
 		// 更新跟进记录表
-		SimpleDateFormat format = new SimpleDateFormat(AFTConstants.YYYYMMDDHHMMSS);
+		Date followTime=DateUtils.StringToDate(fbb.getFollowTime(),AFTConstants.YYYYMMDDHHMMSS);
 		UserFollow userFollow = new UserFollow();
 		String followId = ufid==null?UUID.randomUUID().toString():ufid;
 		userFollow.setId(followId);
@@ -759,11 +759,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		userFollow.setFollowDep(a.getDepartmentName());
 		userFollow.setContactType(Integer.parseInt(fbb.getContactType()));
 		userFollow.setEffective(DeleteStatus.UNDELETE.getCode());
-		try {
-			userFollow.setCreateTime(format.parse(fbb.getFollowTime()));
-		} catch (ParseException e) {
-			e.printStackTrace();
-		}
+		userFollow.setCreateTime(followTime);
 		userFollow.setOcbId(fbb.getOcbId());
 		userFollow.setResult(fbb.getResult());
 		userFollow.setUid(fbb.getUid());
@@ -838,11 +834,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 					userBusiness.setFollowSituation(ub.getFollowSituation());
 					userBusiness.setRemarks(ub.getRemarks());
 					userBusiness.setUid(fbb.getUid());
-					try {
-						userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
-					} catch (ParseException e) {
-						e.printStackTrace();
-					}
+					userBusiness.setUpdateTime(followTime);
 					userBusiness.setAid(TokenManager.getAdminId());
 					userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
 					// 更新业务中间表
@@ -884,12 +876,8 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 					// 更新业务表
 					userBusiness.setId(ubId);
 					userBusiness.setBusinessProjectId(ub.getBusinessProjectId());
-					try {
-						userBusiness.setCreateTime(format.parse(fbb.getFollowTime()));
-						userBusiness.setUpdateTime(format.parse(fbb.getFollowTime()));
-					} catch (ParseException e) {
-						e.printStackTrace();
-					}
+					userBusiness.setCreateTime(followTime);
+					userBusiness.setUpdateTime(followTime);
 					userBusiness.setCustomerStatus(ub.getCustomerStatus());
 					userBusiness.setFollowSituation(ub.getFollowSituation());
 					userBusiness.setUid(fbb.getUid());
@@ -912,9 +900,47 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		if (mainStatus==1){
 		followProject(fbb.getUid());
 		}
+		updateADminUserCountFollow(aid,followTime);
 		return 1;
 	}
 
+	private void updateADminUserCountFollow(String aid, Date transferTime) {
+		{
+			String startTime= DateUtils.formatDate(transferTime,AFTConstants.YYYYMMDD);
+			String endTime=startTime+" 23:59:59";
+			AdminUserCount adminUserCount = adminUserCountMapper.selectByaidAndDate(aid, startTime);
+			int count = userFollowMapper.selectByaidAndDate(aid, startTime, endTime);
+			if (adminUserCount==null){
+				AdminUserCount selectAUC=userMapper.selectByaidAndDate(aid,startTime,endTime);
+				if (selectAUC==null)selectAUC=new AdminUserCount();
+				selectAUC.setFollowCount(count);
+				selectAUC.setAid(aid);
+				selectAUC.setDateTime(transferTime);
+				adminUserCountMapper.insertSelective(selectAUC);
+			}else {
+				AdminUserCount selectAUC=userMapper.selectByaidAndDate(aid,startTime,endTime);
+				AdminUserCount newAUC=new AdminUserCount();
+				newAUC.setId(adminUserCount.getId());
+				newAUC.setFollowCount(count);
+				if (selectAUC==null){
+					newAUC.setPrivateCount(0);
+					newAUC.setChannelCount(0);
+					newAUC.setSignCount(0);
+				}else {
+					if (selectAUC.getPrivateCount()==null)selectAUC.setPrivateCount(0);
+					if (selectAUC.getChannelCount()==null)selectAUC.setChannelCount(0);
+					if (selectAUC.getSignCount()==null)selectAUC.setSignCount(0);
+					newAUC.setPrivateCount(selectAUC.getPrivateCount());
+					newAUC.setChannelCount(selectAUC.getChannelCount());
+					newAUC.setSignCount(selectAUC.getSignCount());
+				}
+
+				adminUserCountMapper.updateByPrimaryKeySelective(newAUC);
+			}
+
+		}
+	}
+
 	/**
 	 * 跟进更新用户中间表
 	 *

+ 38 - 0
src/main/java/com/goafanti/weChat/service/impl/PublicReleaseServiceImpl.java

@@ -59,6 +59,8 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 	private DepartmentService	departmentService;
 	@Autowired
 	private PublicExamineMapper publicExamineMapper;
+	@Autowired
+	private AdminUserCountMapper adminUserCountMapper;
 
 	@Override
 	@Transactional
@@ -650,6 +652,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 		}
 		if (p.getStatus()!=null||p.getPublicType()!=null){
 			publicReleaseMapper.updateByPrimaryKeySelective(p);
+			updateAdminUserCountPublicRelease(use.getAid(),date);
 		}
 		if (a.getOpenId()!=null) {
 			if (remarks.length()>19) {
@@ -666,6 +669,41 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 			return 1;
 	}
 
+	private void updateAdminUserCountPublicRelease(String aid, Date transferTime) {
+		String startTime= DateUtils.formatDate(transferTime,AFTConstants.YYYYMMDD);
+		String endTime=startTime+" 23:59:59";
+		AdminUserCount adminUserCount = adminUserCountMapper.selectByaidAndDate(aid, startTime);
+		int count = publicReleaseMapper.selectByaidAndDate(aid, startTime, endTime);
+		if (adminUserCount==null){
+			AdminUserCount selectAUC=userMapper.selectByaidAndDate(aid,startTime,endTime);
+			if (selectAUC==null)selectAUC=new AdminUserCount();
+			selectAUC.setPublicReleaseCount(count);
+			selectAUC.setAid(aid);
+			selectAUC.setDateTime(transferTime);
+			adminUserCountMapper.insertSelective(selectAUC);
+		}else {
+			AdminUserCount selectAUC=userMapper.selectByaidAndDate(aid,startTime,endTime);
+			AdminUserCount newAUC=new AdminUserCount();
+			newAUC.setId(adminUserCount.getId());
+			newAUC.setPublicReleaseCount(count);
+			if (selectAUC==null){
+				newAUC.setPrivateCount(0);
+				newAUC.setChannelCount(0);
+				newAUC.setSignCount(0);
+			}else {
+				if (selectAUC.getPrivateCount()==null)selectAUC.setPrivateCount(0);
+				if (selectAUC.getChannelCount()==null)selectAUC.setChannelCount(0);
+				if (selectAUC.getSignCount()==null)selectAUC.setSignCount(0);
+				newAUC.setPrivateCount(selectAUC.getPrivateCount());
+				newAUC.setChannelCount(selectAUC.getChannelCount());
+				newAUC.setSignCount(selectAUC.getSignCount());
+			}
+
+			adminUserCountMapper.updateByPrimaryKeySelective(newAUC);
+		}
+
+	}
+
 	private void addpublicLog(Integer id, Integer status, String remarks) {
 		PublicReleaseLog log = new PublicReleaseLog(id, TokenManager.getAdminId(), status, remarks, new Date());
 		publicReleaseLogMapper.insertSelective(log);