winter 3 лет назад
Родитель
Сommit
420790f276
36 измененных файлов: 1245 добавлений и 157 удалений
  1. +40
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/base/DouyinBaseController.java
  2. +99
    -9
      mallinkAdmin/src/main/java/com/iformall/controller/basic/TtGoodsCategoryController.java
  3. +24
    -32
      mallinkAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java
  4. +19
    -11
      mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java
  5. +3
    -0
      mallinkAdmin/src/main/resources/db/migration/V2023053000001_douyin.sql
  6. +57
    -0
      mallinkService/src/main/java/com/iformall/domain/po/TtGoodsCategoryNew.java
  7. +2
    -20
      mallinkService/src/main/java/com/iformall/douyin/web/api/basic/TtBasicService.java
  8. +8
    -35
      mallinkService/src/main/java/com/iformall/douyin/web/api/basic/TtBasicServiceImpl.java
  9. +154
    -0
      mallinkService/src/main/java/com/iformall/douyin/web/api/goodlifesaas/TtGoodLifeSaasGoodsService.java
  10. +14
    -0
      mallinkService/src/main/java/com/iformall/douyin/web/api/goodlifesaas/TtGoodLifeSaasService.java
  11. +273
    -0
      mallinkService/src/main/java/com/iformall/douyin/web/api/goodlifesaas/impl/TtGoodLifeSaasGoodsServiceImpl.java
  12. +22
    -0
      mallinkService/src/main/java/com/iformall/douyin/web/api/goodlifesaas/impl/TtGoodLifeSaasServiceImpl.java
  13. +1
    -1
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebGetRequestExecutor.java
  14. +1
    -1
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebGoodsCategoryGetRequestExecutor.java
  15. +1
    -1
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebGoodsGetRequestExecutor.java
  16. +1
    -1
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebGoodsPostRequestExecutor.java
  17. +2
    -2
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebGoodsService.java
  18. +1
    -1
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebPoiPlanService.java
  19. +1
    -1
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebPostRequestExecutor.java
  20. +1
    -1
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebProductService.java
  21. +27
    -0
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebService.java
  22. +1
    -1
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebShopMatchService.java
  23. +7
    -2
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/impl/TtWebGoodsServiceImpl.java
  24. +4
    -1
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/impl/TtWebPoiPlanServiceImpl.java
  25. +5
    -5
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/impl/TtWebProductServiceImpl.java
  26. +71
    -0
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/impl/TtWebServiceImpl.java
  27. +5
    -5
      mallinkService/src/main/java/com/iformall/douyin/web/api/web/impl/TtWebShopMatchServiceImpl.java
  28. +1
    -1
      mallinkService/src/main/java/com/iformall/enums/EnumDouyinApplicationVersion.java
  29. +20
    -0
      mallinkService/src/main/java/com/iformall/mapper/TtGoodsCategoryNewMapper.java
  30. +7
    -5
      mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java
  31. +4
    -1
      mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java
  32. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java
  33. +193
    -13
      mallinkService/src/main/java/com/iformall/service/impl/TtGoodsCategoryServiceImpl.java
  34. +26
    -3
      mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java
  35. +48
    -2
      mallinkService/src/main/java/com/iformall/utils/MaUtil.java
  36. +100
    -0
      mallinkService/src/main/resources/mapper/TtGoodsCategoryNewMapper.xml

+ 40
- 0
mallinkAdmin/src/main/java/com/iformall/controller/base/DouyinBaseController.java Просмотреть файл

@@ -0,0 +1,40 @@
package com.iformall.controller.base;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import com.iformall.common.ErrorCode;
import com.iformall.domain.po.WxMallVersion;
import com.iformall.enums.EnumDouyinApplicationVersion;
import com.iformall.exception.MallinkException;
import com.iformall.service.WxMallService;

@RestController
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();
if (_e.intValue() == EnumDouyinApplicationVersion.GOODLIFE_SAAS.getCode().intValue()) {
return true;
}else if (_e.intValue() == EnumDouyinApplicationVersion.WEB.getCode().intValue()) {
return false;
}else {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"mallVersion[douyinApplicationVersion]配置错误");
}
}
}

+ 99
- 9
mallinkAdmin/src/main/java/com/iformall/controller/basic/TtGoodsCategoryController.java Просмотреть файл

@@ -4,13 +4,22 @@ package com.iformall.controller.basic;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.controller.base.DouyinBaseController;
import com.iformall.domain.po.TtGoodsCategory;
import com.iformall.domain.po.TtGoodsCategoryNew;
import com.iformall.enums.EnumDouyinApplicationVersion;
import com.iformall.exception.MallinkException;
import com.iformall.service.TtGoodsCategoryService;
import com.iformall.utils.DateUtils;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -23,7 +32,7 @@ import org.springframework.web.bind.annotation.*;
*/
@RestController
@RequestMapping("goodsCategory")
public class TtGoodsCategoryController extends BaseController {
public class TtGoodsCategoryController extends DouyinBaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
@@ -36,7 +45,18 @@ public class TtGoodsCategoryController extends BaseController {
@SystemControllerLog(description = "列表")
public ResultData treeList() {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::treeList");
return new ResultData(ttGoodsCategoryService.findTreeList());
try {
boolean isSaas = this.isGoodLifeSaas();
if (!isSaas) {
return new ResultData(ttGoodsCategoryService.findTreeList());
}else {
return new ResultData(ttGoodsCategoryService.findTreeListForNew());
}
} catch (Exception e) {
logger.error("treeList error.",e);
return new ResultData(Result.ERROR,e.getMessage());
}
}

@TenantIgnore
@@ -49,7 +69,17 @@ public class TtGoodsCategoryController extends BaseController {
if(categoryId == null){
categoryId = 0;
}
return new ResultData(ttGoodsCategoryService.categoryGet(categoryId));
try {
boolean isSaas = this.isGoodLifeSaas();
if (!isSaas) {
return new ResultData(ttGoodsCategoryService.categoryGet(categoryId,false));
}else {
return new ResultData(ttGoodsCategoryService.categoryGet(categoryId,true));
}
} catch (Exception e) {
logger.error("categoryGet error.",e);
return new ResultData(Result.ERROR,e.getMessage());
}
}

@TenantIgnore
@@ -59,7 +89,17 @@ public class TtGoodsCategoryController extends BaseController {
@SystemControllerLog(description = "同步")
public ResultData syncGetTt() {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::syncGetTt");
ttGoodsCategoryService.syncGet();
try {
boolean isSaas = this.isGoodLifeSaas();
if (!isSaas) {
ttGoodsCategoryService.syncGet(false);
}else {
ttGoodsCategoryService.syncGet(true);
}
} catch (Exception e) {
logger.error("syncGetTt error.",e);
return new ResultData(Result.ERROR,e.getMessage());
}
return new ResultData();
}

@@ -70,7 +110,18 @@ public class TtGoodsCategoryController extends BaseController {
@SystemControllerLog(description = "列表")
public ResultData allTreeList() {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::allTreeList");
return new ResultData(ttGoodsCategoryService.findAllTreeList());
try {
boolean isSaas = this.isGoodLifeSaas();
if (!isSaas) {
return new ResultData(ttGoodsCategoryService.findAllTreeList());
}else {
return new ResultData(ttGoodsCategoryService.findAllTreeListForNew());
}
} catch (Exception e) {
logger.error("allTreeList error.",e);
return new ResultData(Result.ERROR,e.getMessage());
}
}

@TenantIgnore
@@ -84,8 +135,27 @@ public class TtGoodsCategoryController extends BaseController {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
record.setSoftwareFee(null);

ttGoodsCategoryService.updateFee(record);
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());
}
}
} catch (Exception e) {
logger.error("setServiceFee error.",e);
return new ResultData(Result.ERROR,e.getMessage());
}
return new ResultData();
}

@@ -100,8 +170,28 @@ public class TtGoodsCategoryController extends BaseController {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
record.setServiceFee(null);

ttGoodsCategoryService.updateFee(record);
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());
}
}
} catch (Exception e) {
logger.error("setSoftwareFee error.",e);
return new ResultData(Result.ERROR,e.getMessage());
}
return new ResultData();
}



+ 24
- 32
mallinkAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java Просмотреть файл

