|
@@ -1,6 +1,8 @@
|
|
|
package com.fjhx.customer.handle;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.DateField;
|
|
|
+import cn.hutool.core.date.DateUnit;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
@@ -127,11 +129,42 @@ public class HandleXiaomanData {
|
|
|
XiaomanConfig config = xiaomanConfigService.getConfig();
|
|
|
String token = config.getAccessToken();
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("companyId", companyId);
|
|
|
+ params.put("company_id", companyId);
|
|
|
params.put("format", "1");
|
|
|
return getData(XiaomanContant.CUSTOMER_DETAIL_API_URL, token, params);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 客户更新列表
|
|
|
+ * @author hj
|
|
|
+ * @date 2024/4/6 21:54
|
|
|
+ */
|
|
|
+ public static void updateList(){
|
|
|
+ try {
|
|
|
+ XiaomanConfig config = xiaomanConfigService.getConfig();
|
|
|
+ String token = config.getAccessToken();
|
|
|
+ List<XiaomanCustomerVo> list = xiaomanCustomerService.getList(new XiaomanCustomerSelectDto());
|
|
|
+ Set<Long> collect = list.stream().map(XiaomanCustomerVo::getCustomerId).collect(Collectors.toSet());
|
|
|
+ int pageIndex = 1;
|
|
|
+ int totalPage;
|
|
|
+ do {
|
|
|
+ Map<String, Object> params = initPageParams(pageIndex);
|
|
|
+ String nowStr = DateUtil.date().toString("yyyy-MM-dd HH:00:00");
|
|
|
+ params.put("start_time", DateUtil.parse(nowStr).offset(DateField.HOUR, -8).toString("yyyy-MM-dd HH:00:00"));
|
|
|
+ params.put("end_time", nowStr);
|
|
|
+ String str = getData(XiaomanContant.UPDATE_CUSTOMER_API_URL, token, params);
|
|
|
+ CustomerListApiVo customerListApiVo = handleAllCustomer(str, collect);
|
|
|
+ int totalItem = customerListApiVo.getTotalItem();
|
|
|
+ totalPage = (totalItem / PAGE_SIZE) + (totalItem % PAGE_SIZE > 0 ? 1 : 0);
|
|
|
+ pageIndex++;
|
|
|
+ } while (pageIndex <= totalPage);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
private static Map<String, Object> initPageParams(int page) {
|
|
|
Map<String, Object> params = new HashMap<>();
|