Commit c27c39c4 authored by zhoumaotao's avatar zhoumaotao

代码调整

parent 28c37814
...@@ -4,7 +4,6 @@ import com.gavel.common.utils.DateUtils; ...@@ -4,7 +4,6 @@ import com.gavel.common.utils.DateUtils;
import com.gavel.common.utils.NumberUtils; import com.gavel.common.utils.NumberUtils;
import com.gavel.datasync.service.DatasyncService; import com.gavel.datasync.service.DatasyncService;
import com.gavel.datasync.util.JDClientUtil; import com.gavel.datasync.util.JDClientUtil;
import com.jd.open.api.sdk.DefaultJdClient;
import com.jd.open.api.sdk.JdClient; import com.jd.open.api.sdk.JdClient;
import com.jd.open.api.sdk.domain.supplier.IDpsSearchAllOrdersInterface.response.searchAllOrders.QueryAllOrdersForJosResult; import com.jd.open.api.sdk.domain.supplier.IDpsSearchAllOrdersInterface.response.searchAllOrders.QueryAllOrdersForJosResult;
import com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.find.CategoryDto; import com.jd.open.api.sdk.domain.supplier.ProductManagementService.response.find.CategoryDto;
...@@ -18,7 +17,6 @@ import com.jd.open.api.sdk.response.supplier.DropshipDpsSearchAllOrdersResponse; ...@@ -18,7 +17,6 @@ import com.jd.open.api.sdk.response.supplier.DropshipDpsSearchAllOrdersResponse;
import com.jd.open.api.sdk.response.supplier.VcItemBrandsFindResponse; import com.jd.open.api.sdk.response.supplier.VcItemBrandsFindResponse;
import com.jd.open.api.sdk.response.supplier.VcItemCategoriesFindResponse; import com.jd.open.api.sdk.response.supplier.VcItemCategoriesFindResponse;
import com.jd.open.api.sdk.response.supplier.VcItemProductsFindResponse; import com.jd.open.api.sdk.response.supplier.VcItemProductsFindResponse;
import com.jd.security.tdeclient.SecretJdClient;
import com.jd.security.tdeclient.TDEClient; import com.jd.security.tdeclient.TDEClient;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -35,7 +33,7 @@ public class DatasyncServiceImpl implements DatasyncService { ...@@ -35,7 +33,7 @@ public class DatasyncServiceImpl implements DatasyncService {
@Override @Override
public List<CategoryDto> getCategories() { public List<CategoryDto> getCategories() {
JdClient client=createClient(); JdClient client= JDClientUtil.createClient();
VcItemCategoriesFindRequest request=new VcItemCategoriesFindRequest(); VcItemCategoriesFindRequest request=new VcItemCategoriesFindRequest();
try { try {
VcItemCategoriesFindResponse response = client.execute(request); VcItemCategoriesFindResponse response = client.execute(request);
...@@ -48,7 +46,7 @@ public class DatasyncServiceImpl implements DatasyncService { ...@@ -48,7 +46,7 @@ public class DatasyncServiceImpl implements DatasyncService {
@Override @Override
public List<SimpleBrandDto> getBrands() { public List<SimpleBrandDto> getBrands() {
JdClient client=createClient(); JdClient client=JDClientUtil.createClient();
VcItemBrandsFindRequest request = new VcItemBrandsFindRequest (); VcItemBrandsFindRequest request = new VcItemBrandsFindRequest ();
try { try {
VcItemBrandsFindResponse response = client.execute(request); VcItemBrandsFindResponse response = client.execute(request);
...@@ -62,7 +60,7 @@ public class DatasyncServiceImpl implements DatasyncService { ...@@ -62,7 +60,7 @@ public class DatasyncServiceImpl implements DatasyncService {
@Override @Override
public List<MyProductInfoDto> getProducts(Date time, String brandid, String categoryid) { public List<MyProductInfoDto> getProducts(Date time, String brandid, String categoryid) {
try { try {
JdClient client = createClient(); JdClient client =JDClientUtil.createClient();
VcItemProductsFindRequest request = new VcItemProductsFindRequest(); VcItemProductsFindRequest request = new VcItemProductsFindRequest();
final int PAGE_SIZE = 50; final int PAGE_SIZE = 50;
request.setOffset(0); request.setOffset(0);
...@@ -103,7 +101,7 @@ public class DatasyncServiceImpl implements DatasyncService { ...@@ -103,7 +101,7 @@ public class DatasyncServiceImpl implements DatasyncService {
@Override @Override
public List<QueryAllOrdersForJosResult> searchOrders(Date start,Date end) { public List<QueryAllOrdersForJosResult> searchOrders(Date start,Date end) {
try { try {
JdClient client = createClient(); JdClient client = JDClientUtil.createClient();
final int PAGE_SIZE = 50; final int PAGE_SIZE = 50;
DropshipDpsSearchAllOrdersRequest request=new DropshipDpsSearchAllOrdersRequest (); DropshipDpsSearchAllOrdersRequest request=new DropshipDpsSearchAllOrdersRequest ();
request.setPage(1); request.setPage(1);
...@@ -152,7 +150,7 @@ public class DatasyncServiceImpl implements DatasyncService { ...@@ -152,7 +150,7 @@ public class DatasyncServiceImpl implements DatasyncService {
@Override @Override
public List<QueryAllOrdersForJosResult> searchOrders2(Date start, Date end) { public List<QueryAllOrdersForJosResult> searchOrders2(Date start, Date end) {
try { try {
JdClient client = createClient(); JdClient client = JDClientUtil.createClient();
final int PAGE_SIZE = 50; final int PAGE_SIZE = 50;
DropshipDpsSearchAllOrdersRequest request=new DropshipDpsSearchAllOrdersRequest (); DropshipDpsSearchAllOrdersRequest request=new DropshipDpsSearchAllOrdersRequest ();
request.setPage(1); request.setPage(1);
...@@ -198,24 +196,10 @@ public class DatasyncServiceImpl implements DatasyncService { ...@@ -198,24 +196,10 @@ public class DatasyncServiceImpl implements DatasyncService {
return null; return null;
} }
private JdClient createClient() {
return new DefaultJdClient(JDClientUtil.SERVER_URL,JDClientUtil.ACCESS_TOKEN,JDClientUtil.APPKEY,JDClientUtil.APPSECRET);
}
private TDEClient getTdeClient() {
TDEClient tdeClient = null;
try {
tdeClient = SecretJdClient.getInstance(JDClientUtil.SERVER_URL,JDClientUtil.ACCESS_TOKEN,JDClientUtil.APPKEY,JDClientUtil.APPSECRET);
} catch (Exception e) {
logger.error("错误信息P01",e.getMessage());
}
return tdeClient;
}
private String getValue(String val){ private String getValue(String val){
TDEClient tdeClient = getTdeClient(); TDEClient tdeClient = JDClientUtil.getTdeClient();
String s = ""; String s = "";
try { try {
s = tdeClient.decryptString(val); s = tdeClient.decryptString(val);
......
package com.gavel.datasync.util; package com.gavel.datasync.util;
import com.gavel.datasync.service.impl.DatasyncServiceImpl;
import com.jd.open.api.sdk.DefaultJdClient;
import com.jd.open.api.sdk.JdClient;
import com.jd.security.tdeclient.SecretJdClient;
import com.jd.security.tdeclient.TDEClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JDClientUtil { public class JDClientUtil {
private static Logger logger = LoggerFactory.getLogger(DatasyncServiceImpl.class);
// 正式环境 // 正式环境
public static final String SERVER_URL = "https://api.jd.com/routerjson"; public static final String SERVER_URL = "https://api.jd.com/routerjson";
//帷易胜店铺信息
public static final String APPKEY = "FEAFBABCDEEC48A569A10818138D7841"; public static final String APPKEY = "FEAFBABCDEEC48A569A10818138D7841";
public static final String APPSECRET = "36c196b5b2ea4c2aaaae6d80010a28a8"; public static final String APPSECRET = "36c196b5b2ea4c2aaaae6d80010a28a8";
public static final String ACCESS_TOKEN = "1d4a07ea9743455d99c2f7f63e2f7971a3zw"; public static final String ACCESS_TOKEN = "1d4a07ea9743455d99c2f7f63e2f7971a3zw";
//hailinking1984店铺信息
public static final String APPKEY_H = "819A568C76FEBC54945536AF7B7BBCBE";
public static final String APPSECRET_H= "374c67fe9ff2410f876686282de33dac";
public static final String ACCESS_TOKEN_H = "ed1bc49527c8449c94bc503dd268cbfem0ot";
public static JdClient createClient() {
return new DefaultJdClient(JDClientUtil.SERVER_URL,JDClientUtil.ACCESS_TOKEN,JDClientUtil.APPKEY,JDClientUtil.APPSECRET);
}
public static TDEClient getTdeClient() {
TDEClient tdeClient = null;
try {
tdeClient = SecretJdClient.getInstance(JDClientUtil.SERVER_URL,JDClientUtil.ACCESS_TOKEN,JDClientUtil.APPKEY,JDClientUtil.APPSECRET);
} catch (Exception e) {
logger.error("错误信息",e.getMessage());
}
return tdeClient;
}
public static JdClient createHClient() {
return new DefaultJdClient(JDClientUtil.SERVER_URL,JDClientUtil.ACCESS_TOKEN_H,JDClientUtil.APPKEY_H,JDClientUtil.APPSECRET_H);
}
public static TDEClient getHTdeClient() {
TDEClient tdeClient = null;
try {
tdeClient = SecretJdClient.getInstance(JDClientUtil.SERVER_URL,JDClientUtil.ACCESS_TOKEN_H,JDClientUtil.APPKEY_H,JDClientUtil.APPSECRET_H);
} catch (Exception e) {
logger.error("错误信息",e.getMessage());
}
return tdeClient;
}
} }
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