|
@@ -6,29 +6,67 @@ import cn.hutool.http.HttpUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.aliyuncs.utils.StringUtils;
|
|
|
import com.gree.mall.manager.bean.policy.ItfGreeSynDownloadRecBean;
|
|
|
import com.gree.mall.manager.constant.Constant;
|
|
|
+import com.gree.mall.manager.exception.RemoteServiceException;
|
|
|
import com.gree.mall.manager.plus.entity.ItfGreeSynDownloadRec;
|
|
|
import com.gree.mall.manager.plus.entity.ItfGreeSynRule;
|
|
|
import com.gree.mall.manager.plus.service.ItfGreeSynDownloadRecService;
|
|
|
import com.gree.mall.manager.plus.service.ItfGreeSynRuleService;
|
|
|
+import com.gree.mall.manager.utils.RedisUtil;
|
|
|
+import com.gree.mall.manager.utils.http.HttpUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
+import org.springframework.util.MultiValueMap;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
@RequiredArgsConstructor
|
|
|
public class SyncOrderInfoLogic {
|
|
|
|
|
|
+
|
|
|
+ @Value("${gree.V3.gettoken}")
|
|
|
+ private String tokenUrl;
|
|
|
+ @Value("${gree.check.barcode}")
|
|
|
+ private String checkBarcodeUrl;
|
|
|
+ @Value("${gree.repair.settle.get}")
|
|
|
+ private String getRepairSettleUrl;
|
|
|
+ @Value("${gree.repair.settle.do}")
|
|
|
+ private String doRepairSettleUrl;
|
|
|
+ @Value("${gree.client.id}")
|
|
|
+ private String clientId;
|
|
|
+ @Value("${gree.V3.client.secert}")
|
|
|
+ private String clientSecert;
|
|
|
+ @Value("${gree.api.url}")
|
|
|
+ private String apiUrl;
|
|
|
+ @Value("${gree.gz.appid}")
|
|
|
+ private String gzAppId;
|
|
|
+ @Value("${gree.gz.appkey}")
|
|
|
+ private String gzAppKey;
|
|
|
+ @Value("${gree.fs.appid}")
|
|
|
+ private String fsAppId;
|
|
|
+ @Value("${gree.fs.appkey}")
|
|
|
+ private String fsAppKey;
|
|
|
+ // @Value("${gree.cloud.api.url}")
|
|
|
+// private String cloudApiUrl;
|
|
|
+ @Value("${gree.V3.api.url}")
|
|
|
+ private String v3ApiUrl;
|
|
|
+ @Value("${gree.V3.gettoken}")
|
|
|
+ private String v3TokenUrl;
|
|
|
+ @Value("${gree.V3.client.secert}")
|
|
|
+ private String v3ClientSecert;
|
|
|
+ @Value("${gree.url}")
|
|
|
+ private String apiUrlFeedBack;
|
|
|
+
|
|
|
@Autowired
|
|
|
ItfGreeSynRuleService itfGreeSynRuleService;
|
|
|
|
|
@@ -38,6 +76,9 @@ public class SyncOrderInfoLogic {
|
|
|
@Value("${gree.url}")
|
|
|
private String greeUrl;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ RedisUtil redisUtil;
|
|
|
+
|
|
|
public void syncGuang() {
|
|
|
ItfGreeSynRule itfGreeSynRule = itfGreeSynRuleService.lambdaQuery().eq(ItfGreeSynRule::getSalesWebsitNumber, Constant.gree.GUANGZHOUXIAOSI)
|
|
|
.one();
|
|
@@ -70,6 +111,33 @@ public class SyncOrderInfoLogic {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取总部接口的请求token
|
|
|
+ * @return
|
|
|
+
|
|
|
+ */
|
|
|
+ public String getAccessToken() throws RemoteServiceException {
|
|
|
+ String redisKey = Constant.RedisPrefix.TOKEN_GREE;
|
|
|
+ String token = (String)redisUtil.get(redisKey);
|
|
|
+ if(token != null){
|
|
|
+ return token;
|
|
|
+ }
|
|
|
+ MultiValueMap<String, String> forms= new LinkedMultiValueMap<String, String>();
|
|
|
+
|
|
|
+ forms.put("client_id", Collections.singletonList(clientId));
|
|
|
+ forms.put("client_secret", Collections.singletonList(clientSecert));
|
|
|
+ forms.put("grant_type", Collections.singletonList("client_credentials"));
|
|
|
+ String s = HttpUtils.requestXwww(tokenUrl, forms);
|
|
|
+ //String s = HttpUtils.requestPostForm(tokenUrl, map, null);
|
|
|
+ log.info("【获取总部token】response:{}",s);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(s);
|
|
|
+ String accessToken = jsonObject.getString("access_token");
|
|
|
+ if(StringUtils.isNotEmpty(accessToken)) {
|
|
|
+ redisUtil.set(Constant.RedisPrefix.TOKEN_GREE, accessToken, 2 * 60 * 60);
|
|
|
+ }
|
|
|
+ return accessToken;
|
|
|
+ }
|
|
|
+
|
|
|
public void syncFo() {
|
|
|
}
|
|
|
}
|