diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index 2d6db382d..9e9d1a276 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -767,13 +767,45 @@ ifnull(round(o.press_succ_count/op.press_count*100,2),0) as change_rate, ifnull(round(cop.xCount/op.press_count*100,2),0) as payment_rate FROM wx_coupon c - left join (SELECT count(id) as press_count, coupon_id FROM wx_order_press WHERE `tenant_id` = #{tenantId} AND `first` = 1 group by coupon_id) op on op.coupon_id = c.id - left join (SELECT count(id) as press_succ_count, product_id FROM wx_order WHERE `tenant_id` = #{tenantId} AND order_status = 1 group by product_id) o on o.product_id = c.id - left join (SELECT count(id) as join_count, coupon_id FROM wx_order_press WHERE `tenant_id` = #{tenantId} group by coupon_id) op2 on op2.coupon_id = c.id - left join (SELECT count(id) as xCount, coupon_id FROM wx_coupon_order WHERE `tenant_id` = #{tenantId} AND coupon_order_status = 1 group by coupon_id) cop on cop.coupon_id = c.id + left join (SELECT count(id) as press_count, coupon_id FROM wx_order_press WHERE `first` = 1 + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + group by coupon_id) op on op.coupon_id = c.id + left join (SELECT count(id) as press_succ_count, product_id FROM wx_order WHERE order_status = 1 + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + group by product_id) o on o.product_id = c.id + left join (SELECT count(id) as join_count, coupon_id FROM wx_order_press WHERE 1=1 + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + group by coupon_id) op2 on op2.coupon_id = c.id + left join (SELECT count(id) as xCount, coupon_id FROM wx_coupon_order WHERE coupon_order_status = 1 + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + group by coupon_id) cop on cop.coupon_id = c.id where c.type = 8 - - and c.tenant_id=#{tenantId} + + + and c.`tenant_id` = #{tenantId} + + + and c.`parent_tenant_id` = #{parentTenantId} and c.id = #{id} @@ -880,7 +912,12 @@ left join wx_order wo on wo.product_id = wc.id where wo.order_status = 1 and wc.type = 8 and wo.create_date between #{startdate} and #{enddate} - and wo.tenant_id = #{tenantId} + + and wo.`tenant_id` = #{tenantId} + + + and wo.`parent_tenant_id` = #{parentTenantId} + ) / (select count(wop.id) from wx_coupon wc @@ -888,7 +925,15 @@ left join wx_order_press wop on wop.order_id = wo.id where wop.first = 1 and wc.type = 8 and wop.create_date between #{startdate} and #{enddate} - and wo.tenant_id = #{tenantId} and wop.tenant_id = #{tenantId}) + + and wo.`tenant_id` = #{tenantId} + and wop.`tenant_id` = #{tenantId} + + + and wo.`parent_tenant_id` = #{parentTenantId} + and wop.`tenant_id` = #{tenantId} + + ) * 100 ,2)