@@ -7,6 +7,7 @@ import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.controller.base.DouyinBaseController;
import com.iformall.controller.mem.AsyncTask;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
@@ -44,7 +45,7 @@ import javax.servlet.http.HttpServletResponse;
*/
@RestController
@RequestMapping("merchantPoi")
public class TtMerchantPoiController extends BaseController {
public class TtMerchantPoiController extends DouyinBaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
@@ -53,9 +54,6 @@ public class TtMerchantPoiController extends BaseController {
@Autowired
private TtMerchantPoiService ttMerchantPoiService;

@Autowired
private WxMallService wxMallService;

@Autowired
StringRedisTemplate stringRedisTemplate;

@@ -234,43 +232,37 @@ public class TtMerchantPoiController extends BaseController {
// return ttMerchantPoiService.spuStockSync(getTenantInfo(),couponChannelId);
// }

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;
}
@TenantIgnore
@RequestMapping("/exportTemplate")
public void exportTemplate(HttpServletRequest request, HttpServletResponse response) {
Integer _e = getCurrentApplicationVersion();
if (_e.intValue() == EnumDouyinApplicationVersion.WEB.getCode().intValue()) {
ttMerchantPoiService.exportTemplate(request, response,false);
}else if (_e.intValue() == EnumDouyinApplicationVersion.MINIAPP.getCode().intValue()) {
ttMerchantPoiService.exportTemplate(request, response,true);
}else {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"mallVersion[douyinApplicationVersion]配置错误");
}
try {
boolean isSaas = this.isGoodLifeSaas();
if (!isSaas) {
ttMerchantPoiService.exportTemplate(request, response,false);
}else {
ttMerchantPoiService.exportTemplate(request, response,true);
}
} catch (Exception e) {
logger.error("allTreeList error.",e);
throw new MallinkException(Result.ERROR,e.getMessage());
}
}
@TenantIgnore
@PostMapping(value = "/importPoi", consumes = "multipart/*")
@SystemControllerLog(description = "poi-导入数据")
public ResultData importPoi(@RequestParam("file") MultipartFile mFile) {
Integer _e = getCurrentApplicationVersion();
if (_e.intValue() == EnumDouyinApplicationVersion.WEB.getCode().intValue()) {
return processImport(mFile,false);
}else if (_e.intValue() == EnumDouyinApplicationVersion.MINIAPP.getCode().intValue()) {
return processImport(mFile,true);
}else {
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"mallVersion[douyinApplicationVersion]配置错误");
}
try {
boolean isSaas = this.isGoodLifeSaas();
if (!isSaas) {
return processImport(mFile,false);
}else {
return processImport(mFile,true);
}
} catch (Exception e) {
logger.error("allTreeList error.",e);
throw new MallinkException(Result.ERROR,e.getMessage());
}
}
private ResultData processImport(MultipartFile mFile,boolean isNew) {


+ 19
- 11
mallinkAdmin/src/main/java/com/iformall/controller/market/TtCouponGoodsController.java Просмотреть файл

@@ -3,8 +3,10 @@ package com.iformall.controller.market;
import com.iformall.annotation.SystemControllerLog;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.controller.base.DouyinBaseController;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.vo.TtCouponChannelVo;
@@ -27,7 +29,7 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("ttgoods")
@Api(description = "抖音商品库")
public class TtCouponGoodsController extends BaseController {
public class TtCouponGoodsController extends DouyinBaseController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
@@ -107,17 +109,23 @@ public class TtCouponGoodsController extends BaseController {
if(coupon == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}

try {
GoodsTemplateGet goodsTemplateGet = ttMerchantPoiService.getTtWebService(getTenantInfo()).getGoodsService().templateGet(categoryId, productType);
ttGoodsCategoryService.adminIsShow(goodsTemplateGet);
ttGoodsCategoryService.handTemplate(goodsTemplateGet,coupon);
return new ResultData(goodsTemplateGet);
} catch (WxErrorException e) {
e.printStackTrace();
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),e.getMessage());
}

boolean isSaas = this.isGoodLifeSaas();
if (!isSaas) {
GoodsTemplateGet goodsTemplateGet = ttMerchantPoiService.getTtWebService(getTenantInfo()).getGoodsService().templateGet(categoryId, productType);
ttGoodsCategoryService.adminIsShow(goodsTemplateGet);
ttGoodsCategoryService.handTemplate(goodsTemplateGet,coupon);
return new ResultData(goodsTemplateGet);
}else {
GoodsTemplateGet goodsTemplateGet = ttMerchantPoiService.getTtGoodLifeSassService(getTenantInfo()).getGoodLifeSaasGoodsService().templateGet(categoryId, productType);
ttGoodsCategoryService.adminIsShow(goodsTemplateGet);
ttGoodsCategoryService.handTemplate(goodsTemplateGet,coupon);
return new ResultData(goodsTemplateGet);
}
} catch (Exception e) {
logger.error("allTreeList error.",e);
return new ResultData(Result.ERROR,e.getMessage());
}
}

@TenantIgnore


+ 3
- 0
mallinkAdmin/src/main/resources/db/migration/V2023053000001_douyin.sql Просмотреть файл

