Browse Source

用户客户统计新增、领取客户修改

anderx 2 years ago
parent
commit
88ee3bafa8

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

@@ -22,4 +22,6 @@ public interface AdminUserCountMapper {
                            @Param("endTime")String endTime,@Param("type")Integer type);
 
     AdminUserCount selectByaidAndDate(@Param("aid") String aid,@Param("startTime") String startTime);
+
+    void updateUserCountResetting(String aid);
 }

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

@@ -200,10 +200,17 @@
     where a.aid=b.aid and a.date_time=b.dates
   </update>
 
+
   <select id="selectByaidAndDate"  resultMap="BaseResultMap">
     select
     <include refid="Base_Column_List" />
     from admin_user_count
     where aid= #{aid} and date_time=#{startTime}
   </select>
+
+  <update id="updateUserCountResetting">
+    update admin_user_count
+    set  private_count=0,sign_count=0,channel_count=0
+    where aid= #{aid}
+  </update>
 </mapper>

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

@@ -1987,7 +1987,7 @@ inner join(
 		and share_type=2
 	</select>
 	<update id="updateShareType">
-	update user set share_type =2,sign_bills =1,aid = #{aid}
+	update user set share_type =2,sign_bills =1,aid = #{aid},transfer_time= now()
 	where id= #{uid}
 	</update>
 
@@ -2359,9 +2359,6 @@ inner join(
 		if(share_type=0 and new_channel=0,1,0) privateCount,
 		if(share_type=0 and new_channel=1,1,0)channelCount, if(share_type=2,1,0)signCount
 		from user a where status =0 and source in(1,2,3) and aid= #{aid}
-		<if test="startTime!=null or endTime !=null">
-			and transfer_time  BETWEEN #{startTime} and #{endTime}
-		</if>
 		)x group by aid,dateTime
 	</select>
 </mapper>

+ 18 - 12
src/main/java/com/goafanti/common/utils/AsyncUtils.java

@@ -61,28 +61,34 @@ public class AsyncUtils {
 @Autowired
 	private AdminUserCountMapper adminUserCountMapper;
 
+	/**
+	 * 处理离职意见转交客户
+	 * 	转出去则全部为0,转入则判定当天有没有,有则修改没有新增
+	 * @param aid
+	 * @param transferId
+	 */
     public  void updateAdminUserCount(String aid, String transferId) {
-		List<AdminUserCount> list1 = userMapper.selectListByaidAndDate(aid);
-		List<AdminUserCount> list2 = userMapper.selectListByaidAndDate(transferId);
-		pushAdminUserCount(list1);
-		pushAdminUserCount(list2);
+		adminUserCountMapper.updateUserCountResetting(aid);
+		List<AdminUserCount> list = userMapper.selectListByaidAndDate(transferId);
+		pushAdminUserCount(list);
 	}
 
 	private void pushAdminUserCount(List<AdminUserCount> list) {
 		for (AdminUserCount e : list) {
 			String startTime=DateUtils.formatDate(e.getDateTime(),AFTConstants.YYYYMMDD);
 			AdminUserCount selectAUC = adminUserCountMapper.selectByaidAndDate(e.getAid(), startTime);
-			AdminUserCount newAUC=new AdminUserCount();
-			newAUC.setId(e.getId());
+
 			if (selectAUC==null){
 				adminUserCountMapper.insertSelective(e);
 			}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());
+				AdminUserCount newAUC=new AdminUserCount();
+				newAUC.setId(selectAUC.getId());
+				if (e.getPrivateCount()==null)selectAUC.setPrivateCount(0);
+				if (e.getChannelCount()==null)selectAUC.setChannelCount(0);
+				if (e.getSignCount()==null)selectAUC.setSignCount(0);
+				newAUC.setPrivateCount(e.getPrivateCount());
+				newAUC.setChannelCount(e.getChannelCount());
+				newAUC.setSignCount(e.getSignCount());
 				adminUserCountMapper.updateByPrimaryKeySelective(newAUC);
 			}
 		}

+ 8 - 0
src/main/java/com/goafanti/customer/service/CustomerService.java

@@ -571,4 +571,12 @@ public interface CustomerService {
 
 
 	void transferUser(List<String> uList, String aid, String uid);
+
+
+	/**
+	 *
+	 * @param aid
+	 * @param transferTime
+	 */
+	void updateAdminUserCount(String aid,Date transferTime);
 }

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

@@ -461,7 +461,8 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	 * @param  aid    管理员编号
 	 * @param  transferTime  客户转换时间
 	 */
-	private void updateAdminUserCount(String aid ,Date transferTime) {
+	@Override
+	public void updateAdminUserCount(String aid ,Date transferTime) {
 		String startTime=DateUtils.formatDate(transferTime,AFTConstants.YYYYMMDD);
 		String endTime=startTime+" 23:59:59";
 		AdminUserCount adminUserCount = adminUserCountMapper.selectByaidAndDate(aid, startTime);

+ 8 - 0
src/main/java/com/goafanti/order/service/impl/OrderProjectServiceImpl.java

@@ -21,6 +21,7 @@ import com.goafanti.common.utils.excel.NewExcelUtil;
 import com.goafanti.core.mybatis.BaseMybatisDao;
 import com.goafanti.core.mybatis.page.Pagination;
 import com.goafanti.core.shiro.token.TokenManager;
+import com.goafanti.customer.service.CustomerService;
 import com.goafanti.order.bo.*;
 import com.goafanti.order.controller.InputTaskStopLog;
 import com.goafanti.order.enums.*;
@@ -121,6 +122,8 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 	private TaskStopMapper taskStopMapper;
 	@Autowired
 	private TaskStopLogMapper taskStopLogMapper;
+	@Autowired
+	private CustomerService customerService;
 
 
 
@@ -188,6 +191,11 @@ public class OrderProjectServiceImpl extends BaseMybatisDao<TOrderTaskMapper> im
 		//处理订单信息
 		checkProjiectAllocation(t.getOrderNo());
 		pushTaskChange(TokenManager.getAdminId(),taskReceiverId,type,t.getOrderNo());
+		//派单后设置用户客户统计
+		if (type==0){
+			customerService.updateAdminUserCount(tn.getSalesmanId(),date);
+
+		}
 		return 1;
 	}