| @@ -5,10 +5,11 @@ package com.iformall.enums; | |||||
| */ | */ | ||||
| public enum EnumPushType { | public enum EnumPushType { | ||||
| // 1-B端, 2-C端, 3-服务号, 4-订阅号 | |||||
| // | |||||
| SPU_STATUS_SYNC(1, "同步状态"), | SPU_STATUS_SYNC(1, "同步状态"), | ||||
| SPU_STOCK_SYNC(2, "同步库存"), | SPU_STOCK_SYNC(2, "同步库存"), | ||||
| SPU_FREE_AUDIT_SYNC(3, "免审修改"), | |||||
| ; | ; | ||||
| public static EnumPushType getEnum(Integer code) { | public static EnumPushType getEnum(Integer code) { | ||||
| @@ -25,4 +25,6 @@ public interface TtCouponGoodsService { | |||||
| ResultData productOperate(TenantEntity tenantInfo, Long id); | ResultData productOperate(TenantEntity tenantInfo, Long id); | ||||
| ResultData productStockSync(TenantEntity tenantInfo, Long id); | ResultData productStockSync(TenantEntity tenantInfo, Long id); | ||||
| ResultData productFreeAudit(TenantEntity tenantInfo, Long id); | |||||
| } | } | ||||
| @@ -348,6 +348,32 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||||
| } | } | ||||
| } | } | ||||
| @Override | |||||
| public ResultData productFreeAudit(TenantEntity tenantInfo, Long id) { | |||||
| WxCoupon wxCoupon = wxCouponMapper.selectById(id, tenantInfo.getTenantId()); | |||||
| if(wxCoupon == null || EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未找到或已作废"); | |||||
| } | |||||
| TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantInfo.getTenantId(),id); | |||||
| if(ttCouponChannelPoi == null || !EnumSpuSyncStatus.sync_audit_pass.getCode().equals(ttCouponChannelPoi.getLastStatus())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"该券未提交审核或审核未通过"); | |||||
| } | |||||
| try { | |||||
| TtWebService ttWebService = ttMerchantPoiService.getTtWebService(ttCouponChannelPoi); | |||||
| boolean b = ttWebService.getGoodsService().productFreeAudit(null,wxCoupon.getId().toString(), | |||||
| wxCoupon.getValidEndDate().getTime(),wxCoupon.getInventory()); | |||||
| if(b){ | |||||
| return new ResultData(); | |||||
| }else{ | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"修改失败"); | |||||
| } | |||||
| } catch (WxErrorException e) { | |||||
| e.printStackTrace(); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),e.getMessage()); | |||||
| } | |||||
| } | |||||
| private void syncCouponChannelPoi(WxCoupon coupon,Long couponChannelId,String productId){ | private void syncCouponChannelPoi(WxCoupon coupon,Long couponChannelId,String productId){ | ||||
| TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(coupon.getTenantId(),coupon.getId()); | TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(coupon.getTenantId(),coupon.getId()); | ||||
| Date date = new Date(); | Date date = new Date(); | ||||
| @@ -981,9 +981,9 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| if(ret != 1) { | if(ret != 1) { | ||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "数据库更新数量错误"); | throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "数据库更新数量错误"); | ||||
| } | } | ||||
| // 更新库存后同步 | |||||
| // 免审修改 | |||||
| try{ | try{ | ||||
| spuStockSync(wxCoupon,wxCoupon.getId()); | |||||
| spuFreeAuditSync(wxCoupon,wxCoupon.getId()); | |||||
| }catch(Exception e){ | }catch(Exception e){ | ||||
| logger.error("send spuStockSync error: " + e.getMessage()); | logger.error("send spuStockSync error: " + e.getMessage()); | ||||
| } | } | ||||
| @@ -1064,6 +1064,28 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush); | logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush); | ||||
| mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | ||||
| // }).start(); | |||||
| } | |||||
| private void spuFreeAuditSync(TenantEntity tenantEntity,Long couponId){ | |||||
| // new Thread(() -> { | |||||
| // //1秒之后同步poi | |||||
| // try { | |||||
| // Thread.currentThread().sleep(1000); | |||||
| // } catch (Exception e) { | |||||
| // logger.error("sleep error: " + e.getMessage()); | |||||
| // } | |||||
| FmInsideProductPushMsg productPush = new FmInsideProductPushMsg(); | |||||
| productPush.setDelayTimeLevel(3); | |||||
| productPush.setMsgType(EnumMsgRecordType.INSIDE_PRODUCT_PUSH.getCode()); | |||||
| productPush.updateTenantInfo(tenantEntity); | |||||
| productPush.setCouponId(couponId); | |||||
| productPush.setSyncType(EnumPushType.SPU_FREE_AUDIT_SYNC); | |||||
| logger.info(">>>>>>>>>>>send FmInsideProductPushMsg :"+productPush); | |||||
| mqBaseProducer.sendMessage(productPush, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||||
| // }).start(); | // }).start(); | ||||
| } | } | ||||
| @@ -38,6 +38,8 @@ public class FmInsideProductPushMsgServiceImpl implements MsgSendService { | |||||
| }else if(EnumPushType.SPU_STOCK_SYNC.equals(msg.getSyncType())){ | }else if(EnumPushType.SPU_STOCK_SYNC.equals(msg.getSyncType())){ | ||||
| ttCouponGoodsService.productOperate(msg.getTenantInfo(),msg.getCouponId()); | ttCouponGoodsService.productOperate(msg.getTenantInfo(),msg.getCouponId()); | ||||
| // poiService.spuStockSync(msg.getTenantInfo(),msg.getCouponId()); | // poiService.spuStockSync(msg.getTenantInfo(),msg.getCouponId()); | ||||
| }else if(EnumPushType.SPU_FREE_AUDIT_SYNC.equals(msg.getSyncType())){ | |||||
| ttCouponGoodsService.productFreeAudit(msg.getTenantInfo(),msg.getCouponId()); | |||||
| } | } | ||||
| } | } | ||||