@@ -5,3 +5,6 @@ CREATE TABLE `wx_mall_version` (
`douyin_application_version` int(3) NOT NULL COMMENT '抖音应用版本',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='商场';


create table tt_goods_category_new like tt_goods_category;

+ 57
- 0
mallinkService/src/main/java/com/iformall/domain/po/TtGoodsCategoryNew.java Просмотреть файл

@@ -0,0 +1,57 @@
package com.iformall.domain.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;
import java.util.List;

@TableName(value = "tt_goods_category_new")
@Data
@EqualsAndHashCode(callSuper = true)
public class TtGoodsCategoryNew extends BaseEntity {

protected Integer id;//category_id

@io.swagger.annotations.ApiModelProperty(value="层级",name="level")
private Integer level;

@io.swagger.annotations.ApiModelProperty(value="",name="name")
private String name;

@io.swagger.annotations.ApiModelProperty(value="",name="parentId")
private Integer parentId;

@io.swagger.annotations.ApiModelProperty(value="类目是否开放",name="enable")
private Integer enable;

@io.swagger.annotations.ApiModelProperty(value="是否是叶子结点",name="isLeaf")
private Integer isLeaf;

@io.swagger.annotations.ApiModelProperty(value="",name="serviceFee")
private Integer serviceFee;

@io.swagger.annotations.ApiModelProperty(value="",name="softwareFee")
private Integer softwareFee;

@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
private Date createDate;
@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")
private Date updateDate;

@io.swagger.annotations.ApiModelProperty(value="",name="isDel")
private Integer isDel;

@TableField(exist = false)
protected List<TtGoodsCategoryNew> child;

@TableField(exist = false)
private List<Integer> categoryIds;//ids

@TableField(exist = false)
private List<Integer> parentIds;

}

mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebService.java → mallinkService/src/main/java/com/iformall/douyin/web/api/basic/TtBasicService.java Просмотреть файл

@@ -1,4 +1,4 @@
package com.iformall.douyin.web.api;
package com.iformall.douyin.web.api.basic;

import cn.binarywang.wx.miniapp.config.WxMaConfig;
import com.iformall.douyin.web.config.TtWebConfig;
@@ -10,7 +10,7 @@ import me.chanjar.weixin.common.util.http.RequestHttp;
/**
*
*/
public interface TtWebService {
public interface TtBasicService {

/**
* 获取access_token.
@@ -96,22 +96,4 @@ public interface TtWebService {
*/
RequestHttp getRequestHttp();

/**
* 返回用户相关接口方法的实现类对象,以方便调用其各个接口.
*
* @return TtMaUserService
*/
TtWebShopMatchService getShopMatchService();

/**
* 返回用户相关接口方法的实现类对象,以方便调用其各个接口.
*
* @return TtMaUserService
*/
TtWebProductService getProductService();

TtWebGoodsService getGoodsService();

TtWebPoiPlanService getPoiPlanService();

}

mallinkService/src/main/java/com/iformall/douyin/web/api/impl/TtWebServiceImpl.java → mallinkService/src/main/java/com/iformall/douyin/web/api/basic/TtBasicServiceImpl.java Просмотреть файл

@@ -1,4 +1,4 @@
package com.iformall.douyin.web.api.impl;
package com.iformall.douyin.web.api.basic;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@@ -34,19 +34,13 @@ import static com.iformall.douyin.web.config.TtWebConstants.ErrorCode.*;
* @author
*/
@Slf4j
public class TtWebServiceImpl implements TtWebService, RequestHttp<CloseableHttpClient, HttpHost> {
private static final JsonParser JSON_PARSER = new JsonParser();
private CloseableHttpClient httpClient;
private HttpHost httpProxy;
private TtWebConfig ttWebConfig;

private TtWebShopMatchService shopMatchService = new TtWebShopMatchServiceImpl(this);
private TtWebProductService productService = new TtWebProductServiceImpl(this);
private TtWebGoodsService goodService = new TtWebGoodsServiceImpl(this);
private TtWebPoiPlanService poiPlanService = new TtWebPoiPlanServiceImpl(this);

private int retrySleepMillis = 1000;
private int maxRetryTimes = 5;
public class TtBasicServiceImpl implements TtBasicService, RequestHttp<CloseableHttpClient, HttpHost> {
protected static final JsonParser JSON_PARSER = new JsonParser();
protected CloseableHttpClient httpClient;
protected HttpHost httpProxy;
protected TtWebConfig ttWebConfig;
protected int retrySleepMillis = 1000;
protected int maxRetryTimes = 5;

protected static final Gson GSON = new Gson();

@@ -274,25 +268,4 @@ public class TtWebServiceImpl implements TtWebService, RequestHttp<CloseableHttp
public void setMaxRetryTimes(int maxRetryTimes) {
this.maxRetryTimes = maxRetryTimes;
}

@Override
public TtWebShopMatchService getShopMatchService() {
return this.shopMatchService;
}

@Override
public TtWebProductService getProductService() {
return this.productService;
}

@Override
public TtWebGoodsService getGoodsService() {
return this.goodService;
}

@Override
public TtWebPoiPlanService getPoiPlanService() {
return this.poiPlanService;
}

}

+ 154
- 0
mallinkService/src/main/java/com/iformall/douyin/web/api/goodlifesaas/TtGoodLifeSaasGoodsService.java Просмотреть файл

@@ -0,0 +1,154 @@
package com.iformall.douyin.web.api.goodlifesaas;


import com.iformall.douyin.web.bean.*;
import me.chanjar.weixin.common.error.WxErrorException;

import java.util.List;

/**
* 接入商品库
*
* @author
*/
public interface TtGoodLifeSaasGoodsService {

/**
*0 查询商品品类
*/
String CATEGORY_GET = "/goodlife/v1/goods/category/get/";
/**
*1 查询商品模板
*/
String TEMPLATE_GET = "/goodlife/v1/goods/template/get/";
/**
*2 查询商品草稿数据
*/
String PRODUCT_DRAFT_GET = "/goodlife/v1/goods/product/draft/get/";
/**
*3 查询商品草稿数据列表
*/
String PRODUCT_DRAFT_LIST = "/goodlife/v1/goods/product/draft/query/";
/**
*4 查询商品线上数据
*/
String PRODUCT_ONLINE_GET = "/goodlife/v1/goods/product/online/get/";
/**
*5 查询商品线上数据列表
*/
String PRODUCT_ONLINE_LIST = "/goodlife/v1/goods/product/online/query/";
/**
*6 创建/更新商品
*/
String PRODUCT_SAVE = "/goodlife/v1/goods/product/save/";
/**
*7 免审修改团购活动
*/
String PRODUCT_FREE_AUDIT = "/goodlife/v1/goods/product/free_audit/";
/**
*8 创建/更新多SKU商品的SKU列表(团购/代金券不用对接这个接口)
*/
String SKU_BATCH_SAVE = "/goodlife/v1/goods/sku/batch_save/";
/**
*9 上下架商品
*/
String PRODUCT_OPERATE = "/goodlife/v1/goods/product/operate/";
/**
*10 同步库存
*/
String STOCK_SYNC = "/goodlife/v1/goods/stock/sync/";

/**
* category_id int FALSE 行业类目ID,返回当前id下的直系子类目信息;传0或者不传,均返回所有一级行业类目
* account_id int FALSE 服务商的入驻商户ID/代运营的商户ID,不传时默认为服务商身份
*/
List<GoodsCategory> categoryGet(Integer category_id,Integer account_id) throws WxErrorException;
/**
* - 查询商品模板,创建商品时的属性列表需与该接口保持一致,否则无法识别
* category_id int TRUE 行业类目;详细见;商品类目表 https://bytedance.feishu.cn/docx/doxcnn02OUCTiKjpmzFR6ItdTye
* product_type int TRUE 商品类型 商品类型 1-团购 11-代金券
*/
GoodsTemplateGet templateGet(Integer category_id,Integer product_type) throws WxErrorException;

/**
* - 使用商品ID或外部商品ID查询商品草稿
* - 处于新建审核中、修改审核中、或审核成功、失败的数据可以通过该接口查询到
* - 一次最多查询10个草稿数据
* product_ids string TRUE 商品ID列表(逗号分隔)
* out_ids string TRUE 外部商品ID列表(逗号分隔)
*/
List<Product> productDraftGet(String product_ids, String out_ids) throws WxErrorException ;

/**
* - 查询本client_key(或绑定的账号)对应的商品草稿列表
* - 处于审核中、或审核成功、失败的数据可以通过该接口查询到
* cursor string FALSE 第一页不传,之后用前一次返回的next_cursor传入进行翻页
* count int FALSE 分页数量,不传默认为5
* status int FALSE 过滤草稿状态,10-审核中 12-审核失败 1-审核通过
*
*/
ProductPage productDraftListGet(String cursor,Integer count,Integer status) throws WxErrorException ;

/**
* - - 使用商品ID或外部商品ID查询商品线上数据
* - 线上数据是指:通过审核后可以被用户看到的数据,包括在线、下线状态的数据
* product_ids string TRUE 商品ID列表(逗号分隔)
* out_ids string TRUE 外部商品ID列表(逗号分隔)
*/
List<Product> productOnlineGet(String product_ids, String out_ids) throws WxErrorException ;

/**
* - 查询本client_key(或绑定的账号)对应的商品线上列表
* - 处于在线、下线、封禁状态的数据可以通过该接口查询到
* cursor string FALSE 第一页不传,之后用前一次返回的next_cursor传入进行翻页
* count int FALSE 分页数量,不传默认为5
* status int FALSE 过滤在线状态 1-在线 2-下线 3-封禁
*
*/
ProductPage productOnlineListGet(String cursor,Integer count,Integer status) throws WxErrorException ;

/**
* - 创建或更新商品
* - 对于同一服务商,相同的out_id会被认为是同一商品,重复创建会被覆盖
* - 商品和SKU属性,需要通过模板获取
* return - product_id 创建/更新商品成功后产生,与老接口spu_id一致
*/
String productSave(Product product) throws WxErrorException ;

/**
* - 免审修改团购活动
* product_id string TRUE 商品id (商品id或商品外部id 选其一)
* out_id string TRUE 商品外部id (商品id或商品外部id 选其一)
* sold_end_time int64 FALSE 售卖结束时间
* stock_qty int64 FALSE 总库存
*/
boolean productFreeAudit(String productId,String outId,Long soldEndTime,Integer stockQty) throws WxErrorException ;

/**
* 创建/更新多SKU商品的SKU列表(团购/代金券不用对接这个接口)
*
* @return
*/
boolean skuBatchSave(ProductSku sku) throws WxErrorException ;

/**
* 上下架商品
* product_id string TRUE 商品id(若有第三方id可不传)
* out_id string TRUE 商品第三方id
* op_type int64 TRUE 1-上线 2-下线
* @return
*/
boolean productOperate(String product_id,String out_id,Integer op_type) throws WxErrorException ;

/**
* 同步库存
* product_id string TRUE 商品id(若有第三方id可不传)
* out_id string TRUE 商品第三方id
* stock StockStruct TRUE 库存信息
* - limit_type int TRUE 库存上限类型,为2时stock_qty和avail_qty字段无意义 1-有限库存 2-无限库存
* - stock_qty int TRUE 总库存,limit_type=2时无意义
*/
boolean stockSync(String product_id,String out_id,Integer stock) throws WxErrorException ;

}

+ 14
- 0
mallinkService/src/main/java/com/iformall/douyin/web/api/goodlifesaas/TtGoodLifeSaasService.java Просмотреть файл

@@ -0,0 +1,14 @@
package com.iformall.douyin.web.api.goodlifesaas;

import com.iformall.douyin.web.api.basic.TtBasicService;
import com.iformall.douyin.web.api.web.TtWebGoodsService;
import com.iformall.douyin.web.api.web.TtWebPoiPlanService;
import com.iformall.douyin.web.api.web.TtWebProductService;
import com.iformall.douyin.web.api.web.TtWebShopMatchService;
/**
*
*/
public interface TtGoodLifeSaasService extends TtBasicService{

TtGoodLifeSaasGoodsService getGoodLifeSaasGoodsService();
}

+ 273
- 0
mallinkService/src/main/java/com/iformall/douyin/web/api/goodlifesaas/impl/TtGoodLifeSaasGoodsServiceImpl.java Просмотреть файл

@@ -0,0 +1,273 @@
package com.iformall.douyin.web.api.goodlifesaas.impl;

import com.alibaba.fastjson.TypeReference;
import com.google.gson.*;
import com.iformall.douyin.web.api.goodlifesaas.TtGoodLifeSaasGoodsService;
import com.iformall.douyin.web.api.goodlifesaas.TtGoodLifeSaasService;
import com.iformall.douyin.web.api.web.TtWebGoodsCategoryGetRequestExecutor;
import com.iformall.douyin.web.api.web.TtWebGoodsGetRequestExecutor;
import com.iformall.douyin.web.api.web.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 org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
*
*/
@AllArgsConstructor
public class TtGoodLifeSaasGoodsServiceImpl implements TtGoodLifeSaasGoodsService {

private static final Gson GSON = new GsonBuilder().create();

private TtGoodLifeSaasService service;


@Override
public List<GoodsCategory> categoryGet(Integer category_id, Integer account_id) throws WxErrorException {
TtWebGoodsCategoryGetRequestExecutor getExecutor = new TtWebGoodsCategoryGetRequestExecutor(this.service.getRequestHttp());
String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.CATEGORY_GET;
String param = "category_id=" + category_id;
if(account_id != null){
param += "&account_id=" + account_id;
}
String result = this.service.execute(getExecutor, apiUrl, param);
JsonObject jsonObject = GSON.fromJson(result, JsonObject.class);
// JsonElement jsonElement = GSON.toJsonTree(result);
// JsonObject asJsonObject = null;
// if(jsonElement.isJsonPrimitive()){
// asJsonObject = jsonElement.getAsJsonPrimitive().getAsJsonObject();
// }else{
// asJsonObject = jsonElement.getAsJsonObject();
// }

JsonArray category_list = jsonObject.getAsJsonArray("category_list");
List<GoodsCategory> list = GSON.fromJson(category_list,
new TypeReference<List<GoodsCategory>>() {}.getType());
return list;
}
@Override
public GoodsTemplateGet templateGet(Integer category_id, Integer product_type) throws WxErrorException {
TtWebGoodsGetRequestExecutor getExecutor = new TtWebGoodsGetRequestExecutor(this.service.getRequestHttp());
String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.TEMPLATE_GET;
String param = "category_id=" + category_id
+ "&product_type=" + product_type;
String result = this.service.execute(getExecutor, apiUrl, param);
BaseGoodsResult<GoodsTemplateGet> baseResult = GSON.fromJson(result,
new TypeReference<BaseGoodsResult<GoodsTemplateGet>>(){}.getType());
if(baseResult.isSuccess()){
return baseResult.getData();
}else{
throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build());
}
}

@Override
public List<Product> productDraftGet(String product_ids, String out_ids) throws WxErrorException {
TtWebGoodsGetRequestExecutor getExecutor = new TtWebGoodsGetRequestExecutor(this.service.getRequestHttp());
String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.PRODUCT_DRAFT_GET;
String param = "" ;
if(StringUtils.isNotBlank(product_ids)){
param = "product_ids=" + product_ids;
}else if(StringUtils.isNotBlank(out_ids)){
param = "out_ids=" + out_ids;
}
String result = this.service.execute(getExecutor, apiUrl, param);
BaseGoodsResult baseResult = GSON.fromJson(result, BaseGoodsResult.class);
if(baseResult.isSuccess()){
Map map = (Map) baseResult.getData();
if(map != null){
Object product_draft_list = map.get("product_draft_list");
List<Product> list = GSON.fromJson(GSON.toJson(product_draft_list),
new TypeReference<List<Product>>() {}.getType());
return list;
}
return null;
}else{
throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build());
}
}

@Override
public ProductPage productDraftListGet(String cursor, Integer count, Integer status) throws WxErrorException {
TtWebGoodsGetRequestExecutor getExecutor = new TtWebGoodsGetRequestExecutor(this.service.getRequestHttp());
String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.PRODUCT_DRAFT_LIST;
String param = "" ;
if(count == null){
param = "count=" + 5;
}else{
param = "count=" + count;
}
if(StringUtils.isNotBlank(cursor)){
param += "&cursor=" + cursor;
}
if(status != null){
param += "&status=" + status;
}
String result = this.service.execute(getExecutor, apiUrl, param);
BaseGoodsResult<ProductPage> baseResult = GSON.fromJson(result,
new TypeReference<BaseGoodsResult<ProductPage>>() {}.getType());
if(baseResult.isSuccess()){
return baseResult.getData();
}else{
throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build());
}
}

@Override
public List<Product> productOnlineGet(String product_ids, String out_ids) throws WxErrorException {
TtWebGoodsGetRequestExecutor getExecutor = new TtWebGoodsGetRequestExecutor(this.service.getRequestHttp());
String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.PRODUCT_ONLINE_GET;
String param = "" ;
if(StringUtils.isNotBlank(product_ids)){
param = "product_ids=" + product_ids;
}else if(StringUtils.isNotBlank(out_ids)){
param = "out_ids=" + out_ids;
}
String result = this.service.execute(getExecutor, apiUrl, param);
BaseGoodsResult baseResult = GSON.fromJson(result, BaseGoodsResult.class);
if(baseResult.isSuccess()){
Map map = (Map) baseResult.getData();
if(map != null){
Object product_online_list = map.get("product_online_list");
List<Product> list = GSON.fromJson(GSON.toJson(product_online_list),
new TypeReference<List<Product>>() {}.getType());
return list;
}
return null;
}else{
throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build());
}
}

