Browse Source

线索客户新增释放任务

anderx 1 year ago
parent
commit
d61e3f90e2

+ 1 - 1
src/main/java/com/goafanti/common/constant/AFTConstants.java

@@ -69,7 +69,7 @@ public class AFTConstants {
 	public static final String  FINANCE_MANAGER						= "997";
 	/** 营销经理 */
 	public static final String  SALESMAN_MANAGER                    = "996";
-	/** 营销经理 */
+	/** 心锁经理 */
 	public static final String  CLUE_MANAGER                    = "986";
 	/** 客服营销员 */
 	public static final String  CUSTOMER_SERVICE_SALESMAN     		= "960";

+ 4 - 0
src/main/java/com/goafanti/common/dao/UserMapper.java

@@ -300,5 +300,9 @@ public interface UserMapper {
     List<LockingReleaseBo > selectSignReleaseUser(String id);
 
     int selectUserLevel(String aid);
+
+    List<User> selectClueUserByClueType(String aid);
+
+    void updateClueUserRelease(List<User> updateList);
 }
 

+ 1 - 0
src/main/java/com/goafanti/common/enums/NoticeStatus.java

@@ -92,6 +92,7 @@ public enum NoticeStatus {
 	PUBLIC_MAX_DURATION(82,"公出时长审核发起"),
 	PUBLIC_MAX_DURATION_YES(83,"公出时长审核通过"),
 	PUBLIC_MAX_DURATION_NO(84,"公出时长审核驳回"),
+	CLUE_USER_RELEASE(85,"线索客户丢失"),
 	OTHER(0, "其他");
 
 	private NoticeStatus(Integer code, String desc) {

+ 1 - 0
src/main/java/com/goafanti/common/enums/NoticeTypes.java

@@ -53,6 +53,7 @@ public enum NoticeTypes {
 		} else if (i == NoticeStatus.CUSTOMER_LOSE30.getCode() || i == NoticeStatus.CUSTOMER_LOSE270.getCode()
 				|| i == NoticeStatus.CUSTOMER_CHENNEL_LOSE.getCode() || i == NoticeStatus.CUSTOMER_CHENNEL_RECOVERY.getCode()
 				|| i == NoticeStatus.RESTRICT_PROJECT_LOSE30.getCode() || i == NoticeStatus.RESTRICT_PROJECT_LOSE270.getCode()
+				||i == NoticeStatus.CLUE_USER_RELEASE.getCode()
 		) {
 			return KHSF.code;
 		} else if (i == NoticeStatus.CUSTOMER_PRIVATE_REMINDER.getCode()|| i == NoticeStatus.CUSTOMER_LOSE_REMINDER.getCode()

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

@@ -2180,7 +2180,8 @@ inner join(
      </foreach>
      )
   </update>
-  <select id="checkBeforeChannel" resultType="java.lang.String">
+
+	<select id="checkBeforeChannel" resultType="java.lang.String">
 	 select b.aid from user_channel a
 	left join user b on a.uid =b.id
 	where a.status=8 and a.uid = #{uid}
@@ -2525,4 +2526,18 @@ inner join(
 		where a.type= 1 and a.source in(1,2,3) and a.share_type = 0 and a.new_channel=0
 		and aid = #{aid}
 	</select>
+    <select id="selectClueUserByClueType" resultMap="UserMap">
+		select
+		    <include refid="UserAllSql"/>
+		from user
+		where clue_status =1 and clue_process in (0,1,2) and clue_aid = #{aid}
+	</select>
+	<update id="updateClueUserRelease">
+		update user
+		set clue_process =3,clue_transfer_time=now()
+		where id in
+		<foreach item="item" collection="list" separator=","  open="(" close=")">
+			#{item.id}
+		</foreach>
+	</update>
 </mapper>

+ 71 - 26
src/main/java/com/goafanti/common/task/ReleaseUserTask.java

@@ -4,10 +4,7 @@ import com.goafanti.business.bo.OutRestrictProject;
 import com.goafanti.common.bo.EmailBo;
 import com.goafanti.common.bo.userDaysBo;
 import com.goafanti.common.constant.AFTConstants;
-import com.goafanti.common.dao.AdminUserCountMapper;
-import com.goafanti.common.dao.NoticeMapper;
-import com.goafanti.common.dao.RestrictProjectMapper;
-import com.goafanti.common.dao.UserTransferLogMapper;
+import com.goafanti.common.dao.*;
 import com.goafanti.common.enums.NoticeStatus;
 import com.goafanti.common.enums.NoticeTypes;
 import com.goafanti.common.model.AdminUserCount;
@@ -22,12 +19,11 @@ import com.goafanti.customer.service.CustomerService;
 import com.goafanti.user.service.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
 import java.util.ArrayList;
 import java.util.Date;
@@ -35,8 +31,8 @@ import java.util.List;
 import java.util.UUID;
 
 
-@Component
-//@RestController
+//@Component
+@RestController
 public class ReleaseUserTask {
 	@Resource
 	private CustomerService customerService;
@@ -52,36 +48,92 @@ public class ReleaseUserTask {
 
 	int pointsDataLimit = 50;
 
-	@Autowired
+	@Resource
 	private AdminUserCountMapper adminUserCountMapper;
 
-	@Autowired
+	@Resource
 	private RestrictProjectMapper restProjectMapper;
 
-	@Autowired
+	@Resource
 	private UserTransferLogMapper userTransferLogMapper;
+	@Resource
+	private UserMapper userMapper;
 
 	/**
 	 * 客户释放
 	 *
 	 */
 //	@Scheduled(cron = "0 10 17  * * ?")
-//	@RequestMapping("/open/test")
-	@Scheduled(cron = "0 0 1  * * ?")
+	@RequestMapping("/open/test")
+//	@Scheduled(cron = "0 0 1  * * ?")
 	public void startTask() {
 		try {
 			List<User> userList = userService.selectUserByRoleName("营销员", "营销经理");
-			pushUserDays(userList);
-			Thread.sleep(2000);
-			updateUser(userList);
+//			pushUserDays(userList);
+//			Thread.sleep(2000);
+//			updateUser(userList);
+//			Thread.sleep(2000);
+//			pushRestrictProject(userList);
 			Thread.sleep(2000);
-			pushRestrictProject(userList);
+			pushReleaseClueyUser(userList);
 		} catch (InterruptedException e) {
 			e.printStackTrace();
 		}
 
 	}
 
+	private void pushReleaseClueyUser(List<User> userList) {
+		LoggerUtils.debug(getClass(), "==============线索客户丢失开始============");
+		LocalDateTime now = LocalDateTime.now();
+		Date date = new Date();
+		List<Notice> ln = new ArrayList<>();
+		List<User> releaseUserList = new ArrayList<>();
+		List<UserTransferLog> logList=new ArrayList<>();
+		for (User admin : userList) {
+			List<User> users = userMapper.selectClueUserByClueType(admin.getId());
+			for (User u : users) {
+				LocalDateTime clueTime = u.getClueTime().toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDateTime();
+				LocalDateTime endTime = clueTime.plusDays(15);
+				long between= ChronoUnit.DAYS.between(now, endTime);
+				if (between<1){
+					releaseUserList.add(u);
+					String aid=admin.getId();
+					if (u.getClueProcess()==1)aid=u.getAid();
+					logList.add(new UserTransferLog(u.getId(), "1",null, 27, "",date));
+					ln.add(new Notice(UUID.randomUUID().toString(),date, 0, aid,
+							NoticeStatus.CLUE_USER_RELEASE.getCode(),
+							String.format("您的线索客户[%s]已丢失!",u.getNickname())
+							,u.getId()));
+				}
+			}
+
+		}
+		addNoticeBatch(ln);
+		addUserTransferLogBatch(logList);
+		pushClueUserRelease(releaseUserList);
+		LoggerUtils.debug(getClass(), "==============线索客户丢失结束============");
+	}
+
+	private void pushClueUserRelease(List<User> lu) {
+		List<User> updateList=new ArrayList<>();
+		if (lu != null && !lu.isEmpty()) {
+			for (int i = 0; i < lu.size(); i++) {
+				updateList.add(lu.get(i));
+				if (50 == updateList.size() || i == lu.size() - 1) {
+                    userMapper.updateClueUserRelease(updateList);
+                    updateList.clear();
+					try {
+						Thread.sleep(1000);
+					} catch (InterruptedException e) {
+						e.printStackTrace();
+					}
+				}
+			}
+		}
+
+	}
+
+
 	/**
 	 * 限时项目定时任务
 	 */
@@ -163,14 +215,7 @@ public class ReleaseUserTask {
 		}
 	}
 
-	public static void main(String[] args) {
-		LocalDateTime now = LocalDateTime.now();
-		LocalDateTime endTime = LocalDateTime.of(2024,5,14,0,0);
-		endTime= endTime.minusDays(270);
-		long between = ChronoUnit.DAYS.between(now, endTime);
-		System.out.println(between);
-		System.out.println(endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
-	}
+
 
 	private void pushReleaseRestrictProject(List<Integer> list) {
 		List<Integer> list2 = new ArrayList<>();

+ 9 - 0
src/main/java/com/goafanti/customer/bo/OutUserClueList.java

@@ -19,6 +19,15 @@ public class OutUserClueList {
     private String clueProcess;
     private Date clueTime;
     private Date clueTransferTime;
+    private Integer days;
+
+    public Integer getDays() {
+        return days;
+    }
+
+    public void setDays(Integer days) {
+        this.days = days;
+    }
 
     public String getClueAname() {
         return clueAname;

+ 15 - 1
src/main/java/com/goafanti/customer/service/impl/UserClueServiceImpl.java

@@ -15,6 +15,8 @@ import com.goafanti.customer.service.UserClueService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -55,7 +57,19 @@ public class UserClueServiceImpl extends BaseMybatisDao<UserMapper> implements U
         }
         in.setAid(TokenManager.getAdminId());
         if(in.getEndTime()!=null)in.setEndTime(in.getEndTime()+ " 23:59:59");
-        return (Pagination<OutUserClueList>)findPage("selectUserClueList", "selectUserClueCount", in);
+        return pushReleaseUser((Pagination<OutUserClueList>) findPage("selectUserClueList", "selectUserClueCount", in));
+    }
+
+    private Pagination<OutUserClueList> pushReleaseUser(Pagination<OutUserClueList> page) {
+        List<OutUserClueList> list = (List<OutUserClueList>) page.getList();
+        LocalDateTime now=LocalDateTime.now().withHour(0).withMinute(0).withSecond(0);
+        for (OutUserClueList e : list) {
+            LocalDateTime clueTime = e.getClueTime().toInstant().atZone(java.time.ZoneId.systemDefault()).toLocalDateTime();
+            clueTime = clueTime.plusDays(15).withHour(0).withMinute(0).withSecond(0);
+            long between = ChronoUnit.DAYS.between(now,clueTime);
+            e.setDays((int) between);
+        }
+        return page;
     }
 
     @Override

+ 2 - 0
src/main/resources/props/config_local.properties

@@ -52,6 +52,8 @@ user_channel_days=90
 yxzj_max=800
 yxy_max=100
 yxjl_max=100
+#\u7EBF\u7D22\u5BA2\u6237\u91CA\u653E\u65F6\u95F4
+clue_release_day=15
 
 amb.maxLvl=6
 

+ 2 - 0
src/main/resources/props/config_test.properties

@@ -47,6 +47,8 @@ user_channel_days=90
 yxzj_max=800
 yxy_max=100
 yxjl_max=100
+#\u7EBF\u7D22\u5BA2\u6237\u91CA\u653E\u65F6\u95F4
+clue_release_day=15
 
 amb.maxLvl=6