Browse Source

//tt product

release_toaliyun_real
xhxu 4 years ago
parent
commit
3008f6d84a
12 changed files with 568 additions and 605 deletions
  1. +69
    -69
      mallinkAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java
  2. +19
    -19
      mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java
  3. +16
    -16
      mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantPoiSchedule.java
  4. +2
    -2
      mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideProductPushMsg.java
  5. +3
    -11
      mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java
  6. +5
    -5
      mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java
  7. +1
    -1
      mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java
  8. +411
    -411
      mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java
  9. +8
    -28
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java
  10. +19
    -24
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java
  11. +9
    -2
      mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideProductPushMsgServiceImpl.java
  12. +6
    -17
      mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml

+ 69
- 69
mallinkAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java View File

@@ -137,80 +137,80 @@ public class TtMerchantPoiController extends BaseController {
return ttMerchantPoiService.supplierQuery(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, String> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuSync");
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);
}
// String merchantIdStr = param.get("merchantIds");
// List<Long> merchantIds = new ArrayList<>();
// @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, String> param) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuSync");
// String couponChannelIdStr = param.get("couponChannelId");
// Long couponChannelId = null;
// try{
// List<String> strings = Arrays.asList(merchantIdStr.split(","));
// merchantIds = strings.stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
// couponChannelId = Long.parseLong(couponChannelIdStr);
// }catch(Exception e){
// return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR);
// }
// if(merchantIds == null || merchantIds.size() == 0){
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
return ttMerchantPoiService.spuSync(getTenantInfo(),couponChannelId,null);
}

@ApiOperation("商品同步查询")
@GetMapping("spuGet")
@SystemControllerLog(description = "商品同步查询")
public ResultData spuGet(Long couponChannelId) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuGet");
if(couponChannelId == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return ttMerchantPoiService.spuGet(getTenantInfo(),couponChannelId);
}

