| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.poteviohealth.cgp.statistics.mapper.OrderMapper">
- <select id="integralTransList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralTrans">
- SELECT
- IFNULL(
- c.now_city_id,(
- SELECT
- p.address_city_id
- FROM
- ${dbName}_common.f_operator p
- WHERE
- p.id = c.operator_id
- )) AS cityId,
- c.now_country_id AS countryId,
- c.now_street_id AS streetId,
- od.product_category_id AS productCategoryId,
- g.parent_id AS parentId,
- g.full_name AS fullName,
- t.trans_type AS transType,
- t.amount AS amount,
- t.build_time AS buildTime
- FROM
- ${dbName}_finance.c_card_acc_trans t
- LEFT JOIN ${dbName}_finance.c_card_acc_detail d ON t.detail_id = d.id
- LEFT JOIN ${dbName}_order.o_order_detail_${operatorId} od ON od.order_detail_id = t.trans_id
- LEFT JOIN ${dbName}_customer.c_customer_subsidy_${operatorId} c ON c.subsidy_customer_id = d.subsidy_customer_id
- LEFT JOIN ${dbName}_common.f_category g ON g.id = od.product_category_id
- WHERE
- d.yn = 0
- AND t.yn = 0
- AND d.ENABLE = 1
- AND d.type = 2
- AND t.trans_type IN (0,1)
- and ${ew.sqlSegment}
- </select>
- <select id="integralCustomerList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralTrans">
- SELECT
- c.age AS age,
- c.sex AS sex,
- IFNULL(
- c.now_city_id,(
- SELECT
- p.address_city_id
- FROM
- ${dbName}_common.f_operator p
- WHERE
- p.id = c.operator_id
- )) AS cityId,
- c.now_country_id AS countryId,
- c.now_street_id AS streetId,
- d.created_date AS createdDate
- FROM
- ${dbName}_finance.c_card_acc_detail d
- LEFT JOIN ${dbName}_customer.c_customer_subsidy_${operatorId} c ON c.subsidy_customer_id = d.subsidy_customer_id
- WHERE
- d.yn = 0
- AND d.ENABLE = 1
- AND d.type = 2
- and ${ew.sqlSegment}
- </select>
- <select id="areaList" resultType="com.poteviohealth.cgp.common.integrated.partner.model.AreaDTO">
- select id,parent as parentId,name,tree_path, region_area_code,
- (LENGTH(tree_path) - LENGTH(replace(tree_path,',','')))-1 as `level`
- from ${dbName}_common.f_area
- where yn = 0
- and parent is not null
- and length(tree_path)-length(replace(tree_path,',','')) <=4
- and (region_area_code like '37%' or
- region_area_code like '32%' or
- region_area_code like '11%' or
- region_area_code like '13%' or
- region_area_code like '21%' or
- region_area_code like '51%')
- </select>
- <select id="supplierStationEmployeeList"
- resultType="com.poteviohealth.cgp.statistics.model.outdto.SupplierStationEmployee">
- select station_id,employee_id from ${dbName}_common.f_supplier_station_employee where yn = 0
- </select>
- <select id="supplierStationList" resultType="com.poteviohealth.cgp.statistics.model.outdto.SupplierStation">
- select id,city,country,street from ${dbName}_common.f_supplier_station
- where yn = 0 and `level` >=2 and status = 1 and type = 1 and LENGTH(region_code) = 12
- </select>
- <select id="employeeList" resultType="com.poteviohealth.cgp.statistics.model.outdto.Employee">
- select id,age,gender from ${dbName}_common.f_employee
- where yn = 0
- and role_id_str like '%25%'
- and status = 1
- and age is not null
- and gender is not null
- </select>
- <select id="getOperatorList" resultType="java.lang.Integer">
- select id from ${dbName}_common.f_operator
- where yn = 0 and id>0 and enabled = 1 and check_status = 2
- </select>
- <select id="getSubsidyCustomerList"
- resultType="com.poteviohealth.cgp.common.integrated.customer.model.CustomerSubsidyDTO">
- SELECT
- c.subsidy_customer_id as subsidyCustomerId,
- c.customer_id as customerId,
- IFNULL(c.now_city_id,(select p.address_city_id from ${dbName}_common.f_operator p where p.id = c.operator_id)) as nowCityId,
- IFNULL(c.now_city_name,(select p.address_city_name from ${dbName}_common.f_operator p where p.id = c.operator_id)) as nowCityName,
- c.now_country_id as nowCountryId,
- c.now_country_name as nowCountryName,
- c.now_street_id as nowStreetId,
- c.now_street_name as nowStreetName,
- c.customer_sign_id as customerSignId,
- cs.customer_type_id as customerTypeId,
- cs.customer_type as customerType,
- c.age as age,
- c.sex as sex,
- if(sum(IF( d.settlement = 1, 1, 0 ) )>0,1,0) as category
- FROM
- ${dbName}_finance.c_card_acc_detail d
- ,${dbName}_customer.c_customer_subsidy_${operatorId} c
- ,${dbName}_customer.c_customer_subsidy_supplier_${operatorId} cs
- where c.subsidy_customer_id = d.subsidy_customer_id
- and cs.subsidy_customer_id = c.subsidy_customer_id
- and c.yn = 0 AND d.yn = 0 AND cs.yn = 0
- and cs.enabled = 1
- and ${ew.sqlSegment}
- GROUP BY c.subsidy_customer_id
- </select>
- <select id="orderServiceCustomerList"
- resultType="com.poteviohealth.cgp.common.integrated.customer.model.CustomerServiceParams">
- SELECT
- IFNULL(c.now_city_id,(select p.address_city_id from ${dbName}_common.f_operator p where p.id = c.operator_id)) as cityId,
- IFNULL(c.now_country_id,-1) AS countryId,
- IFNULL(c.now_street_id,-1) AS streetId,
- count(DISTINCT c.customer_id) as customerNum,
- CONCAT(',',c.customer_type_id,',') as customerTypeId
- FROM
- ${dbName}_customer.c_customer_subsidy_${operatorId} c
- join (select subsidy_customer_id from ${dbName}_customer.c_customer_subsidy_supplier_${operatorId} where yn =0 and enabled = 1 group by subsidy_customer_id) csp
- on c.subsidy_customer_id = csp.subsidy_customer_id
- LEFT JOIN ${dbName}_order.o_order_${operatorId} o ON o.customer_id = c.customer_id
- WHERE
- o.order_status = 6
- AND o.order_type = 2
- and c.yn =0
- and o.yn = 0
- GROUP BY c.now_street_id,c.customer_type_id;
- </select>
- <select id="getSubsidyCustomerMealList" resultType="com.poteviohealth.cgp.statistics.model.outdto.Customer">
- select IFNULL(now_city_id,(select p.address_city_id from ${dbName}_common.f_operator p where p.id = operator_id)) as nowCityId,
- IFNULL(now_country_id,-1) AS nowCountryId,
- IFNULL(now_street_id,-1) AS nowStreetId
- from ${dbName}_customer.c_customer_subsidy_${operatorId}
- where yn = 0
- and ${ew.sqlSegment}
- </select>
- <select id="queryOrderIntegrationData"
- resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderIntegrationData">
- SELECT o.order_id as orderId,o.city_id as cityId,o.country_id as countryId,o.street_id as streetId,o.visit_status as visitStatus
- ,o.customer_id as customerId,o.finish_time as finishTime,od.product_category_id as productCategoryId,v.qualified as qualified,
- v.result as result FROM ${dbName}_order.o_order_${operatorId} o,${dbName}_order.o_order_detail_${operatorId} od,${dbName}_order.o_visit_${operatorId} v
- where o.order_id = od.order_id
- and v.order_id = o.order_id
- and o.yn= 0 and v.yn = 0
- and o.order_status = 6
- and o.order_type = 2
- and o.city_id is not null
- and o.country_id is not null
- and o.street_id is not null
- and o.finish_time is not null
- and od.product_category_id is not null
- and ${ew.sqlSegment}
- group by o.order_id
- </select>
- <select id="getAllCategory" resultType="com.poteviohealth.cgp.common.integrated.ListParams">
- select id,name,parent_id as `key` from ${dbName}_common.f_category where yn = 0
- </select>
- <select id="integralTransactionList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralTransaction">
- select num,integral,merchant_id,merchant_name from ${dbName}_customer.c_integral_transaction_${operatorId} where yn =0 and type = 0
- </select>
- <select id="integralProductList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralProduct">
- select merchant_id from ${dbName}_customer.c_integral_product where yn =0 and type = 0 and own_review = 1
- </select>
- <select id="getStationMerchantList"
- resultType="com.poteviohealth.cgp.statistics.model.outdto.StationMerchant">
- select id,name,status,type,city,country,street,supplier_id,country_name,street_name from ${dbName}_common.f_station_merchant where yn = 0
- </select>
- <select id="queryIntegralProduct" resultType="com.poteviohealth.cgp.statistics.model.outdto.Product">
- select provider_id,parent_category_id from ${dbName}_product.p_product where operator_id = #{operatorId} and yn = 0 and own_status = 1 and tags like '%8962319%'
- </select>
- <select id="getIntegralCardAccOperatorIdList" resultType="java.lang.Integer">
- select operator_id from ${dbName}_finance.c_card_acc_detail where yn = 0 and type = 2 and enable = 1 and ${ew.sqlSegment} group by operator_id
- </select>
- <select id="getIntegralCardDetailOperatorIdList" resultType="java.lang.Integer">
- select operator_id from ${dbName}_finance.c_card_acc_detail where yn = 0 and type = 2 and enable = 1 group by operator_id
- </select>
- <select id="orderExcel" resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderExcelDTO">
- SELECT
- o.id as id,
- o.supplier_name as supplierName,
- o.order_id as orderId,
- o.sn as sn,
- o.customer_name as customerName,
- o.id_number as idNumber,
- o.name as name,
- o.phone as phone,
- o.address as address,
- o.product_string as productString,
- o.service_name as serviceName,
- o.service_sku_name as serviceSkuName,
- o.service_num as serviceNum,
- TRUNCATE(IFNULL(o.sum_order_price,0)/100.0,2) as sumOrderPrice,
- TRUNCATE(IFNULL(o.sum_price,0)/100.0,2) as sumPrice,
- o.pay_style as payStyle,
- o.reservation_time as reservationTime,
- o.pay_status as payStatus,
- o.order_style as orderStyle,
- o.order_status as orderStatus,
- DATE_FORMAT(o.order_time, '%Y-%m-%d %H:%i') as orderTime,
- o.home_time as homeTime,
- o.send_time as sendTime,
- o.pickup_time as pickupTime,
- o.employee_name as employeeName,
- DATE_FORMAT(o.start_time, '%Y-%m-%d %H:%i') as startTime,
- DATE_FORMAT(o.end_time, '%Y-%m-%d %H:%i') as endTime,
- TRUNCATE(IFNULL(o.settlement_price_sum,0)/100.0,2) as settlementPriceSum,
- o.pay_account as payAccount,
- o.service_station_name as serviceStationName,
- o.group_leader_name as groupLeaderName,
- o.visit_reserve_date as visitReserveDate,
- o.station_name as stationName,
- o.belong as belong,
- o.supplier_one_name as supplierOneName,
- o.contract_no as contractNo,
- TRUNCATE(IFNULL(o.consignment_price_sum,0)/100.0,2) as consignmentPriceSum,
- o.review_reason as reviewReason,
- TRUNCATE(IFNULL(o.pay_price,0)/100.0,2) as payPrice,
- TRUNCATE(IFNULL(o.card_price,0)/100.0,2) as cardPrice,
- TRUNCATE(IFNULL(o.subsidy_price,0)/100.0,2) as subsidyPrice,
- o.fund_price as fundPrice,
- od.tracking_code,
- od.tracking_company,
- od.man_hour,
- o.card_names as cardNameStr
- FROM
- ${dbName}_order.o_order_${operatorId} o
- left join ${dbName}_order.o_order_detail_${operatorId} od on o.order_id = od.order_id and od.yn=0
- WHERE
- o.yn=0
- and o.id > #{start}
- and ${ew.sqlSegment}
- order by o.id
- limit 10000
- </select>
- <select id="orderPageListSize" resultType="java.lang.Integer">
- SELECT count(*)
- FROM
- ${dbName}_order.o_order_${operatorId} o
- WHERE o.yn = 0
- and ${ew.sqlSegment}
- </select>
- <select id="orderPageListAllSize" resultType="java.lang.Integer">
- SELECT count(*)
- FROM
- ${dbName}_order.o_order_${operatorId} o
- left join ${dbName}_order.o_order_detail_${operatorId} od on o.order_id = od.order_id
- WHERE o.yn = 0
- AND od.yn = 0
- and ${ew.sqlSegment}
- </select>
- <select id="dishesOrderPageListAllSize" resultType="java.lang.Integer">
- SELECT count(*)
- FROM
- ${dbName}_order.o_dishes_order_${operatorId} o
- WHERE o.yn = 0
- and ${ew.sqlSegment}
- </select>
- <select id="dishesOrderExcel" resultType="com.poteviohealth.cgp.statistics.model.outdto.DishesOrderWebOutDTO">
- SELECT
- id,
- customer_name,
- sn,
- customer_phone,
- product_string,
- DATE_FORMAT(order_time,'%Y-%m-%d %H:%i') AS orderTime,
- TRUNCATE ( sum_price/ 100.0, 2 ) AS sumPrice,
- TRUNCATE ( card_price/ 100.0, 2 ) AS cardPrice,
- TRUNCATE ( subsidy_price/ 100.0, 2 ) AS subsidyPrice,
- TRUNCATE ( pay_price/ 100.0, 2 ) AS payPrice,
- fund_price,
- '已支付' as payStatusStr,
- pay_account as payAccountStr,
- service_station_name
- FROM
- ${dbName}_order.o_dishes_order_${operatorId} o
- WHERE o.yn = 0
- and o.id > #{start}
- and ${ew.sqlSegment}
- order by o.id
- limit 10000
- </select>
- <select id="costOrderPageListAllSize" resultType="java.lang.Integer">
- SELECT count(*)
- FROM
- ${dbName}_order.o_order_cost_${operatorId} o
- WHERE o.yn = 0
- and ${ew.sqlSegment}
- </select>
- <select id="costOrderExcel" resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderCostWebOutDTO">
- SELECT
- o.id,
- o.sn,
- o.category_name,
- o.cost_year,
- o.customer_name,
- o.customer_type,
- o.station_name,
- o.settlement_attribution,
- o.service_station_name,
- o.country_name,
- o.address,
- o.employee_name,
- o.service_name,
- DATE_FORMAT(o.order_time,'%Y-%m-%d %H:%i') AS orderTime,
- DATE_FORMAT(o.end_time,'%Y-%m-%d %H:%i') AS endTime,
- case when o.revenue_status = 1 then '未核算' else '已核算' end as revenueStatusStr,
- TRUNCATE (o.sign_price/ 100.0, 2 ) AS signPrice,
- o.man_hour,
- o.num,
- TRUNCATE (o.price/ 100.0, 2 ) AS price,
- TRUNCATE (o.labor/ 100.0, 2 ) as labor,
- TRUNCATE (o.standard/ 100.0, 2 ) as standard,
- TRUNCATE (o.adjustment/ 100.0, 2 ) as adjustment,
- TRUNCATE (o.actual/ 100.0, 2 ) as actual,
- TRUNCATE (o.income/ 100.0, 2 ) as income,
- TRUNCATE (o.money/ 100.0, 2 ) as money,
- DATE_FORMAT(o.revenue_date,'%Y-%m-%d %H:%i') AS revenueDate,
- o.remark,
- o.transaction_id,
- TRUNCATE (o.pay_price/ 100.0, 2 ) as payPrice
- FROM
- ${dbName}_order.o_order_cost_${operatorId} o
- WHERE o.yn = 0
- and o.id > #{start}
- and ${ew.sqlSegment}
- order by o.id
- limit 10000
- </select>
- <select id="pageCardListSize" resultType="java.lang.Integer">
- select count(*) from (
- select count(d.id)
- from ${dbName}_finance.c_card_acc_detail d
- left join (SELECT d.id,
- SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
- FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN t_number b ON b.id <(
- LENGTH( d.station_ids ) - LENGTH( REPLACE(d.station_ids,',','') ) + 1
- )
- where d.yn = 0 and d.type = 1 and d.station_ids != '' and ${ew.sqlSegment} ) a
- on d.id = a.id
- <if test="queryParam.stationIds!=null and queryParam.stationIds.size()>0">
- and a.stationId in
- <foreach collection="queryParam.stationIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- where d.yn = 0 and d.type = 1 and d.station_ids != ''
- and ${ew.sqlSegment}
- group by d.id) t
- </select>
- <select id="pageCardList" resultType="com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanDTO">
- select d.id,d.name,d.phone,d.id_number,d.category_name,d.type_name,d.customer_address,d.customer_type_name,
- case when d.enable =1 then '启用' else '停用' end as enabled,TRUNCATE(d.balance/100,2) as balance
- from ${dbName}_finance.c_card_acc_detail d
- left join (SELECT d.id,
- SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
- FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN t_number b ON b.id <(
- LENGTH( d.station_ids ) - LENGTH( REPLACE(d.station_ids,',','') ) + 1
- )
- where d.yn = 0 and d.type = 1 and d.station_ids != '' and ${ew.sqlSegment} ) a
- on d.id = a.id
- <if test="queryParam.stationIds!=null and queryParam.stationIds.size()>0">
- and a.stationId in
- <foreach collection="queryParam.stationIds" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- where d.yn = 0 and d.type = 1 and d.station_ids != ''
- and d.id > #{start}
- and ${ew.sqlSegment}
- group by d.id
- order by d.id
- limit 10000
- </select>
- </mapper>
|