Commit 90402558 by huluobin

# 更新

parent 3b60457e
...@@ -7,6 +7,7 @@ import com.gogirl.domain.user.customer.CustomerBalanceRecord; ...@@ -7,6 +7,7 @@ import com.gogirl.domain.user.customer.CustomerBalanceRecord;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.time.LocalDate;
import java.util.List; import java.util.List;
...@@ -20,7 +21,7 @@ public interface CustomerBalanceRecordMapper extends BaseMapper<CustomerBalanceR ...@@ -20,7 +21,7 @@ public interface CustomerBalanceRecordMapper extends BaseMapper<CustomerBalanceR
* @param day 日期形如2020-03-03 * @param day 日期形如2020-03-03
* @return list * @return list
*/ */
List<CustomerBalanceRecord> getXcxChargeRecord(String day); List<CustomerBalanceRecord> getXcxChargeRecord(LocalDate day);
/** /**
* 查询会员卡消费记录 * 查询会员卡消费记录
......
...@@ -163,16 +163,9 @@ public class Schedule { ...@@ -163,16 +163,9 @@ public class Schedule {
log.debug("每天晚上11:50定时设置当天服务的技师为推荐人** 任务结束"); log.debug("每天晚上11:50定时设置当天服务的技师为推荐人** 任务结束");
} }
/**
* 每天23:50设置推荐人:当天服务的技师为推荐人。
*/
@Scheduled(cron = "0 50 23 * * *")
public void setChargeReferees() {
log.debug("每天晚上11:50定时设置当天服务的技师为推荐人** 任务开始");
SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd"); public void setChargeReferees(LocalDate localDate) {
String day = yyyyMMdd.format(new Date());
log.debug("设置推荐人:当天服务的技师为推荐人"); log.debug("设置推荐人:当天服务的技师为推荐人");
Map<String, String> mapTechnicianManage = new HashMap<>(); Map<String, String> mapTechnicianManage = new HashMap<>();
...@@ -184,7 +177,7 @@ public class Schedule { ...@@ -184,7 +177,7 @@ public class Schedule {
} }
//找到当天的订单的推荐人 //找到当天的订单的推荐人
List<CustomerBalanceRecord> list = balanceRecordDao.getXcxChargeRecord(day); List<CustomerBalanceRecord> list = balanceRecordDao.getXcxChargeRecord(localDate);
//遍历设置推荐人 //遍历设置推荐人
for (CustomerBalanceRecord customerBalanceRecord : list) { for (CustomerBalanceRecord customerBalanceRecord : list) {
...@@ -222,7 +215,17 @@ public class Schedule { ...@@ -222,7 +215,17 @@ public class Schedule {
} }
} }
log.debug("每天晚上11:50定时设置当天服务的技师为推荐人** 任务结束"); }
/**
* 每天23:50设置推荐人:当天服务的技师为推荐人。
*/
@Scheduled(cron = "0 0 3 * * *")
public void setChargeReferees() {
log.debug("每天晚上03:00定时设置昨天服务的技师为推荐人** 任务开始");
LocalDate day = LocalDate.now().minusDays(1);
this.setChargeReferees(day);
log.debug("每天晚上03:00定时设置昨天服务的技师为推荐人** 任务结束");
} }
/** /**
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
</select> </select>
<select id="getXcxChargeRecord" resultMap="BaseResultMap" parameterType="java.lang.String"> <select id="getXcxChargeRecord" resultMap="BaseResultMap" parameterType="java.time.LocalDate">
select cbr.id, select cbr.id,
group_concat(os.technician_id) referee_id, group_concat(os.technician_id) referee_id,
(select om.department_id (select om.department_id
......
...@@ -302,63 +302,6 @@ public class Test { ...@@ -302,63 +302,6 @@ public class Test {
@Resource @Resource
CustomerBalanceRecordMapper customerBalanceRecordMapper; CustomerBalanceRecordMapper customerBalanceRecordMapper;
@org.junit.Test
public void setChargeReferees() {
log.debug("每天晚上11:50定时设置当天服务的技师为推荐人** 任务开始");
SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");
String day = "2020-04-04";
log.debug("设置推荐人:当天服务的技师为推荐人");
Map<String, String> mapTechnicianManage = new HashMap<>();
List<StoreTechnician> listTechnicianManage = storeTechnicianService.listTechnicianForPage(new StoreTechnician());
//查出所有的技师,找到技师id和user_id
for (StoreTechnician item : listTechnicianManage) {
mapTechnicianManage.put(String.valueOf(item.getTechnicianId()), String.valueOf(item.getUserId()));
}
//找到当天的订单的推荐人
List<CustomerBalanceRecord> list = customerBalanceRecordMapper.getXcxChargeRecord(day);
//遍历设置推荐人
for (CustomerBalanceRecord customerBalanceRecord : list) {
//推荐人列表
Map<String, String> map = new HashMap<>();
//推荐人id
StringBuilder referee_ids = new StringBuilder();
//充值记录
CustomerBalanceRecord cbrt = customerBalanceRecordMapper.selectById(customerBalanceRecord.getId());
//每次都修改推荐人,且每晚都会设置推荐人
if (customerBalanceRecord.getRefereeId() != null) {
String[] arr = customerBalanceRecord.getRefereeId().split(",");
//
for (String s : arr) {
if (!map.containsKey(s)) {
map.put(s, s);
referee_ids.append(",").append(mapTechnicianManage.get(s));
}
}
//去掉首尾,
if (referee_ids.toString().startsWith(",")) {
referee_ids = new StringBuilder(referee_ids.substring(1));
}
customerBalanceRecord.setRefereeId(referee_ids.toString());
}
//如果店铺id不为空
if (cbrt != null && cbrt.getDepartmentId() != null) {
customerBalanceRecord.setDepartmentId(cbrt.getDepartmentId());
}
if (customerBalanceRecord.getId() != null
&& (customerBalanceRecord.getRefereeId() != null || customerBalanceRecord.getDepartmentId() != null)) {
customerBalanceRecordMapper.updateById(customerBalanceRecord);
}
}
log.debug("每天晚上11:50定时设置当天服务的技师为推荐人** 任务结束");
}
@Resource @Resource
PurchaseStockMapper purchaseStockMapper; PurchaseStockMapper purchaseStockMapper;
......
package com.gogirl.infrastructure.schedule; package com.gogirl.infrastructure.schedule;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import java.time.LocalDate;
/** /**
* <p> * <p>
* *
...@@ -24,5 +27,9 @@ public class ScheduleTest { ...@@ -24,5 +27,9 @@ public class ScheduleTest {
@Autowired @Autowired
Schedule schedule; Schedule schedule;
@Test
public void setChargeReferees() {
schedule.setChargeReferees(LocalDate.of(2021, 2, 5));
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment