|
@@ -7,13 +7,18 @@ import com.kuaishou.merchant.open.api.client.AccessTokenKsMerchantClient;
|
|
import com.kuaishou.merchant.open.api.common.utils.GsonUtils;
|
|
import com.kuaishou.merchant.open.api.common.utils.GsonUtils;
|
|
import com.kuaishou.merchant.open.api.request.order.OpenOrderCursorListRequest;
|
|
import com.kuaishou.merchant.open.api.request.order.OpenOrderCursorListRequest;
|
|
import com.kuaishou.merchant.open.api.request.order.OpenOrderDetailRequest;
|
|
import com.kuaishou.merchant.open.api.request.order.OpenOrderDetailRequest;
|
|
|
|
+import com.kuaishou.merchant.open.api.request.shop.OpenScoreMasterGetRequest;
|
|
|
|
+import com.kuaishou.merchant.open.api.request.shop.OpenScoreShopGetRequest;
|
|
import com.kuaishou.merchant.open.api.response.order.OpenOrderCursorListResponse;
|
|
import com.kuaishou.merchant.open.api.response.order.OpenOrderCursorListResponse;
|
|
import com.kuaishou.merchant.open.api.response.order.OpenOrderDetailResponse;
|
|
import com.kuaishou.merchant.open.api.response.order.OpenOrderDetailResponse;
|
|
|
|
+import com.kuaishou.merchant.open.api.response.shop.OpenScoreMasterGetResponse;
|
|
|
|
+import com.kuaishou.merchant.open.api.response.shop.OpenScoreShopGetResponse;
|
|
import com.ruixuan.common.utils.Check;
|
|
import com.ruixuan.common.utils.Check;
|
|
import com.ruixuan.common.utils.DateUtils;
|
|
import com.ruixuan.common.utils.DateUtils;
|
|
import com.ruixuan.isc.constants.KuaiShouConstants;
|
|
import com.ruixuan.isc.constants.KuaiShouConstants;
|
|
import com.ruixuan.isc.entity.KuaishouAccessToken;
|
|
import com.ruixuan.isc.entity.KuaishouAccessToken;
|
|
import com.ruixuan.isc.entity.KwaixiaodianOrderCursorList;
|
|
import com.ruixuan.isc.entity.KwaixiaodianOrderCursorList;
|
|
|
|
+import com.ruixuan.isc.entity.KwaixiaodianShopScore;
|
|
import com.ruixuan.isc.mapper.KwaixiaodianOrderCursorListMapper;
|
|
import com.ruixuan.isc.mapper.KwaixiaodianOrderCursorListMapper;
|
|
import com.ruixuan.isc.service.IAccessTokenService;
|
|
import com.ruixuan.isc.service.IAccessTokenService;
|
|
import com.ruixuan.isc.service.IKwaixiaodianOrderCursorListService;
|
|
import com.ruixuan.isc.service.IKwaixiaodianOrderCursorListService;
|
|
@@ -221,4 +226,98 @@ public class KwaixiaodianOrderCursorListServiceImpl implements IKwaixiaodianOrde
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void queryMaster(String shopId) {
|
|
|
|
+ KuaishouAccessToken token = accessTokenService.getKWaiAccessToken(shopId);
|
|
|
|
+ if (Check.isNull(token)) {
|
|
|
|
+ log.error("----kwaixiaodian获取带货口碑分信息失败,shopId:{} 没有token信息", shopId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(KuaiShouConstants.KFX_URL, token.getAppKey(), token.getSignSecret());
|
|
|
|
+ OpenScoreMasterGetRequest request = new OpenScoreMasterGetRequest();
|
|
|
|
+ request.setAccessToken(token.getAccessToken());
|
|
|
|
+ request.setApiMethodVersion(1L);
|
|
|
|
+ OpenScoreMasterGetResponse response = null;
|
|
|
|
+ try {
|
|
|
|
+ response = client.execute(request);
|
|
|
|
+ } catch (KsMerchantApiException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(GsonUtils.toJSON(response));
|
|
|
|
+ String code = jsonObject.getString("code");
|
|
|
|
+ if ("1".equals(code)) {
|
|
|
|
+ JSONObject data = jsonObject.getJSONObject("data");
|
|
|
|
+ String scoreStr = null;
|
|
|
|
+ JSONObject summary = data.getJSONObject("summary");
|
|
|
|
+ if (Check.isNotNull(summary)) {
|
|
|
|
+ scoreStr = summary.getString("scoreStr");
|
|
|
|
+ }
|
|
|
|
+ KwaixiaodianShopScore shopScore = mapper.getScore(shopId);
|
|
|
|
+ if (Check.isNull(shopScore)) {
|
|
|
|
+ shopScore = new KwaixiaodianShopScore();
|
|
|
|
+ shopScore.setShopId(shopId);
|
|
|
|
+ shopScore.setShopName(token.getShopName());
|
|
|
|
+ shopScore.setCompanyId(token.getCompanyId());
|
|
|
|
+ shopScore.setCompanyName(token.getCompanyName());
|
|
|
|
+ shopScore.setLeaderName(token.getLeaderName());
|
|
|
|
+ shopScore.setMasterScore(scoreStr);
|
|
|
|
+ shopScore.setMasterScoreBody(data.toJSONString());
|
|
|
|
+ mapper.insertKwaixiaodianShopScore(shopScore);
|
|
|
|
+ } else {
|
|
|
|
+ shopScore.setMasterScore(scoreStr);
|
|
|
|
+ shopScore.setMasterScoreBody(data.toJSONString());
|
|
|
|
+ mapper.updateKwaixiaodianShopScore(shopScore);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.error("===kwaixiaodian获取带货口碑分信息异常,shopId:{},信息:{}", shopId, jsonObject.getString("error_msg"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void queryShop(String shopId) {
|
|
|
|
+ KuaishouAccessToken token = accessTokenService.getKWaiAccessToken(shopId);
|
|
|
|
+ if (Check.isNull(token)) {
|
|
|
|
+ log.error("----kwaixiaodian获取店铺体验分信息,shopId:{} 没有token信息", shopId);
|
|
|
|
+ }
|
|
|
|
+ AccessTokenKsMerchantClient client = new AccessTokenKsMerchantClient(KuaiShouConstants.KFX_URL, token.getAppKey(), token.getSignSecret());
|
|
|
|
+ OpenScoreShopGetRequest request = new OpenScoreShopGetRequest();
|
|
|
|
+ request.setAccessToken(token.getAccessToken());
|
|
|
|
+ request.setApiMethodVersion(1L);
|
|
|
|
+
|
|
|
|
+ OpenScoreShopGetResponse response = null;
|
|
|
|
+ try {
|
|
|
|
+ response = client.execute(request);
|
|
|
|
+ } catch (KsMerchantApiException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(GsonUtils.toJSON(response));
|
|
|
|
+ String code = jsonObject.getString("code");
|
|
|
|
+ if ("1".equals(code)) {
|
|
|
|
+ JSONObject data = jsonObject.getJSONObject("data");
|
|
|
|
+ String scoreStr = null;
|
|
|
|
+ JSONObject summary = data.getJSONObject("summary");
|
|
|
|
+ if (Check.isNotNull(summary)) {
|
|
|
|
+ scoreStr = summary.getString("scoreStr");
|
|
|
|
+ }
|
|
|
|
+ KwaixiaodianShopScore shopScore = mapper.getScore(shopId);
|
|
|
|
+ if (Check.isNull(shopScore)) {
|
|
|
|
+ shopScore = new KwaixiaodianShopScore();
|
|
|
|
+ shopScore.setShopId(shopId);
|
|
|
|
+ shopScore.setShopName(token.getShopName());
|
|
|
|
+ shopScore.setCompanyId(token.getCompanyId());
|
|
|
|
+ shopScore.setCompanyName(token.getCompanyName());
|
|
|
|
+ shopScore.setLeaderName(token.getLeaderName());
|
|
|
|
+ shopScore.setShopScore(scoreStr);
|
|
|
|
+ shopScore.setShopScoreBody(data.toJSONString());
|
|
|
|
+ mapper.insertKwaixiaodianShopScore(shopScore);
|
|
|
|
+ } else {
|
|
|
|
+ shopScore.setShopScore(scoreStr);
|
|
|
|
+ shopScore.setShopScoreBody(data.toJSONString());
|
|
|
|
+ mapper.updateKwaixiaodianShopScore(shopScore);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.error("===kwaixiaodian获取店铺体验分信息异常,shopId:{},信息:{}", shopId, jsonObject.getString("error_msg"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|