| @@ -14,20 +14,8 @@ public class DouyinBaseController extends BaseController{ | |||
| @Autowired | |||
| private WxMallService wxMallService; | |||
| private Integer getCurrentApplicationVersion() { | |||
| WxMallVersion mallVersion = wxMallService.getMallVersion(getTenantInfo()); | |||
| if (null == mallVersion) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"mallVersion未查询到配置"); | |||
| } | |||
| Integer v = mallVersion.getDouyinApplicationVersion() ; | |||
| if (v == null) { | |||
| return 0; | |||
| } | |||
| return v; | |||
| } | |||
| public boolean isGoodLifeSaas() throws Exception{ | |||
| Integer _e = getCurrentApplicationVersion(); | |||
| return EnumDouyinApplicationVersion.isSaas(_e); | |||
| EnumDouyinApplicationVersion douyinApplicationVersion = wxMallService.getDouyinApplicationVersion(getTenantInfo()); | |||
| return EnumDouyinApplicationVersion.GOODLIFE_SAAS.equals(douyinApplicationVersion); | |||
| } | |||
| } | |||
| @@ -38,30 +38,32 @@ public class TtGoodsCategoryController extends DouyinBaseController { | |||
| @Autowired | |||
| private TtGoodsCategoryService ttGoodsCategoryService; | |||
| @TenantIgnore | |||
| @ApiOperation("分页列表接口") | |||
| /** | |||
| * 本地所有抖音类目 树 | |||
| * @return | |||
| */ | |||
| @TenantIgnore | |||
| @ApiOperation("接口") | |||
| @GetMapping("treeList") | |||
| @ApiImplicitParams({}) | |||
| @SystemControllerLog(description = "列表") | |||
| public ResultData treeList() { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::treeList"); | |||
| try { | |||
| boolean isSaas = this.isGoodLifeSaas(); | |||
| if (!isSaas) { | |||
| return new ResultData(ttGoodsCategoryService.findTreeList()); | |||
| }else { | |||
| return new ResultData(ttGoodsCategoryService.findTreeListForNew()); | |||
| } | |||
| return new ResultData(ttGoodsCategoryService.findTreeList()); | |||
| } catch (Exception e) { | |||
| logger.error("treeList error.",e); | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("查询类目") | |||
| @GetMapping("get") | |||
| /** | |||
| * 分级获取抖音类目 onlin | |||
| * @param categoryId | |||
| * @return | |||
| */ | |||
| @ApiOperation("查询类目") | |||
| @GetMapping("getOnlin") | |||
| @ApiImplicitParams({}) | |||
| @SystemControllerLog(description = "列表") | |||
| public ResultData categoryGet(Integer categoryId) { | |||
| @@ -70,12 +72,7 @@ public class TtGoodsCategoryController extends DouyinBaseController { | |||
| categoryId = 0; | |||
| } | |||
| try { | |||
| boolean isSaas = this.isGoodLifeSaas(); | |||
| if (!isSaas) { | |||
| return new ResultData(ttGoodsCategoryService.categoryGet(categoryId,false)); | |||
| }else { | |||
| return new ResultData(ttGoodsCategoryService.categoryGet(categoryId,true)); | |||
| } | |||
| return new ResultData(ttGoodsCategoryService.categoryGet(getTenantInfo(),categoryId)); | |||
| } catch (Exception e) { | |||
| logger.error("categoryGet error.",e); | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| @@ -90,7 +87,7 @@ public class TtGoodsCategoryController extends DouyinBaseController { | |||
| public ResultData syncGetTt() { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::syncGetTt"); | |||
| try { | |||
| ttGoodsCategoryService.syncGet(false); | |||
| ttGoodsCategoryService.syncGet(null,false); | |||
| } catch (Exception e) { | |||
| logger.error("syncGetTt error.",e); | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| @@ -98,7 +95,7 @@ public class TtGoodsCategoryController extends DouyinBaseController { | |||
| return new ResultData(); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("同步抖音类目") | |||
| @GetMapping("syncGetTtNew") | |||
| @ApiImplicitParams({}) | |||
| @@ -106,7 +103,7 @@ public class TtGoodsCategoryController extends DouyinBaseController { | |||
| public ResultData syncGetTtNew() { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::syncGetTt"); | |||
| try { | |||
| ttGoodsCategoryService.syncGet(true); | |||
| ttGoodsCategoryService.syncGet(getTenantInfo(),true); | |||
| } catch (Exception e) { | |||
| logger.error("syncGetTt error.",e); | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| @@ -122,12 +119,7 @@ public class TtGoodsCategoryController extends DouyinBaseController { | |||
| public ResultData allTreeList() { | |||
| logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::allTreeList"); | |||
| try { | |||
| boolean isSaas = this.isGoodLifeSaas(); | |||
| if (!isSaas) { | |||
| return new ResultData(ttGoodsCategoryService.findAllTreeList()); | |||
| }else { | |||
| return new ResultData(ttGoodsCategoryService.findAllTreeListForNew()); | |||
| } | |||
| return new ResultData(ttGoodsCategoryService.findAllTreeList()); | |||
| } catch (Exception e) { | |||
| logger.error("allTreeList error.",e); | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| @@ -147,22 +139,7 @@ public class TtGoodsCategoryController extends DouyinBaseController { | |||
| } | |||
| record.setSoftwareFee(null); | |||
| try { | |||
| boolean isSaas = this.isGoodLifeSaas(); | |||
| if (!isSaas) { | |||
| ttGoodsCategoryService.updateFee(record); | |||
| }else { | |||
| try { | |||
| TtGoodsCategoryNew gn = new TtGoodsCategoryNew(); | |||
| BeanUtils.copyProperties(gn, record); | |||
| ttGoodsCategoryService.updateFeeForNew(gn); | |||
| } catch (IllegalAccessException e) { | |||
| logger.error("setServiceFee error",e); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),e.getMessage()); | |||
| } catch (InvocationTargetException e) { | |||
| logger.error("setServiceFee error",e); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),e.getMessage()); | |||
| } | |||
| } | |||
| ttGoodsCategoryService.updateFee(record); | |||
| } catch (Exception e) { | |||
| logger.error("setServiceFee error.",e); | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| @@ -183,22 +160,7 @@ public class TtGoodsCategoryController extends DouyinBaseController { | |||
| record.setServiceFee(null); | |||
| try { | |||
| boolean isSaas = this.isGoodLifeSaas(); | |||
| if (!isSaas) { | |||
| ttGoodsCategoryService.updateFee(record); | |||
| }else { | |||
| try { | |||
| TtGoodsCategoryNew gn = new TtGoodsCategoryNew(); | |||
| BeanUtils.copyProperties(gn, record); | |||
| ttGoodsCategoryService.updateFeeForNew(gn); | |||
| } catch (IllegalAccessException e) { | |||
| logger.error("setServiceFee error",e); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),e.getMessage()); | |||
| } catch (InvocationTargetException e) { | |||
| logger.error("setServiceFee error",e); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),e.getMessage()); | |||
| } | |||
| } | |||
| ttGoodsCategoryService.updateFee(record); | |||
| } catch (Exception e) { | |||
| logger.error("setSoftwareFee error.",e); | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| @@ -63,10 +63,10 @@ public class TtWebGetRequestExecutor implements RequestExecutor<String, String> | |||
| } | |||
| HttpGet httpGet = new HttpGet(uri); | |||
| httpGet.addHeader("Content-Type","application/json"); | |||
| // httpGet.addHeader("Content-Type","application/json"); | |||
| httpGet.addHeader("access-token",access_token); | |||
| // logger.info("get请求地址uri{}"+uri); | |||
| // logger.info("header-----access_token{}"+access_token); | |||
| logger.info("get请求地址uri{}"+uri); | |||
| logger.info("header-----access_token{}"+access_token); | |||
| if (requestHttp.getRequestHttpProxy() != null) { | |||
| RequestConfig config = RequestConfig.custom().setProxy(requestHttp.getRequestHttpProxy()).build(); | |||
| @@ -76,10 +76,22 @@ public class TtWebGetRequestExecutor implements RequestExecutor<String, String> | |||
| try (CloseableHttpResponse response = requestHttp.getRequestHttpClient().execute(httpGet)) { | |||
| String responseContent = Utf8ResponseHandler.INSTANCE.handleResponse(response); | |||
| logger.info("response{}"+responseContent); | |||
| if (responseContent.isEmpty()) { | |||
| throw new WxErrorException(WxError.builder().errorCode(9999).errorMsg("无响应内容").build()); | |||
| } | |||
| if (responseContent.startsWith("<xml>")) { | |||
| //xml格式输出直接返回 | |||
| return responseContent; | |||
| } | |||
| JSONObject jsonObject = JSON.parseObject(responseContent); | |||
| JSONObject data = jsonObject.getJSONObject("data"); | |||
| WxError error = WxError.fromJson(data.toJSONString()); | |||
| JSONObject extra = jsonObject.getJSONObject("extra"); | |||
| WxError error = WxError.fromJson(extra.toJSONString()); | |||
| if (error.getErrorCode() != 0) { | |||
| String sub_description = extra.getString("sub_description"); | |||
| if(StringUtils.isNotBlank(sub_description)){ | |||
| error.setErrorMsg(sub_description); | |||
| } | |||
| throw new WxErrorException(error); | |||
| } | |||
| return data.toString(); | |||
| @@ -62,7 +62,7 @@ public interface TtGoodLifeSaasGoodsService { | |||
| * category_id int FALSE 行业类目ID,返回当前id下的直系子类目信息;传0或者不传,均返回所有一级行业类目 | |||
| * account_id int FALSE 服务商的入驻商户ID/代运营的商户ID,不传时默认为服务商身份 | |||
| */ | |||
| List<GoodsCategory> categoryGet(Integer category_id,Integer account_id) throws WxErrorException; | |||
| List<GoodsCategory> categoryGet(Integer category_id,String account_id) throws WxErrorException; | |||
| /** | |||
| * - 查询商品模板,创建商品时的属性列表需与该接口保持一致,否则无法识别 | |||
| @@ -2,15 +2,14 @@ package com.iformall.douyin.web.api.goodlifesaas.impl; | |||
| import com.alibaba.fastjson.TypeReference; | |||
| import com.google.gson.*; | |||
| import com.iformall.douyin.web.api.basic.*; | |||
| import com.iformall.douyin.web.api.goodlifesaas.TtGoodLifeSaasGoodsService; | |||
| import com.iformall.douyin.web.api.goodlifesaas.TtGoodLifeSaasService; | |||
| import com.iformall.douyin.web.api.basic.TtWebGoodsCategoryGetRequestExecutor; | |||
| import com.iformall.douyin.web.api.basic.TtWebGoodsGetRequestExecutor; | |||
| import com.iformall.douyin.web.api.basic.TtWebGoodsPostRequestExecutor; | |||
| import com.iformall.douyin.web.bean.*; | |||
| import lombok.AllArgsConstructor; | |||
| import me.chanjar.weixin.common.error.WxError; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import me.chanjar.weixin.common.util.json.GsonHelper; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| @@ -28,11 +27,11 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| @Override | |||
| public List<GoodsCategory> categoryGet(Integer category_id, Integer account_id) throws WxErrorException { | |||
| TtWebGoodsCategoryGetRequestExecutor getExecutor = new TtWebGoodsCategoryGetRequestExecutor(this.service.getRequestHttp()); | |||
| public List<GoodsCategory> categoryGet(Integer category_id, String account_id) throws WxErrorException { | |||
| TtWebGetRequestExecutor getExecutor = new TtWebGetRequestExecutor(this.service.getRequestHttp()); | |||
| String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.CATEGORY_GET; | |||
| String param = "category_id=" + category_id; | |||
| if(account_id != null){ | |||
| if(StringUtils.isNotBlank(account_id)){ | |||
| param += "&account_id=" + account_id; | |||
| } | |||
| String result = this.service.execute(getExecutor, apiUrl, param); | |||
| @@ -45,7 +44,7 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| // asJsonObject = jsonElement.getAsJsonObject(); | |||
| // } | |||
| JsonArray category_list = jsonObject.getAsJsonArray("category_list"); | |||
| JsonArray category_list = jsonObject.getAsJsonArray("category_infos"); | |||
| List<GoodsCategory> list = GSON.fromJson(category_list, | |||
| new TypeReference<List<GoodsCategory>>() {}.getType()); | |||
| return list; | |||
| @@ -53,7 +52,7 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| @Override | |||
| public GoodsTemplateGet templateGet(Integer category_id, Integer product_type) throws WxErrorException { | |||
| TtWebGoodsGetRequestExecutor getExecutor = new TtWebGoodsGetRequestExecutor(this.service.getRequestHttp()); | |||
| TtWebGetRequestExecutor getExecutor = new TtWebGetRequestExecutor(this.service.getRequestHttp()); | |||
| String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.TEMPLATE_GET; | |||
| String param = "category_id=" + category_id | |||
| + "&product_type=" + product_type; | |||
| @@ -69,7 +68,7 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| @Override | |||
| public List<Product> productDraftGet(String accountId,String product_ids, String out_ids) throws WxErrorException { | |||
| TtWebGoodsGetRequestExecutor getExecutor = new TtWebGoodsGetRequestExecutor(this.service.getRequestHttp()); | |||
| TtWebGetRequestExecutor getExecutor = new TtWebGetRequestExecutor(this.service.getRequestHttp()); | |||
| String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.PRODUCT_DRAFT_GET; | |||
| String param = "" ; | |||
| if(StringUtils.isNotBlank(product_ids)){ | |||
| @@ -95,7 +94,7 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| @Override | |||
| public ProductPage productDraftListGet(String accountId,String cursor, Integer count, Integer status) throws WxErrorException { | |||
| TtWebGoodsGetRequestExecutor getExecutor = new TtWebGoodsGetRequestExecutor(this.service.getRequestHttp()); | |||
| TtWebGetRequestExecutor getExecutor = new TtWebGetRequestExecutor(this.service.getRequestHttp()); | |||
| String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.PRODUCT_DRAFT_LIST; | |||
| String param = "" ; | |||
| if(count == null){ | |||
| @@ -121,7 +120,7 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| @Override | |||
| public List<Product> productOnlineGet(String accountId,String product_ids, String out_ids) throws WxErrorException { | |||
| TtWebGoodsGetRequestExecutor getExecutor = new TtWebGoodsGetRequestExecutor(this.service.getRequestHttp()); | |||
| TtWebGetRequestExecutor getExecutor = new TtWebGetRequestExecutor(this.service.getRequestHttp()); | |||
| String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.PRODUCT_ONLINE_GET; | |||
| String param = "" ; | |||
| if(StringUtils.isNotBlank(product_ids)){ | |||
| @@ -147,7 +146,7 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| @Override | |||
| public ProductPage productOnlineListGet(String accountId,String cursor, Integer count, Integer status) throws WxErrorException { | |||
| TtWebGoodsGetRequestExecutor getExecutor = new TtWebGoodsGetRequestExecutor(this.service.getRequestHttp()); | |||
| TtWebGetRequestExecutor getExecutor = new TtWebGetRequestExecutor(this.service.getRequestHttp()); | |||
| String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.PRODUCT_ONLINE_LIST; | |||
| String param = "" ; | |||
| if(count == null){ | |||
| @@ -173,21 +172,17 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| @Override | |||
| public String productSave(Product product) throws WxErrorException { | |||
| TtWebGoodsPostRequestExecutor postExecutor = new TtWebGoodsPostRequestExecutor(this.service.getRequestHttp()); | |||
| TtWebPostRequestExecutor postExecutor = new TtWebPostRequestExecutor(this.service.getRequestHttp()); | |||
| String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.PRODUCT_SAVE; | |||
| String result = this.service.execute(postExecutor, apiUrl, GSON.toJson(product)); | |||
| BaseGoodsResult baseResult = GSON.fromJson(result, BaseGoodsResult.class); | |||
| if(baseResult.isSuccess()){ | |||
| Map map = (Map) baseResult.getData(); | |||
| return map.get("product_id").toString(); | |||
| }else{ | |||
| throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build()); | |||
| } | |||
| JsonParser parser = new JsonParser(); | |||
| JsonObject jsonObject = parser.parse(result).getAsJsonObject(); | |||
| return GsonHelper.getString(jsonObject,"product_id"); | |||
| } | |||
| @Override | |||
| public boolean productFreeAudit(String accountId,String productId, String outId, Long soldEndTime, Integer stockQty) throws WxErrorException { | |||
| TtWebGoodsPostRequestExecutor postExecutor = new TtWebGoodsPostRequestExecutor(this.service.getRequestHttp()); | |||
| TtWebPostRequestExecutor postExecutor = new TtWebPostRequestExecutor(this.service.getRequestHttp()); | |||
| String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.PRODUCT_FREE_AUDIT; | |||
| Map<String,Object> map = new HashMap<>(); | |||
| if(StringUtils.isNotBlank(productId)){ | |||
| @@ -202,31 +197,37 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| map.put("stock_qty",stockQty); | |||
| } | |||
| map.put("account_id",accountId); | |||
| String result = this.service.execute(postExecutor, apiUrl, GSON.toJson(map)); | |||
| BaseGoodsResult baseResult = GSON.fromJson(result, BaseGoodsResult.class); | |||
| if(baseResult.isSuccess()){ | |||
| JsonParser parser = new JsonParser(); | |||
| JsonObject jsonObject = parser.parse(result).getAsJsonObject(); | |||
| Integer error_code = GsonHelper.getInteger(jsonObject, "error_code"); | |||
| if(error_code == 0){ | |||
| return true; | |||
| }else{ | |||
| throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build()); | |||
| } | |||
| String description = GsonHelper.getString(jsonObject, "description"); | |||
| throw new WxErrorException(WxError.builder().errorCode(error_code).errorMsg(description).build()); | |||
| } | |||
| @Override | |||
| public boolean skuBatchSave(ProductSku sku) throws WxErrorException { | |||
| TtWebGoodsPostRequestExecutor postExecutor = new TtWebGoodsPostRequestExecutor(this.service.getRequestHttp()); | |||
| TtWebPostRequestExecutor postExecutor = new TtWebPostRequestExecutor(this.service.getRequestHttp()); | |||
| String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.SKU_BATCH_SAVE; | |||
| String result = this.service.execute(postExecutor, apiUrl, GSON.toJson(sku)); | |||
| BaseGoodsResult baseResult = GSON.fromJson(result, BaseGoodsResult.class); | |||
| if(baseResult.isSuccess()){ | |||
| JsonParser parser = new JsonParser(); | |||
| JsonObject jsonObject = parser.parse(result).getAsJsonObject(); | |||
| Integer error_code = GsonHelper.getInteger(jsonObject, "error_code"); | |||
| if(error_code == 0){ | |||
| return true; | |||
| }else{ | |||
| throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build()); | |||
| } | |||
| String description = GsonHelper.getString(jsonObject, "description"); | |||
| throw new WxErrorException(WxError.builder().errorCode(error_code).errorMsg(description).build()); | |||
| } | |||
| @Override | |||
| public boolean productOperate(String accountId,String product_id, String out_id, Integer op_type) throws WxErrorException { | |||
| TtWebGoodsPostRequestExecutor postExecutor = new TtWebGoodsPostRequestExecutor(this.service.getRequestHttp()); | |||
| TtWebPostRequestExecutor postExecutor = new TtWebPostRequestExecutor(this.service.getRequestHttp()); | |||
| String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.PRODUCT_OPERATE; | |||
| Map<String,Object> map = new HashMap<>(); | |||
| if(StringUtils.isNotBlank(product_id)){ | |||
| @@ -237,17 +238,19 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| map.put("op_type",op_type); | |||
| map.put("account_id",accountId); | |||
| String result = this.service.execute(postExecutor, apiUrl, GSON.toJson(map)); | |||
| BaseGoodsResult baseResult = GSON.fromJson(result, BaseGoodsResult.class); | |||
| if(baseResult.isSuccess()){ | |||
| JsonParser parser = new JsonParser(); | |||
| JsonObject jsonObject = parser.parse(result).getAsJsonObject(); | |||
| Integer error_code = GsonHelper.getInteger(jsonObject, "error_code"); | |||
| if(error_code == 0){ | |||
| return true; | |||
| }else{ | |||
| throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build()); | |||
| } | |||
| String description = GsonHelper.getString(jsonObject, "description"); | |||
| throw new WxErrorException(WxError.builder().errorCode(error_code).errorMsg(description).build()); | |||
| } | |||
| @Override | |||
| public boolean stockSync(String accountId,String product_id, String out_id, Integer stock) throws WxErrorException { | |||
| TtWebGoodsPostRequestExecutor postExecutor = new TtWebGoodsPostRequestExecutor(this.service.getRequestHttp()); | |||
| TtWebPostRequestExecutor postExecutor = new TtWebPostRequestExecutor(this.service.getRequestHttp()); | |||
| String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.STOCK_SYNC; | |||
| Map<String,Object> map = new HashMap<>(); | |||
| if(StringUtils.isNotBlank(product_id)){ | |||
| @@ -265,12 +268,14 @@ public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsServic | |||
| map.put("stock",stockStruct); | |||
| map.put("account_id",accountId); | |||
| String result = this.service.execute(postExecutor, apiUrl, GSON.toJson(map)); | |||
| BaseGoodsResult baseResult = GSON.fromJson(result, BaseGoodsResult.class); | |||
| if(baseResult.isSuccess()){ | |||
| JsonParser parser = new JsonParser(); | |||
| JsonObject jsonObject = parser.parse(result).getAsJsonObject(); | |||
| Integer error_code = GsonHelper.getInteger(jsonObject, "error_code"); | |||
| if(error_code == 0){ | |||
| return true; | |||
| }else{ | |||
| throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build()); | |||
| } | |||
| String description = GsonHelper.getString(jsonObject, "description"); | |||
| throw new WxErrorException(WxError.builder().errorCode(error_code).errorMsg(description).build()); | |||
| } | |||
| } | |||
| @@ -41,6 +41,8 @@ public interface TtWebConfig { | |||
| String getAppid(); | |||
| String getAccountId(); | |||
| String getSecret(); | |||
| String getToken(); | |||
| @@ -26,6 +26,8 @@ public class TtWebDefaultConfigImpl implements TtWebConfig { | |||
| private volatile String aesKey; | |||
| private volatile long expiresTime; | |||
| protected volatile String accountId; | |||
| private volatile String httpProxyHost; | |||
| private volatile int httpProxyPort; | |||
| @@ -211,4 +213,13 @@ public class TtWebDefaultConfigImpl implements TtWebConfig { | |||
| public void setAppid(String appid) { | |||
| this.appid = appid; | |||
| } | |||
| @Override | |||
| public String getAccountId() { | |||
| return accountId; | |||
| } | |||
| public void setAccountId(String accountId) { | |||
| this.accountId = accountId; | |||
| } | |||
| } | |||
| @@ -5,6 +5,7 @@ import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.TtGoodsCategory; | |||
| import com.iformall.domain.po.TtGoodsCategoryNew; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.douyin.web.bean.GoodsCategory; | |||
| import com.iformall.douyin.web.bean.GoodsTemplateGet; | |||
| @@ -19,10 +20,10 @@ public interface TtGoodsCategoryService { | |||
| * @return | |||
| */ | |||
| List<TtGoodsCategory> findTreeList(); | |||
| List<TtGoodsCategoryNew> findTreeListForNew(); | |||
| // List<TtGoodsCategoryNew> findTreeListForNew(); | |||
| List<TtGoodsCategory> findAllTreeList(); | |||
| List<TtGoodsCategoryNew> findAllTreeListForNew(); | |||
| // List<TtGoodsCategoryNew> findAllTreeListForNew(); | |||
| /** | |||
| * A端是否显示处理 | |||
| @@ -43,14 +44,14 @@ public interface TtGoodsCategoryService { | |||
| /** | |||
| * 同步抖音类目 | |||
| */ | |||
| void syncGet(boolean isNew); | |||
| void syncGet(TenantEntity tenantEntity,boolean isNew); | |||
| List<GoodsCategory> categoryGet(Integer categoryId,boolean isNew); | |||
| List<GoodsCategory> categoryGet(TenantEntity tenantEntity,Integer categoryId); | |||
| void updateFee(TtGoodsCategory record); | |||
| void updateFeeForNew(TtGoodsCategoryNew record); | |||
| int getTtServiceFee(Integer categoryId,boolean isNew); | |||
| int getTtServiceFee(Integer categoryId); | |||
| } | |||
| @@ -6,6 +6,7 @@ import com.iformall.domain.po.WxProjectConfig; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxMallVersion; | |||
| import com.iformall.enums.EnumDouyinApplicationVersion; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -97,6 +98,6 @@ public interface WxMallService { | |||
| boolean isgroupSupport(TenantEntity tenantEntity); | |||
| Map<String, WxMall> getMallMap(WxMall mallQ); | |||
| WxMallVersion getMallVersion(TenantEntity tenantEntity); | |||
| EnumDouyinApplicationVersion getDouyinApplicationVersion(TenantEntity tenantEntity); | |||
| } | |||
| @@ -7,6 +7,7 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.TtGoodsCategory; | |||
| import com.iformall.domain.po.TtGoodsCategoryNew; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| @@ -14,15 +15,14 @@ import com.iformall.douyin.web.api.goodlifesaas.TtGoodLifeSaasService; | |||
| import com.iformall.douyin.web.api.web.TtWebService; | |||
| import com.iformall.douyin.web.bean.GoodsCategory; | |||
| import com.iformall.douyin.web.bean.GoodsTemplateGet; | |||
| import com.iformall.enums.EnumCouponValidType; | |||
| import com.iformall.enums.EnumGoodsCategoryRate; | |||
| import com.iformall.enums.EnumMerchantStatus; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.TtGoodsCategoryMapper; | |||
| import com.iformall.mapper.TtGoodsCategoryNewMapper; | |||
| import com.iformall.service.TtGoodsCategoryService; | |||
| import com.iformall.service.TtMerchantPoiService; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import com.microsoft.schemas.vml.STExt; | |||
| @@ -55,6 +55,12 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService { | |||
| @Autowired | |||
| private TtMerchantPoiService ttMerchantPoiService; | |||
| @Autowired | |||
| private WxMallService wxMallService; | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> categoryRedisTemplate; | |||
| @@ -79,25 +85,25 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService { | |||
| return topList; | |||
| } | |||
| @Override | |||
| public List<TtGoodsCategoryNew> findTreeListForNew() { | |||
| TtGoodsCategoryNew record = new TtGoodsCategoryNew(); | |||
| record.setEnable(EnumYesOrNo.YES.getCode()); | |||
| record.setIsDel(EnumYesOrNo.NO.getCode()); | |||
| record.setSortColumns(BaseEntity.SortField.Id_ASC); | |||
| List<TtGoodsCategoryNew> listAll = ttGoodsCategoryNewMapper.findMinList(record); | |||
| if(listAll == null || listAll.isEmpty()){ | |||
| return new ArrayList<>(); | |||
| } | |||
| List<TtGoodsCategoryNew> topList = listAll.stream().filter(gc -> gc.getParentId().intValue() == 0).collect(Collectors.toList()); | |||
| if(topList != null && !topList.isEmpty()){ | |||
| listAll.removeAll(topList); | |||
| for (TtGoodsCategoryNew category:topList) { | |||
| category.setChild(getChildForNew(listAll,category.getId())); | |||
| } | |||
| } | |||
| return topList; | |||
| } | |||
| // @Override | |||
| // public List<TtGoodsCategoryNew> findTreeListForNew() { | |||
| // TtGoodsCategoryNew record = new TtGoodsCategoryNew(); | |||
| // record.setEnable(EnumYesOrNo.YES.getCode()); | |||
| // record.setIsDel(EnumYesOrNo.NO.getCode()); | |||
| // record.setSortColumns(BaseEntity.SortField.Id_ASC); | |||
| // List<TtGoodsCategoryNew> listAll = ttGoodsCategoryNewMapper.findMinList(record); | |||
| // if(listAll == null || listAll.isEmpty()){ | |||
| // return new ArrayList<>(); | |||
| // } | |||
| // List<TtGoodsCategoryNew> topList = listAll.stream().filter(gc -> gc.getParentId().intValue() == 0).collect(Collectors.toList()); | |||
| // if(topList != null && !topList.isEmpty()){ | |||
| // listAll.removeAll(topList); | |||
| // for (TtGoodsCategoryNew category:topList) { | |||
| // category.setChild(getChildForNew(listAll,category.getId())); | |||
| // } | |||
| // } | |||
| // return topList; | |||
| // } | |||
| @Override | |||
| public List<TtGoodsCategory> findAllTreeList() { | |||
| @@ -119,25 +125,25 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService { | |||
| return topList; | |||
| } | |||
| @Override | |||
| public List<TtGoodsCategoryNew> findAllTreeListForNew() { | |||
| TtGoodsCategoryNew record = new TtGoodsCategoryNew(); | |||
| // record.setEnable(EnumYesOrNo.YES.getCode()); | |||
| record.setIsDel(EnumYesOrNo.NO.getCode()); | |||
| record.setSortColumns(BaseEntity.SortField.Id_ASC); | |||
| List<TtGoodsCategoryNew> listAll = ttGoodsCategoryNewMapper.findList(record); | |||
| if(listAll == null || listAll.isEmpty()){ | |||
| return new ArrayList<>(); | |||
| } | |||
| List<TtGoodsCategoryNew> topList = listAll.stream().filter(gc -> gc.getParentId().intValue() == 0).collect(Collectors.toList()); | |||
| if(topList != null && !topList.isEmpty()){ | |||
| listAll.removeAll(topList); | |||
| for (TtGoodsCategoryNew category:topList) { | |||
| category.setChild(getChildForNew(listAll,category.getId())); | |||
| } | |||
| } | |||
| return topList; | |||
| } | |||
| // @Override | |||
| // public List<TtGoodsCategoryNew> findAllTreeListForNew() { | |||
| // TtGoodsCategoryNew record = new TtGoodsCategoryNew(); | |||
| //// record.setEnable(EnumYesOrNo.YES.getCode()); | |||
| // record.setIsDel(EnumYesOrNo.NO.getCode()); | |||
| // record.setSortColumns(BaseEntity.SortField.Id_ASC); | |||
| // List<TtGoodsCategoryNew> listAll = ttGoodsCategoryNewMapper.findList(record); | |||
| // if(listAll == null || listAll.isEmpty()){ | |||
| // return new ArrayList<>(); | |||
| // } | |||
| // List<TtGoodsCategoryNew> topList = listAll.stream().filter(gc -> gc.getParentId().intValue() == 0).collect(Collectors.toList()); | |||
| // if(topList != null && !topList.isEmpty()){ | |||
| // listAll.removeAll(topList); | |||
| // for (TtGoodsCategoryNew category:topList) { | |||
| // category.setChild(getChildForNew(listAll,category.getId())); | |||
| // } | |||
| // } | |||
| // return topList; | |||
| // } | |||
| private List<TtGoodsCategory> getChild(List<TtGoodsCategory> listAll,Integer parentId){ | |||
| @@ -582,23 +588,23 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService { | |||
| // @Async | |||
| @Transactional(rollbackFor = {Exception.class}) | |||
| @Override | |||
| public void syncGet(boolean isNew) { | |||
| public void syncGet(TenantEntity tenantEntity,boolean isNew) { | |||
| if(!isNew) { | |||
| TtWebService ttWebService = ttMerchantPoiService.getTtWebService(null); | |||
| handSyncCategory(ttWebService,0,new Date()); | |||
| }else { | |||
| TenantEntity defaultEntity = new TenantEntity(); | |||
| defaultEntity.setTenantId("1036"); | |||
| TtGoodLifeSaasService ttWebService = ttMerchantPoiService.getTtGoodLifeSassService(defaultEntity); | |||
| TtGoodLifeSaasService ttWebService = ttMerchantPoiService.getTtGoodLifeSassService(tenantEntity); | |||
| handSyncCategoryForNew(ttWebService,0,new Date()); | |||
| } | |||
| } | |||
| @Override | |||
| public List<GoodsCategory> categoryGet(Integer categoryId,boolean isNew) { | |||
| public List<GoodsCategory> categoryGet(TenantEntity tenantEntity,Integer categoryId) { | |||
| EnumDouyinApplicationVersion douyinApplicationVersion = wxMallService.getDouyinApplicationVersion(tenantEntity); | |||
| boolean isSaas = EnumDouyinApplicationVersion.GOODLIFE_SAAS.equals(douyinApplicationVersion); | |||
| String key = null; | |||
| if(isNew){ | |||
| key = "goods_category:new:"+categoryId; | |||
| if(isSaas){ | |||
| key = "goods_category:"+tenantEntity.getTenantId()+":"+categoryId; | |||
| }else{ | |||
| key = "goods_category:"+categoryId; | |||
| } | |||
| @@ -608,17 +614,15 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService { | |||
| } | |||
| try { | |||
| List<GoodsCategory> goodsCategories = null; | |||
| if (isNew) { | |||
| TenantEntity defaultEntity = new TenantEntity(); | |||
| defaultEntity.setTenantId("1036"); | |||
| TtGoodLifeSaasService ttWebService = ttMerchantPoiService.getTtGoodLifeSassService(defaultEntity); | |||
| goodsCategories = ttWebService.getGoodsService().categoryGet(categoryId, null); | |||
| if (isSaas) { | |||
| TtGoodLifeSaasService ttWebService = ttMerchantPoiService.getTtGoodLifeSassService(tenantEntity); | |||
| goodsCategories = ttWebService.getGoodsService().categoryGet(categoryId, ttWebService.getTtWebConfig().getAccountId()); | |||
| }else { | |||
| TtWebService ttWebService = ttMerchantPoiService.getTtWebService(null); | |||
| goodsCategories = ttWebService.getGoodsService().categoryGet(categoryId, null); | |||
| } | |||
| if(goodsCategories != null && goodsCategories.size() > 0){ | |||
| RedisCacheUtils.cache(categoryRedisTemplate,key,goodsCategories,24*3600); | |||
| RedisCacheUtils.cache(categoryRedisTemplate,key,goodsCategories,24*7*3600); | |||
| } | |||
| return goodsCategories; | |||
| } catch (WxErrorException e) { | |||
| @@ -652,20 +656,12 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService { | |||
| } | |||
| @Override | |||
| public int getTtServiceFee(Integer categoryId,boolean isNew) { | |||
| if (!isNew) { | |||
| TtGoodsCategory goodsCategory = ttGoodsCategoryMapper.selectById(categoryId); | |||
| if(goodsCategory != null && goodsCategory.getServiceFee() != null){ | |||
| return goodsCategory.getServiceFee(); | |||
| } | |||
| return 0; | |||
| }else { | |||
| TtGoodsCategoryNew goodsCategory = ttGoodsCategoryNewMapper.selectById(categoryId); | |||
| if(goodsCategory != null && goodsCategory.getServiceFee() != null){ | |||
| return goodsCategory.getServiceFee(); | |||
| } | |||
| return 0; | |||
| } | |||
| public int getTtServiceFee(Integer categoryId) { | |||
| TtGoodsCategory goodsCategory = ttGoodsCategoryMapper.selectById(categoryId); | |||
| if(goodsCategory != null && goodsCategory.getServiceFee() != null){ | |||
| return goodsCategory.getServiceFee(); | |||
| } | |||
| return 0; | |||
| } | |||
| /** | |||
| @@ -8,10 +8,8 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumGroupSupport; | |||
| import com.iformall.enums.EnumInvestUserType; | |||
| import com.iformall.enums.EnumMallUserStatus; | |||
| import com.iformall.enums.EnumUserAdmin; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxMallBuildingMapper; | |||
| import com.iformall.mapper.WxMallFloorMapper; | |||
| import com.iformall.mapper.WxMallMapper; | |||
| @@ -413,8 +411,16 @@ public class WxMallServiceImpl implements WxMallService { | |||
| } | |||
| @Override | |||
| public WxMallVersion getMallVersion(TenantEntity tenantEntity) { | |||
| return wxMallVersionMapper.getByTenantInfo(tenantEntity); | |||
| public EnumDouyinApplicationVersion getDouyinApplicationVersion(TenantEntity tenantEntity) { | |||
| WxMallVersion mallVersion = wxMallVersionMapper.getByTenantInfo(tenantEntity); | |||
| if(mallVersion == null){ | |||
| return EnumDouyinApplicationVersion.WEB; | |||
| } | |||
| EnumDouyinApplicationVersion anEnum = EnumDouyinApplicationVersion.getEnum(mallVersion.getDouyinApplicationVersion()); | |||
| if(anEnum == null){ | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"DouyinApplicationVersion 配置错误"); | |||
| } | |||
| return anEnum; | |||
| } | |||
| } | |||
| @@ -41,12 +41,8 @@ public class FmInsideProductPushMsgServiceImpl implements MsgSendService { | |||
| try{ | |||
| Thread.currentThread().sleep(1000);//延时秒 | |||
| }catch(Exception e){} | |||
| WxMallVersion mallVersion = wxMallService.getMallVersion(msg.getTenantInfo()); | |||
| boolean isSaas = false; | |||
| if (null != mallVersion && null != mallVersion.getDouyinApplicationVersion()) { | |||
| isSaas = EnumDouyinApplicationVersion.isSaas(mallVersion.getDouyinApplicationVersion()); | |||
| } | |||
| EnumDouyinApplicationVersion douyinApplicationVersion = wxMallService.getDouyinApplicationVersion(msg.getTenantInfo()); | |||
| boolean isSaas = EnumDouyinApplicationVersion.GOODLIFE_SAAS.equals(douyinApplicationVersion); | |||
| if(EnumPushType.SPU_STATUS_SYNC.equals(msg.getSyncType())){ | |||
| ttCouponGoodsService.productOperate(msg.getTenantInfo(),msg.getCouponId(),isSaas); | |||
| @@ -42,10 +42,6 @@ public class TtServiceFeeService implements ServiceFeeAdapterService{ | |||
| @Autowired | |||
| TtMallGoodsCategoryService ttMallGoodsCategoryService; | |||
| @Lazy | |||
| @Autowired | |||
| WxMallService wxMallService; | |||
| @Override | |||
| @@ -60,21 +56,12 @@ public class TtServiceFeeService implements ServiceFeeAdapterService{ | |||
| @Override | |||
| public int getOfficialCommission(Integer categoryId, WxPayAccount payAccount) { | |||
| if(categoryId != null){ | |||
| WxMallVersion mv = wxMallService.getMallVersion(payAccount); | |||
| if (null == mv || null == mv.getDouyinApplicationVersion()) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"mallVersion[douyinApplicationVersion]未配置"); | |||
| } | |||
| boolean isSaas; | |||
| try { | |||
| isSaas = EnumDouyinApplicationVersion.isSaas(mv.getDouyinApplicationVersion()); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage()); | |||
| } | |||
| int ttServiceFee = ttGoodsCategoryService.getTtServiceFee(categoryId,isSaas); | |||
| int ttServiceFee = ttGoodsCategoryService.getTtServiceFee(categoryId); | |||
| int realRate = this.getRealRate(payAccount); | |||
| if(ttServiceFee > realRate){ | |||
| return ttServiceFee - realRate; | |||
| } | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"抖音服务费设置异常"); | |||
| } | |||
| return 0; | |||
| } | |||
| @@ -353,6 +353,8 @@ public class MaUtil { | |||
| config.setAccessToken(appinfo.getAccessToken()); | |||
| config.setExpiresTime(appinfo.getLastTokenTime().getTime()+appinfo.getExpiresIn()*1000); | |||
| } | |||
| config.setAccountId(appinfo.getLaikeId()); | |||
| config.setApacheHttpClientBuilder(FmHttpClientBuilder.get()); | |||
| //默认抖音 | |||