Просмотр исходного кода

//update test

release_toaliyun_real
xhxu 4 лет назад
Родитель
Сommit
626ec89bfa
4 измененных файлов: 99 добавлений и 20 удалений
  1. +44
    -4
      mallinkAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java
  2. +1
    -1
      mallinkService/src/main/java/com/iformall/douyin/web/api/impl/TtWebServiceImpl.java
  3. +4
    -1
      mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java
  4. +50
    -14
      mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java

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

@@ -7,7 +7,8 @@ import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.enums.EnumSupplierMathStatus;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.*;
import com.iformall.service.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -17,8 +18,11 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* @author gongbiao
@@ -31,6 +35,12 @@ public class TtMerchantPoiController extends BaseController {
@Autowired
private TtMerchantPoiService ttMerchantPoiService;

@Autowired
private WxCouponChannelService wxCouponChannelService;

@Autowired
private WxCouponService wxCouponService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@@ -116,16 +126,46 @@ public class TtMerchantPoiController extends BaseController {
return ttMerchantPoiService.merchantSync(getTenantInfo(),id);
}

@ApiOperation("获取商品可用的POI")
@GetMapping("/findPoi")
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)
@SystemControllerLog(description = "查询")
public ResultData findPoi(Long couponChannelId) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::findPoi");
if(couponChannelId == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return ttMerchantPoiService.findPoi(getTenantInfo(),couponChannelId);
}

@ApiOperation("商品同步")
@PostMapping("spuSync")
@SystemControllerLog(description = "商品同步")
public ResultData spuSync(@RequestBody Map<String, Long> param) {
public ResultData spuSync(@RequestBody Map<String, String> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuSync");
Long couponChannelId = param.get("couponChannelId");
String couponChannelIdStr = param.get("couponChannelId");
Long couponChannelId = null;
try{
couponChannelId = Long.parseLong(couponChannelIdStr);
}catch(Exception e){
return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR);
}
if(couponChannelId == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return ttMerchantPoiService.spuSync(getTenantInfo(),couponChannelId);
String merchantIdStr = param.get("merchantIds");
List<Long> merchantIds = new ArrayList<>();
try{
List<String> strings = Arrays.asList(merchantIdStr.split(","));
merchantIds = strings.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
}catch(Exception e){
return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR);
}
if(merchantIds == null || merchantIds.size() == 0){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}

return ttMerchantPoiService.spuSync(getTenantInfo(),couponChannelId,merchantIds);
}

@ApiOperation("商品同步查询")


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

@@ -115,7 +115,7 @@ public class TtWebServiceImpl implements TtWebService, RequestHttp<CloseableHttp
+ "?client_key="+this.getTtWebConfig().getAppid()
+ "&client_secret="+this.getTtWebConfig().getSecret()
+ "&grant_type=client_credential";
log.info("apiUrl-----------"+apiUrl);
log.info("apiUrl-----------"+apiUrl);
HttpPost httpPost = new HttpPost(apiUrl);
if (this.getRequestHttpProxy() != null) {
RequestConfig config = RequestConfig.custom().setProxy(this.getRequestHttpProxy()).build();


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

@@ -43,11 +43,14 @@ public interface TtMerchantPoiService {

TtWebService getTtWebService(TenantEntity tenantInfo);

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

ResultData spuSync(TenantEntity tenantInfo, Long couponChannelId,List<Long> merchantIds);

ResultData spuGet(TenantEntity tenantInfo, Long couponChannelId);

ResultData spuStatusSync(TenantEntity tenantInfo, Long couponChannelId);

ResultData spuStockSync(TenantEntity tenantInfo, Long couponChannelId);

}

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

@@ -271,7 +271,7 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
TtMerchantPoi updPoi = new TtMerchantPoi();
updPoi.setId(id);
updPoi.setSupplierId(supplierId);
updPoi.setLastSyncStatus(EnumSupplierSyncStatus.sync_wait.getCode());
updPoi.setLastSyncStatus(EnumSupplierSyncStatus.sync_success.getCode());
updPoi.setUpdateDate(new Date());
ttMerchantPoiMapper.updateById(merchantPoi);
return new ResultData();
@@ -475,6 +475,45 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
return ttWebService;
}

@Override
public ResultData findPoi(TenantEntity tenantInfo, Long couponChannelId) {
WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId());
if(couponChannel == null || !EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到上架卷数据");
}
if(!EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode().equals(couponChannel.getTargetAd())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"只有投放在列表的卷才能进行同步poi");
}
WxCoupon coupon = wxCouponMapper.selectById(couponChannel.getCouponId(), tenantInfo.getTenantId());
if(coupon == null || !EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode().equals(coupon.getStatus())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到可投放的卷");
}
if(!EnumCouponType.getSpuSyncType().contains(coupon.getType())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"卷类型不支持同步poi");
}
List<TtMerchantPoi> list = new ArrayList<>();
// TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong(tenantInfo.getTenantId()));
TtMerchantPoi merchantPoi = ttMerchantPoiMapper.selectById(Long.parseLong("1038"));
list.add(merchantPoi);

List<Long> merchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), tenantInfo.getTenantId());
if(merchantIds == null || merchantIds.size() == 0 ){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到门店");
}

TtMerchantPoi poi = new TtMerchantPoi();
poi.updateTenantInfo(tenantInfo);
poi.setIds(merchantIds);
poi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode());
poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode());
List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi);
if(poiList != null && poiList.size() > 0){
list.addAll(poiList);
}

return new ResultData(list);
}

private void updateWebAccessToken(WxAppinfo appinfo, TtWebService ttWebService) {
try {
String accessToken = ttWebService.getAccessToken(true);
@@ -496,7 +535,7 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
}

@Override
public ResultData spuSync(TenantEntity tenantInfo, Long couponChannelId) {
public ResultData spuSync(TenantEntity tenantInfo, Long couponChannelId, List<Long> merchantIds) {
WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId());
if(couponChannel == null || !EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到上架卷数据");
@@ -511,19 +550,16 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
if(!EnumCouponType.getSpuSyncType().contains(coupon.getType())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"卷类型不支持同步poi");
}
List<Long> merchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), tenantInfo.getTenantId());
if(merchantIds == null || merchantIds.size() == 0 ){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到门店");
}
TtMerchantPoi poiQ = new TtMerchantPoi();
poiQ.updateTenantInfo(tenantInfo);
poiQ.setIds(merchantIds);
poiQ.setMatchStatus(EnumSupplierMathStatus.match_success.getCode());
poiQ.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode());
List<TtMerchantPoi> list = ttMerchantPoiMapper.findList(poiQ);
if(list == null || list.size() != merchantIds.size()){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"部分商品门店未同步,请先同步门店");
TtMerchantPoi poi = new TtMerchantPoi();
poi.updateTenantInfo(tenantInfo);
poi.setIds(merchantIds);
poi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode());
poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode());
List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi);
if(merchantIds.size() != poiList.size()){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到poi或poi不匹配");
}

String spuId = spuSync(coupon,couponChannel,merchantIds);
if(StringUtils.isBlank(spuId)){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"同步失败");


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