@Override
public ProductPage productOnlineListGet(String cursor, Integer count, Integer status) throws WxErrorException {
TtWebGoodsGetRequestExecutor getExecutor = new TtWebGoodsGetRequestExecutor(this.service.getRequestHttp());
String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.PRODUCT_ONLINE_LIST;
String param = "" ;
if(count == null){
param = "count=" + 5;
}else{
param = "count=" + count;
}
if(StringUtils.isNotBlank(cursor)){
param += "&cursor=" + cursor;
}
if(status != null){
param += "&status=" + status;
}
String result = this.service.execute(getExecutor, apiUrl, param);
BaseGoodsResult<ProductPage> baseResult = GSON.fromJson(result,
new TypeReference<BaseGoodsResult<ProductPage>>() {}.getType());
if(baseResult.isSuccess()){
return baseResult.getData();
}else{
throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build());
}
}

@Override
public String productSave(Product product) throws WxErrorException {
TtWebGoodsPostRequestExecutor postExecutor = new TtWebGoodsPostRequestExecutor(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());
}
}

@Override
public boolean productFreeAudit(String productId, String outId, Long soldEndTime, Integer stockQty) throws WxErrorException {
TtWebGoodsPostRequestExecutor postExecutor = new TtWebGoodsPostRequestExecutor(this.service.getRequestHttp());
String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.PRODUCT_FREE_AUDIT;
Map<String,Object> map = new HashMap<>();
if(StringUtils.isNotBlank(productId)){
map.put("product_id",productId);
}else if(StringUtils.isNotBlank(outId)){
map.put("out_id",outId);
}
if(soldEndTime != null){
map.put("sold_end_time",soldEndTime);
}
if(stockQty != null){
map.put("stock_qty",stockQty);
}
String result = this.service.execute(postExecutor, apiUrl, GSON.toJson(map));
BaseGoodsResult baseResult = GSON.fromJson(result, BaseGoodsResult.class);
if(baseResult.isSuccess()){
return true;
}else{
throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build());
}
}

@Override
public boolean skuBatchSave(ProductSku sku) throws WxErrorException {
TtWebGoodsPostRequestExecutor postExecutor = new TtWebGoodsPostRequestExecutor(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()){
return true;
}else{
throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build());
}
}

@Override
public boolean productOperate(String product_id, String out_id, Integer op_type) throws WxErrorException {
TtWebGoodsPostRequestExecutor postExecutor = new TtWebGoodsPostRequestExecutor(this.service.getRequestHttp());
String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.PRODUCT_OPERATE;
Map<String,Object> map = new HashMap<>();
if(StringUtils.isNotBlank(product_id)){
map.put("product_id",product_id);
}else if(StringUtils.isNotBlank(out_id)){
map.put("out_id",out_id);
}
map.put("op_type",op_type);
String result = this.service.execute(postExecutor, apiUrl, GSON.toJson(map));
BaseGoodsResult baseResult = GSON.fromJson(result, BaseGoodsResult.class);
if(baseResult.isSuccess()){
return true;
}else{
throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build());
}
}