@ApiOperation("商品状态同步")
@PostMapping("spuStatusSync")
@SystemControllerLog(description = "商品状态同步")
public ResultData spuStatusSync(@RequestBody Map<String, Long> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStatusSync");
Long couponChannelId = param.get("couponChannelId");
if(couponChannelId == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return ttMerchantPoiService.spuStatusSync(getTenantInfo(),couponChannelId);
}

@ApiOperation("商品库存同步")
@PostMapping("spuStockSync")
@SystemControllerLog(description = "商品库存同步")
public ResultData spuStockSync(@RequestBody Map<String, Long> param) {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStockSync");
Long couponChannelId = param.get("couponChannelId");
if(couponChannelId == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return ttMerchantPoiService.spuStockSync(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,null);
// }

// @ApiOperation("商品同步查询")
// @GetMapping("spuGet")
// @SystemControllerLog(description = "商品同步查询")
// public ResultData spuGet(Long couponChannelId) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuGet");
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// return ttMerchantPoiService.spuGet(getTenantInfo(),couponChannelId);
// }
//
// @ApiOperation("商品状态同步")
// @PostMapping("spuStatusSync")
// @SystemControllerLog(description = "商品状态同步")
// public ResultData spuStatusSync(@RequestBody Map<String, Long> param) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStatusSync");
// Long couponChannelId = param.get("couponChannelId");
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// return ttMerchantPoiService.spuStatusSync(getTenantInfo(),couponChannelId);
// }
//
// @ApiOperation("商品库存同步")
// @PostMapping("spuStockSync")
// @SystemControllerLog(description = "商品库存同步")
// public ResultData spuStockSync(@RequestBody Map<String, Long> param) {
// logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::spuStockSync");
// Long couponChannelId = param.get("couponChannelId");
// if(couponChannelId == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
// }
// return ttMerchantPoiService.spuStockSync(getTenantInfo(),couponChannelId);
// }

}

+ 19
- 19
mallinkSchedule/src/main/java/com/iformall/schedule/CouponExpiringSchedule.java View File

@@ -68,13 +68,13 @@ public class CouponExpiringSchedule {

wxCouponSendMapper.offExpiriedCouponSendByCouponStatus(mall.getTenantId());

List<Long> ids = wxCouponChannelMapper.getExpiriedCouponChannelIdsByCouponStatus(mall.getTenantId());
List<Long> couponIds = wxCouponChannelMapper.getExpiriedCouponIdsByCouponStatus(mall.getTenantId());
wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus(mall.getTenantId());
//同步poi
if(ids != null && ids.size() > 0){
for (Long id: ids) {
if(couponIds != null && couponIds.size() > 0){
for (Long couponId: couponIds) {
try{
wxCouponChannelService.spuStatusSync(mall,id);
wxCouponChannelService.spuStatusSyncByCoupon(mall,couponId);
}catch(Exception e){
logger.error("send spuStatusSync error: " + e.getMessage());
}
@@ -107,34 +107,34 @@ public class CouponExpiringSchedule {
List<WxMall> malls = getMalls();
for (WxMall mall : malls) {
try {
List<Long> ids = new ArrayList<>();
List<Long> couponIds = new ArrayList<>();

List<Long> id1s = wxCouponChannelMapper.getExpiriedCouponChannelIdsByEndTime(mall.getTenantId());
if(id1s != null && id1s.size() > 0){
ids.removeAll(id1s);
ids.addAll(id1s);
List<Long> couponId1s = wxCouponChannelMapper.getExpiriedCouponIdsByEndTime(mall.getTenantId());
if(couponId1s != null && couponId1s.size() > 0){
couponIds.removeAll(couponId1s);
couponIds.addAll(couponId1s);
}
wxCouponChannelMapper.offExpiriedCouponChannelByEndTime(mall.getTenantId());

List<Long> id2s = wxCouponChannelMapper.getExpiriedCouponChannelIdsByValidDate(mall.getTenantId());
if(id2s != null && id2s.size() > 0){
ids.removeAll(id2s);
ids.addAll(id2s);
List<Long> couponId2s = wxCouponChannelMapper.getExpiriedCouponIdsByValidDate(mall.getTenantId());
if(couponId2s != null && couponId2s.size() > 0){
couponIds.removeAll(couponId2s);
couponIds.addAll(couponId2s);
}
wxCouponChannelMapper.offExpiriedCouponChannelByValidDate(mall.getTenantId());

List<Long> id3s = wxCouponChannelMapper.getExpiriedCouponChannelIdsByCouponStatus(mall.getTenantId());
List<Long> id3s = wxCouponChannelMapper.getExpiriedCouponIdsByCouponStatus(mall.getTenantId());
if(id3s != null && id3s.size() > 0){
ids.removeAll(id3s);
ids.addAll(id3s);
couponIds.removeAll(id3s);
couponIds.addAll(id3s);
}
wxCouponChannelMapper.offExpiriedCouponChannelByCouponStatus(mall.getTenantId());

//同步poi
if(ids != null && ids.size() > 0){
for (Long id: ids) {
if(couponIds != null && couponIds.size() > 0){
for (Long couponId: couponIds) {
try{
wxCouponChannelService.spuStatusSync(mall,id);
wxCouponChannelService.spuStatusSyncByCoupon(mall,couponId);
}catch(Exception e){
logger.error("send spuStatusSync error: " + e.getMessage());
}


+ 16
- 16
mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantPoiSchedule.java View File

@@ -59,21 +59,21 @@ public class TtMerchantPoiSchedule {
// }
// }

@Async
@Scheduled(cron = "0 0 */1 * * *?") // 每小时检查一次
public void supplierQueryTaskSchedule() {
TtCouponChannelPoi ttCouponChannelPoi = new TtCouponChannelPoi();
ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode());
List<TtCouponChannelPoi> list = ttCouponChannelPoiMapper.findList(ttCouponChannelPoi);
if(list != null && list.size() > 0){
for (TtCouponChannelPoi poi:list) {
try{
ttMerchantPoiService.spuGet(poi,poi.getId());
}catch(Exception e){
logger.error("查询商品同步任务失败");
}
}
}
}
// @Async
// @Scheduled(cron = "0 0 */1 * * *?") // 每小时检查一次
// public void supplierQueryTaskSchedule() {
// TtCouponChannelPoi ttCouponChannelPoi = new TtCouponChannelPoi();
// ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode());
// List<TtCouponChannelPoi> list = ttCouponChannelPoiMapper.findList(ttCouponChannelPoi);
// if(list != null && list.size() > 0){
// for (TtCouponChannelPoi poi:list) {
// try{
// ttMerchantPoiService.spuGet(poi,poi.getId());
// }catch(Exception e){
// logger.error("查询商品同步任务失败");
// }
// }
// }
// }

}

+ 2
- 2
mallinkService/src/main/java/com/iformall/domain/po/msg/FmInsideProductPushMsg.java View File

@@ -10,8 +10,8 @@ import lombok.ToString;
@EqualsAndHashCode(callSuper = true)
public class FmInsideProductPushMsg extends BaseMsg{

@io.swagger.annotations.ApiModelProperty(value = "卷Id", name = "couponChannelId")
private Long couponChannelId;
@io.swagger.annotations.ApiModelProperty(value = "卷Id", name = "couponId")
private Long couponId;

@io.swagger.annotations.ApiModelProperty(value = "同步类型", name = "syncType")
private EnumPushType syncType;


+ 3
- 11
mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java View File

@@ -26,13 +26,13 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str

int updateEndTimeByCouponId(WxCouponChannel wxCouponChannel);

List<Long> getExpiriedCouponChannelIdsByEndTime(@Param("tenantId")String tenantId);//同步poi状态
List<Long> getExpiriedCouponIdsByEndTime(@Param("tenantId")String tenantId);//同步poi状态
void offExpiriedCouponChannelByEndTime(@Param("tenantId")String tenantId);

List<Long> getExpiriedCouponChannelIdsByValidDate(@Param("tenantId")String tenantId);//同步poi状态
List<Long> getExpiriedCouponIdsByValidDate(@Param("tenantId")String tenantId);//同步poi状态
void offExpiriedCouponChannelByValidDate(@Param("tenantId")String tenantId);

List<Long> getExpiriedCouponChannelIdsByCouponStatus(@Param("tenantId")String tenantId);//同步poi状态
List<Long> getExpiriedCouponIdsByCouponStatus(@Param("tenantId")String tenantId);//同步poi状态
void offExpiriedCouponChannelByCouponStatus(@Param("tenantId")String tenantId);

void offExpiriedCouponChannel2ByEndTime(@Param("tenantId")String tenantId);
@@ -51,14 +51,6 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str
List<WxCouponChannel> newfindCList(WxCouponChannel wxCouponChannel);
List<WxCouponChannel> liveHomeList(WxCouponChannel wxCouponChannel);

/**
* 查询已同步的上架卷的Id
* @param tenantId
* @param id
* @return
*/
List<Long> getPoiProductIdList(@Param("tenantId")String tenantId, @Param("couponId")Long couponId);
Integer reduceChannelStock(@Param("id")Long id,@Param("tenantId")String tenantId,@Param("number")Integer number);



+ 5
- 5
mallinkService/src/main/java/com/iformall/service/TtMerchantPoiService.java View File

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

TtWebService getTtWebService(TenantEntity tenantInfo);

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

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

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

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

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

}

+ 1
- 1
mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java View File

@@ -46,7 +46,7 @@ public interface WxCouponChannelService {
*/
ResultData saveOrUpdate(WxCouponChannel record);

void spuStatusSync(TenantEntity tenantEntity,Long id);
void spuStatusSyncByCoupon(TenantEntity tenantEntity,Long couponId);

/**
* 创建二维码


+ 411
- 411
mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java View File

@@ -505,45 +505,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 && merchantIds.size() == poiList.size()){
return new ResultData(poiList);
}else{
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该商品店铺与poi门店不匹配");
}
}
// @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 && merchantIds.size() == poiList.size()){
// return new ResultData(poiList);
// }else{
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该商品店铺与poi门店不匹配");
// }
//
// }

private void updateWebAccessToken(WxAppinfo appinfo, TtWebService ttWebService) {
try {
@@ -565,386 +565,386 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
}
}

@Override
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(),"未找到上架卷数据");
}
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<Long> couponMerchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), tenantInfo.getTenantId());
if(couponMerchantIds == null || couponMerchantIds.size() == 0 ){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到门店");
}
TtMerchantPoi poi = new TtMerchantPoi();
poi.updateTenantInfo(tenantInfo);
poi.setIds(couponMerchantIds);
poi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode());
poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode());
List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi);
if(poiList == null || poiList.isEmpty()){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到匹配的poi");
}
// List<Long> collect = poiList.stream().map(p -> p.getId()).collect(Collectors.toList());
String spuId = spuSync(coupon,couponChannel,couponMerchantIds);
if(StringUtils.isBlank(spuId)){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"同步失败");
}
WxCouponChannel ccUpd = new WxCouponChannel();
ccUpd.setId(couponChannel.getId());
ccUpd.updateTenantInfo(couponChannel);
ccUpd.setTtSpuId(spuId);
ccUpd.setUpdateDate(new Date());
wxCouponChannelMapper.updateById(ccUpd);
syncCouponChannelPoi(ccUpd);
return new ResultData();
}
private void syncCouponChannelPoi(WxCouponChannel ccUpd){
TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(ccUpd.getTenantId(),ccUpd.getId());
if(ttCouponChannelPoi != null){
ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode());
ttCouponChannelPoi.setLastStatusDesc("");
ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate());
ttCouponChannelPoiMapper.updateById(ttCouponChannelPoi);
}else{
ttCouponChannelPoi = new TtCouponChannelPoi();
ttCouponChannelPoi.setId(ccUpd.getId());
ttCouponChannelPoi.updateTenantInfo(ccUpd);
ttCouponChannelPoi.setSpuId(ccUpd.getTtSpuId());
ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode());
ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode());
ttCouponChannelPoi.setCreateDate(ccUpd.getUpdateDate());
ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate());
ttCouponChannelPoiMapper.insert(ttCouponChannelPoi);
}
}
private String spuSync(WxCoupon coupon,WxCouponChannel couponChannel, List<Long> merchantIds){
TtSpuSync spuSync = new TtSpuSync();
spuSync.setEntryInfo(getEntryInfo(couponChannel));
// spuSync.setFrontCategoryTag();//前台品类标签
// spuSync.setRecommendWord();//推荐语,5~20个字
// spuSync.setSortWeight();//排序权重,按降序排列
List<String> collect = merchantIds.stream().map(merchantId -> merchantId.toString()).collect(Collectors.toList());
spuSync.setSupplierExtIdList(collect);
spuSync.setPrice(coupon.getSalePrice());
spuSync.setSpuExtId(couponChannel.getId().toString());
spuSync.setImageList(JSONArray.parseArray(coupon.getCoverPicture(),String.class));
// spuSync.setMpSettletype();//小程序结算类型 1-包销 2-代销
spuSync.setOriginPrice(coupon.getPrice());
// spuSync.setTakeRate();//商品的抽佣率,万分数
spuSync.setAttribute(getAttribute(coupon,couponChannel));
// spuSync.setHighlights(getHighlights(coupon));
spuSync.setName(coupon.getTitle());
// spuSync.setOrderDependsOnDate(false);//下单是否依赖日期
spuSync.setSpuType(91);//spu类型号,1-日历房,30-酒店民宿预售券,90-门票,91-团购券
if(EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){
spuSync.setStatus(1);
}else{
spuSync.setStatus(2);
}
spuSync.setStock(coupon.getRemainInventory());
String spuId = null;
try {
spuId = getTtWebService(coupon).getProductService().spuSync(spuSync);
} catch (WxErrorException e) {
logger.error("发起商品同步error"+e.getMessage());
throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage());
}
return spuId;
}
// @Override
// 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(),"未找到上架卷数据");
// }
// 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<Long> couponMerchantIds = wxCouponMerchantMapper.findMerchantIdListByProduct(coupon.getId(), tenantInfo.getTenantId());
// if(couponMerchantIds == null || couponMerchantIds.size() == 0 ){
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到门店");
// }
//
// TtMerchantPoi poi = new TtMerchantPoi();
// poi.updateTenantInfo(tenantInfo);
// poi.setIds(couponMerchantIds);
// poi.setMatchStatus(EnumSupplierMathStatus.match_success.getCode());
// poi.setSyncStatus(EnumSupplierSyncStatus.sync_success.getCode());
// List<TtMerchantPoi> poiList = ttMerchantPoiMapper.findList(poi);
// if(poiList == null || poiList.isEmpty()){
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到匹配的poi");
// }
//// List<Long> collect = poiList.stream().map(p -> p.getId()).collect(Collectors.toList());
//
// String spuId = spuSync(coupon,couponChannel,couponMerchantIds);
// if(StringUtils.isBlank(spuId)){
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"同步失败");
// }
// WxCouponChannel ccUpd = new WxCouponChannel();
// ccUpd.setId(couponChannel.getId());
// ccUpd.updateTenantInfo(couponChannel);
// ccUpd.setTtSpuId(spuId);
// ccUpd.setUpdateDate(new Date());
// wxCouponChannelMapper.updateById(ccUpd);
//
// syncCouponChannelPoi(ccUpd);
// return new ResultData();
// }
// private void syncCouponChannelPoi(WxCouponChannel ccUpd){
// TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(ccUpd.getTenantId(),ccUpd.getId());
// if(ttCouponChannelPoi != null){
// ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode());
// ttCouponChannelPoi.setLastStatusDesc("");
// ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate());
// ttCouponChannelPoiMapper.updateById(ttCouponChannelPoi);
// }else{
// ttCouponChannelPoi = new TtCouponChannelPoi();
// ttCouponChannelPoi.setId(ccUpd.getId());
// ttCouponChannelPoi.updateTenantInfo(ccUpd);
// ttCouponChannelPoi.setSpuId(ccUpd.getTtSpuId());
// ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode());
// ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode());
// ttCouponChannelPoi.setCreateDate(ccUpd.getUpdateDate());
// ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate());
// ttCouponChannelPoiMapper.insert(ttCouponChannelPoi);
// }
// }
// private String spuSync(WxCoupon coupon,WxCouponChannel couponChannel, List<Long> merchantIds){
// TtSpuSync spuSync = new TtSpuSync();
// spuSync.setEntryInfo(getEntryInfo(couponChannel));
//// spuSync.setFrontCategoryTag();//前台品类标签
//// spuSync.setRecommendWord();//推荐语,5~20个字
//// spuSync.setSortWeight();//排序权重,按降序排列
// List<String> collect = merchantIds.stream().map(merchantId -> merchantId.toString()).collect(Collectors.toList());
// spuSync.setSupplierExtIdList(collect);
// spuSync.setPrice(coupon.getSalePrice());
// spuSync.setSpuExtId(couponChannel.getId().toString());
// spuSync.setImageList(JSONArray.parseArray(coupon.getCoverPicture(),String.class));
//// spuSync.setMpSettletype();//小程序结算类型 1-包销 2-代销
// spuSync.setOriginPrice(coupon.getPrice());
//// spuSync.setTakeRate();//商品的抽佣率,万分数
// spuSync.setAttribute(getAttribute(coupon,couponChannel));
//// spuSync.setHighlights(getHighlights(coupon));
// spuSync.setName(coupon.getTitle());
//// spuSync.setOrderDependsOnDate(false);//下单是否依赖日期
// spuSync.setSpuType(91);//spu类型号,1-日历房,30-酒店民宿预售券,90-门票,91-团购券
// if(EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){
// spuSync.setStatus(1);
// }else{
// spuSync.setStatus(2);
// }
// spuSync.setStock(coupon.getRemainInventory());
//
// String spuId = null;
// try {
// spuId = getTtWebService(coupon).getProductService().spuSync(spuSync);
// } catch (WxErrorException e) {
// logger.error("发起商品同步error"+e.getMessage());
// throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage());
// }
// return spuId;
// }

//__________________________________商品同步_______________________________________________
//获取入口信息
private JsonObject getEntryInfo(WxCouponChannel couponChannel){
JsonObject object = new JsonObject();
object.addProperty("entry_type",2);//入口类型(1:H5,2:抖音小程序,3:抖音链接)
JsonObject miniApp = new JsonObject();
miniApp.addProperty("params",couponChannel.getTtparams());
miniApp.addProperty("path",couponChannel.getTtPath());
WxAppinfo appInfo = wxAppinfoService.getCAppInfo(couponChannel, EnumAppPlat.TOUTIAO);
miniApp.addProperty("app_id",appInfo.getAppId());
object.add("entry_miniApp",miniApp);
return object;
}

//获取SPU属性字段
private JsonObject getAttribute(WxCoupon coupon,WxCouponChannel couponChannel){
// private JsonObject getEntryInfo(WxCouponChannel couponChannel){
// JsonObject object = new JsonObject();
JsonObject productObjuct = new JsonObject();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
productObjuct.addProperty("groupon_valid_start",dateFormat.format(couponChannel.getShowBeginTime()));//团购售卖时间开始
// todo 要求必传, 可能为空
productObjuct.addProperty("groupon_valid_end",dateFormat.format(coupon.getValidEndDate()));//*******

productObjuct.addProperty("order_limit",coupon.getUseLimitQuantity());//单个用户购买数量限制
if(EnumCouponValidType.BETWEEN_TWO_TIME.getCode().equals(coupon.getValidType())){
productObjuct.addProperty("order_valid_start",dateFormat.format(coupon.getValidStartDate()));
productObjuct.addProperty("order_valid_end",dateFormat.format(coupon.getValidEndDate()));
}else if(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode().equals(coupon.getValidType())){
productObjuct.addProperty("post_purchase_day",coupon.getValidDays());
}
//todo 商家客服电话 目前传的广场的客服电话 联系人广场名称
WxMall mall = wxMallMapper.getByTenantId(coupon.getTenantId());
JsonArray phoneArray = new JsonArray();
phoneArray.add(mall.getServicePhone());
productObjuct.add("service_phone",phoneArray);
productObjuct.addProperty("contact_name",mall.getName());

//todo 团购须知 要求格式 标题加类容 是否二选一 待测试
JsonArray notificationArray = new JsonArray();
// for ( : ) {
JsonObject contentObject = new JsonObject();
contentObject.addProperty("title","");//标题
contentObject.addProperty("content",coupon.getRemark());//内容
notificationArray.add(contentObject);
// }
productObjuct.add("notification",notificationArray);
if(EnumCouponContentType.HTML.getCode().equals(coupon.getContentType())){
productObjuct.addProperty("notification_rich_text",coupon.getHtml());
}
productObjuct.addProperty("sub_title",coupon.getSubTitle());

//todo 团购详情 要求必传, 待测试
if(StringUtils.isNotBlank(coupon.getItemGroup())){
JsonArray groupArray = new JsonParser().parse(coupon.getItemGroup()).getAsJsonArray();
productObjuct.add("pay_item_groups",groupArray);
}
// JsonArray groupArray = new JsonArray();
// for ( : ) {
// JsonObject groupObject = new JsonObject();
// groupObject.addProperty("group_name","标题");//标题
// JsonArray itemArray = new JsonArray(); //菜品
// for (:) {
// JsonObject itemObject = new JsonObject();
// itemObject.addProperty("name","菜名");
// itemObject.addProperty("count","数量");
// itemObject.addProperty("price","价格");
// itemArray.add(itemObject);
// }
// groupObject.add("item_list",itemArray);
// groupArray.add(groupObject);
// }
// productObjuct.add("pay_item_groups",groupArray);

//使用日期规则
// JsonObject dateRuleObject = new JsonObject();
// JsonObject unDateObject = new JsonObject();//不可用日期
// JsonArray dateArray = new JsonArray();//日期列表,格式yyyy-mm-dd,最多传100个
// JsonArray weekDayArray = new JsonArray();//星期列表,1-7代表周一到周天,[1,2]代表周一周二不可用
// unDateObject.add("date_list",dateArray);
// unDateObject.add("weekday_list",weekDayArray);
// dateRuleObject.add("unavailable_date",unDateObject);
// productObjuct.add("date_rule",dateRuleObject);

return productObjuct;
}

//商品亮点标签
private JsonArray getHighlights(WxCoupon coupon){
JsonArray array = new JsonArray();
// for (:) {
// JsonObject object = new JsonObject();
// object.addProperty("content",);//介绍,字符串长度<=5
// object.addProperty("priority",);//优先级,数字越小优先级越高
// array.add(object);
// object.addProperty("entry_type",2);//入口类型(1:H5,2:抖音小程序,3:抖音链接)
// JsonObject miniApp = new JsonObject();
// miniApp.addProperty("params",couponChannel.getTtparams());
// miniApp.addProperty("path",couponChannel.getTtPath());
// WxAppinfo appInfo = wxAppinfoService.getCAppInfo(couponChannel, EnumAppPlat.TOUTIAO);
// miniApp.addProperty("app_id",appInfo.getAppId());
// object.add("entry_miniApp",miniApp);
// return object;
// }
//
// //获取SPU属性字段
// private JsonObject getAttribute(WxCoupon coupon,WxCouponChannel couponChannel){
//// JsonObject object = new JsonObject();
// JsonObject productObjuct = new JsonObject();
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// productObjuct.addProperty("groupon_valid_start",dateFormat.format(couponChannel.getShowBeginTime()));//团购售卖时间开始
// // todo 要求必传, 可能为空
// productObjuct.addProperty("groupon_valid_end",dateFormat.format(coupon.getValidEndDate()));//*******
//
// productObjuct.addProperty("order_limit",coupon.getUseLimitQuantity());//单个用户购买数量限制
// if(EnumCouponValidType.BETWEEN_TWO_TIME.getCode().equals(coupon.getValidType())){
// productObjuct.addProperty("order_valid_start",dateFormat.format(coupon.getValidStartDate()));
// productObjuct.addProperty("order_valid_end",dateFormat.format(coupon.getValidEndDate()));
// }else if(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode().equals(coupon.getValidType())){
// productObjuct.addProperty("post_purchase_day",coupon.getValidDays());
// }
return array;
}
// //todo 商家客服电话 目前传的广场的客服电话 联系人广场名称
// WxMall mall = wxMallMapper.getByTenantId(coupon.getTenantId());
// JsonArray phoneArray = new JsonArray();
// phoneArray.add(mall.getServicePhone());
// productObjuct.add("service_phone",phoneArray);
// productObjuct.addProperty("contact_name",mall.getName());
//
// //todo 团购须知 要求格式 标题加类容 是否二选一 待测试
// JsonArray notificationArray = new JsonArray();
//// for ( : ) {
// JsonObject contentObject = new JsonObject();
// contentObject.addProperty("title","");//标题
// contentObject.addProperty("content",coupon.getRemark());//内容
// notificationArray.add(contentObject);
//// }
// productObjuct.add("notification",notificationArray);
// if(EnumCouponContentType.HTML.getCode().equals(coupon.getContentType())){
// productObjuct.addProperty("notification_rich_text",coupon.getHtml());
// }
// productObjuct.addProperty("sub_title",coupon.getSubTitle());
//
// //todo 团购详情 要求必传, 待测试
// if(StringUtils.isNotBlank(coupon.getItemGroup())){
// JsonArray groupArray = new JsonParser().parse(coupon.getItemGroup()).getAsJsonArray();
// productObjuct.add("pay_item_groups",groupArray);
// }
//// JsonArray groupArray = new JsonArray();
//// for ( : ) {
//// JsonObject groupObject = new JsonObject();
//// groupObject.addProperty("group_name","标题");//标题
//// JsonArray itemArray = new JsonArray(); //菜品
//// for (:) {
//// JsonObject itemObject = new JsonObject();
//// itemObject.addProperty("name","菜名");
//// itemObject.addProperty("count","数量");
//// itemObject.addProperty("price","价格");
//// itemArray.add(itemObject);
//// }
//// groupObject.add("item_list",itemArray);
//// groupArray.add(groupObject);
//// }
//// productObjuct.add("pay_item_groups",groupArray);
//
// //使用日期规则
//// JsonObject dateRuleObject = new JsonObject();
//// JsonObject unDateObject = new JsonObject();//不可用日期
//// JsonArray dateArray = new JsonArray();//日期列表,格式yyyy-mm-dd,最多传100个
//// JsonArray weekDayArray = new JsonArray();//星期列表,1-7代表周一到周天,[1,2]代表周一周二不可用
//// unDateObject.add("date_list",dateArray);
//// unDateObject.add("weekday_list",weekDayArray);
//// dateRuleObject.add("unavailable_date",unDateObject);
//// productObjuct.add("date_rule",dateRuleObject);
//
// return productObjuct;
// }
//
// //商品亮点标签
// private JsonArray getHighlights(WxCoupon coupon){
// JsonArray array = new JsonArray();
//// for (:) {
//// JsonObject object = new JsonObject();
//// object.addProperty("content",);//介绍,字符串长度<=5
//// object.addProperty("priority",);//优先级,数字越小优先级越高
//// array.add(object);
//// }
// return array;
// }

//_________________________________________________________________________________

@Override
public ResultData spuGet(TenantEntity tenantInfo, Long couponChannelId) {
WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId());
if(couponChannel == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据");
}
if(StringUtils.isBlank(couponChannel.getTtSpuId())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi");
}
TtSpuGet spuGet = new TtSpuGet();
spuGet.setSpuExtId(couponChannel.getId().toString());
spuGet.setNeedSpuDraft(true);
spuGet.setSpuDraftcount(3);
try {
TtSpuGetResult spuGetResult = getTtWebService(tenantInfo).getProductService().spuGet(spuGet);
handSyncCouponChannelPoi(tenantInfo,spuGetResult);
//处理一下数据
Map<String,Object> map = new HashMap<>();
if(spuGetResult.getSpuDetail() != null){//线上数据
TtSpuSync spuDetail = spuGetResult.getSpuDetail();
map.put("spuDetail",handSpuSync(spuDetail));
}
if(spuGetResult.getSpuDraft() != null && spuGetResult.getSpuDraft().size() > 0){//最近一次审核数据
TtSpuSync spuDraft = spuGetResult.getSpuDraft().get(0);
map.put("spuDraft",handSpuSync(spuDraft));
}
return new ResultData(map);
} catch (WxErrorException e) {
logger.error("couponChannelId:"+couponChannelId +" 多门店SPU信息查询error "+e.getMessage());
return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage());
}
}

private void handSyncCouponChannelPoi(TenantEntity tenantInfo,TtSpuGetResult spuGetResult){
Date now = new Date();
TtSpuSync spuDetail = spuGetResult.getSpuDetail();
if(spuDetail != null && StringUtils.isNotBlank(spuDetail.getSpuId()) && StringUtils.isNotBlank(spuDetail.getSpuExtId())
&& spuDetail.getStatus() != null){
TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),Long.parseLong(spuDetail.getSpuExtId()));
if(ttCouponChannelPoi != null && !spuDetail.getStatus().equals(ttCouponChannelPoi.getStatus())){
TtCouponChannelPoi ccPoi = new TtCouponChannelPoi();
ccPoi.setId(ttCouponChannelPoi.getId());
ccPoi.setStatus(spuDetail.getStatus());
ccPoi.setStatusDesc(spuDetail.getStatusDesc());
ccPoi.setUpdateDate(now);
ttCouponChannelPoiMapper.updateById(ccPoi);
}else if(ttCouponChannelPoi == null){
ttCouponChannelPoi = new TtCouponChannelPoi();
ttCouponChannelPoi.setId(Long.parseLong(spuDetail.getSpuExtId()));
ttCouponChannelPoi.updateTenantInfo(tenantInfo);
ttCouponChannelPoi.setSpuId(spuDetail.getSpuId());
ttCouponChannelPoi.setStatus(spuDetail.getStatus());
ttCouponChannelPoi.setStatusDesc(spuDetail.getStatusDesc());
ttCouponChannelPoi.setCreateDate(now);
ttCouponChannelPoi.setUpdateDate(now);
ttCouponChannelPoiMapper.insert(ttCouponChannelPoi);
}
}
List<TtSpuSync> spuDraftList = spuGetResult.getSpuDraft();
if(spuDraftList != null && spuDraftList.size() > 0){
TtSpuSync spuDraft = spuDraftList.get(0);
if(spuDraft != null && StringUtils.isNotBlank(spuDraft.getSpuId()) && StringUtils.isNotBlank(spuDraft.getSpuExtId())
&& spuDraft.getStatus() != null){
TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),Long.parseLong(spuDraft.getSpuExtId()));
if(ttCouponChannelPoi != null && !spuDraft.getStatus().equals(ttCouponChannelPoi.getStatus())){
TtCouponChannelPoi ccPoi = new TtCouponChannelPoi();
ccPoi.setId(ttCouponChannelPoi.getId());
ccPoi.setLastStatus(spuDraft.getStatus());
ccPoi.setLastStatusDesc(spuDraft.getStatusDesc());
ccPoi.setUpdateDate(now);
ttCouponChannelPoiMapper.updateById(ccPoi);
}else if(ttCouponChannelPoi == null){
ttCouponChannelPoi = new TtCouponChannelPoi();
ttCouponChannelPoi.setId(Long.parseLong(spuDraft.getSpuExtId()));
ttCouponChannelPoi.updateTenantInfo(tenantInfo);
ttCouponChannelPoi.setSpuId(spuDraft.getSpuId());
ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode());
ttCouponChannelPoi.setLastStatus(spuDraft.getStatus());
ttCouponChannelPoi.setLastStatusDesc(spuDraft.getStatusDesc());
ttCouponChannelPoi.setCreateDate(now);
ttCouponChannelPoi.setUpdateDate(now);
ttCouponChannelPoiMapper.insert(ttCouponChannelPoi);
}
}
}
}

private Map<String,Object> handSpuSync(TtSpuSync spuSync){
Map<String,Object> map = new HashMap<>();
map.put("id",spuSync.getSpuExtId());
map.put("spu_id",spuSync.getSpuId());
map.put("image_list",spuSync.getImageList());
map.put("name",spuSync.getName());
if(spuSync.getAttribute() != null){
JsonObject attribute = spuSync.getAttribute();
JsonArray pay_item_groups = attribute.getAsJsonArray("pay_item_groups");
map.put("pay_item_groups",pay_item_groups.toString());
JsonArray notification = attribute.getAsJsonArray("notification");
map.put("notification",notification.toString());
map.put("order_limit", GsonHelper.getString(attribute, "order_limit"));
//售卖有效期
map.put("groupon_valid_start", GsonHelper.getString(attribute, "groupon_valid_start"));
map.put("groupon_valid_end", GsonHelper.getString(attribute, "groupon_valid_end"));
//卷有效期
map.put("order_valid_start", GsonHelper.getString(attribute, "order_valid_start"));
map.put("order_valid_end", GsonHelper.getString(attribute, "order_valid_end"));

}

map.put("price",spuSync.getPrice());
map.put("origin_price",spuSync.getOriginPrice());
map.put("stock",spuSync.getStock());
map.put("status",spuSync.getStatus());
map.put("status_desc",spuSync.getStatusDesc());
return map;
}

@Override
public ResultData spuStatusSync(TenantEntity tenantInfo, Long couponChannelId) {
WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId());
if(couponChannel == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据");
}
if(StringUtils.isBlank(couponChannel.getTtSpuId())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi");
}
TtSpuStatusSync statusSync = new TtSpuStatusSync();
List<String> ids = new ArrayList<>();
ids.add(couponChannel.getId().toString());
statusSync.setSpuExtIdList(ids);
if(EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){
statusSync.setStatus(1);
}else{
statusSync.setStatus(2);
}
try {
TtSpuStatusSync statusSyncResult = getTtWebService(tenantInfo).getProductService().spuStatusSync(statusSync);
if(statusSyncResult.getSpuExtIdList() != null && statusSyncResult.getSpuExtIdList().containsAll(ids)){
return new ResultData();
}
} catch (WxErrorException e) {
logger.error("couponChannelId:"+couponChannelId +" 多门店SPU状态同步error "+e.getMessage());
throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage());
// return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage());
}
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败");
// return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败");
}

@Override
public ResultData spuStockSync(TenantEntity tenantInfo, Long couponChannelId) {
WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId());
if(couponChannel == null){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据");
}
if(StringUtils.isBlank(couponChannel.getTtSpuId())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi");
}
WxCoupon coupon = wxCouponMapper.selectById(couponChannel.getCouponId(), tenantInfo.getTenantId());
if(coupon == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到卷数据");
}
TtSpuStockSync stockSync = new TtSpuStockSync();
stockSync.setSpuExtId(couponChannel.getId().toString());
stockSync.setStock(coupon.getRemainInventory());
try {
boolean syncResult = getTtWebService(tenantInfo).getProductService().spuStockUpdate(stockSync);
if(syncResult){
return new ResultData();
}
} catch (WxErrorException e) {
logger.error("couponChannelId:"+couponChannelId +" 多门店SPU状态同步error "+e.getMessage());
throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage());
// @Override
// public ResultData spuGet(TenantEntity tenantInfo, Long couponChannelId) {
// WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId());
// if(couponChannel == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据");
// }
// if(StringUtils.isBlank(couponChannel.getTtSpuId())){
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi");
// }
// TtSpuGet spuGet = new TtSpuGet();
// spuGet.setSpuExtId(couponChannel.getId().toString());
// spuGet.setNeedSpuDraft(true);
// spuGet.setSpuDraftcount(3);
// try {
// TtSpuGetResult spuGetResult = getTtWebService(tenantInfo).getProductService().spuGet(spuGet);
// handSyncCouponChannelPoi(tenantInfo,spuGetResult);
// //处理一下数据
// Map<String,Object> map = new HashMap<>();
// if(spuGetResult.getSpuDetail() != null){//线上数据
// TtSpuSync spuDetail = spuGetResult.getSpuDetail();
// map.put("spuDetail",handSpuSync(spuDetail));
// }
// if(spuGetResult.getSpuDraft() != null && spuGetResult.getSpuDraft().size() > 0){//最近一次审核数据
// TtSpuSync spuDraft = spuGetResult.getSpuDraft().get(0);
// map.put("spuDraft",handSpuSync(spuDraft));
// }
// return new ResultData(map);
// } catch (WxErrorException e) {
// logger.error("couponChannelId:"+couponChannelId +" 多门店SPU信息查询error "+e.getMessage());
// return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage());
}
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败");
// return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败");
}
// }
// }
//
// private void handSyncCouponChannelPoi(TenantEntity tenantInfo,TtSpuGetResult spuGetResult){
// Date now = new Date();
// TtSpuSync spuDetail = spuGetResult.getSpuDetail();
// if(spuDetail != null && StringUtils.isNotBlank(spuDetail.getSpuId()) && StringUtils.isNotBlank(spuDetail.getSpuExtId())
// && spuDetail.getStatus() != null){
// TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),Long.parseLong(spuDetail.getSpuExtId()));
// if(ttCouponChannelPoi != null && !spuDetail.getStatus().equals(ttCouponChannelPoi.getStatus())){
// TtCouponChannelPoi ccPoi = new TtCouponChannelPoi();
// ccPoi.setId(ttCouponChannelPoi.getId());
// ccPoi.setStatus(spuDetail.getStatus());
// ccPoi.setStatusDesc(spuDetail.getStatusDesc());
// ccPoi.setUpdateDate(now);
// ttCouponChannelPoiMapper.updateById(ccPoi);
// }else if(ttCouponChannelPoi == null){
// ttCouponChannelPoi = new TtCouponChannelPoi();
// ttCouponChannelPoi.setId(Long.parseLong(spuDetail.getSpuExtId()));
// ttCouponChannelPoi.updateTenantInfo(tenantInfo);
// ttCouponChannelPoi.setSpuId(spuDetail.getSpuId());
// ttCouponChannelPoi.setStatus(spuDetail.getStatus());
// ttCouponChannelPoi.setStatusDesc(spuDetail.getStatusDesc());
// ttCouponChannelPoi.setCreateDate(now);
// ttCouponChannelPoi.setUpdateDate(now);
// ttCouponChannelPoiMapper.insert(ttCouponChannelPoi);
// }
// }
// List<TtSpuSync> spuDraftList = spuGetResult.getSpuDraft();
// if(spuDraftList != null && spuDraftList.size() > 0){
// TtSpuSync spuDraft = spuDraftList.get(0);
// if(spuDraft != null && StringUtils.isNotBlank(spuDraft.getSpuId()) && StringUtils.isNotBlank(spuDraft.getSpuExtId())
// && spuDraft.getStatus() != null){
// TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),Long.parseLong(spuDraft.getSpuExtId()));
// if(ttCouponChannelPoi != null && !spuDraft.getStatus().equals(ttCouponChannelPoi.getStatus())){
// TtCouponChannelPoi ccPoi = new TtCouponChannelPoi();
// ccPoi.setId(ttCouponChannelPoi.getId());
// ccPoi.setLastStatus(spuDraft.getStatus());
// ccPoi.setLastStatusDesc(spuDraft.getStatusDesc());
// ccPoi.setUpdateDate(now);
// ttCouponChannelPoiMapper.updateById(ccPoi);
// }else if(ttCouponChannelPoi == null){
// ttCouponChannelPoi = new TtCouponChannelPoi();
// ttCouponChannelPoi.setId(Long.parseLong(spuDraft.getSpuExtId()));
// ttCouponChannelPoi.updateTenantInfo(tenantInfo);
// ttCouponChannelPoi.setSpuId(spuDraft.getSpuId());
// ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode());
// ttCouponChannelPoi.setLastStatus(spuDraft.getStatus());
// ttCouponChannelPoi.setLastStatusDesc(spuDraft.getStatusDesc());
// ttCouponChannelPoi.setCreateDate(now);
// ttCouponChannelPoi.setUpdateDate(now);
// ttCouponChannelPoiMapper.insert(ttCouponChannelPoi);
// }
// }
// }
// }
//
// private Map<String,Object> handSpuSync(TtSpuSync spuSync){
// Map<String,Object> map = new HashMap<>();
// map.put("id",spuSync.getSpuExtId());
// map.put("spu_id",spuSync.getSpuId());
// map.put("image_list",spuSync.getImageList());
// map.put("name",spuSync.getName());
// if(spuSync.getAttribute() != null){
// JsonObject attribute = spuSync.getAttribute();
// JsonArray pay_item_groups = attribute.getAsJsonArray("pay_item_groups");
// map.put("pay_item_groups",pay_item_groups.toString());
// JsonArray notification = attribute.getAsJsonArray("notification");
// map.put("notification",notification.toString());
// map.put("order_limit", GsonHelper.getString(attribute, "order_limit"));
// //售卖有效期
// map.put("groupon_valid_start", GsonHelper.getString(attribute, "groupon_valid_start"));
// map.put("groupon_valid_end", GsonHelper.getString(attribute, "groupon_valid_end"));
// //卷有效期
// map.put("order_valid_start", GsonHelper.getString(attribute, "order_valid_start"));
// map.put("order_valid_end", GsonHelper.getString(attribute, "order_valid_end"));
//
// }
//
// map.put("price",spuSync.getPrice());
// map.put("origin_price",spuSync.getOriginPrice());
// map.put("stock",spuSync.getStock());
// map.put("status",spuSync.getStatus());
// map.put("status_desc",spuSync.getStatusDesc());
// return map;
// }

// @Override
// public ResultData spuStatusSync(TenantEntity tenantInfo, Long couponChannelId) {
// WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId());
// if(couponChannel == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据");
// }
// if(StringUtils.isBlank(couponChannel.getTtSpuId())){
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi");
// }
// TtSpuStatusSync statusSync = new TtSpuStatusSync();
// List<String> ids = new ArrayList<>();
// ids.add(couponChannel.getId().toString());
// statusSync.setSpuExtIdList(ids);
// if(EnumCouponChannelStatus.STATUS_THROW_IN.getCode().equals(couponChannel.getStatus())){
// statusSync.setStatus(1);
// }else{
// statusSync.setStatus(2);
// }
// try {
// TtSpuStatusSync statusSyncResult = getTtWebService(tenantInfo).getProductService().spuStatusSync(statusSync);
// if(statusSyncResult.getSpuExtIdList() != null && statusSyncResult.getSpuExtIdList().containsAll(ids)){
// return new ResultData();
// }
// } catch (WxErrorException e) {
// logger.error("couponChannelId:"+couponChannelId +" 多门店SPU状态同步error "+e.getMessage());
// throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage());
//// return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage());
// }
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败");
//// return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败");
// }

// @Override
// public ResultData spuStockSync(TenantEntity tenantInfo, Long couponChannelId) {
// WxCouponChannel couponChannel = wxCouponChannelMapper.selectById(couponChannelId, tenantInfo.getTenantId());
// if(couponChannel == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到卷数据");
// }
// if(StringUtils.isBlank(couponChannel.getTtSpuId())){
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未同步poi");
// }
// WxCoupon coupon = wxCouponMapper.selectById(couponChannel.getCouponId(), tenantInfo.getTenantId());
// if(coupon == null){
// return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到卷数据");
// }
// TtSpuStockSync stockSync = new TtSpuStockSync();
// stockSync.setSpuExtId(couponChannel.getId().toString());
// stockSync.setStock(coupon.getRemainInventory());
// try {
// boolean syncResult = getTtWebService(tenantInfo).getProductService().spuStockUpdate(stockSync);
// if(syncResult){
// return new ResultData();
// }
// } catch (WxErrorException e) {
// logger.error("couponChannelId:"+couponChannelId +" 多门店SPU状态同步error "+e.getMessage());
// throw new MallinkException(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage());
//// return new ResultData(ErrorCode.MSG_METHOD_REQUEST_ERROR.getCode(),e.getMessage());
// }
// throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败");
//// return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"同步失败");
// }

}

+ 8
- 28
mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java View File

@@ -157,19 +157,17 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
wxCardInfoMapper.updateTransferStatusByCouponId(orignal.getCouponId());
//浮层下架
wxFloatingLayerMapper.updateStatus(orignal.getCouponId());

try{
spuStatusSyncByCoupon(orignal,orignal.getCouponId());
}catch(Exception e){
logger.error("send spuStatusSync error: " + e.getMessage());
}
}
}
record.setUpdateDate(new Date());
wxCouponChannelMapper.updateById(record);

if(EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode().equals(record.getStatus())){
try{
spuStatusSync(record,record.getId());
}catch(Exception e){
logger.error("send spuStatusSync error: " + e.getMessage());
}
}

}

//清除缓存
@@ -178,12 +176,12 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
}

@Override
public void spuStatusSync(TenantEntity tenantEntity, Long id) {
public void spuStatusSyncByCoupon(TenantEntity tenantEntity, Long couponId) {
FmInsideProductPushMsg productPush = new FmInsideProductPushMsg();
productPush.setDelayTimeLevel(3);
productPush.setMsgType(EnumMsgRecordType.INSIDE_PRODUCT_PUSH.getCode());
productPush.updateTenantInfo(tenantEntity);
productPush.setCouponChannelId(id);
productPush.setCouponId(couponId);
productPush.setSyncType(EnumPushType.SPU_STATUS_SYNC);
logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush);
mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode());
@@ -304,24 +302,6 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
}
}

private void spuStatusSyncByCoupon(TenantEntity tenantEntity, Long couponId){

List<Long> couponChannelIds = wxCouponChannelMapper.getPoiProductIdList(tenantEntity.getTenantId(),couponId);
if(couponChannelIds != null && couponChannelIds.size() > 0){
for (Long couponChannelId:couponChannelIds) {
FmInsideProductPushMsg productPush = new FmInsideProductPushMsg();
productPush.setDelayTimeLevel(3);
productPush.setMsgType(EnumMsgRecordType.INSIDE_PRODUCT_PUSH.getCode());
productPush.updateTenantInfo(tenantEntity);
productPush.setCouponChannelId(couponChannelId);
productPush.setSyncType(EnumPushType.SPU_STATUS_SYNC);
logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush);
mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode());
}
}

}

@Override
public ResultData change(WxCouponChannel record) {
Long couponId = 0L;


+ 19
- 24
mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java View File

@@ -1020,11 +1020,11 @@ public class WxCouponServiceImpl implements WxCouponService {
if (num == 0) {
throw new MallinkException(ErrorCode.ORDER_SAVE_ERR);
}
try{
spuStockSync(tenantEntity,id);
}catch(Exception e){
logger.error("send spuStockSync error: " + e.getMessage());
}
// try{
// spuStockSync(tenantEntity,id);
// }catch(Exception e){
// logger.error("send spuStockSync error: " + e.getMessage());
// }
}

@Override
@@ -1034,14 +1034,14 @@ public class WxCouponServiceImpl implements WxCouponService {
if (num == 0) {
throw new MallinkException(ErrorCode.REMAIN_BACK_FAIL);
}
try{
spuStockSync(tenantEntity,id);
}catch(Exception e){
logger.error("send spuStockSync error: " + e.getMessage());
}
// try{
// spuStockSync(tenantEntity,id);
// }catch(Exception e){
// logger.error("send spuStockSync error: " + e.getMessage());
// }
}

private void spuStockSync(TenantEntity tenantEntity,Long id){
private void spuStockSync(TenantEntity tenantEntity,Long couponId){
// new Thread(() -> {
// //1秒之后同步poi
// try {
@@ -1050,19 +1050,14 @@ public class WxCouponServiceImpl implements WxCouponService {
// logger.error("sleep error: " + e.getMessage());
// }

List<Long> couponChannelIds = wxCouponChannelMapper.getPoiProductIdList(tenantEntity.getTenantId(),id);
if(couponChannelIds != null && couponChannelIds.size() > 0){
for (Long couponChannelId:couponChannelIds) {
FmInsideProductPushMsg productPush = new FmInsideProductPushMsg();
productPush.setDelayTimeLevel(3);
productPush.setMsgType(EnumMsgRecordType.INSIDE_PRODUCT_PUSH.getCode());
productPush.updateTenantInfo(tenantEntity);
productPush.setCouponChannelId(couponChannelId);
productPush.setSyncType(EnumPushType.SPU_STOCK_SYNC);
logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush);
mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode());
}
}
FmInsideProductPushMsg productPush = new FmInsideProductPushMsg();
productPush.setDelayTimeLevel(3);
productPush.setMsgType(EnumMsgRecordType.INSIDE_PRODUCT_PUSH.getCode());
productPush.updateTenantInfo(tenantEntity);
productPush.setCouponId(couponId);
productPush.setSyncType(EnumPushType.SPU_STOCK_SYNC);
logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush);
mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode());

// }).start();



+ 9
- 2
mallinkService/src/main/java/com/iformall/service/msg/impl/FmInsideProductPushMsgServiceImpl.java View File

@@ -3,6 +3,8 @@ package com.iformall.service.msg.impl;
import com.iformall.domain.po.msg.BaseMsg;
import com.iformall.domain.po.msg.FmInsideProductPushMsg;
import com.iformall.enums.EnumPushType;
import com.iformall.service.TtCouponGoodsService;
import com.iformall.service.TtGoodsCategoryService;
import com.iformall.service.TtMerchantPoiService;
import com.iformall.service.msg.MsgSendService;
import org.slf4j.Logger;
@@ -23,14 +25,19 @@ public class FmInsideProductPushMsgServiceImpl implements MsgSendService {
@Autowired
private TtMerchantPoiService poiService;

@Autowired
private TtCouponGoodsService ttCouponGoodsService;

@Override
public void send(BaseMsg baseMsg) throws Exception{
FmInsideProductPushMsg msg = (FmInsideProductPushMsg)baseMsg;

if(EnumPushType.SPU_STATUS_SYNC.equals(msg.getSyncType())){
poiService.spuStatusSync(msg.getTenantInfo(),msg.getCouponChannelId());
ttCouponGoodsService.productOperate(msg.getTenantInfo(),msg.getCouponId());
// poiService.spuStatusSync(msg.getTenantInfo(),msg.getCouponId());
}else if(EnumPushType.SPU_STOCK_SYNC.equals(msg.getSyncType())){
poiService.spuStockSync(msg.getTenantInfo(),msg.getCouponChannelId());
ttCouponGoodsService.productOperate(msg.getTenantInfo(),msg.getCouponId());
// poiService.spuStockSync(msg.getTenantInfo(),msg.getCouponId());
}

}


+ 6
- 17
mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml View File

@@ -192,10 +192,9 @@
<include refid="dynamicWhereConditions" />
</select>

<select id="getExpiriedCouponChannelIdsByEndTime" resultType="Long">
select id from wx_coupon_channel
<select id="getExpiriedCouponIdsByEndTime" resultType="Long">
select distinct coupon_id from wx_coupon_channel
where status = 0 and tenant_id = #{tenantId} and end_time &lt; now()
and `tt_spu_id` is not null
</select>

<update id="offExpiriedCouponChannelByEndTime">
@@ -203,11 +202,10 @@
where status = 0 and tenant_id = #{tenantId} and end_time &lt; now()
</update>

<select id="getExpiriedCouponChannelIdsByValidDate" resultType="Long">
select cc.id from wx_coupon_channel cc, wx_coupon c
<select id="getExpiriedCouponIdsByValidDate" resultType="Long">
select distinct cc.coupon_id from wx_coupon_channel cc, wx_coupon c
where cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date &lt; now()
and cc.status = 0 and cc.tenant_id = #{tenantId}
and cc.`tt_spu_id` is not null
</select>

<update id="offExpiriedCouponChannelByValidDate">
@@ -215,11 +213,10 @@
where cc.status = 0 and cc.tenant_id = #{tenantId} and cc.coupon_id = c.id and c.valid_type = 1 and c.valid_end_date &lt; now()
</update>

<select id="getExpiriedCouponChannelIdsByCouponStatus" resultType="Long">
select cc.id from wx_coupon_channel cc, wx_coupon c
<select id="getExpiriedCouponIdsByCouponStatus" resultType="Long">
select distinct cc.coupon_id from wx_coupon_channel cc, wx_coupon c
where cc.coupon_id = c.id and c.status = 1
and cc.status = 0 and cc.tenant_id = #{tenantId}
and cc.`tt_spu_id` is not null
</select>

<update id="offExpiriedCouponChannelByCouponStatus">
@@ -359,14 +356,6 @@
</if>
<if test=" null != sortColumns"> order by ${sortColumns} </if>
</select>


<select id="getPoiProductIdList" parameterType="java.util.HashMap" resultType="Long">
select id from wx_coupon_channel
where `tenant_id` = #{tenantId}
and `coupon_id` = #{couponId}
and `tt_spu_id` is not null
</select>
<update id="reduceChannelStock">
update wx_coupon_channel SET channel_stock = channel_stock - #{number} where id = #{id} and tenant_id =#{tenantId} and channel_stock is not null and channel_stock - #{number} &gt;= 0


Loading…
Cancel
Save