资源简介
java调用有赞接口demo,五分钟获取一次客户的订单号并写入数据库中。导入自己的项目中直接可以调用。
代码片段和文件信息
package com.util;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import cn.zh.dao.insert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONobject;
import com.youzan.open.sdk.client.auth.Token;
import com.youzan.open.sdk.client.core.DefaultYZClient;
import com.youzan.open.sdk.client.core.YZClient;
import com.youzan.open.sdk.gen.v3_0_0.api.YouzanTradesSoldGet;
import com.youzan.open.sdk.gen.v3_0_0.model.YouzanTradesSoldGetParams;
import com.youzan.open.sdk.gen.v3_0_0.model.YouzanTradesSoldGetResult;
import fl.zh.ltd.pool.ConnectionPool;
public class youzanUtility {
private static String accessToken =“92aabc4e0efc3b87877423cb32d56772“;
private static YouzanTradesSoldGetResult result =null;
private static String jsonobject = ““;
public static void youzanJD(){
Calendar calendar1 = Calendar.getInstance();
Date firstTime = calendar1.getTime();
// 间隔:5分钟 从有攒获取一次订单号
long period = 1000 * 60 * 5;
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
youzanUtility ty = new youzanUtility();
ty.yz();
}
} firstTime period);
}
/**
* 交易管理
*
* 调用查询卖家已卖出的交易列表
*/
public void yz(){
SimpleDateFormat df = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss“);//设置日期格式
Date date = new Date();
System.out.println(df.format(date));// new Date()结束时间
Date date1=new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date1);
calendar.add(Calendar.DAY_OF_MONTH -6);
date1 = calendar.getTime();
System.out.println(df.format(date1)); //开始时间
YZClient client = new DefaultYZClient(new Token(accessToken)); //new Sign(appKey appSecret)
YouzanTradesSoldGetParams youzanTradesSoldGetParams = new YouzanTradesSoldGetPara
- 上一篇:pc0123机器码修改工具
- 下一篇:获取有赞token
评论
共有 条评论