@Override
public boolean stockSync(String product_id, String out_id, Integer stock) throws WxErrorException {
TtWebGoodsPostRequestExecutor postExecutor = new TtWebGoodsPostRequestExecutor(this.service.getRequestHttp());
String apiUrl = this.service.getTtWebConfig().getApiBegin().getPrefix() + this.STOCK_SYNC;
Map<String,Object> map = new HashMap<>();
if(StringUtils.isNotBlank(product_id)){
map.put("product_id",product_id);
}else if(StringUtils.isNotBlank(out_id)){
map.put("out_id",out_id);
}
Map<String,Integer> stockStruct = new HashMap<>();
if(stock == null || stock < 0){
stockStruct.put("limit_type",2);
}else{
stockStruct.put("limit_type",1);
stockStruct.put("stock_qty",stock);
}
map.put("stock",stockStruct);
String result = this.service.execute(postExecutor, apiUrl, GSON.toJson(map));
BaseGoodsResult baseResult = GSON.fromJson(result, BaseGoodsResult.class);
if(baseResult.isSuccess()){
return true;
}else{
throw new WxErrorException(WxError.builder().errorCode(baseResult.getErrCode()).errorMsg(baseResult.getErrMsg()).build());
}
}

}

+ 22
- 0
mallinkService/src/main/java/com/iformall/douyin/web/api/goodlifesaas/impl/TtGoodLifeSaasServiceImpl.java Просмотреть файл

@@ -0,0 +1,22 @@
package com.iformall.douyin.web.api.goodlifesaas.impl;

import com.iformall.douyin.web.api.basic.TtBasicServiceImpl;
import com.iformall.douyin.web.api.goodlifesaas.TtGoodLifeSaasGoodsService;
import com.iformall.douyin.web.api.goodlifesaas.TtGoodLifeSaasService;
import lombok.extern.slf4j.Slf4j;

/**
* @author
*/
@Slf4j
public class TtGoodLifeSaasServiceImpl extends TtBasicServiceImpl implements TtGoodLifeSaasService {
private TtGoodLifeSaasGoodsService shopMatchService = new TtGoodLifeSaasGoodsServiceImpl(this);

@Override
public TtGoodLifeSaasGoodsService getGoodLifeSaasGoodsService() {
return this.shopMatchService;
}


}

mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebGetRequestExecutor.java → mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebGetRequestExecutor.java Просмотреть файл

@@ -1,4 +1,4 @@
package com.iformall.douyin.web.api;
package com.iformall.douyin.web.api.web;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebGoodsCategoryGetRequestExecutor.java → mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebGoodsCategoryGetRequestExecutor.java Просмотреть файл

@@ -1,4 +1,4 @@
package com.iformall.douyin.web.api;
package com.iformall.douyin.web.api.web;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebGoodsGetRequestExecutor.java → mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebGoodsGetRequestExecutor.java Просмотреть файл

@@ -1,4 +1,4 @@
package com.iformall.douyin.web.api;
package com.iformall.douyin.web.api.web;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebGoodsPostRequestExecutor.java → mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebGoodsPostRequestExecutor.java Просмотреть файл

@@ -1,4 +1,4 @@
package com.iformall.douyin.web.api;
package com.iformall.douyin.web.api.web;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebGoodsService.java → mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebGoodsService.java Просмотреть файл

@@ -1,4 +1,4 @@
package com.iformall.douyin.web.api;
package com.iformall.douyin.web.api.web;


