|
|
@@ -0,0 +1,63 @@
|
|
|
+package com.goafanti.common.task;
|
|
|
+
|
|
|
+import com.goafanti.common.dao.PublicReleaseMapper;
|
|
|
+import com.goafanti.common.dao.TOrderNewMapper;
|
|
|
+import com.goafanti.common.model.outUserFollowCount;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Component
|
|
|
+public class UserFollowTask {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PublicReleaseMapper publicReleaseMapper;
|
|
|
+ @Autowired
|
|
|
+ private TOrderNewMapper tOrderNewMapper;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 每月1号凌晨5点轮询统计
|
|
|
+ *
|
|
|
+ */
|
|
|
+
|
|
|
+ @Scheduled(cron = "0 0 5 1 * ?")
|
|
|
+ @RequestMapping(value = "/open/pushOrderArrearsDun", method = RequestMethod.GET)
|
|
|
+ public void userFollowStatistics(){
|
|
|
+ //获取上月1号到本月1号的外出
|
|
|
+ Calendar now=getNowDate();
|
|
|
+ Calendar date=getNowDate();
|
|
|
+ date.set(Calendar.MONTH,now.get(Calendar.MONTH)-1);
|
|
|
+ List<outUserFollowCount> list =publicReleaseMapper.getTimeUserFollow(date.getTime(),now.getTime());
|
|
|
+ for (outUserFollowCount out : list) {
|
|
|
+ List<BigDecimal> aList=tOrderNewMapper.selectByUidAndNewUser(out.getUid(),out.getNewUser(),date.getTime(),now.getTime());
|
|
|
+ if (aList.isEmpty()){
|
|
|
+ out.setQuantity(0);
|
|
|
+ out.setTotal(new BigDecimal(0));
|
|
|
+ }else{
|
|
|
+ out.setQuantity(aList.size());
|
|
|
+ BigDecimal total=new BigDecimal(0);
|
|
|
+ for (BigDecimal bigDecimal : aList) {
|
|
|
+ total=total.add(bigDecimal);
|
|
|
+ }
|
|
|
+ out.setTotal(total);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public Calendar getNowDate(){
|
|
|
+ Calendar now=Calendar.getInstance();
|
|
|
+ now.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ now.clear(Calendar.MINUTE);
|
|
|
+ now.clear(Calendar.SECOND);
|
|
|
+ return now;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {}
|
|
|
+}
|