|
@@ -11,6 +11,7 @@ import com.taobao.api.response.TradesSoldGetResponse;
|
|
|
import com.uas.eis.core.config.TaoBaoConfig;
|
|
import com.uas.eis.core.config.TaoBaoConfig;
|
|
|
import com.uas.eis.dao.BaseDao;
|
|
import com.uas.eis.dao.BaseDao;
|
|
|
import com.uas.eis.utils.DateUtil;
|
|
import com.uas.eis.utils.DateUtil;
|
|
|
|
|
+import com.uas.eis.utils.StringUtil;
|
|
|
import oracle.sql.DATE;
|
|
import oracle.sql.DATE;
|
|
|
import org.apache.log4j.Logger;
|
|
import org.apache.log4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -39,7 +40,7 @@ public class TaoBaoDownLoadTask {
|
|
|
/**
|
|
/**
|
|
|
* 有效店铺
|
|
* 有效店铺
|
|
|
* */
|
|
* */
|
|
|
- List<Map<String,Object>> shopList = baseDao.queryForList("SELECT TB_CODE,TB_LASTSYNCDATE,TB_OPENUID from TBAUTHORIZATION where validflag = 1 ORDER BY TB_CODE ASC");
|
|
|
|
|
|
|
+ List<Map<String,Object>> shopList = baseDao.queryForList("SELECT TB_ID,TB_CODE,TB_LASTSYNCDATE,TB_OPENUID from TBAUTHORIZATION where validflag=1 ORDER BY TB_CODE ASC");
|
|
|
logger.info("Start downLoad SaleOrder---");
|
|
logger.info("Start downLoad SaleOrder---");
|
|
|
TaobaoClient client = new DefaultTaobaoClient(taoBaoConfig.getServerUrl(), taoBaoConfig.getAppKey(), taoBaoConfig.getAppSecret());
|
|
TaobaoClient client = new DefaultTaobaoClient(taoBaoConfig.getServerUrl(), taoBaoConfig.getAppKey(), taoBaoConfig.getAppSecret());
|
|
|
TradesSoldGetRequest req = new TradesSoldGetRequest();
|
|
TradesSoldGetRequest req = new TradesSoldGetRequest();
|
|
@@ -73,14 +74,18 @@ public class TaoBaoDownLoadTask {
|
|
|
req.setEndCreated(endDate);
|
|
req.setEndCreated(endDate);
|
|
|
try {
|
|
try {
|
|
|
TradesSoldGetResponse rsp = client.execute(req, sessionKey);
|
|
TradesSoldGetResponse rsp = client.execute(req, sessionKey);
|
|
|
- List<Trade> trades = rsp.getTrades();
|
|
|
|
|
- logger.info("店铺获取单数"+trades.size());
|
|
|
|
|
- for(Trade trade: trades){
|
|
|
|
|
- formatTrade(trade, sessionKey,tbOpenuid, executeSQLS);
|
|
|
|
|
|
|
+ if(rsp.getMsg()!=null&&"Invalid session".equals(rsp.getMsg())){
|
|
|
|
|
+ baseDao.execute("update TBAUTHORIZATION set validflag=0, UNVALIDREMARK='"+ "("+rsp.getErrorCode()+")"+StringUtil.nvl(rsp.getSubMsg(),rsp.getMsg()) +"' where tb_id = "+shop.get("TB_ID"));
|
|
|
|
|
+ }else {
|
|
|
|
|
+ List<Trade> trades = rsp.getTrades();
|
|
|
|
|
+ logger.info("店铺获取单数"+trades.size());
|
|
|
|
|
+ for(Trade trade: trades){
|
|
|
|
|
+ formatTrade(trade, sessionKey,tbOpenuid, executeSQLS);
|
|
|
|
|
+ }
|
|
|
|
|
+ baseDao.execute(executeSQLS);
|
|
|
|
|
+ //更新当前店铺的最近更新时间
|
|
|
|
|
+ baseDao.updateByCondition("TBAUTHORIZATION","TB_LASTSYNCDATE=to_date ( '" + DateUtil.format(endDate, DateUtil.FORMAT_YMD_HMS) + "','YYYY-MM-DD hh24:mi:ss') ","TB_CODE ='"+sessionKey+"'");
|
|
|
}
|
|
}
|
|
|
- baseDao.execute(executeSQLS);
|
|
|
|
|
- //更新当前店铺的最近更新时间
|
|
|
|
|
- baseDao.updateByCondition("TBAUTHORIZATION","TB_LASTSYNCDATE=to_date ( '" + DateUtil.format(endDate, DateUtil.FORMAT_YMD_HMS) + "','YYYY-MM-DD hh24:mi:ss') ","TB_CODE ='"+sessionKey+"'");
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
logger.info("淘宝未响应并返回订单数据");
|
|
logger.info("淘宝未响应并返回订单数据");
|