import com.iformall.douyin.web.bean.*;
@@ -63,7 +63,7 @@ public interface TtWebGoodsService {
* account_id int FALSE 服务商的入驻商户ID/代运营的商户ID,不传时默认为服务商身份
*/
List<GoodsCategory> categoryGet(Integer category_id,Integer account_id) throws WxErrorException;
/**
* - 查询商品模板,创建商品时的属性列表需与该接口保持一致,否则无法识别
* category_id int TRUE 行业类目;详细见;商品类目表 https://bytedance.feishu.cn/docx/doxcnn02OUCTiKjpmzFR6ItdTye

mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebPoiPlanService.java → mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebPoiPlanService.java Просмотреть файл

@@ -1,4 +1,4 @@
package com.iformall.douyin.web.api;
package com.iformall.douyin.web.api.web;


import com.iformall.douyin.web.bean.*;

mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebPostRequestExecutor.java → mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebPostRequestExecutor.java Просмотреть файл

@@ -1,4 +1,4 @@
package com.iformall.douyin.web.api;
package com.iformall.douyin.web.api.web;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebProductService.java → mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebProductService.java Просмотреть файл

@@ -1,4 +1,4 @@
package com.iformall.douyin.web.api;
package com.iformall.douyin.web.api.web;


import com.iformall.douyin.web.bean.*;

+ 27
- 0
mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebService.java Просмотреть файл

@@ -0,0 +1,27 @@
package com.iformall.douyin.web.api.web;

import com.iformall.douyin.web.api.basic.TtBasicService;
/**
*
*/
public interface TtWebService extends TtBasicService{

/**
* 返回用户相关接口方法的实现类对象,以方便调用其各个接口.
*
* @return TtMaUserService
*/
TtWebShopMatchService getShopMatchService();

/**
* 返回用户相关接口方法的实现类对象,以方便调用其各个接口.
*
* @return TtMaUserService
*/
TtWebProductService getProductService();

TtWebGoodsService getGoodsService();
TtWebPoiPlanService getPoiPlanService();

}

mallinkService/src/main/java/com/iformall/douyin/web/api/TtWebShopMatchService.java → mallinkService/src/main/java/com/iformall/douyin/web/api/web/TtWebShopMatchService.java Просмотреть файл

@@ -1,4 +1,4 @@
package com.iformall.douyin.web.api;
package com.iformall.douyin.web.api.web;

import com.iformall.douyin.web.bean.TtSupplierMatchList;
import me.chanjar.weixin.common.error.WxErrorException;

mallinkService/src/main/java/com/iformall/douyin/web/api/impl/TtWebGoodsServiceImpl.java → mallinkService/src/main/java/com/iformall/douyin/web/api/web/impl/TtWebGoodsServiceImpl.java Просмотреть файл

@@ -1,10 +1,15 @@
package com.iformall.douyin.web.api.impl;
package com.iformall.douyin.web.api.web.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.google.gson.*;
import com.iformall.douyin.web.api.*;
import com.iformall.douyin.web.api.web.TtWebGoodsCategoryGetRequestExecutor;
import com.iformall.douyin.web.api.web.TtWebGoodsGetRequestExecutor;
import com.iformall.douyin.web.api.web.TtWebGoodsPostRequestExecutor;
import com.iformall.douyin.web.api.web.TtWebGoodsService;
import com.iformall.douyin.web.api.web.TtWebService;
import com.iformall.douyin.web.bean.*;
import lombok.AllArgsConstructor;
import me.chanjar.weixin.common.error.WxError;
@@ -49,7 +54,7 @@ public class TtWebGoodsServiceImpl implements TtWebGoodsService {
new TypeReference<List<GoodsCategory>>() {}.getType());
return list;
}
@Override
public GoodsTemplateGet templateGet(Integer category_id, Integer product_type) throws WxErrorException {
TtWebGoodsGetRequestExecutor getExecutor = new TtWebGoodsGetRequestExecutor(this.service.getRequestHttp());

mallinkService/src/main/java/com/iformall/douyin/web/api/impl/TtWebPoiPlanServiceImpl.java → mallinkService/src/main/java/com/iformall/douyin/web/api/web/impl/TtWebPoiPlanServiceImpl.java Просмотреть файл

@@ -1,10 +1,13 @@
package com.iformall.douyin.web.api.impl;
package com.iformall.douyin.web.api.web.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.iformall.douyin.web.api.*;
import com.iformall.douyin.web.api.web.TtWebPoiPlanService;
import com.iformall.douyin.web.api.web.TtWebPostRequestExecutor;
import com.iformall.douyin.web.api.web.TtWebService;
import com.iformall.douyin.web.bean.*;
import lombok.AllArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException;

mallinkService/src/main/java/com/iformall/douyin/web/api/impl/TtWebProductServiceImpl.java → mallinkService/src/main/java/com/iformall/douyin/web/api/web/impl/TtWebProductServiceImpl.java Просмотреть файл

@@ -1,11 +1,11 @@
package com.iformall.douyin.web.api.impl;
package com.iformall.douyin.web.api.web.impl;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.iformall.douyin.web.api.TtWebGetRequestExecutor;
import com.iformall.douyin.web.api.TtWebPostRequestExecutor;
import com.iformall.douyin.web.api.TtWebProductService;
import com.iformall.douyin.web.api.TtWebService;
import com.iformall.douyin.web.api.web.TtWebGetRequestExecutor;
import com.iformall.douyin.web.api.web.TtWebPostRequestExecutor;
import com.iformall.douyin.web.api.web.TtWebProductService;
import com.iformall.douyin.web.api.web.TtWebService;
import com.iformall.douyin.web.bean.*;
import lombok.AllArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException;

+ 71
- 0
mallinkService/src/main/java/com/iformall/douyin/web/api/web/impl/TtWebServiceImpl.java Просмотреть файл

@@ -0,0 +1,71 @@
package com.iformall.douyin.web.api.web.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.JsonParser;
import com.iformall.douyin.web.api.*;
import com.iformall.douyin.web.api.basic.TtBasicServiceImpl;
import com.iformall.douyin.web.api.web.TtWebGoodsService;
import com.iformall.douyin.web.api.web.TtWebPoiPlanService;
import com.iformall.douyin.web.api.web.TtWebProductService;
import com.iformall.douyin.web.api.web.TtWebService;
import com.iformall.douyin.web.api.web.TtWebShopMatchService;
import com.iformall.douyin.web.config.TtWebConfig;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.WxType;
import me.chanjar.weixin.common.bean.WxAccessToken;
import me.chanjar.weixin.common.error.WxError;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.util.DataUtils;
import me.chanjar.weixin.common.util.http.*;
import me.chanjar.weixin.common.util.http.apache.ApacheHttpClientBuilder;
import me.chanjar.weixin.common.util.http.apache.DefaultApacheHttpClientBuilder;
import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.CloseableHttpClient;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.Lock;

import static com.iformall.douyin.web.config.TtWebConstants.ErrorCode.*;


/**
* @author
*/
@Slf4j
public class TtWebServiceImpl extends TtBasicServiceImpl implements TtWebService {
private TtWebShopMatchService shopMatchService = new TtWebShopMatchServiceImpl(this);
private TtWebProductService productService = new TtWebProductServiceImpl(this);
private TtWebGoodsService goodService = new TtWebGoodsServiceImpl(this);
private TtWebPoiPlanService poiPlanService = new TtWebPoiPlanServiceImpl(this);

@Override
public TtWebShopMatchService getShopMatchService() {
return this.shopMatchService;
}

@Override
public TtWebProductService getProductService() {
return this.productService;
}

@Override
public TtWebGoodsService getGoodsService() {
return this.goodService;
}

@Override
public TtWebPoiPlanService getPoiPlanService() {
return this.poiPlanService;
}


}

mallinkService/src/main/java/com/iformall/douyin/web/api/impl/TtWebShopMatchServiceImpl.java → mallinkService/src/main/java/com/iformall/douyin/web/api/web/impl/TtWebShopMatchServiceImpl.java Просмотреть файл

@@ -1,10 +1,10 @@
package com.iformall.douyin.web.api.impl;
package com.iformall.douyin.web.api.web.impl;

import com.google.gson.JsonObject;
import com.iformall.douyin.web.api.TtWebGetRequestExecutor;
import com.iformall.douyin.web.api.TtWebPostRequestExecutor;
import com.iformall.douyin.web.api.TtWebService;
import com.iformall.douyin.web.api.TtWebShopMatchService;
import com.iformall.douyin.web.api.web.TtWebGetRequestExecutor;
import com.iformall.douyin.web.api.web.TtWebPostRequestExecutor;
import com.iformall.douyin.web.api.web.TtWebService;
import com.iformall.douyin.web.api.web.TtWebShopMatchService;
import com.iformall.douyin.web.bean.TtSupplierMatch;
import com.iformall.douyin.web.bean.TtSupplierMatchList;
import lombok.AllArgsConstructor;

+ 1
- 1
mallinkService/src/main/java/com/iformall/enums/EnumDouyinApplicationVersion.java Просмотреть файл

@@ -7,7 +7,7 @@ package com.iformall.enums;
public enum EnumDouyinApplicationVersion {

WEB(1, "网站应用"),
MINIAPP(2, "小程序应用");
GOODLIFE_SAAS(2, "本地生活SAAS应用");

public static EnumDouyinApplicationVersion getEnum(Integer code) {
for (EnumDouyinApplicationVersion value : values()) {


+ 20
- 0
mallinkService/src/main/java/com/iformall/mapper/TtGoodsCategoryNewMapper.java Просмотреть файл

@@ -0,0 +1,20 @@
package com.iformall.mapper;

import com.iformall.common.CommonMapper;
import com.iformall.domain.po.TtGoodsCategoryNew;

import java.util.List;

public interface TtGoodsCategoryNewMapper extends CommonMapper<TtGoodsCategoryNew, String> {

List<TtGoodsCategoryNew> findList(TtGoodsCategoryNew record);

List<TtGoodsCategoryNew> findMinList(TtGoodsCategoryNew record);

List<Integer> findIdAll(TtGoodsCategoryNew record);

int updDelByIds(TtGoodsCategoryNew record);

int updateFeeByIds(TtGoodsCategoryNew updgc);

}

+ 7
- 5
mallinkService/src/main/java/com/iformall/service/TtGoodsCategoryService.java Просмотреть файл

@@ -3,6 +3,7 @@ package com.iformall.service;
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.WxCoupon;
import com.iformall.douyin.web.bean.GoodsCategory;
import com.iformall.douyin.web.bean.GoodsTemplateGet;
@@ -18,16 +19,16 @@ public interface TtGoodsCategoryService {
* @return
*/
List<TtGoodsCategory> findTreeList();
List<TtGoodsCategoryNew> findTreeListForNew();

List<TtGoodsCategory> findAllTreeList();
List<TtGoodsCategoryNew> findAllTreeListForNew();

/**
* A端是否显示处理
*/
void adminIsShow(GoodsTemplateGet temp);


/**
* 处理回显
* @param temp
@@ -42,13 +43,14 @@ public interface TtGoodsCategoryService {
/**
* 同步抖音类目
*/
void syncGet();
void syncGet(boolean isNew);


List<GoodsCategory> categoryGet(Integer categoryId);
List<GoodsCategory> categoryGet(Integer categoryId,boolean isNew);

void updateFee(TtGoodsCategory record);
void updateFeeForNew(TtGoodsCategoryNew record);

int getTtServiceFee(Integer categoryId);
int getTtServiceFee(Integer categoryId,boolean isNew);

}

+ 4
- 1
mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java Просмотреть файл

@@ -7,7 +7,8 @@ import com.iformall.domain.po.TtMerchantPoi;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.MerchantPoiT;
import com.iformall.domain.vo.MerchantPoiTNew;
import com.iformall.douyin.web.api.TtWebService;
import com.iformall.douyin.web.api.goodlifesaas.TtGoodLifeSaasService;
import com.iformall.douyin.web.api.web.TtWebService;

import java.util.List;

@@ -48,6 +49,8 @@ public interface TtMerchantPoiService {
ResultData supplierQuery(TenantEntity tenantInfo,Long id);

TtWebService getTtWebService(TenantEntity tenantInfo);
TtGoodLifeSaasService getTtGoodLifeSassService(TenantEntity tenantInfo);

// ResultData findPoi(TenantEntity tenantInfo, Long couponChannelId);



+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java Просмотреть файл

@@ -12,8 +12,8 @@ import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.*;
import com.iformall.douyin.web.api.TtWebPoiPlanService;
import com.iformall.douyin.web.api.TtWebService;
import com.iformall.douyin.web.api.web.TtWebPoiPlanService;
import com.iformall.douyin.web.api.web.TtWebService;
import com.iformall.douyin.web.bean.*;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;


+ 193
- 13
mallinkService/src/main/java/com/iformall/service/impl/TtGoodsCategoryServiceImpl.java Просмотреть файл

@@ -6,9 +6,11 @@ import com.github.binarywang.wxpay.bean.bank.BankingResult;
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.WxCoupon;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.douyin.web.api.TtWebService;
import com.iformall.domain.po.base.TenantEntity;
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;
@@ -17,6 +19,7 @@ import com.iformall.enums.EnumMerchantStatus;
import com.iformall.enums.EnumYesOrNo;
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.utils.DateUtils;
@@ -44,6 +47,9 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
@Autowired
TtGoodsCategoryMapper ttGoodsCategoryMapper;
@Autowired
TtGoodsCategoryNewMapper ttGoodsCategoryNewMapper;

@Autowired
private TtMerchantPoiService ttMerchantPoiService;
@@ -71,6 +77,26 @@ 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<TtGoodsCategory> findAllTreeList() {
@@ -91,6 +117,26 @@ 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;
}


private List<TtGoodsCategory> getChild(List<TtGoodsCategory> listAll,Integer parentId){
@@ -112,6 +158,26 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {

return childList;
}
private List<TtGoodsCategoryNew> getChildForNew(List<TtGoodsCategoryNew> listAll,Integer parentId){
List<TtGoodsCategoryNew> childList = new ArrayList<TtGoodsCategoryNew>();
if(listAll == null || listAll.isEmpty()){
return childList;
}
for(TtGoodsCategoryNew category : listAll){
if(parentId.equals(category.getParentId())){
childList.add(category);
}
}
if(!childList.isEmpty()){
listAll.removeAll(childList);
for (TtGoodsCategoryNew category:childList) {
category.setChild(getChildForNew(listAll,category.getId()));
}
}

return childList;
}

private List<String> getProductAdminIsNotShowKey(){
List<String> keyList = new ArrayList<>();
@@ -515,21 +581,36 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
// @Async
@Transactional(rollbackFor = {Exception.class})
@Override
public void syncGet() {
TtWebService ttWebService = ttMerchantPoiService.getTtWebService(null);
handSyncCategory(ttWebService,0,new Date());
public void syncGet(boolean isNew) {
if(!isNew) {
TtWebService ttWebService = ttMerchantPoiService.getTtWebService(null);
handSyncCategory(ttWebService,0,new Date());
}else {
TenantEntity defaultEntity = new TenantEntity();
defaultEntity.setTenantId("789");
TtWebService ttWebService = ttMerchantPoiService.getTtMiniAppService(defaultEntity);
handSyncCategoryForNew(ttWebService,0,new Date());
}
}

@Override
public List<GoodsCategory> categoryGet(Integer categoryId) {
public List<GoodsCategory> categoryGet(Integer categoryId,boolean isNew) {
String key = "goods_category:"+categoryId;
List<GoodsCategory> cacheListObject = RedisCacheUtils.getCacheListObject(categoryRedisTemplate, key, GoodsCategory.class);
if(cacheListObject != null && cacheListObject.size() > 0){
return cacheListObject;
}
try {
TtWebService ttWebService = ttMerchantPoiService.getTtWebService(null);
List<GoodsCategory> goodsCategories = ttWebService.getGoodsService().categoryGet(categoryId, null);
List<GoodsCategory> goodsCategories = null;
if (isNew) {
TenantEntity defaultEntity = new TenantEntity();
defaultEntity.setTenantId("789");
TtWebService ttWebService = ttMerchantPoiService.getTtMiniAppService(defaultEntity);
goodsCategories = ttWebService.getGoodLifeSaasGoodsService().categoryGet(categoryId, null);
}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);
}
@@ -551,14 +632,34 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
updateFeeByIds(ids,record.getServiceFee(),record.getSoftwareFee(),new Date());
}
}

@Transactional(rollbackFor = {Exception.class})
@Override
public int getTtServiceFee(Integer categoryId) {
TtGoodsCategory goodsCategory = ttGoodsCategoryMapper.selectById(categoryId);
if(goodsCategory != null && goodsCategory.getServiceFee() != null){
return goodsCategory.getServiceFee();
public void updateFeeForNew(TtGoodsCategoryNew record) {
List<Integer> ids = new ArrayList<>();
if(record.getId() != null){
ids.add(record.getId());
}
return 0;
if(!ids.isEmpty()){
updateFeeByIdsForNew(ids,record.getServiceFee(),record.getSoftwareFee(),new Date());
}
}

@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;
}
}

/**
@@ -610,6 +711,50 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
}

}
private void handSyncCategoryForNew(TtWebService ttWebService,Integer category_id,Date now){
try {
List<GoodsCategory> goodsCategories = ttWebService.getGoodLifeSaasGoodsService().categoryGet(category_id, null);
if(goodsCategories != null){
TtGoodsCategoryNew record = new TtGoodsCategoryNew();
record.setParentId(category_id);
List<Integer> listAll = ttGoodsCategoryNewMapper.findIdAll(record);
for (GoodsCategory gc:goodsCategories) {

TtGoodsCategoryNew updgc = new TtGoodsCategoryNew();
updgc.setId(gc.getCategoryId());
updgc.setLevel(gc.getLevel());
updgc.setName(gc.getName());
updgc.setParentId(gc.getParentId());
updgc.setEnable(gc.getEnable()?EnumYesOrNo.YES.getCode():EnumYesOrNo.NO.getCode());
updgc.setIsLeaf(gc.getEnable()?EnumYesOrNo.YES.getCode():EnumYesOrNo.NO.getCode());
updgc.setIsDel(EnumYesOrNo.NO.getCode());
updgc.setUpdateDate(now);
if(listAll.contains(gc.getCategoryId())){
ttGoodsCategoryNewMapper.updateById(updgc);
listAll.remove(gc.getCategoryId());
}else{
updgc.setCreateDate(now);
ttGoodsCategoryNewMapper.insert(updgc);
}
if(!gc.getIsLeaf()){
handSyncCategoryForNew(ttWebService,gc.getCategoryId(),now);
}
}
updateDelByIdsForNew(listAll,now);
}
} catch (WxErrorException e) {
e.printStackTrace();
logger.error("同步商品类目失败"+e.getMessage());
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR);
}
catch (Exception e) {
e.printStackTrace();
logger.error("同步商品类目失败"+e.getMessage());
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR);
}

}

/**
* 循环删除类目
@@ -632,6 +777,23 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
updateDelByIds(idAll,now);
}
}
private void updateDelByIdsForNew(List<Integer> ids,Date now){
if(ids == null || ids.size() <= 0){
return;
}
TtGoodsCategoryNew delgc = new TtGoodsCategoryNew();
delgc.setCategoryIds(ids);
delgc.setIsDel(EnumYesOrNo.YES.getCode());
delgc.setUpdateDate(now);
int i = ttGoodsCategoryNewMapper.updDelByIds(delgc);
if(i > 0){
TtGoodsCategoryNew gcq = new TtGoodsCategoryNew();
gcq.setParentIds(ids);
List<Integer> idAll = ttGoodsCategoryNewMapper.findIdAll(gcq);
updateDelByIdsForNew(idAll,now);
}
}

/**
* 循环修改费率
@@ -653,5 +815,23 @@ public class TtGoodsCategoryServiceImpl implements TtGoodsCategoryService {
updateFeeByIds(idAll,serviceFee,softwareFee,now);
}
}
private void updateFeeByIdsForNew(List<Integer> ids,Integer serviceFee,Integer softwareFee,Date now){
if(ids == null || ids.size() <= 0){
return;
}
TtGoodsCategoryNew updgc = new TtGoodsCategoryNew();
updgc.setCategoryIds(ids);
updgc.setServiceFee(serviceFee);
updgc.setSoftwareFee(softwareFee);
updgc.setUpdateDate(now);
int i = ttGoodsCategoryNewMapper.updateFeeByIds(updgc);
if(i > 0){
TtGoodsCategoryNew gcq = new TtGoodsCategoryNew();
gcq.setParentIds(ids);
List<Integer> idAll = ttGoodsCategoryNewMapper.findIdAll(gcq);
updateFeeByIdsForNew(idAll,serviceFee,softwareFee,now);
}
}

}

+ 26
- 3
mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java Просмотреть файл

@@ -13,7 +13,9 @@ import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.MerchantPoiT;
import com.iformall.domain.vo.MerchantPoiTNew;
import com.iformall.domain.vo.WxCardPriceTemplate;
import com.iformall.douyin.web.api.TtWebService;
import com.iformall.douyin.web.api.basic.TtBasicService;
import com.iformall.douyin.web.api.goodlifesaas.TtGoodLifeSaasService;
import com.iformall.douyin.web.api.web.TtWebService;
import com.iformall.douyin.web.bean.*;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
@@ -515,6 +517,27 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
}
return ttWebService;
}
@Override
public TtGoodLifeSaasService getTtGoodLifeSassService(TenantEntity tenantInfo){
WxAppinfo appinfoQ = new WxAppinfo();
appinfoQ.updateTenantInfo(tenantInfo);
appinfoQ.setPlat(EnumAppPlat.TOUTIAO.getCode());
appinfoQ.setType(EnumAppType.C.getCode());
WxAppinfo appinfo = wxAppinfoMapper.selectOne(new QueryWrapper<>(appinfoQ));
TtGoodLifeSaasService ttWebService = maUtil.getTtGoodLifeSassService(appinfo);
if (StringUtils.isBlank(appinfo.getAccessToken())) {
// 如果没有accessToken,主动获取保存到数据库中,下次访问可以拿来使用
updateWebAccessToken(appinfo, ttWebService);
} else {
// 检查token是否已过期, 1小时就重新获取
Date curDate = new Date();
if (curDate.getTime() > appinfo.getLastTokenTime().getTime() + Constant.H_EXPIRE) {
updateWebAccessToken(appinfo, ttWebService);
}
}
return ttWebService;
}

@Override
public void exportTemplate(HttpServletRequest request, HttpServletResponse response, boolean isNew) {
@@ -665,9 +688,9 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
//
// }

private void updateWebAccessToken(WxAppinfo appinfo, TtWebService ttWebService) {
private void updateWebAccessToken(WxAppinfo appinfo, TtBasicService ttbasicService) {
try {
String accessToken = ttWebService.getAccessToken(true);
String accessToken = ttbasicService.getAccessToken(true);
WxAppinfo updateApp = new WxAppinfo();
updateApp.setAppId(appinfo.getAppId());
updateApp.setAccessToken(accessToken);


+ 48
- 2
mallinkService/src/main/java/com/iformall/utils/MaUtil.java Просмотреть файл

@@ -19,8 +19,10 @@ import java.util.concurrent.ConcurrentHashMap;
import com.iformall.douyin.pay.TtPayService;
import com.iformall.douyin.pay.impl.TtPayServiceImpl;
import com.iformall.douyin.payv2.config.TtPayConfig;
import com.iformall.douyin.web.api.TtWebService;
import com.iformall.douyin.web.api.impl.TtWebServiceImpl;
import com.iformall.douyin.web.api.goodlifesaas.TtGoodLifeSaasService;
import com.iformall.douyin.web.api.goodlifesaas.impl.TtGoodLifeSaasServiceImpl;
import com.iformall.douyin.web.api.web.TtWebService;
import com.iformall.douyin.web.api.web.impl.TtWebServiceImpl;
import com.iformall.douyin.web.config.TtWebDefaultConfigImpl;
import com.iformall.douyin.web.enums.TtWebApiBeginEnum;
import com.iformall.mapper.WxAppinfoMapper;
@@ -56,6 +58,9 @@ public class MaUtil {

private static Map<String,TtWebService> webServiceMap = new ConcurrentHashMap<String,TtWebService>();
private static Map<String,String> webServiceKeyMap = new ConcurrentHashMap<String,String>();
private static Map<String,TtGoodLifeSaasService> goodLifeSaasServiceMap = new ConcurrentHashMap<String,TtGoodLifeSaasService>();
private static Map<String,String> goodLifeSaasServiceKeyMap = new ConcurrentHashMap<String,String>();
public WxMaService getWeappService(WxAppinfo appinfo) {
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
@@ -290,4 +295,45 @@ public class MaUtil {
}
return service;
}
public TtGoodLifeSaasService getTtGoodLifeSassService(WxAppinfo appinfo) {
TtWebDefaultConfigImpl config = new TtWebDefaultConfigImpl();
config.setAppid(appinfo.getAppId());
config.setSecret(appinfo.getSecret());
config.setToken(appinfo.getToken());
config.setAesKey(appinfo.getAesKey());
config.setMsgDataFormat(appinfo.getMsgDataFormat());
if (StringUtils.isNotBlank(appinfo.getAccessToken())) {
config.setAccessToken(appinfo.getAccessToken());
config.setExpiresTime(appinfo.getLastTokenTime().getTime()+appinfo.getExpiresIn()*1000);
}
config.setApacheHttpClientBuilder(FmHttpClientBuilder.get());

//默认抖音
config.setApiBegin(TtWebApiBeginEnum.DY);

String key = appinfo.getAppId()+String.valueOf(config.getExpiresTime());
TtGoodLifeSaasService service = goodLifeSaasServiceMap.get(key);
if ( null == service ) {
synchronized("getTtGoodLifeSaasServiceBlock"+appinfo.getAppId()) {
service = goodLifeSaasServiceMap.get(key);
if (null == service) {
//删除掉之前的
String appServiceKey = goodLifeSaasServiceKeyMap.get(appinfo.getAppId());
if (!StringUtils.isBlank(appServiceKey)) {
if (goodLifeSaasServiceMap.containsKey(appServiceKey)) {
goodLifeSaasServiceMap.remove(appServiceKey);
}
goodLifeSaasServiceKeyMap.remove(appinfo.getAppId());
}

service = new TtGoodLifeSaasServiceImpl();
service.setTtWebConfig(config);
goodLifeSaasServiceMap.put(key, service);
goodLifeSaasServiceKeyMap.put(appinfo.getAppId(),key);
}
}
}
return service;
}
}

+ 100
- 0
mallinkService/src/main/resources/mapper/TtGoodsCategoryNewMapper.xml Просмотреть файл

@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.iformall.mapper.TtGoodsCategoryNewMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.TtGoodsCategoryNew">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="level" jdbcType="INTEGER" property="level" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="parent_id" jdbcType="INTEGER" property="parentId" />
<result column="enable" jdbcType="INTEGER" property="enable" />
<result column="is_leaf" jdbcType="INTEGER" property="isLeaf" />
<result column="service_fee" jdbcType="INTEGER" property="serviceFee" />
<result column="software_fee" jdbcType="INTEGER" property="softwareFee" />
</resultMap>
<sql id="allColumns">
`id`,`level`,`name`,`parent_id`,`enable`,`is_leaf`,`service_fee`,`software_fee`
</sql>

<sql id="dynamicWhereConditions">
where 1=1
<if test=" null != id ">
and `id` = #{id}
</if>

<if test=" null != isDel ">
and `is_del` = #{isDel}
</if>

<if test=" null != level ">
and `level` = #{level}
</if>
<if test=" null != name ">
and `name` like concat('%', #{name},'%')
</if>

<if test=" null != parentId ">
and `parent_id` = #{parentId}
</if>

<if test=" null != enable ">
and `enable` = #{enable}
</if>

<if test=" null != isLeaf ">
and `is_leaf` = #{isLeaf}
</if>

<if test=" null != parentIds ">
and parent_id in
<foreach collection="parentIds" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>

<if test=" null != categoryIds ">
and id in
<foreach collection="categoryIds" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>
<if test=" null != sortColumns"> order by ${sortColumns} </if>
</sql>
<select id="findList" parameterType="com.iformall.domain.po.TtGoodsCategoryNew" resultMap="BaseResultMap">
select <include refid="allColumns" /> from tt_goods_category_new
<include refid="dynamicWhereConditions" />
</select>

<select id="findMinList" parameterType="com.iformall.domain.po.TtGoodsCategoryNew" resultMap="BaseResultMap">
select `id`,`level`,`name`,`parent_id`,`enable`,`is_leaf`
from tt_goods_category_new
<include refid="dynamicWhereConditions" />
</select>

<select id="findIdAll" parameterType="com.iformall.domain.po.TtGoodsCategoryNew" resultType="Integer">
select id from tt_goods_category_new
<include refid="dynamicWhereConditions" />
</select>

<update id="updDelByIds" parameterType="com.iformall.domain.po.TtGoodsCategoryNew">
update tt_goods_category_new set is_del = #{isDel}, update_date = #{updateDate}
where id in
<foreach collection="categoryIds" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</update>

<update id="updateFeeByIds" parameterType="com.iformall.domain.po.TtGoodsCategoryNew">
update tt_goods_category_new set update_date = #{updateDate}
<if test=" null != serviceFee ">,`service_fee` = #{serviceFee}</if>
<if test=" null != softwareFee ">,`software_fee` = #{softwareFee}</if>
where id in
<foreach collection="categoryIds" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</update>

</mapper>

Загрузка…
Отмена
Сохранить