| @@ -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 | |||
| <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) 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 | |||
| <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 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 | |||
| <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) 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 | |||
| <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) cop on cop.coupon_id = c.id | |||
| where c.type = 8 | |||
| <if test="tenantId != null"> | |||
| and c.tenant_id=#{tenantId} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and c.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and c.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test="id != null"> | |||
| 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} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and wo.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and wo.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| ) | |||
| / | |||
| (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}) | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and wo.`tenant_id` = #{tenantId} | |||
| and wop.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and wo.`parent_tenant_id` = #{parentTenantId} | |||
| and wop.`tenant_id` = #{tenantId} | |||
| </if> | |||
| ) | |||
| * 100 | |||
| ,2) | |||
| </select> | |||