diff --git a/mallinkAdmin/src/main/resources/db/migration/V202007131031__GROUP__ADD_001.sql b/mallinkAdmin/src/main/resources/db/migration/V202007131031__GROUP__ADD_001.sql
index 99da1da0b..df2c697f3 100644
--- a/mallinkAdmin/src/main/resources/db/migration/V202007131031__GROUP__ADD_001.sql
+++ b/mallinkAdmin/src/main/resources/db/migration/V202007131031__GROUP__ADD_001.sql
@@ -10,4 +10,257 @@ ADD COLUMN `live_support` SMALLINT(1) DEFAULT '0' COMMENT '是否支持直播(0-
ALTER TABLE `wx_user_visit`
ADD COLUMN `parent_tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID' AFTER `tenant_id`;
-CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = `root`@`%` SQL SECURITY DEFINER VIEW `mallink`.`view_touch_user` AS select date_format(`u`.`day_date`,'%Y-%m-%d') AS `xTime`,`u`.`tenant_id` AS `tenant_id`,`u`.`parent_tenant_id` AS `parent_tenant_id`,`u`.`visit_pv` AS `pv`,`u`.`visit_uv` AS `uv`,ifnull(`o`.`couponCount`,0) AS `couponCount`,ifnull(`o`.`userCount`,0) AS `userCount`,ifnull(`v`.`verifyCount`,0) AS `verifyCount`,ifnull(`v`.`verifyUserCount`,0) AS `verifyUserCount` from ((`mallink`.`wx_user_visit` `u` left join (select `mallink`.`wx_coupon_order`.`tenant_id` AS `tenant_id`,date_format(`mallink`.`wx_coupon_order`.`create_date`,'%Y-%m-%d') AS `xTime`,count(distinct `mallink`.`wx_coupon_order`.`c_user_id`) AS `userCount`,count(0) AS `couponCount` from `mallink`.`wx_coupon_order` group by `xTime`,`mallink`.`wx_coupon_order`.`tenant_id`) `o` on(((date_format(`u`.`day_date`,'%Y-%m-%d') = `o`.`xTime`) and (`o`.`tenant_id` = `u`.`tenant_id`)))) left join (select `mallink`.`wx_coupon_order`.`tenant_id` AS `tenant_id`,date_format(`mallink`.`wx_coupon_order`.`update_date`,'%Y-%m-%d') AS `xTime`,count(0) AS `verifyCount`,count(distinct `mallink`.`wx_coupon_order`.`c_user_id`) AS `verifyUserCount` from `mallink`.`wx_coupon_order` where (`mallink`.`wx_coupon_order`.`coupon_order_status` = 1) group by `xTime`,`mallink`.`wx_coupon_order`.`tenant_id`) `v` on(((date_format(`u`.`day_date`,'%Y-%m-%d') = `v`.`xTime`) and (`v`.`tenant_id` = `u`.`tenant_id`))));
+
+CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = `root`@`%` SQL SECURITY DEFINER VIEW `mallink`.`view_touch_user` AS SELECT
+ date_format( `u`.`day_date`, '%Y-%m-%d' ) AS `xTime`,
+ `u`.`tenant_id` AS `tenant_id`,
+ `u`.`parent_tenant_id` AS `parent_tenant_id`,
+ `u`.`visit_pv` AS `pv`,
+ `u`.`visit_uv` AS `uv`,
+ ifnull( `o`.`couponCount`, 0 ) AS `couponCount`,
+ ifnull( `o`.`userCount`, 0 ) AS `userCount`,
+ ifnull( `v`.`verifyCount`, 0 ) AS `verifyCount`,
+ ifnull( `v`.`verifyUserCount`, 0 ) AS `verifyUserCount`
+FROM
+ (
+ (
+ `mallink`.`wx_user_visit` `u`
+ LEFT JOIN (
+SELECT
+ `mallink`.`wx_coupon_order`.`tenant_id` AS `tenant_id`,
+ date_format( `mallink`.`wx_coupon_order`.`create_date`, '%Y-%m-%d' ) AS `xTime`,
+ count( DISTINCT `mallink`.`wx_coupon_order`.`c_user_id` ) AS `userCount`,
+ count( 0 ) AS `couponCount`
+FROM
+ `mallink`.`wx_coupon_order`
+GROUP BY
+ `xTime`,
+ `mallink`.`wx_coupon_order`.`tenant_id`
+ ) `o` ON (
+ ( ( date_format( `u`.`day_date`, '%Y-%m-%d' ) = `o`.`xTime` ) AND ( `o`.`tenant_id` = `u`.`tenant_id` ) )
+ )
+ )
+ LEFT JOIN (
+SELECT
+ `mallink`.`wx_coupon_order`.`tenant_id` AS `tenant_id`,
+ date_format( `mallink`.`wx_coupon_order`.`update_date`, '%Y-%m-%d' ) AS `xTime`,
+ count( 0 ) AS `verifyCount`,
+ count( DISTINCT `mallink`.`wx_coupon_order`.`c_user_id` ) AS `verifyUserCount`
+FROM
+ `mallink`.`wx_coupon_order`
+WHERE
+ ( `mallink`.`wx_coupon_order`.`coupon_order_status` = 1 )
+GROUP BY
+ `xTime`,
+ `mallink`.`wx_coupon_order`.`tenant_id`
+ ) `v` ON (
+ ( ( date_format( `u`.`day_date`, '%Y-%m-%d' ) = `v`.`xTime` ) AND ( `v`.`tenant_id` = `u`.`tenant_id` ) )
+ )
+ );
+
+CREATE OR REPLACE ALGORITHM = UNDEFINED DEFINER = `root`@`%` SQL SECURITY DEFINER VIEW `mallink`.`view_coupon_data` AS SELECT
+ `baseInfo`.`createTime` AS `createTime`,
+ `baseInfo`.`couponId` AS `couponId`,
+ `baseInfo`.`couponUserCount` AS `couponUserCount`,
+ `baseInfo`.`couponCount` AS `couponCount`,
+ `baseInfo`.`verifyUserCount` AS `verifyUserCount`,
+ `baseInfo`.`verifyCount` AS `verifyCount`,
+ `c`.`type` AS `couponType`,
+ `c`.`tenant_id` AS `tenant_id`,
+ `c`.`parent_tenant_id` AS `parent_tenant_id`,
+ `c`.`title` AS `couponTitle`
+FROM
+ (
+ (
+ (
+SELECT
+ `orderInfo`.`createTime` AS `createTime`,
+ `orderInfo`.`couponId` AS `couponId`,
+ `orderInfo`.`couponUserCount` AS `couponUserCount`,
+ `orderInfo`.`couponCount` AS `couponCount`,
+ ifnull( `verifiedInfo`.`verifyUserCount`, 0 ) AS `verifyUserCount`,
+ ifnull( `verifiedInfo`.`verifyCount`, 0 ) AS `verifyCount`
+FROM
+ (
+ (
+ (
+ (
+SELECT
+ date_format( `co`.`create_date`, '%Y-%m-%d' ) AS `createTime`,
+ `co`.`coupon_id` AS `couponId`,
+ count( `co`.`c_user_id` ) AS `couponUserCount`,
+ count( `co`.`coupon_id` ) AS `couponCount`
+FROM
+ `mallink`.`wx_coupon_order` `co`
+GROUP BY
+ `createTime`,
+ `couponId`
+ )
+ ) `orderInfo`
+ LEFT JOIN (
+SELECT
+ date_format( `co`.`update_date`, '%Y-%m-%d' ) AS `updateTime`,
+ `co`.`coupon_id` AS `couponId`,
+ (
+CASE
+
+ WHEN ( `co`.`coupon_type` < 100 ) THEN
+ count( IF ( ( `co`.`coupon_order_status` = 1 ), `co`.`coupon_id`, NULL ) ) ELSE (
+ SELECT
+ count( `xcs`.`card_id` )
+ FROM
+ ( `mallink`.`wx_coupon_order` `xco` JOIN `mallink`.`wx_card_spend` `xcs` )
+ WHERE
+ (
+ ( date_format( `xcs`.`create_date`, '%Y-%m-%d' ) = `updateTime` )
+ AND ( `xco`.`coupon_id` = `co`.`coupon_id` )
+ AND ( `xco`.`id` = `xcs`.`card_id` )
+ )
+ )
+END
+ ) AS `verifyCount`,
+ (
+ CASE
+
+ WHEN ( `co`.`coupon_type` < 100 ) THEN
+ count( DISTINCT IF ( ( `co`.`coupon_order_status` = 1 ), `co`.`c_user_id`, NULL ) ) ELSE (
+ SELECT
+ count( DISTINCT `xcs`.`owner_id` )
+ FROM
+ ( `mallink`.`wx_coupon_order` `xco` JOIN `mallink`.`wx_card_spend` `xcs` )
+ WHERE
+ (
+ ( date_format( `xcs`.`create_date`, '%Y-%m-%d' ) = `updateTime` )
+ AND ( `xco`.`coupon_id` = `co`.`coupon_id` )
+ AND ( `xco`.`id` = `xcs`.`card_id` )
+ )
+ )
+ END
+ ) AS `verifyUserCount`
+ FROM
+ `mallink`.`wx_coupon_order` `co`
+ WHERE
+ (
+ CASE
+
+ WHEN ( `co`.`coupon_type` < 100 ) THEN
+ ( `co`.`coupon_order_status` = 1 ) ELSE (
+ (
+ SELECT
+ count( DISTINCT `xcs`.`owner_id` )
+ FROM
+ ( `mallink`.`wx_coupon_order` `xco` JOIN `mallink`.`wx_card_spend` `xcs` )
+ WHERE
+ (
+ ( date_format( `xcs`.`create_date`, '%Y-%m-%d' ) = date_format( `co`.`update_date`, '%Y-%m-%d' ) )
+ AND ( `xco`.`coupon_id` = `co`.`coupon_id` )
+ AND ( `xco`.`id` = `xcs`.`card_id` )
+ )
+ ) > 0
+ )
+ END
+ )
+ GROUP BY
+ `updateTime`,
+ `couponId`
+ ) `verifiedInfo` ON ( ( ( `orderInfo`.`createTime` = `verifiedInfo`.`updateTime` ) AND ( `orderInfo`.`couponId` = `verifiedInfo`.`couponId` ) ) )
+ )
+ LEFT JOIN `mallink`.`wx_coupon` `c` ON ( ( `c`.`id` = `orderInfo`.`couponId` ) )
+ )
+ ) UNION
+SELECT
+ `verifiedInfo`.`updateTime` AS `createTime`,
+ `verifiedInfo`.`couponId` AS `couponId`,
+ ifnull( `orderInfo`.`couponUserCount`, 0 ) AS `couponUserCount`,
+ ifnull( `orderInfo`.`couponCount`, 0 ) AS `couponCount`,
+ `verifiedInfo`.`verifyUserCount` AS `verifyUserCount`,
+ `verifiedInfo`.`verifyCount` AS `verifyCount`
+FROM
+ (
+ (
+ (
+ SELECT
+ date_format( `co`.`update_date`, '%Y-%m-%d' ) AS `updateTime`,
+ `co`.`coupon_id` AS `couponId`,
+ (
+ CASE
+
+ WHEN ( `co`.`coupon_type` < 100 ) THEN
+ count( IF ( ( `co`.`coupon_order_status` = 1 ), `co`.`coupon_id`, NULL ) ) ELSE (
+ SELECT
+ count( `xcs`.`card_id` )
+ FROM
+ ( `mallink`.`wx_coupon_order` `xco` JOIN `mallink`.`wx_card_spend` `xcs` )
+ WHERE
+ (
+ ( date_format( `xcs`.`create_date`, '%Y-%m-%d' ) = `updateTime` )
+ AND ( `xco`.`coupon_id` = `co`.`coupon_id` )
+ AND ( `xco`.`id` = `xcs`.`card_id` )
+ )
+ )
+ END
+ ) AS `verifyCount`,
+ (
+ CASE
+
+ WHEN ( `co`.`coupon_type` < 100 ) THEN
+ count( DISTINCT IF ( ( `co`.`coupon_order_status` = 1 ), `co`.`c_user_id`, NULL ) ) ELSE (
+ SELECT
+ count( DISTINCT `xcs`.`owner_id` )
+ FROM
+ ( `mallink`.`wx_coupon_order` `xco` JOIN `mallink`.`wx_card_spend` `xcs` )
+ WHERE
+ (
+ ( date_format( `xcs`.`create_date`, '%Y-%m-%d' ) = `updateTime` )
+ AND ( `xco`.`coupon_id` = `co`.`coupon_id` )
+ AND ( `xco`.`id` = `xcs`.`card_id` )
+ )
+ )
+ END
+ ) AS `verifyUserCount`
+ FROM
+ `mallink`.`wx_coupon_order` `co`
+ WHERE
+ (
+ CASE
+
+ WHEN ( `co`.`coupon_type` < 100 ) THEN
+ ( `co`.`coupon_order_status` = 1 ) ELSE (
+ (
+ SELECT
+ count( DISTINCT `xcs`.`owner_id` )
+ FROM
+ ( `mallink`.`wx_coupon_order` `xco` JOIN `mallink`.`wx_card_spend` `xcs` )
+ WHERE
+ (
+ ( date_format( `xcs`.`create_date`, '%Y-%m-%d' ) = date_format( `co`.`update_date`, '%Y-%m-%d' ) )
+ AND ( `xco`.`coupon_id` = `co`.`coupon_id` )
+ AND ( `xco`.`id` = `xcs`.`card_id` )
+ )
+ ) > 0
+ )
+ END
+ )
+ GROUP BY
+ `updateTime`,
+ `couponId`
+ )
+ ) `verifiedInfo`
+ LEFT JOIN (
+ SELECT
+ date_format( `co`.`create_date`, '%Y-%m-%d' ) AS `createTime`,
+ `co`.`coupon_id` AS `couponId`,
+ count( `co`.`c_user_id` ) AS `couponUserCount`,
+ count( `co`.`coupon_id` ) AS `couponCount`
+ FROM
+ `mallink`.`wx_coupon_order` `co`
+ GROUP BY
+ `createTime`,
+ `couponId`
+ ) `orderInfo` ON ( ( ( `orderInfo`.`createTime` = `verifiedInfo`.`updateTime` ) AND ( `orderInfo`.`couponId` = `verifiedInfo`.`couponId` ) ) )
+ )
+ ) `baseInfo`
+ LEFT JOIN `mallink`.`wx_coupon` `c` ON ( ( `c`.`id` = `baseInfo`.`couponId` ) )
+ )
+ORDER BY
+`baseInfo`.`createTime` DESC;
\ No newline at end of file
diff --git a/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml b/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml
index 29d4e5ce2..6d535ee39 100644
--- a/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml
+++ b/mallinkService/src/main/resources/mapper/WxBillDailyMapper.xml
@@ -109,12 +109,25 @@
update wx_bill_daily set status=#{notPaid},expired_day=DATEDIFF(now(),receive_date)
- where tenant_id=#{tenantId} and status!=#{paid} and DATEDIFF(now(),receive_date)>0
+ where status!=#{paid}
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
+ and DATEDIFF(now(),receive_date)>0
- update wx_bill_daily set status=#{waitPay} where tenant_id=#{tenantId}
- and status!=#{paid} and DATEDIFF(now(),receive_date) <=0
+ update wx_bill_daily set status=#{waitPay} where status!=#{paid}
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
+ and DATEDIFF(now(),receive_date) <=0
diff --git a/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml b/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml
index 64863fba5..e28bd518c 100644
--- a/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml
+++ b/mallinkService/src/main/resources/mapper/WxBillRentMapper.xml
@@ -319,7 +319,15 @@
- update wx_bill_rent set service_charge_pay=round(receive_pay*#{serviceChargeRate}/10000),owe=receive_pay + service_charge_pay + ifnull(late_pay_price,0) - pay where tenant_id=#{tenantId} and service_charge_pay=0 and status in(1,2,4)
+ update wx_bill_rent set service_charge_pay=round(receive_pay*#{serviceChargeRate}/10000),owe=receive_pay + service_charge_pay + ifnull(late_pay_price,0) - pay
+ where service_charge_pay=0
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
+ and status in(1,2,4)
diff --git a/mallinkService/src/main/resources/mapper/WxBusinessMapper.xml b/mallinkService/src/main/resources/mapper/WxBusinessMapper.xml
index 0eec6cebc..dfe9d0b84 100644
--- a/mallinkService/src/main/resources/mapper/WxBusinessMapper.xml
+++ b/mallinkService/src/main/resources/mapper/WxBusinessMapper.xml
@@ -100,30 +100,71 @@
round(
(select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
from wx_merchant m
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
+ left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id
+
+ and m.`tenant_id` = #{tenantId}
+
+
+ and m.`parent_tenant_id` = #{parentTenantId}
+
+ and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
/100,2) volume,
round(
(select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
from wx_merchant m
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
+ left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id
+
+ and m.`tenant_id` = #{tenantId}
+
+
+ and m.`parent_tenant_id` = #{parentTenantId}
+
+ and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
/
(select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
from wx_merchant m
left join wx_merchant_shop mtd on mtd.merchant_id = m.id
left join wx_shop ws on(mtd.shop_id = ws.id)
- where m.business_id = b.id and m.tenant_id=#{tenantId} and m.status = 1 and m.is_del = 0 )
+ where m.business_id = b.id and m.status = 1 and m.is_del = 0
+
+ and m.`tenant_id` = #{tenantId}
+
+
+ and m.`parent_tenant_id` = #{parentTenantId}
+
+ )
/100,2) sale,
- (select ifnull(sum(rent_area),0) from wx_rent_contract where tenant_id=#{tenantId} and business_id=b.id and status in (2,3,4)) area,
-
+ (select ifnull(sum(rent_area),0) from wx_rent_contract where business_id=b.id
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
+ and status in (2,3,4)) area,
round(
(select if(sum(mtd.trade_amt) is null,0,sum(mtd.trade_amt))
from wx_merchant m
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 ) /
+ left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id
+
+ and m.`tenant_id` = #{tenantId}
+
+
+ and m.`parent_tenant_id` = #{parentTenantId}
+
+ and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 ) /
(select sum(mtd.trade_count)
from wx_merchant m
- left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id and m.tenant_id=#{tenantId} and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
+ left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id where m.business_id = b.id
+
+ and m.`tenant_id` = #{tenantId}
+
+
+ and m.`parent_tenant_id` = #{parentTenantId}
+
+ and STR_TO_DATE(mtd.report_date,'%Y-%m-%d') between #{startdate} and #{enddate} and m.status = 1 and m.is_del = 0 )
/100,2) comPrice
from wx_business b
@@ -137,7 +178,12 @@
from wx_merchant m
left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
where m.business_id = #{id}
- and m.tenant_id=#{tenantId}
+
+ and m.`tenant_id` = #{tenantId}
+
+
+ and m.`parent_tenant_id` = #{parentTenantId}
+
and mtd.report_date between #{startdate} and #{enddate}
and m.status = 1 and m.is_del = 0 and m.id = mm.id)
/
@@ -146,7 +192,12 @@
left join wx_merchant_shop mtd on mtd.merchant_id = m.id
left join wx_shop ws on(mtd.shop_id = ws.id)
where m.status = 1 and m.is_del = 0 and m.business_id = #{id}
- and m.tenant_id=#{tenantId}
+
+ and m.`tenant_id` = #{tenantId}
+
+
+ and m.`parent_tenant_id` = #{parentTenantId}
+
and m.id = mm.id)
/100,2) sale,
@@ -157,7 +208,12 @@
from wx_merchant m
left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
where m.business_id = #{id}
- and m.tenant_id=#{tenantId}
+
+ and m.`tenant_id` = #{tenantId}
+
+
+ and m.`parent_tenant_id` = #{parentTenantId}
+
and mtd.report_date between #{startdate} and #{enddate}
and m.status = 1 and m.is_del = 0 and m.id = mm.id)/
(select if(sum(ws.operation_area) is null,0,sum(ws.operation_area))
@@ -165,7 +221,12 @@
left join wx_merchant_shop mtd on mtd.merchant_id = m.id
left join wx_shop ws on(mtd.shop_id = ws.id)
where m.status = 1 and m.is_del = 0 and m.business_id = #{id}
- and m.tenant_id=#{tenantId}
+
+ and m.`tenant_id` = #{tenantId}
+
+
+ and m.`parent_tenant_id` = #{parentTenantId}
+
and m.id = mm.id)/100,2)
/
round(
@@ -173,7 +234,12 @@
from wx_merchant m
left join wx_merchant_trade_daily mtd on mtd.merchant_id = m.id
where m.business_id = #{id}
- and m.tenant_id=#{tenantId}
+
+ and m.`tenant_id` = #{tenantId}
+
+
+ and m.`parent_tenant_id` = #{parentTenantId}
+
and mtd.report_date between #{startdate} and #{enddate}
and m.status = 1 and m.is_del = 0 )
/
@@ -181,7 +247,14 @@
from wx_merchant m
left join wx_merchant_shop mtd on mtd.merchant_id = m.id
left join wx_shop ws on(mtd.shop_id = ws.id)
- where m.business_id = #{id} and m.tenant_id=#{tenantId} and m.status = 1 and m.is_del = 0 )
+ where m.business_id = #{id}
+
+ and m.`tenant_id` = #{tenantId}
+
+
+ and m.`parent_tenant_id` = #{parentTenantId}
+
+ and m.status = 1 and m.is_del = 0 )
/100,2)
*100,2) devoteRate
@@ -190,7 +263,13 @@
left join wx_merchant_trade_daily mtd on mtd.merchant_id = mm.id
left join wx_merchant_shop wmt on wmt.merchant_id = mm.id
left join wx_shop ws on(wmt.shop_id = ws.id)
- where mm.business_id=#{id} and mm.tenant_id=#{tenantId}
+ where mm.business_id=#{id}
+
+ and mm.`tenant_id` = #{tenantId}
+
+
+ and mm.`parent_tenant_id` = #{parentTenantId}
+
and mm.status = 1 and mm.is_del = 0
and mtd.report_date between #{startdate} and #{enddate}
group by mm.id
diff --git a/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml
index 67f32dffe..b1e2b9345 100644
--- a/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml
+++ b/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml
@@ -65,7 +65,7 @@
update wx_c_user_tags
set user_id=#{newUserId}
- where tenant_id=#{tenantId}
+ where tenant_id = #{tenantId}
and user_id = #{userId}
diff --git a/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml b/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml
index 2752346b4..4b56d1176 100644
--- a/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml
+++ b/mallinkService/src/main/resources/mapper/WxCarCmdLogMapper.xml
@@ -141,7 +141,13 @@
@@ -206,20 +211,26 @@
diff --git a/mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml
index 2d03d6d2f..0ffe0e054 100644
--- a/mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml
+++ b/mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml
@@ -152,7 +152,14 @@
resultMap="CouponCountInfoMap">
select cp.coupon_id,c.title,c.price,cp.coupon_count from
(select count(*) as coupon_count,coupon_id from wx_coupon_password
- where tenant_id=#{tenantId} and status=0 group by coupon_id) cp
+ where status=0
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
+ group by coupon_id) cp
inner join wx_coupon c on cp.coupon_id = c.id
where c.status=0 and c.put_apply_status in(0,2)
@@ -180,7 +187,13 @@
update wx_coupon_password
set expire_date=#{expireDate}
- where tenant_id=#{tenantId} and coupon_id=#{couponId} and status=1
+ where coupon_id=#{couponId} and status=1
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
diff --git a/mallinkService/src/main/resources/mapper/WxLevelConfigMapper.xml b/mallinkService/src/main/resources/mapper/WxLevelConfigMapper.xml
index 19558a0ca..3655d41c1 100644
--- a/mallinkService/src/main/resources/mapper/WxLevelConfigMapper.xml
+++ b/mallinkService/src/main/resources/mapper/WxLevelConfigMapper.xml
@@ -113,10 +113,10 @@
diff --git a/mallinkService/src/main/resources/mapper/WxMerchantMapper.xml b/mallinkService/src/main/resources/mapper/WxMerchantMapper.xml
index d42bb3d13..0ac6e6dca 100644
--- a/mallinkService/src/main/resources/mapper/WxMerchantMapper.xml
+++ b/mallinkService/src/main/resources/mapper/WxMerchantMapper.xml
@@ -128,8 +128,14 @@
and id not in(
- select merchant_id from wx_rent_contract where tenant_id=#{tenantId} and rent_shop_type=1 and merchant_id is
- not null and status in(1,2,3,4)
+ select merchant_id from wx_rent_contract where rent_shop_type=1
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
+ and merchant_id is not null and status in(1,2,3,4)
)
@@ -145,7 +151,13 @@
select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms
inner join wx_merchant m on ms.merchant_id = m.id
inner join wx_shop s on s.id=ms.shop_id
- where m.tenant_id=#{tenantId} and s.is_del=0
+ where s.is_del=0
+
+ and m.`tenant_id` = #{tenantId}
+
+
+ and m.`parent_tenant_id` = #{parentTenantId}
+
and m.business_id in (${businessForRule})
@@ -168,8 +180,15 @@
- update wx_rent_contract set status=1 where tenant_id=#{tenantId} and status=2 and merchant_id is null
+ update wx_rent_contract set status=1 where status=2 and merchant_id is null
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
select id from wx_rent_contract where shop_id in (
- select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE tenant_id = #{tenantId} and status in(2,3,4)
- )s) and status in(0,1) and status!=7 and tenant_id=#{tenantId} and apply_status=1
+ select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE status in(2,3,4)
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
+ )s) and status in(0,1) and status!=7 and apply_status=1
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
@@ -328,7 +417,14 @@
- select count(*) from wx_rent_contract where tenant_id=#{tenantId} and json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"')) and status in (2,3,4)
+ select count(*) from wx_rent_contract where 1=1
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
+ and json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"')) and status in (2,3,4)
and id!=#{id}
@@ -372,13 +468,23 @@
select count(*) from (
- select * from wx_rent_contract where tenant_id=#{tenantId}
- and contract_number=#{contractNumber}
+ select * from wx_rent_contract where contract_number=#{contractNumber}
and status not in(5,6,7)
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
union
- select * from wx_rent_contract where tenant_id=#{tenantId}
- and contract_number=#{contractNumber}
+ select * from wx_rent_contract where contract_number=#{contractNumber}
and apply_status in(1,2)
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
) r
@@ -426,7 +532,12 @@
from wx_rent_contract rc left join wx_property_contract pc on rc.id=pc.rent_contract_id
left join wx_shop s on rc.shop_id=s.id
- rc.tenant_id=#{tenantId}
+
+ and rc.`tenant_id` = #{tenantId}
+
+
+ and rc.`parent_tenant_id` = #{parentTenantId}
+ and rc.`merchant_name` like
concat('%',#{merchantName},'%')
@@ -451,13 +562,33 @@
and rc.`id` in
- select id from wx_rent_contract where tenant_id=#{tenantId} and
- json_unquote(json_extract(json_extract(rent_info,'$[*].shopId'),concat('$[',#{idx},']'))) in(select
- id from wx_shop where tenant_id=#{tenantId} and floor in (${floorForRule}))
+ select id from wx_rent_contract where 1=1
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
+ and json_unquote(json_extract(json_extract(rent_info,'$[*].shopId'),concat('$[',#{idx},']'))) in(select
+ id from wx_shop where 1=1
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
+ and floor in (${floorForRule}))
- and rc.shop_id in (select id from wx_shop where tenant_id=#{tenantId} and floor in (${floorForRule}))
+ and rc.shop_id in (select id from wx_shop where 1=1
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
+ and floor in (${floorForRule}))
diff --git a/mallinkService/src/main/resources/mapper/WxShopMapper.xml b/mallinkService/src/main/resources/mapper/WxShopMapper.xml
index a7a651672..c2c8c2973 100644
--- a/mallinkService/src/main/resources/mapper/WxShopMapper.xml
+++ b/mallinkService/src/main/resources/mapper/WxShopMapper.xml
@@ -488,7 +488,12 @@
left join wx_mall_building b on s.building=b.id
left join wx_mall_floor f on s.floor=f.id
where s.is_del=0 and ms.is_del=0
- and s.tenant_id=#{tenantId}
+
+ and s.`tenant_id` = #{tenantId}
+
+
+ and s.`parent_tenant_id` = #{parentTenantId}
+
and s.`status` = #{status}
@@ -529,8 +534,14 @@
- select count(*) from wx_shop where tenant_id=#{tenantId} and shop_number=#{shopNumber} and `type`=#{type} and
- is_del=0
+ select count(*) from wx_shop where shop_number=#{shopNumber} and `type`=#{type}
+ and is_del=0
+
+ and `tenant_id` = #{tenantId}
+
+
+ and `parent_tenant_id` = #{parentTenantId}
+
and id != #{id}