diff --git a/mallinkAdmin/src/main/resources/db/migration/V201904031030__UPDATE_WX_SHOP.sql b/mallinkAdmin/src/main/resources/db/migration/V201904031030__UPDATE_WX_SHOP.sql new file mode 100644 index 000000000..3ed494ce0 --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V201904031030__UPDATE_WX_SHOP.sql @@ -0,0 +1,2 @@ +ALTER TABLE `wx_shop` +ADD COLUMN `is_del` smallint(2) DEFAULT 0 COMMENT '是否删除1是0否'; \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java b/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java index 878e050c0..45459b3fd 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxShop.java @@ -126,6 +126,17 @@ public class WxShop implements Serializable { @io.swagger.annotations.ApiModelProperty(value = "邮箱", name = "email") private String email; + @io.swagger.annotations.ApiModelProperty(value = "是否删除1是0否", name = " ") + private Integer isDel; + + public Integer getIsDel() { + return isDel; + } + + public void setIsDel(Integer isDel) { + this.isDel = isDel; + } + public String getEmail() { return email; } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java index 73cbf2bca..50fa7259a 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxShopServiceImpl.java @@ -9,6 +9,7 @@ import com.iformall.common.ResultData; import com.iformall.domain.po.WxMerchantShop; import com.iformall.domain.po.WxShop; import com.iformall.domain.vo.WxShopVo; +import com.iformall.enums.EnumDelStatus; import com.iformall.enums.EnumRentShopType; import com.iformall.enums.EnumShopStatus; import com.iformall.enums.EnumUserAdmin; @@ -91,10 +92,22 @@ public class WxShopServiceImpl implements WxShopService { //2、是否关联过商户 WxMerchantShop wxMerchantShop = new WxMerchantShop(); wxMerchantShop.setShopId(wxShop.getId()); - int count = wxMerchantShopMapper.selectCount(wxMerchantShop); + List wxMerchantShops = wxMerchantShopMapper.select(wxMerchantShop); //有关联过商户必须是管理员才能删除 - if (count > 0 && !isAdmin.equals(EnumUserAdmin.ADMIN.getCode())) { - throw new MallinkException(ErrorCode.SHOP_DELETED_BY_ADMIN); + int count = wxMerchantShops.size(); + if (count > 0) { + if (!isAdmin.equals(EnumUserAdmin.ADMIN.getCode())) { + throw new MallinkException(ErrorCode.SHOP_DELETED_BY_ADMIN); + } + //更新标记 + wxShop.setIsDel(EnumDelStatus.DEL.getCode()); + wxShopMapper.updateByPrimaryKeySelective(wxShop); + //关联表 + for (int i = 0; i < count; i++) { + WxMerchantShop updateMerchantShop = wxMerchantShops.get(i); + updateMerchantShop.setIsDel(EnumDelStatus.DEL.getCode()); + wxMerchantShopMapper.updateByPrimaryKeySelective(updateMerchantShop); + } } wxShopMapper.deleteByPrimaryKey(id); } diff --git a/mallinkService/src/main/resources/mapper/WxShopMapper.xml b/mallinkService/src/main/resources/mapper/WxShopMapper.xml index eb7e550b6..345f59a03 100644 --- a/mallinkService/src/main/resources/mapper/WxShopMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxShopMapper.xml @@ -25,16 +25,18 @@ + + `id`,`tenant_id`,`shop_number`,`build_area`,`operation_area`,`building`, `floor`,`status`,`x`,`y`,`addr`,`baidu_poi`,`longitude`,`latitude`,`create_date`, - `update_date`,`img_url`,`manager`,`manager_phone`,`type`,`point_type`,`comments`,email + `update_date`,`img_url`,`manager`,`manager_phone`,`type`,`point_type`,`comments`,email,`is_del` - where 1 = 1 + where is_del=0 and `id` = #{id} @@ -132,6 +134,7 @@ and `email` = #{email} + and id in @@ -160,7 +163,7 @@ left join wx_merchant m on ms.merchant_id=m.id left join wx_mall_building b on s.building=b.id left join wx_mall_floor f on s.floor=f.id - where 1 = 1 + where is_del=0 and s.`id` = #{id} @@ -322,7 +325,7 @@ left join wx_mall_floor f on s.floor=f.id left join wx_business bus on m.business_id = bus.id left join wx_brand brand on m.brand = brand.id - where 1 = 1 + where s.is_del=0 and s.`id` = #{id} @@ -442,12 +445,12 @@ from wx_merchant_shop ms inner join wx_merchant m on ms.merchant_id=m.id inner join wx_shop s on ms.shop_id=s.id inner join wx_rent_contract c on ms.merchant_id=c.merchant_id - where ms.tenant_id=#{tenantId} and ms.shop_id=#{shopId} and ms.is_del=0 + where ms.tenant_id=#{tenantId} and ms.shop_id=#{shopId} and ms.is_del=0 and s.is_del=0 - select count(*) from wx_shop where tenant_id=#{tenantId} and shop_number=#{shopNumber} and `type`=#{type} + select count(*) from wx_shop where tenant_id=#{tenantId} and shop_number=#{shopNumber} and `type`=#{type} and + is_del=0 and id != #{id}