Przeglądaj źródła

营销员新增客户统计表处理

anderx 2 lat temu
rodzic
commit
6aa1234ffb

+ 3 - 0
src/main/java/com/goafanti/common/dao/AdminUserCountMapper.java

@@ -1,6 +1,7 @@
 package com.goafanti.common.dao;
 
 import com.goafanti.common.model.AdminUserCount;
+import org.apache.ibatis.annotations.Param;
 
 public interface AdminUserCountMapper {
     int deleteByPrimaryKey(Integer id);
@@ -16,4 +17,6 @@ public interface AdminUserCountMapper {
     int updateByPrimaryKey(AdminUserCount record);
 
     int updateByAidAndDateSelective(AdminUserCount e);
+
+    Integer updateByaidAndDate(@Param("aid") String aid,@Param("startTime") String startTime, @Param("endTime")String endTime);
 }

+ 11 - 0
src/main/java/com/goafanti/common/mapper/AdminUserCountMapper.xml

@@ -23,6 +23,7 @@
     from admin_user_count
     where id = #{id,jdbcType=INTEGER}
   </select>
+
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
     delete from admin_user_count
     where id = #{id,jdbcType=INTEGER}
@@ -168,4 +169,14 @@
       </set>
       where aid = #{aid,jdbcType=VARCHAR} and date_time = #{dateTime,jdbcType=DATE}
     </update>
+
+
+  <select id="updateByaidAndDate" resultType="java.lang.Integer">
+    update admin_user_count a,(select aid,dates,count(*)counts
+        from (select aid,DATE_FORMAT(a.transfer_time , '%Y-%m-%d') dates
+        from user a where status =0 and source in(1,2,3) and share_type=0 and new_channel=0 and aid=  #{aid}
+        and create_time BETWEEN #{startTime} and  #{endTime})x group by aid,dates)b
+    set a.private_count =b.counts
+    where a.aid=b.aid and a.date_time=b.dates
+  </select>
 </mapper>

+ 18 - 1
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -106,7 +106,8 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	private PublicReleaseMapper publicReleaseMapper;
 	@Autowired
 	private SystemWebSocketHandler systemWebSocketHandler;
-
+	@Autowired
+	private AdminUserCountMapper adminUserCountMapper;
 	@Autowired
 	private	AsyncUtils asyncUtils;
 
@@ -450,9 +451,25 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		}
 		addUserLock(uid, TokenManager.getAdminId(), now, uList);
 		addUserTransferLog(uid, TokenManager.getAdminId(), null,0, null, now, uList);
+		updateAdminUserCount(user);
 		return 1;
 	}
 
+	private void updateAdminUserCount(User user) {
+		String startTime=DateUtils.formatDate(user.getCreateTime(),AFTConstants.YYYYMMDD);
+		String endTime=startTime+" 23:59:59";
+		//
+		Integer i = adminUserCountMapper.updateByaidAndDate(user.getAid(), startTime, endTime);
+		if (i==null||i==0){
+			AdminUserCount adminUserCount=new AdminUserCount();
+			adminUserCount.setDateTime(user.getCreateTime());
+			adminUserCount.setPrivateCount(1);
+			adminUserCount.setAid(user.getAid());
+			adminUserCountMapper.insertSelective(adminUserCount);
+		}
+
+	}
+
 	private void checkUserName(InputAddCustomer in) {
 		if (userMapper.checkUser("", in.getName(), "", in.getType(), null, null).size() > 0)
 			throw new BusinessException(new Error(ErrorConstants.CUSTOMER_ALREADY_EXIST, in.getName(), ""));