diff --git a/mallinkAdmin/src/main/resources/db/migration/V2022111500001__plat_coupon.sql b/mallinkAdmin/src/main/resources/db/migration/V2022111500001__plat_coupon.sql index 24fb769f7..878cbe8b7 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V2022111500001__plat_coupon.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V2022111500001__plat_coupon.sql @@ -110,4 +110,6 @@ create table wx_coupon_mall_95 like wx_coupon_mall; create table wx_coupon_mall_96 like wx_coupon_mall; create table wx_coupon_mall_97 like wx_coupon_mall; create table wx_coupon_mall_98 like wx_coupon_mall; -create table wx_coupon_mall_99 like wx_coupon_mall; \ No newline at end of file +create table wx_coupon_mall_99 like wx_coupon_mall; + +drop table wx_coupon_mall; \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java index c0016d9b4..107fae939 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java @@ -394,6 +394,9 @@ public class WxCoupon extends TenantEntity { @TableField(exist = false) private Long[] merchantIds; + + @TableField(exist = false) + private String[] mallTenantIds; public String getSalePriceStr() { if(salePrice!=null) { @@ -496,6 +499,7 @@ public class WxCoupon extends TenantEntity { return valid_date; } + //是不是必须要有商户 public boolean checkCreateWithMerchants() { if(type == null) { return true; @@ -505,5 +509,16 @@ public class WxCoupon extends TenantEntity { } return true; } + + //是不是必须要有商场 + public boolean checkCreateWithMalls() { + if(type == null) { + return false; + } + if(type == EnumCouponType.COUPON_DOUYIN_PLAT.getCode()) { + return true; + } + return false; + } } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMallMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMallMapper.java index c938f0593..64057ed30 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMallMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMallMapper.java @@ -14,4 +14,5 @@ public interface WxCouponMallMapper extends CommonMapper { List findList(WxCouponMall wxCouponMall); void updateStatus(WxCouponMall wxCouponMall); + void delteAllByProductId(WxCouponMall wxCouponMall); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index 5c51f3703..4fed358cc 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -147,6 +147,9 @@ public class WxCouponServiceImpl implements WxCouponService { @Autowired PayServiceFactory payServiceFactory; + + @Autowired + WxCouponMallMapper wxCouponMallMapper; @Override public ResultData list(TenantEntity tenantEntity,WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { @@ -520,9 +523,12 @@ public class WxCouponServiceImpl implements WxCouponService { return new ResultData(Result.ERROR,e.getMessage()); } merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); + }else if (record.checkCreateWithMalls()) { + String[] mallTenantIds = record.getMallTenantIds(); + if (null == mallTenantIds || mallTenantIds.length <= 0 ) { + return new ResultData(Result.ERROR,"请选择商场"); + } } - - final IdWorker idWorker = IdWorker.get(); if (record.getId() == null) { @@ -541,6 +547,17 @@ public class WxCouponServiceImpl implements WxCouponService { cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); wxCouponMerchantMapper.insert(cm); }); + }else if (record.checkCreateWithMalls()) { + for (String mt : record.getMallTenantIds()) { + WxCouponMall mall = new WxCouponMall(); + mall.updateTenantInfo(record); + mall.setMallTenantId(mt); + mall.setProductId(record.getId()); + mall.setCreateDate(new Date()); + mall.setUpdateDate(new Date()); + mall.setStatus(EnumCouponMallStatus.UNFINISED.getCode()); + wxCouponMallMapper.insert(mall); + } } if (record.getPasswordSupport() != null && record.getPasswordSupport().equals(EnumCouponPasswordSupport.SUPPORTED.getCode())) { @@ -571,6 +588,21 @@ public class WxCouponServiceImpl implements WxCouponService { } if (record.checkCreateWithMerchants()) { updateCouponMerchants(record,merchantParamList,idWorker); + }else if (record.checkCreateWithMalls()) { + WxCouponMall couponMall = new WxCouponMall(); + couponMall.updateTenantInfo(record); + couponMall.setProductId(record.getId()); + wxCouponMallMapper.delteAllByProductId(couponMall); + for (String mt : record.getMallTenantIds()) { + WxCouponMall mall = new WxCouponMall(); + mall.updateTenantInfo(record); + mall.setMallTenantId(mt); + mall.setProductId(record.getId()); + mall.setCreateDate(new Date()); + mall.setUpdateDate(new Date()); + mall.setStatus(EnumCouponMallStatus.UNFINISED.getCode()); + wxCouponMallMapper.insert(mall); + } } record.setUpdateDate(new Date()); diff --git a/mallinkService/src/main/resources/mapper/WxCouponMallMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMallMapper.xml index 8a5836da4..7ca9d1158 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMallMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMallMapper.xml @@ -82,4 +82,7 @@ and `tenant_id` = #{tenantId} and `mall_tenant_id` = #{mallTenantId} + + delete from wx_coupon_mall where `product_id` = #{productId} and `tenant_id` = #{tenantId} +