|
|
|
@ -19,19 +19,18 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -66,22 +65,41 @@ public class MerchantIdManageServiceImpl implements MerchantIdManageService {
|
|
|
|
|
return getClientMap(clients);
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject listNotTradeSubMerchantId(JSONObject manager) {
|
|
|
|
|
List<JSONObject> clients = clientSubMerchantIdMapper.listSubMerchantId(new PageBounds(Order.formString("create_time.desc")));
|
|
|
|
|
public JSONObject listNotTradeSubMerchantId(int type, JSONObject manager) {
|
|
|
|
|
List<JSONObject> clients = new ArrayList<>();
|
|
|
|
|
switch (type) {
|
|
|
|
|
case 0: //all
|
|
|
|
|
clients = clientSubMerchantIdMapper.listSubMerchantId(new PageBounds(Order.formString("diff_days.desc")));
|
|
|
|
|
break;
|
|
|
|
|
case 1://0~15天
|
|
|
|
|
clients = clientSubMerchantIdMapper.listSubMerchantIdByDiffDays(0,15);
|
|
|
|
|
break;
|
|
|
|
|
case 2://15~30天
|
|
|
|
|
clients = clientSubMerchantIdMapper.listSubMerchantIdByDiffDays(15,30);
|
|
|
|
|
break;
|
|
|
|
|
case 3://30~45天
|
|
|
|
|
clients = clientSubMerchantIdMapper.listSubMerchantIdByDiffDays(30,45);
|
|
|
|
|
break;
|
|
|
|
|
case 4://45~60天
|
|
|
|
|
clients = clientSubMerchantIdMapper.listSubMerchantIdByDiffDays(45,60);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Map<String, List<JSONObject>> merchantIdMap = clients.stream().filter(t->t.containsKey("merchant_id")).filter(t->t.containsKey("sub_merchant_id")).collect(Collectors.groupingBy(t->t.getString("merchant_id")));
|
|
|
|
|
JSONObject returnJason = new JSONObject();
|
|
|
|
|
returnJason.put("merchant_id_map",merchantIdMap);
|
|
|
|
|
returnJason.put("refresh_time",clients.size()>0?clients.get(0).getDate("create_time"):"");
|
|
|
|
|
return returnJason;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void generateClientsSunMerchantId() {
|
|
|
|
|
//重构未交易商户号逻辑
|
|
|
|
|
String tempSubMerchantIds = sysConfigManager.getSysConfig().getString("temp_sub_mch_id");
|
|
|
|
|
List<JSONObject> clients = clientAnalysisMapper.notTradeSubMerchantId();
|
|
|
|
|
List<JSONObject> clientSubMerchantId = clientSubMerchantIdMapper.listSubMerchantId(new PageBounds(Order.formString("create_time.desc")));
|
|
|
|
|
Map<String, JSONObject> subMerchantIdMapFromDB = new HashMap<>();
|
|
|
|
|
for (JSONObject id : clientSubMerchantId) {
|
|
|
|
|
subMerchantIdMapFromDB.put(id.getString("sub_merchant_id"), id);
|
|
|
|
|
List<JSONObject> clients = clientAnalysisMapper.tradeSubMerchantIdBy60Days(DateUtils.addDays(new Date(), -60));
|
|
|
|
|
if (clients.size() > 0) {
|
|
|
|
|
clientSubMerchantIdMapper.deleteAll();
|
|
|
|
|
}
|
|
|
|
|
for (JSONObject client: clients) {
|
|
|
|
|
String subMerchantId = client.getString("sub_merchant_id");
|
|
|
|
@ -90,15 +108,7 @@ public class MerchantIdManageServiceImpl implements MerchantIdManageService {
|
|
|
|
|
}
|
|
|
|
|
String id = client.getString("sub_merchant_id");
|
|
|
|
|
client.put("create_time",new Date());
|
|
|
|
|
if (subMerchantIdMapFromDB.containsKey(id)) {
|
|
|
|
|
subMerchantIdMapFromDB.remove(id);
|
|
|
|
|
clientSubMerchantIdMapper.update(client);
|
|
|
|
|
} else {
|
|
|
|
|
clientSubMerchantIdMapper.save(client);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (String id : subMerchantIdMapFromDB.keySet()) {
|
|
|
|
|
clientSubMerchantIdMapper.delete(id);
|
|
|
|
|
clientSubMerchantIdMapper.save(client);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|