| @@ -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; | |||
| @@ -109,12 +109,25 @@ | |||
| <update id="updateNotPaidStatus" parameterType="hashmap"> | |||
| 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} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and DATEDIFF(now(),receive_date)>0 | |||
| </update> | |||
| <update id="updateWaitPayStatus" parameterType="hashmap"> | |||
| 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} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and DATEDIFF(now(),receive_date) <=0 | |||
| </update> | |||
| @@ -319,7 +319,15 @@ | |||
| </update> | |||
| <update id="updateServiceCharge" parameterType="com.iformall.domain.po.WxPayAccountBill"> | |||
| 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and status in(1,2,4) | |||
| </update> | |||
| <update id="updateOwe"> | |||
| @@ -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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and m.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and m.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and m.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| ) | |||
| /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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and m.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and m.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| 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} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and m.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| 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} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and m.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| 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} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and m.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| 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} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and m.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| 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} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and m.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| 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} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and m.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| 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} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and mm.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and mm.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and mm.status = 1 and mm.is_del = 0 | |||
| and mtd.report_date between #{startdate} and #{enddate} | |||
| group by mm.id | |||
| @@ -65,7 +65,7 @@ | |||
| <update id="updateNewId" parameterType="com.iformall.domain.vo.CUserTagNewIdVo"> | |||
| update wx_c_user_tags | |||
| set user_id=#{newUserId} | |||
| where tenant_id=#{tenantId} | |||
| where tenant_id = #{tenantId} | |||
| and user_id = #{userId} | |||
| </update> | |||
| @@ -141,7 +141,13 @@ | |||
| <select id="queryPlateNumberList" parameterType="hashmap" resultType="hashmap"> | |||
| select json_unquote(JSON_EXTRACT(cmd_json,'$.plateNumber')) plateNumber from wx_car_cmd_log where tenant_id=#{tenantId} | |||
| select json_unquote(JSON_EXTRACT(cmd_json,'$.plateNumber')) plateNumber from wx_car_cmd_log where 1=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != startdate and null != enddate"> | |||
| and create_date BETWEEN #{startdate} and #{enddate} | |||
| </if> | |||
| @@ -102,7 +102,13 @@ | |||
| (select Count(*) from wx_coupon_action_log c | |||
| where DATE_FORMAT(create_time,'%m/%d')=xTime | |||
| and c.channel_type=4 | |||
| and tenant_id=#{tenantId}) as microPaySendCount, | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| ) as microPaySendCount, | |||
| (select Count(*) from wx_coupon_action_log c | |||
| where DATE_FORMAT(create_time,'%m/%d')=xTime | |||
| and c.channel_type=5 | |||
| @@ -143,7 +143,12 @@ | |||
| `update_date` = #{updateDate}, | |||
| `verify_type` = #{verifyType} | |||
| where 1=1 | |||
| and `tenant_id`=#{tenantId} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and id=#{id} | |||
| </update> | |||
| @@ -206,20 +211,26 @@ | |||
| <select id="couponDataList" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap"> | |||
| SELECT createTime,couponId,couponCount,couponUserCount,verifyCount,verifyUserCount | |||
| from view_coupon_data | |||
| where view_coupon_data.tenant_id=#{tenantId} | |||
| where 1=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test="startTime != null"> | |||
| and view_coupon_data.createTime >= DATE_FORMAT(#{startTime},'%Y-%m-%d') | |||
| and createTime >= DATE_FORMAT(#{startTime},'%Y-%m-%d') | |||
| </if> | |||
| <if test="endTime != null"> | |||
| and view_coupon_data.createTime <= DATE_FORMAT(#{endTime},'%Y-%m-%d') | |||
| </if> | |||
| <if test="couponType != null"> | |||
| and view_coupon_data.couponType = #{couponType} | |||
| and couponType = #{couponType} | |||
| </if> | |||
| <if test="couponTitle != null"> | |||
| and view_coupon_data.couponTitle like concat('%', #{couponTitle},'%') | |||
| and couponTitle like concat('%', #{couponTitle},'%') | |||
| </if> | |||
| order by view_coupon_data.createTime desc | |||
| order by createTime desc | |||
| </select> | |||
| @@ -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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| 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) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| @@ -180,7 +187,13 @@ | |||
| <update id="updatePostpone"> | |||
| 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| </update> | |||
| </mapper> | |||
| @@ -113,10 +113,10 @@ | |||
| </delete> | |||
| <select id="getLevel" parameterType="com.iformall.domain.po.WxLevelConfig" resultType="String"> | |||
| SELECT `level` FROM `wx_level_config` where tenant_id=#{tenantId} and points <= #{points} ORDER BY points desc LIMIT 1 | |||
| SELECT `level` FROM `wx_level_config` where tenant_id = #{tenantId} and points <= #{points} ORDER BY points desc LIMIT 1 | |||
| </select> | |||
| <select id="getScale" parameterType="com.iformall.domain.po.WxLevelConfig" resultType="java.lang.Integer"> | |||
| select `scale` from wx_level_config where #{points} >=points and tenant_id=#{tenantId} order by points desc limit 1 ; | |||
| select `scale` from wx_level_config where #{points} >=points and tenant_id = #{tenantId} order by points desc limit 1 ; | |||
| </select> | |||
| </mapper> | |||
| @@ -128,8 +128,14 @@ | |||
| </if> | |||
| <if test=" null != rentShopType "> | |||
| 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and merchant_id is not null and status in(1,2,3,4) | |||
| ) | |||
| </if> | |||
| @@ -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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and m.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != businessForRule and '' != businessForRule "> | |||
| and m.business_id in (${businessForRule}) | |||
| </if> | |||
| @@ -168,8 +180,15 @@ | |||
| <select id="findListVo" parameterType="com.iformall.domain.po.WxMerchant" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumnsVo"/> | |||
| from wx_merchant m left join (select merchant_id,rental_start_date,rental_end_date from wx_rent_contract where | |||
| tenant_id=#{tenantId} and status in(2,3,4)) r | |||
| from wx_merchant m left join (select merchant_id,rental_start_date,rental_end_date from wx_rent_contract | |||
| where 1=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and status in(2,3,4)) r | |||
| on m.id=r.merchant_id | |||
| <include refid="dynamicWhereConditionsVo"/> | |||
| @@ -181,7 +200,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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and m.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and m.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != businessForRule and '' != businessForRule "> | |||
| and m.business_id in (${businessForRule}) | |||
| </if> | |||
| @@ -267,8 +292,14 @@ | |||
| </if> | |||
| <if test=" null != rentShopType "> | |||
| and m.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,8) | |||
| select merchant_id from wx_rent_contract where rent_shop_type=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and merchant_id is not null and status in(1,2,3,4,8) | |||
| ) | |||
| </if> | |||
| <if test=" null != ids "> | |||
| @@ -490,9 +521,11 @@ | |||
| left join wx_coupon co on(o.`coupon_id`=co.id) | |||
| left join wx_c_user_basic_info cb on o.c_user_id=cb.id | |||
| where o.coupon_order_status=1 | |||
| and o.tenant_id=#{tenantId} | |||
| <if test=" null != parentTenantId"> | |||
| and o.parent_tenant_id = #{parentTenantId} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and o.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and o.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != id "> | |||
| and o.b_user_id in( | |||
| @@ -141,11 +141,11 @@ | |||
| select pso.*,m.`name` merchant_name from wx_profit_sharing_order pso | |||
| left join wx_merchant m on pso.merchant_id=m.id | |||
| <where> | |||
| <if test="tenantId!=null"> | |||
| and pso.tenant_id =#{tenantId} | |||
| </if> | |||
| <if test="parentTenantId!=null"> | |||
| and pso.parent_tenant_id =#{parentTenantId} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and pso.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and pso.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test="id!=null"> | |||
| and pso.id =#{id} | |||
| @@ -173,12 +173,12 @@ | |||
| select count(*) merchantCount from ( | |||
| select distinct merchant_id from wx_profit_sharing_order | |||
| <where> | |||
| <if test="tenantId!=null"> | |||
| and tenant_id =#{tenantId} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test="parentTenantId!=null"> | |||
| and parent_tenant_id =#{parentTenantId} | |||
| </if> | |||
| <if test="startdate!=null and enddate!=null"> | |||
| and create_time between #{startdate} and #{enddate} | |||
| </if> | |||
| @@ -189,12 +189,12 @@ | |||
| <select id="queryOrderForSum" resultType="Long" parameterType="hashmap"> | |||
| select ifnull(sum(pay_amount),0) payment from wx_profit_sharing_order | |||
| <where> | |||
| <if test="tenantId!=null"> | |||
| and tenant_id =#{tenantId} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test="parentTenantId!=null"> | |||
| and parent_tenant_id =#{parentTenantId} | |||
| </if> | |||
| <if test="startdate!=null and enddate!=null"> | |||
| and create_time between #{startdate} and #{enddate} | |||
| </if> | |||
| @@ -161,13 +161,33 @@ | |||
| <if test="null != rentShopType and 1 == rentShopType and null != floorForRule and '' != floorForRule "> | |||
| and rc.`id` in | |||
| <foreach collection="tempShop" index="idx" separator=" union all " open="(" close=")"> | |||
| select id from wx_property_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_property_contract where 1=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and json_unquote(json_extract(json_extract(rent_info,'$[*].shopId'),concat('$[',#{idx},']'))) in(select | |||
| id from wx_shop where 1=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and floor in (${floorForRule})) | |||
| </foreach> | |||
| </if> | |||
| <if test="null != rentShopType and 2 == rentShopType and null != floorForRule and '' != 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and floor in (${floorForRule})) | |||
| </if> | |||
| </where> | |||
| @@ -177,54 +197,129 @@ | |||
| <select id="queryRentContractWaitSignStatus" resultType="int" | |||
| parameterType="com.iformall.domain.po.WxPropertyContract"> | |||
| select count(id) from wx_property_contract where tenant_id=#{tenantId} and status=#{status} | |||
| select count(id) from wx_property_contract where status=#{status} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if> | |||
| </select> | |||
| <select id="queryRentContractEndSoonStatus" resultType="int" | |||
| parameterType="com.iformall.domain.po.WxPropertyContract"> | |||
| select count(id) from wx_property_contract where tenant_id=#{tenantId} and status=4 | |||
| select count(id) from wx_property_contract where status=4 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if> | |||
| </select> | |||
| <select id="queryRentContractPaidStatus" resultType="int" parameterType="com.iformall.domain.po.WxPropertyContract"> | |||
| select count(id) from wx_property_contract where tenant_id=#{tenantId} and status in (2,3,4) | |||
| select count(id) from wx_property_contract where status in (2,3,4) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if> | |||
| </select> | |||
| <select id="queryRentContractEndStatus" resultType="int" parameterType="com.iformall.domain.po.WxPropertyContract"> | |||
| select count(id) from wx_property_contract where tenant_id=#{tenantId} | |||
| and status!=1 and status!=6 and status!=7 and rental_end_date <now() | |||
| select count(id) from wx_property_contract where status!=1 and status!=6 and status!=7 and rental_end_date <now() | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if> | |||
| </select> | |||
| <update id="updateRentContractEndSoonStatus" parameterType="com.iformall.domain.po.WxPropertyContract"> | |||
| update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=1 and status!=5 and status!=6 and status!=7 and DATEDIFF(rental_end_date,now()) <= 30 and rental_end_date > now() | |||
| update wx_property_contract set status=#{status} where status!=1 and status!=5 and status!=6 and status!=7 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and DATEDIFF(rental_end_date,now()) <= 30 and rental_end_date > now() | |||
| </update> | |||
| <update id="updateRentContractPaidStatus" parameterType="com.iformall.domain.po.WxPropertyContract"> | |||
| update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=1 and status!=5 and status!=6 and status!=7 and rental_start_date <= now() and rental_end_date >= now() | |||
| update wx_property_contract set status=#{status} where status!=1 and status!=5 and status!=6 and status!=7 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and rental_start_date <= now() and rental_end_date >= now() | |||
| </update> | |||
| <update id="updateRentContractEndStatus" parameterType="com.iformall.domain.po.WxPropertyContract"> | |||
| update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=1 and status!=5 and status!=6 and status!=7 and rental_end_date <now() | |||
| update wx_property_contract set status=#{status} where status!=1 and status!=5 and status!=6 and status!=7 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and rental_end_date <now() | |||
| </update> | |||
| <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxPropertyContract"> | |||
| update wx_property_contract set status=#{status} where tenant_id=#{tenantId} and status!=7 and merchant_id is null | |||
| update wx_property_contract set status=#{status} where status!=7 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and merchant_id is null | |||
| </update> | |||
| <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxPropertyContract"> | |||
| update wx_property_contract set status=#{status} where shop_id in ( | |||
| select s.shop_id from (SELECT shop_id FROM wx_property_contract WHERE tenant_id = #{tenantId} and merchant_id is not null and status!=6 | |||
| )s) and merchant_id is null and tenant_id=#{tenantId} | |||
| select s.shop_id from (SELECT shop_id FROM wx_property_contract WHERE merchant_id is not null and status!=6 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| )s) and merchant_id is null | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| </update> | |||
| <select id="getRentContractListByShop" parameterType="hashmap" resultType="com.iformall.domain.po.WxRentContract"> | |||
| select rc.* from wx_rent_contract rc | |||
| where rc.status not in(0,1,5,6,7,8) and rc.tenant_id=#{tenantId} | |||
| where rc.status not in(0,1,5,6,7,8) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and rc.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and rc.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and rc.id not in (select pc.rent_contract_id from ( | |||
| select rent_contract_id from wx_property_contract where status not in(5,6,7) and tenant_id=#{tenantId} | |||
| select rent_contract_id from wx_property_contract where status not in(5,6,7) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| ) pc) | |||
| <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if> | |||
| </select> | |||
| @@ -232,9 +327,21 @@ | |||
| <select id="getRentContractListByPoint" parameterType="hashmap" resultType="com.iformall.domain.po.WxRentContract"> | |||
| select rc.*,s.shop_number from wx_rent_contract rc | |||
| inner join wx_shop s on rc.shop_id=s.id | |||
| where rc.status not in(0,1,5,6,7,8) and rc.tenant_id=#{tenantId} | |||
| where rc.status not in(0,1,5,6,7,8) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and rc.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and rc.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and rc.id not in (select pc.rent_contract_id from ( | |||
| select rent_contract_id from wx_property_contract where status not in(5,6,7) and tenant_id=#{tenantId} | |||
| select rent_contract_id from wx_property_contract where status not in(5,6,7) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| ) pc) | |||
| <if test=" null != rentShopType ">and rent_shop_type = #{rentShopType}</if> | |||
| </select> | |||
| @@ -275,9 +382,21 @@ | |||
| <select id="getMerchantList" parameterType="com.iformall.domain.po.WxPropertyContract" resultType="com.iformall.domain.po.WxRentContract"> | |||
| select rc.* from wx_rent_contract rc | |||
| where rc.status in(3,9) and rc.tenant_id=#{tenantId} | |||
| where rc.status in(3,9) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and rc.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and rc.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and rc.id not in (select pc.rent_contract_id from ( | |||
| select rent_contract_id from wx_property_contract where tenant_id=#{tenantId} | |||
| select rent_contract_id from wx_property_contract where 1=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| ) pc) | |||
| and rent_shop_type = 1 | |||
| </select> | |||
| @@ -161,7 +161,12 @@ | |||
| left join wx_mall_building b on s.building=b.id | |||
| left join wx_brand br on rc.brand=br.id | |||
| <where> | |||
| rc.tenant_id=#{tenantId} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and rc.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and rc.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like concat('%',#{merchantName},'%')</if> | |||
| <if test=" null != shopNumber and shopNumber!='' and null != rentShopType and rentShopType==1"> | |||
| and json_extract(rc.rent_info,'$[*].shopNumber') like concat('%',#{shopNumber},'%') | |||
| @@ -183,13 +188,33 @@ | |||
| <if test="null != rentShopType and 1 == rentShopType and null != floorForRule and '' != floorForRule "> | |||
| and rc.`id` in | |||
| <foreach collection="tempShop" index="idx" separator=" union all " open="(" close=")"> | |||
| 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and json_unquote(json_extract(json_extract(rent_info,'$[*].shopId'),concat('$[',#{idx},']'))) in(select | |||
| id from wx_shop where 1=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and floor in (${floorForRule})) | |||
| </foreach> | |||
| </if> | |||
| <if test="null != rentShopType and 2 == rentShopType and null != floorForRule and '' != 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and floor in (${floorForRule})) | |||
| </if> | |||
| <if test=" null != merchantId">and rc.`merchant_id` = #{merchantId}</if> | |||
| @@ -247,19 +272,47 @@ | |||
| </select> | |||
| <update id="updateRentContractEndSoonStatus" parameterType="com.iformall.domain.po.WxRentContract"> | |||
| update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and status not in(0,1,5,6,7,8) and DATEDIFF(rental_end_date,now()) <= 30 and rental_end_date > now() | |||
| update wx_rent_contract set status=#{status} where status not in(0,1,5,6,7,8) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and DATEDIFF(rental_end_date,now()) <= 30 and rental_end_date > now() | |||
| </update> | |||
| <update id="updateRentContractPaidStatus" parameterType="com.iformall.domain.po.WxRentContract"> | |||
| update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and status not in(0,1,5,6,7,8) and rental_start_date <= now() and rental_end_date >= now() | |||
| update wx_rent_contract set status=#{status} where status not in(0,1,5,6,7,8) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and rental_start_date <= now() and rental_end_date >= now() | |||
| </update> | |||
| <update id="updateRentContractEndStatus" parameterType="com.iformall.domain.po.WxRentContract"> | |||
| update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and status not in(0,1,5,6,7,8) and rental_end_date <now() | |||
| update wx_rent_contract set status=#{status} where status not in(0,1,5,6,7,8) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and rental_end_date <now() | |||
| </update> | |||
| <update id="updateRentWaitSignStatus" parameterType="com.iformall.domain.po.WxRentContract"> | |||
| update wx_rent_contract set status=#{status} where tenant_id=#{tenantId} and status not in(0,5,6,7) and merchant_id is null | |||
| update wx_rent_contract set status=#{status} where status not in(0,5,6,7) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and merchant_id is null | |||
| </update> | |||
| <update id="updateApplyStatus" parameterType="com.iformall.domain.po.WxRentContract"> | |||
| @@ -276,8 +329,20 @@ | |||
| <update id="updateRentInvalidStatus" parameterType="com.iformall.domain.po.WxRentContract"> | |||
| update wx_rent_contract set status=#{status} 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 rent_shop_type=2 | |||
| select s.shop_id from (SELECT shop_id FROM wx_rent_contract WHERE status in(2,3,4) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| )s) and status in(0,1) and status!=7 and rent_shop_type=2 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| </update> | |||
| <select id="getRentContractList" parameterType="com.iformall.domain.po.WxRentContract" | |||
| @@ -290,7 +355,13 @@ | |||
| left join wx_merchant_shop ms on s.id=ms.shop_id | |||
| where ms.is_del=0) s | |||
| inner join (select * from wx_rent_contract where status in(2,3,4)) rc on s.merchant_id=rc.merchant_id | |||
| where rc.tenant_id=#{tenantId} | |||
| where 1=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and rc.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and rc.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != shopNumber and ''!=shopNumber"> | |||
| and s.shop_number like concat('%', #{shopNumber},'%') | |||
| </if> | |||
| @@ -305,14 +376,32 @@ | |||
| </select> | |||
| <select id="updateStatusForUnsign" parameterType="com.iformall.domain.po.WxRentContract"> | |||
| 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| </select> | |||
| <select id="getRentInvalidList" parameterType="com.iformall.domain.po.WxRentContract" | |||
| resultType="com.iformall.domain.po.WxRentContract"> | |||
| 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) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| )s) and status in(0,1) and status!=7 and apply_status=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| </select> | |||
| <select id="queryOweCount" parameterType="com.iformall.domain.po.WxRentContract" resultType="Long"> | |||
| @@ -328,7 +417,14 @@ | |||
| </select> | |||
| <select id="selectRentContractCountByShopId" parameterType="com.iformall.domain.po.WxRentContract" resultType="int"> | |||
| 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and json_contains(json_extract(rent_info,'$[*].shopId'),concat('"',${shopId},'"')) and status in (2,3,4) | |||
| <if test="id!=null"> | |||
| and id!=#{id} | |||
| </if> | |||
| @@ -372,13 +468,23 @@ | |||
| <select id="hasContractNumber" parameterType="com.iformall.domain.po.WxRentContract" | |||
| resultType="int"> | |||
| 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) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| 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) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| ) r | |||
| <where> | |||
| <if test="id!=null and id!=''"> | |||
| @@ -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 | |||
| <where> | |||
| rc.tenant_id=#{tenantId} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and rc.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and rc.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != merchantName and merchantName!=''">and rc.`merchant_name` like | |||
| concat('%',#{merchantName},'%') | |||
| </if> | |||
| @@ -451,13 +562,33 @@ | |||
| <if test="null != rentShopType and 1 == rentShopType and null != floorForRule and '' != floorForRule "> | |||
| and rc.`id` in | |||
| <foreach collection="tempShop" index="idx" separator=" union all " open="(" close=")"> | |||
| 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and json_unquote(json_extract(json_extract(rent_info,'$[*].shopId'),concat('$[',#{idx},']'))) in(select | |||
| id from wx_shop where 1=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and floor in (${floorForRule})) | |||
| </foreach> | |||
| </if> | |||
| <if test="null != rentShopType and 2 == rentShopType and null != floorForRule and '' != 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| and floor in (${floorForRule})) | |||
| </if> | |||
| </where> | |||
| @@ -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} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and s.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and s.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != status"> | |||
| and s.`status` = #{status} | |||
| </if> | |||
| @@ -529,8 +534,14 @@ | |||
| <select id="hasShopNumber" parameterType="com.iformall.domain.po.WxShop" resultType="Integer"> | |||
| 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 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != id"> | |||
| and id != #{id} | |||
| </if> | |||