OrderMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.poteviohealth.cgp.statistics.mapper.OrderMapper">
  4. <select id="integralTransList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralTrans">
  5. SELECT
  6. IFNULL(
  7. c.now_city_id,(
  8. SELECT
  9. p.address_city_id
  10. FROM
  11. ${dbName}_common.f_operator p
  12. WHERE
  13. p.id = c.operator_id
  14. )) AS cityId,
  15. c.now_country_id AS countryId,
  16. c.now_street_id AS streetId,
  17. od.product_category_id AS productCategoryId,
  18. g.parent_id AS parentId,
  19. g.full_name AS fullName,
  20. t.trans_type AS transType,
  21. t.amount AS amount,
  22. t.remark as remark,
  23. t.build_time AS buildTime
  24. FROM
  25. ${dbName}_finance.c_card_acc_trans t
  26. LEFT JOIN ${dbName}_finance.c_card_acc_detail d ON t.detail_id = d.id
  27. LEFT JOIN ${dbName}_order.o_order_detail_${operatorId} od ON od.order_detail_id = t.trans_id
  28. LEFT JOIN ${dbName}_customer.c_customer_subsidy_${operatorId} c ON c.subsidy_customer_id = d.subsidy_customer_id
  29. LEFT JOIN ${dbName}_common.f_category g ON g.id = od.product_category_id
  30. WHERE
  31. d.yn = 0
  32. AND t.yn = 0
  33. AND d.ENABLE = 1
  34. AND d.type = 2
  35. AND t.trans_type IN (0,1)
  36. </select>
  37. <select id="integralCustomerList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralTrans">
  38. SELECT
  39. c.age AS age,
  40. c.sex AS sex,
  41. IFNULL(
  42. c.now_city_id,(
  43. SELECT
  44. p.address_city_id
  45. FROM
  46. ${dbName}_common.f_operator p
  47. WHERE
  48. p.id = c.operator_id
  49. )) AS cityId,
  50. c.now_country_id AS countryId,
  51. c.now_street_id AS streetId,
  52. d.created_date AS createdDate
  53. FROM
  54. ${dbName}_finance.c_card_acc_detail d
  55. LEFT JOIN ${dbName}_customer.c_customer_subsidy_${operatorId} c ON c.subsidy_customer_id = d.subsidy_customer_id
  56. WHERE
  57. d.yn = 0
  58. AND d.ENABLE = 1
  59. AND d.type = 2
  60. </select>
  61. <select id="areaList" resultType="com.poteviohealth.cgp.common.integrated.partner.model.AreaDTO">
  62. select id,parent as parentId,name,tree_path, region_area_code,
  63. (LENGTH(tree_path) - LENGTH(replace(tree_path,',','')))-1 as `level`
  64. from ${dbName}_common.f_area
  65. where yn = 0
  66. and parent is not null
  67. and length(tree_path)-length(replace(tree_path,',','')) &lt;=4
  68. and (region_area_code like '37%' or
  69. region_area_code like '32%' or
  70. region_area_code like '11%' or
  71. region_area_code like '13%' or
  72. region_area_code like '21%' or
  73. region_area_code like '41%' or
  74. region_area_code like '51%' or region_area_code like '53%' )
  75. </select>
  76. <select id="supplierStationEmployeeList"
  77. resultType="com.poteviohealth.cgp.statistics.model.outdto.SupplierStationEmployee">
  78. select station_id,employee_id from ${dbName}_common.f_supplier_station_employee where yn = 0
  79. </select>
  80. <select id="supplierStationList" resultType="com.poteviohealth.cgp.statistics.model.outdto.SupplierStation">
  81. select id,city,country,street from ${dbName}_common.f_supplier_station
  82. where yn = 0 and `level` >=2 and status = 1 and type = 1 and (LENGTH(region_code) = 12 or LENGTH(region_code) = 9)
  83. </select>
  84. <select id="employeeList" resultType="com.poteviohealth.cgp.statistics.model.outdto.Employee">
  85. select id,age,gender from ${dbName}_common.f_employee
  86. where yn = 0
  87. and role_id_str like '%25%'
  88. and status = 1
  89. and age is not null
  90. and gender is not null
  91. </select>
  92. <select id="getOperatorList" resultType="java.lang.Integer">
  93. select id from ${dbName}_common.f_operator
  94. where yn = 0 and id>0 and enabled = 1 and check_status = 2
  95. </select>
  96. <select id="getSubsidyCustomerList"
  97. resultType="com.poteviohealth.cgp.common.integrated.customer.model.CustomerSubsidyDTO">
  98. SELECT
  99. c.subsidy_customer_id as subsidyCustomerId,
  100. c.customer_id as customerId,
  101. IFNULL(c.now_city_id,(select p.address_city_id from ${dbName}_common.f_operator p where p.id = c.operator_id)) as nowCityId,
  102. IFNULL(c.now_city_name,(select p.address_city_name from ${dbName}_common.f_operator p where p.id = c.operator_id)) as nowCityName,
  103. c.now_country_id as nowCountryId,
  104. c.now_country_name as nowCountryName,
  105. c.now_street_id as nowStreetId,
  106. c.now_street_name as nowStreetName,
  107. c.customer_sign_id as customerSignId,
  108. CONCAT_WS( ',', cs.customer_type_id ) as customerTypeId,
  109. CONCAT_WS(',',cs.customer_type) as customerType,
  110. c.age as age,
  111. c.sex as sex,
  112. if(sum(IF( d.service_tags like '%1%' , 1, 0 ) )>0,1,0) as category
  113. FROM
  114. ${dbName}_finance.c_card_acc_detail d
  115. ,${dbName}_customer.c_customer_subsidy_${operatorId} c
  116. ,${dbName}_customer.c_customer_subsidy_supplier_${operatorId} cs
  117. where c.subsidy_customer_id = d.subsidy_customer_id
  118. and cs.subsidy_customer_id = c.subsidy_customer_id
  119. and c.yn = 0 AND d.yn = 0 AND cs.yn = 0
  120. and cs.customer_type_id is not null
  121. and cs.enabled = 1
  122. GROUP BY c.subsidy_customer_id
  123. </select>
  124. <select id="orderServiceCustomerList"
  125. resultType="com.poteviohealth.cgp.common.integrated.customer.model.CustomerServiceParams">
  126. SELECT
  127. IFNULL(c.now_city_id,(select p.address_city_id from ${dbName}_common.f_operator p where p.id = c.operator_id)) as cityId,
  128. IFNULL(c.now_country_id,-1) AS countryId,
  129. IFNULL(c.now_street_id,-1) AS streetId,
  130. count(DISTINCT c.customer_id) as customerNum,
  131. CONCAT(',',CONCAT_WS( ',', csp.customer_type_id ),',') as customerTypeId
  132. FROM
  133. ${dbName}_customer.c_customer_subsidy_${operatorId} c
  134. join (select subsidy_customer_id,customer_type_id from ${dbName}_customer.c_customer_subsidy_supplier_${operatorId} where yn =0 and enabled = 1 group by subsidy_customer_id) csp
  135. on c.subsidy_customer_id = csp.subsidy_customer_id
  136. LEFT JOIN ${dbName}_order.o_order_${operatorId} o ON o.customer_id = c.customer_id
  137. WHERE
  138. o.order_status = 6
  139. AND o.order_type = 2
  140. and c.yn =0
  141. and o.yn = 0
  142. GROUP BY c.now_street_id,CONCAT_WS(',',csp.customer_type_id);
  143. </select>
  144. <select id="getSubsidyCustomerMealList" resultType="com.poteviohealth.cgp.statistics.model.outdto.Customer">
  145. select IFNULL(now_city_id,(select p.address_city_id from ${dbName}_common.f_operator p where p.id = operator_id)) as nowCityId,
  146. IFNULL(now_country_id,-1) AS nowCountryId,
  147. IFNULL(now_street_id,-1) AS nowStreetId
  148. from ${dbName}_customer.c_customer_subsidy_${operatorId}
  149. where yn = 0 and meal_date is not null
  150. </select>
  151. <select id="queryOrderIntegrationData"
  152. resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderIntegrationData">
  153. SELECT o.city_id as cityId,o.country_id as countryId,o.street_id as streetId,od.product_category_id as productCategoryId, count(o.order_id) as orderId,
  154. sum(if (o.finish_time BETWEEN #{beginDay} and #{endDay}, 1,0)) as visitStatus,
  155. sum(if (o.finish_time BETWEEN #{beginWeek} and #{endWeek}, 1,0)) as result,
  156. sum(if (o.finish_time BETWEEN #{beginMonth} and #{endMonth}, 1,0)) as qualified
  157. FROM ${dbName}_order.o_order_${operatorId} o,${dbName}_order.o_order_detail_${operatorId} od
  158. where o.order_id = od.order_id
  159. and o.yn= 0
  160. and o.order_status = 6
  161. and o.order_type = 2
  162. and o.city_id is not null
  163. and o.country_id is not null
  164. and o.street_id is not null
  165. and o.finish_time is not null
  166. and od.product_category_id is not null
  167. group by o.street_id, od.product_category_id
  168. </select>
  169. <select id="queryOrderVisitData"
  170. resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderIntegrationData">
  171. SELECT
  172. o.city_id AS cityId,
  173. o.country_id AS countryId,
  174. o.street_id AS streetId,
  175. count(o.order_id) AS order_id,
  176. count(DISTINCT o.customer_id) AS customer_id,
  177. sum(IF(v.qualified = 1, 1, 0)) AS qualified,
  178. sum(IF(v.result = 1, 1, 0)) AS result
  179. FROM
  180. (
  181. SELECT
  182. MAX(t2.id) AS maxv
  183. FROM
  184. ${dbName}_order.o_visit_${operatorId} t2
  185. WHERE
  186. t2.yn = 0
  187. GROUP BY
  188. t2.order_id
  189. ) t
  190. JOIN ${dbName}_order.o_visit_${operatorId} v ON t.maxv = v.id
  191. JOIN ${dbName}_order.o_order_${operatorId} o ON v.order_id = o.order_id
  192. WHERE
  193. o.yn = 0
  194. AND o.order_type = 2
  195. AND o.city_id IS NOT NULL
  196. AND o.country_id IS NOT NULL
  197. AND o.street_id IS NOT NULL
  198. GROUP BY
  199. o.street_id
  200. </select>
  201. <select id="getAllCategory" resultType="com.poteviohealth.cgp.common.integrated.ListParams">
  202. select id,name,parent_id as `key` from ${dbName}_common.f_category where yn = 0
  203. </select>
  204. <select id="integralTransactionList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralTransaction">
  205. select num,integral,merchant_id,merchant_name from ${dbName}_customer.c_integral_transaction_${operatorId} where yn =0 and type = 0
  206. </select>
  207. <select id="integralProductList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralProduct">
  208. select merchant_id from ${dbName}_customer.c_integral_product where yn =0 and type = 0 and own_review = 1
  209. </select>
  210. <select id="getStationMerchantList"
  211. resultType="com.poteviohealth.cgp.statistics.model.outdto.StationMerchant">
  212. select id,name,status,type,city,country,street,supplier_id,country_name,street_name from ${dbName}_common.f_station_merchant where yn = 0
  213. </select>
  214. <select id="queryIntegralProduct" resultType="com.poteviohealth.cgp.statistics.model.outdto.Product">
  215. 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%'
  216. </select>
  217. <select id="getIntegralCardAccOperatorIdList" resultType="java.lang.Integer">
  218. select operator_id from ${dbName}_finance.c_card_acc_detail where yn = 0 and type = 2 and enable = 1 group by operator_id
  219. </select>
  220. <select id="getIntegralCardDetailOperatorIdList" resultType="java.lang.Integer">
  221. select operator_id from ${dbName}_finance.c_card_acc_detail where yn = 0 and type = 2 and enable = 1 group by operator_id
  222. </select>
  223. <select id="orderExcel" resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderExcelDTO">
  224. SELECT
  225. o.id as id,
  226. o.supplier_name as supplierName,
  227. o.order_id as orderId,
  228. o.sn as sn,
  229. o.customer_name as customerName,
  230. o.id_number as idNumber,
  231. o.name as name,
  232. o.phone as phone,
  233. o.address as address,
  234. o.product_string as productString,
  235. o.service_name as serviceName,
  236. o.service_sku_name as serviceSkuName,
  237. o.service_num as serviceNum,
  238. TRUNCATE(IFNULL(o.sum_order_price,0)/100.0,2) as sumOrderPrice,
  239. TRUNCATE(IFNULL(o.sum_price,0)/100.0,2) as sumPrice,
  240. o.pay_style as payStyle,
  241. o.reservation_time as reservationTime,
  242. o.pay_status as payStatus,
  243. o.order_style as orderStyle,
  244. o.order_status as orderStatus,
  245. DATE_FORMAT(o.order_time, '%Y-%m-%d %H:%i') as orderTime,
  246. o.home_time as homeTime,
  247. o.send_time as sendTime,
  248. o.pickup_time as pickupTime,
  249. o.employee_name as employeeName,
  250. DATE_FORMAT(o.start_time, '%Y-%m-%d %H:%i') as startTime,
  251. DATE_FORMAT(o.end_time, '%Y-%m-%d %H:%i') as endTime,
  252. TRUNCATE(IFNULL(o.settlement_price_sum,0)/100.0,2) as settlementPriceSum,
  253. o.pay_account as payAccount,
  254. o.service_station_name as serviceStationName,
  255. o.group_leader_name as groupLeaderName,
  256. o.visit_reserve_date as visitReserveDate,
  257. o.station_name as stationName,
  258. o.belong as belong,
  259. o.supplier_one_name as supplierOneName,
  260. o.contract_no as contractNo,
  261. TRUNCATE(IFNULL(o.consignment_price_sum,0)/100.0,2) as consignmentPriceSum,
  262. o.review_reason as reviewReason,
  263. TRUNCATE(IFNULL(o.pay_price,0)/100.0,2) as payPrice,
  264. TRUNCATE(IFNULL(o.card_price,0)/100.0,2) as cardPrice,
  265. TRUNCATE(IFNULL(o.subsidy_price,0)/100.0,2) as subsidyPrice,
  266. o.fund_price as fundPrice,
  267. od.tracking_code,
  268. od.tracking_company,
  269. od.man_hour,
  270. o.card_names as cardNameStr,
  271. o.customer_type
  272. FROM
  273. ${dbName}_order.o_order_${operatorId} o
  274. left join ${dbName}_order.o_order_detail_${operatorId} od on o.order_id = od.order_id and od.yn=0
  275. WHERE
  276. o.yn=0
  277. and o.id > #{start}
  278. and ${ew.sqlSegment}
  279. order by o.id
  280. limit 10000
  281. </select>
  282. <select id="orderPageListSize" resultType="java.lang.Integer">
  283. SELECT count(*)
  284. FROM
  285. ${dbName}_order.o_order_${operatorId} o
  286. WHERE o.yn = 0
  287. and ${ew.sqlSegment}
  288. </select>
  289. <select id="orderPageListAllSize" resultType="java.lang.Integer">
  290. SELECT count(*)
  291. FROM
  292. ${dbName}_order.o_order_${operatorId} o
  293. left join ${dbName}_order.o_order_detail_${operatorId} od on o.order_id = od.order_id
  294. WHERE o.yn = 0
  295. AND od.yn = 0
  296. and ${ew.sqlSegment}
  297. </select>
  298. <select id="dishesOrderPageListAllSize" resultType="java.lang.Integer">
  299. SELECT count(*)
  300. FROM
  301. ${dbName}_order.o_dishes_order_${operatorId} o
  302. WHERE o.yn = 0
  303. and ${ew.sqlSegment}
  304. </select>
  305. <select id="dishesOrderExcel" resultType="com.poteviohealth.cgp.statistics.model.outdto.DishesOrderWebOutDTO">
  306. SELECT
  307. id,
  308. customer_name,
  309. sn,
  310. customer_phone,
  311. product_string,
  312. id_card as idCard,
  313. DATE_FORMAT(order_time,'%Y-%m-%d %H:%i') AS orderTime,
  314. TRUNCATE ( sum_price/ 100.0, 2 ) AS sumPrice,
  315. TRUNCATE ( card_price/ 100.0, 2 ) AS cardPrice,
  316. TRUNCATE ( subsidy_price/ 100.0, 2 ) AS subsidyPrice,
  317. TRUNCATE ( special_price/ 100.0, 2 ) AS specialPrice,
  318. TRUNCATE ( pay_price/ 100.0, 2 ) AS payPrice,
  319. fund_price,
  320. '已支付' as payStatusStr,
  321. pay_account as payAccountStr,
  322. service_station_name,
  323. street_name as streetName,
  324. country_name as countryName,
  325. case when source_id = 1 then '刷脸' when source_id = 2 then '手机号' else '' end as sourceStr,
  326. case when eat_in = 0 then '否' when eat_in = 1 then '是' else '' end as eatInStr
  327. FROM
  328. ${dbName}_order.o_dishes_order_${operatorId} o
  329. WHERE o.yn = 0
  330. and o.id > #{start}
  331. and ${ew.sqlSegment}
  332. order by o.id
  333. limit 10000
  334. </select>
  335. <select id="costOrderPageListAllSize" resultType="java.lang.Integer">
  336. SELECT count(*)
  337. FROM
  338. ${dbName}_order.o_order_cost_${operatorId} o
  339. WHERE o.yn = 0
  340. and ${ew.sqlSegment}
  341. </select>
  342. <select id="costOrderExcel" resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderCostWebOutDTO">
  343. SELECT
  344. o.id,
  345. o.sn,
  346. o.category_name,
  347. o.cost_year,
  348. o.customer_name,
  349. o.customer_type,
  350. o.station_name,
  351. o.settlement_attribution,
  352. o.service_station_name,
  353. o.country_name,
  354. o.address,
  355. o.employee_name,
  356. o.service_name,
  357. DATE_FORMAT(o.order_time,'%Y-%m-%d %H:%i') AS orderTime,
  358. DATE_FORMAT(o.end_time,'%Y-%m-%d %H:%i') AS endTime,DATE_FORMAT(o.start_time,'%Y-%m-%d %H:%i') AS startTime,
  359. case when o.revenue_status = 1 then '未核算' else '已核算' end as revenueStatusStr,
  360. TRUNCATE (o.sign_price/ 100.0, 2 ) AS signPrice,
  361. o.man_hour,
  362. o.num,
  363. TRUNCATE (o.price/ 100.0, 2 ) AS price,
  364. TRUNCATE (o.labor/ 100.0, 2 ) as labor,
  365. TRUNCATE (o.standard/ 100.0, 2 ) as standard,
  366. TRUNCATE (o.adjustment/ 100.0, 2 ) as adjustment,
  367. TRUNCATE (o.actual/ 100.0, 2 ) as actual,
  368. TRUNCATE (o.income/ 100.0, 2 ) as income,
  369. TRUNCATE (o.money/ 100.0, 2 ) as money,
  370. DATE_FORMAT(o.revenue_date,'%Y-%m-%d %H:%i') AS revenueDate,
  371. o.remark,
  372. o.transaction_id,
  373. TRUNCATE (o.pay_price/ 100.0, 2 ) as payPrice
  374. FROM
  375. ${dbName}_order.o_order_cost_${operatorId} o
  376. WHERE o.yn = 0
  377. and o.id > #{start}
  378. and ${ew.sqlSegment}
  379. order by o.id
  380. limit 10000
  381. </select>
  382. <select id="pageCardListSize" resultType="java.lang.Integer">
  383. select count(*) from (
  384. select count(d.id)
  385. from ${dbName}_finance.c_card_acc_detail d
  386. <if test="queryParam.stationIds.size()>0">
  387. left join (SELECT d.id,
  388. SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
  389. FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN t_number b ON b.id &lt;(
  390. LENGTH( d.station_ids ) - LENGTH( REPLACE(d.station_ids,',','') ) + 1
  391. )
  392. where d.yn = 0 and d.type = 1 and d.station_ids != '' and ${ew.sqlSegment} ) a
  393. on d.id = a.id
  394. </if>
  395. where d.yn = 0 and d.type = 1 and d.station_ids != ''
  396. <if test="queryParam.stationIds.size()>0">
  397. and a.stationId in
  398. <foreach collection="queryParam.stationIds" item="item" separator="," open="(" close=")">
  399. #{item}
  400. </foreach>
  401. </if>
  402. and ${ew.sqlSegment}
  403. group by d.id) t
  404. </select>
  405. <select id="pageCardList" resultType="com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanDTO">
  406. select d.id,d.name,d.phone,d.id_number,d.category_name,d.type_name,d.customer_address,d.customer_type_name,
  407. case when d.enable =1 then '启用' else '停用' end as enabled,TRUNCATE(d.balance/100,2) as balance
  408. from ${dbName}_finance.c_card_acc_detail d
  409. <if test="queryParam.stationIds.size()>0">
  410. left join (SELECT d.id,
  411. SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
  412. FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN t_number b ON b.id &lt;(
  413. LENGTH( d.station_ids ) - LENGTH( REPLACE(d.station_ids,',','') ) + 1
  414. )
  415. where d.yn = 0 and d.type = 1 and d.station_ids != '' and ${ew.sqlSegment} ) a
  416. on d.id = a.id
  417. </if>
  418. where d.yn = 0 and d.type = 1 and d.station_ids != ''
  419. and d.id > #{start}
  420. <if test="queryParam.stationIds.size()>0">
  421. and a.stationId in
  422. <foreach collection="queryParam.stationIds" item="item" separator="," open="(" close=")">
  423. #{item}
  424. </foreach>
  425. </if>
  426. and ${ew.sqlSegment}
  427. group by d.id
  428. order by d.id
  429. limit 10000
  430. </select>
  431. <select id="transRechargeExcelListAllSize" resultType="int">
  432. select count(*)
  433. from ${dbName}_finance.c_card_acc_detail d
  434. <if test="queryParam.stationIds.size()>0">
  435. left join (SELECT d.id,
  436. SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
  437. FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN ${dbName}_finance.t_number b ON b.id &lt;(
  438. LENGTH( d.station_ids ) - LENGTH( REPLACE(d.station_ids,',','') ) + 1
  439. )
  440. where d.yn = 0 and d.type = 1 and d.station_ids != '' and ${ew.sqlSegment} ) a
  441. on d.id = a.id
  442. </if>
  443. left join ${dbName}_finance.c_card_acc_trans t on t.detail_id = d.id
  444. where d.yn = 0 and t.yn = 0 and d.type = 1
  445. and t.trans_type = 0
  446. <if test="queryParam.startDate != null">
  447. and t.build_time between #{queryParam.startDate} and #{queryParam.endDate}
  448. </if>
  449. and d.station_ids != ''
  450. <if test="queryParam.stationIds.size()>0">
  451. and a.stationId in
  452. <foreach collection="queryParam.stationIds" item="item" separator="," open="(" close=")">
  453. #{item}
  454. </foreach>
  455. </if>
  456. and ${ew.sqlSegment}
  457. </select>
  458. <select id="transRechargeExcel"
  459. resultType="com.poteviohealth.cgp.common.integrated.finance.model.CardAccTransRecharge">
  460. select t.id, t.build_time,
  461. d.name,
  462. d.id_number,
  463. TRUNCATE(t.amount/100,2) as amount,
  464. d.type_name
  465. from ${dbName}_finance.c_card_acc_detail d
  466. <if test="queryParam.stationIds.size()>0">
  467. left join (SELECT d.id,
  468. SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
  469. FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN ${dbName}_finance.t_number b ON b.id &lt;(
  470. LENGTH( d.station_ids ) - LENGTH( REPLACE(d.station_ids,',','') ) + 1
  471. )
  472. where d.yn = 0 and d.type = 1 and d.station_ids != '' and ${ew.sqlSegment} ) a
  473. on d.id = a.id
  474. </if>
  475. left join ${dbName}_finance.c_card_acc_trans t on t.detail_id = d.id
  476. where d.yn = 0 and t.yn = 0 and d.type = 1
  477. and t.trans_type = 0
  478. and t.id > #{start}
  479. <if test="queryParam.startDate != null">
  480. and t.build_time between #{queryParam.startDate} and #{queryParam.endDate}
  481. </if>
  482. and d.station_ids != ''
  483. <if test="queryParam.stationIds.size()>0">
  484. and a.stationId in
  485. <foreach collection="queryParam.stationIds" item="item" separator="," open="(" close=")">
  486. #{item}
  487. </foreach>
  488. </if>
  489. and ${ew.sqlSegment}
  490. order by t.id
  491. limit 10000
  492. </select>
  493. <select id="goldSendListSize" resultType="int">
  494. select count(*)
  495. from ${dbName}_customer.c_gold_send_${yearTime} d where d.yn = 0
  496. and ${ew.sqlSegment}
  497. </select>
  498. <select id="goldSendList" resultType="com.poteviohealth.cgp.statistics.model.outdto.GoldSendExcelDTO">
  499. select d.id, d.expect_time as sendMonth,
  500. d.name,
  501. d.id_number,
  502. TRUNCATE(d.money/100,2) as moneyStr,
  503. d.country_name,
  504. d.street_name,
  505. d.community_name,
  506. d.bank_name,
  507. d.bank_card,
  508. d.bank_holder,
  509. case when d.gold_type = 0 then '80-89周岁'
  510. when d.gold_type = 1 then '90-99周岁'
  511. when d.gold_type = 2 then '100周岁以上' end as goldTypeStr
  512. from ${dbName}_customer.c_gold_send_${yearTime} d
  513. where d.yn = 0
  514. and d.id > #{start}
  515. and ${ew.sqlSegment}
  516. order by d.id
  517. limit 10000
  518. </select>
  519. <select id="goldSendBankList" resultType="com.poteviohealth.cgp.statistics.model.outdto.GoldSendBankExcelDTO">
  520. select d.id,d.name,d.id_number,'1' as idNumberType,TRUNCATE(d.money/100,2) as moneyStr,d.area_code,d.link_mobile,
  521. d.now_address,d.bank_code,d.bank_card,d.bank_holder
  522. from ${dbName}_customer.c_gold_send_${yearTime} d
  523. where d.yn = 0
  524. and d.id > #{start}
  525. and ${ew.sqlSegment}
  526. order by d.id
  527. limit 10000
  528. </select>
  529. </mapper>