OrderMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  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%')
  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
  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.order_id as orderId,o.city_id as cityId,o.country_id as countryId,o.street_id as streetId,o.visit_status as visitStatus
  154. ,o.customer_id as customerId,o.finish_time as finishTime,od.product_category_id as productCategoryId
  155. FROM ${dbName}_order.o_order_${operatorId} o,${dbName}_order.o_order_detail_${operatorId} od
  156. where o.order_id = od.order_id
  157. and o.yn= 0
  158. and o.order_status = 6
  159. and o.order_type = 2
  160. and o.city_id is not null
  161. and o.country_id is not null
  162. and o.street_id is not null
  163. and o.finish_time is not null
  164. and od.product_category_id is not null
  165. group by o.order_id
  166. </select>
  167. <select id="queryOrderVisitData"
  168. resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderIntegrationData">
  169. SELECT
  170. o.order_id AS orderId,
  171. o.city_id AS cityId,
  172. o.country_id AS countryId,
  173. o.street_id AS streetId,
  174. o.customer_id AS customerId,
  175. v.qualified AS qualified,
  176. v.result AS result
  177. FROM
  178. ${dbName}_order.o_order_${operatorId} o,
  179. ${dbName}_order.o_visit_${operatorId} v
  180. JOIN (
  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 ON t.maxv = v.id
  190. WHERE
  191. v.order_id = o.order_id
  192. AND o.yn = 0
  193. AND v.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 o.order_id
  199. </select>
  200. <select id="getAllCategory" resultType="com.poteviohealth.cgp.common.integrated.ListParams">
  201. select id,name,parent_id as `key` from ${dbName}_common.f_category where yn = 0
  202. </select>
  203. <select id="integralTransactionList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralTransaction">
  204. select num,integral,merchant_id,merchant_name from ${dbName}_customer.c_integral_transaction_${operatorId} where yn =0 and type = 0
  205. </select>
  206. <select id="integralProductList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralProduct">
  207. select merchant_id from ${dbName}_customer.c_integral_product where yn =0 and type = 0 and own_review = 1
  208. </select>
  209. <select id="getStationMerchantList"
  210. resultType="com.poteviohealth.cgp.statistics.model.outdto.StationMerchant">
  211. select id,name,status,type,city,country,street,supplier_id,country_name,street_name from ${dbName}_common.f_station_merchant where yn = 0
  212. </select>
  213. <select id="queryIntegralProduct" resultType="com.poteviohealth.cgp.statistics.model.outdto.Product">
  214. 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%'
  215. </select>
  216. <select id="getIntegralCardAccOperatorIdList" resultType="java.lang.Integer">
  217. select operator_id from ${dbName}_finance.c_card_acc_detail where yn = 0 and type = 2 and enable = 1 group by operator_id
  218. </select>
  219. <select id="getIntegralCardDetailOperatorIdList" resultType="java.lang.Integer">
  220. select operator_id from ${dbName}_finance.c_card_acc_detail where yn = 0 and type = 2 and enable = 1 group by operator_id
  221. </select>
  222. <select id="orderExcel" resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderExcelDTO">
  223. SELECT
  224. o.id as id,
  225. o.supplier_name as supplierName,
  226. o.order_id as orderId,
  227. o.sn as sn,
  228. o.customer_name as customerName,
  229. o.id_number as idNumber,
  230. o.name as name,
  231. o.phone as phone,
  232. o.address as address,
  233. o.product_string as productString,
  234. o.service_name as serviceName,
  235. o.service_sku_name as serviceSkuName,
  236. o.service_num as serviceNum,
  237. TRUNCATE(IFNULL(o.sum_order_price,0)/100.0,2) as sumOrderPrice,
  238. TRUNCATE(IFNULL(o.sum_price,0)/100.0,2) as sumPrice,
  239. o.pay_style as payStyle,
  240. o.reservation_time as reservationTime,
  241. o.pay_status as payStatus,
  242. o.order_style as orderStyle,
  243. o.order_status as orderStatus,
  244. DATE_FORMAT(o.order_time, '%Y-%m-%d %H:%i') as orderTime,
  245. o.home_time as homeTime,
  246. o.send_time as sendTime,
  247. o.pickup_time as pickupTime,
  248. o.employee_name as employeeName,
  249. DATE_FORMAT(o.start_time, '%Y-%m-%d %H:%i') as startTime,
  250. DATE_FORMAT(o.end_time, '%Y-%m-%d %H:%i') as endTime,
  251. TRUNCATE(IFNULL(o.settlement_price_sum,0)/100.0,2) as settlementPriceSum,
  252. o.pay_account as payAccount,
  253. o.service_station_name as serviceStationName,
  254. o.group_leader_name as groupLeaderName,
  255. o.visit_reserve_date as visitReserveDate,
  256. o.station_name as stationName,
  257. o.belong as belong,
  258. o.supplier_one_name as supplierOneName,
  259. o.contract_no as contractNo,
  260. TRUNCATE(IFNULL(o.consignment_price_sum,0)/100.0,2) as consignmentPriceSum,
  261. o.review_reason as reviewReason,
  262. TRUNCATE(IFNULL(o.pay_price,0)/100.0,2) as payPrice,
  263. TRUNCATE(IFNULL(o.card_price,0)/100.0,2) as cardPrice,
  264. TRUNCATE(IFNULL(o.subsidy_price,0)/100.0,2) as subsidyPrice,
  265. o.fund_price as fundPrice,
  266. od.tracking_code,
  267. od.tracking_company,
  268. od.man_hour,
  269. o.card_names as cardNameStr
  270. FROM
  271. ${dbName}_order.o_order_${operatorId} o
  272. left join ${dbName}_order.o_order_detail_${operatorId} od on o.order_id = od.order_id and od.yn=0
  273. WHERE
  274. o.yn=0
  275. and o.id > #{start}
  276. and ${ew.sqlSegment}
  277. order by o.id
  278. limit 10000
  279. </select>
  280. <select id="orderPageListSize" resultType="java.lang.Integer">
  281. SELECT count(*)
  282. FROM
  283. ${dbName}_order.o_order_${operatorId} o
  284. WHERE o.yn = 0
  285. and ${ew.sqlSegment}
  286. </select>
  287. <select id="orderPageListAllSize" resultType="java.lang.Integer">
  288. SELECT count(*)
  289. FROM
  290. ${dbName}_order.o_order_${operatorId} o
  291. left join ${dbName}_order.o_order_detail_${operatorId} od on o.order_id = od.order_id
  292. WHERE o.yn = 0
  293. AND od.yn = 0
  294. and ${ew.sqlSegment}
  295. </select>
  296. <select id="dishesOrderPageListAllSize" resultType="java.lang.Integer">
  297. SELECT count(*)
  298. FROM
  299. ${dbName}_order.o_dishes_order_${operatorId} o
  300. WHERE o.yn = 0
  301. and ${ew.sqlSegment}
  302. </select>
  303. <select id="dishesOrderExcel" resultType="com.poteviohealth.cgp.statistics.model.outdto.DishesOrderWebOutDTO">
  304. SELECT
  305. id,
  306. customer_name,
  307. sn,
  308. customer_phone,
  309. product_string,
  310. id_card as idCard,
  311. DATE_FORMAT(order_time,'%Y-%m-%d %H:%i') AS orderTime,
  312. TRUNCATE ( sum_price/ 100.0, 2 ) AS sumPrice,
  313. TRUNCATE ( card_price/ 100.0, 2 ) AS cardPrice,
  314. TRUNCATE ( subsidy_price/ 100.0, 2 ) AS subsidyPrice,
  315. TRUNCATE ( pay_price/ 100.0, 2 ) AS payPrice,
  316. fund_price,
  317. '已支付' as payStatusStr,
  318. pay_account as payAccountStr,
  319. service_station_name,
  320. street_name as streetName,
  321. country_name as countryName,
  322. case when source_id = 1 then '刷脸' when source_id = 2 then '手机号' else '' end as sourceStr,
  323. case when eat_in = 0 then '否' when eat_in = 1 then '是' else '' end as eatInStr
  324. FROM
  325. ${dbName}_order.o_dishes_order_${operatorId} o
  326. WHERE o.yn = 0
  327. and o.id > #{start}
  328. and ${ew.sqlSegment}
  329. order by o.id
  330. limit 10000
  331. </select>
  332. <select id="costOrderPageListAllSize" resultType="java.lang.Integer">
  333. SELECT count(*)
  334. FROM
  335. ${dbName}_order.o_order_cost_${operatorId} o
  336. WHERE o.yn = 0
  337. and ${ew.sqlSegment}
  338. </select>
  339. <select id="costOrderExcel" resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderCostWebOutDTO">
  340. SELECT
  341. o.id,
  342. o.sn,
  343. o.category_name,
  344. o.cost_year,
  345. o.customer_name,
  346. o.customer_type,
  347. o.station_name,
  348. o.settlement_attribution,
  349. o.service_station_name,
  350. o.country_name,
  351. o.address,
  352. o.employee_name,
  353. o.service_name,
  354. DATE_FORMAT(o.order_time,'%Y-%m-%d %H:%i') AS orderTime,
  355. DATE_FORMAT(o.end_time,'%Y-%m-%d %H:%i') AS endTime,
  356. case when o.revenue_status = 1 then '未核算' else '已核算' end as revenueStatusStr,
  357. TRUNCATE (o.sign_price/ 100.0, 2 ) AS signPrice,
  358. o.man_hour,
  359. o.num,
  360. TRUNCATE (o.price/ 100.0, 2 ) AS price,
  361. TRUNCATE (o.labor/ 100.0, 2 ) as labor,
  362. TRUNCATE (o.standard/ 100.0, 2 ) as standard,
  363. TRUNCATE (o.adjustment/ 100.0, 2 ) as adjustment,
  364. TRUNCATE (o.actual/ 100.0, 2 ) as actual,
  365. TRUNCATE (o.income/ 100.0, 2 ) as income,
  366. TRUNCATE (o.money/ 100.0, 2 ) as money,
  367. DATE_FORMAT(o.revenue_date,'%Y-%m-%d %H:%i') AS revenueDate,
  368. o.remark,
  369. o.transaction_id,
  370. TRUNCATE (o.pay_price/ 100.0, 2 ) as payPrice
  371. FROM
  372. ${dbName}_order.o_order_cost_${operatorId} o
  373. WHERE o.yn = 0
  374. and o.id > #{start}
  375. and ${ew.sqlSegment}
  376. order by o.id
  377. limit 10000
  378. </select>
  379. <select id="pageCardListSize" resultType="java.lang.Integer">
  380. select count(*) from (
  381. select count(d.id)
  382. from ${dbName}_finance.c_card_acc_detail d
  383. <if test="queryParam.stationIds.size()>0">
  384. left join (SELECT d.id,
  385. SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
  386. FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN t_number b ON b.id &lt;(
  387. LENGTH( d.station_ids ) - LENGTH( REPLACE(d.station_ids,',','') ) + 1
  388. )
  389. where d.yn = 0 and d.type = 1 and d.station_ids != '' and ${ew.sqlSegment} ) a
  390. on d.id = a.id
  391. </if>
  392. where d.yn = 0 and d.type = 1 and d.station_ids != ''
  393. <if test="queryParam.stationIds.size()>0">
  394. and a.stationId in
  395. <foreach collection="queryParam.stationIds" item="item" separator="," open="(" close=")">
  396. #{item}
  397. </foreach>
  398. </if>
  399. and ${ew.sqlSegment}
  400. group by d.id) t
  401. </select>
  402. <select id="pageCardList" resultType="com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanDTO">
  403. select d.id,d.name,d.phone,d.id_number,d.category_name,d.type_name,d.customer_address,d.customer_type_name,
  404. case when d.enable =1 then '启用' else '停用' end as enabled,TRUNCATE(d.balance/100,2) as balance
  405. from ${dbName}_finance.c_card_acc_detail d
  406. <if test="queryParam.stationIds.size()>0">
  407. left join (SELECT d.id,
  408. SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
  409. FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN t_number b ON b.id &lt;(
  410. LENGTH( d.station_ids ) - LENGTH( REPLACE(d.station_ids,',','') ) + 1
  411. )
  412. where d.yn = 0 and d.type = 1 and d.station_ids != '' and ${ew.sqlSegment} ) a
  413. on d.id = a.id
  414. </if>
  415. where d.yn = 0 and d.type = 1 and d.station_ids != ''
  416. and d.id > #{start}
  417. <if test="queryParam.stationIds.size()>0">
  418. and a.stationId in
  419. <foreach collection="queryParam.stationIds" item="item" separator="," open="(" close=")">
  420. #{item}
  421. </foreach>
  422. </if>
  423. and ${ew.sqlSegment}
  424. group by d.id
  425. order by d.id
  426. limit 10000
  427. </select>
  428. <select id="transRechargeExcelListAllSize" resultType="int">
  429. select count(*)
  430. from ${dbName}_finance.c_card_acc_detail d
  431. <if test="queryParam.stationIds.size()>0">
  432. left join (SELECT d.id,
  433. SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
  434. FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN ${dbName}_finance.t_number b ON b.id &lt;(
  435. LENGTH( d.station_ids ) - LENGTH( REPLACE(d.station_ids,',','') ) + 1
  436. )
  437. where d.yn = 0 and d.type = 1 and d.station_ids != '' and ${ew.sqlSegment} ) a
  438. on d.id = a.id
  439. </if>
  440. left join ${dbName}_finance.c_card_acc_trans t on t.detail_id = d.id
  441. where d.yn = 0 and t.yn = 0 and d.type = 1
  442. and t.trans_type = 0
  443. <if test="queryParam.startDate != null">
  444. and t.build_time between #{queryParam.startDate} and #{queryParam.endDate}
  445. </if>
  446. and d.station_ids != ''
  447. <if test="queryParam.stationIds.size()>0">
  448. and a.stationId in
  449. <foreach collection="queryParam.stationIds" item="item" separator="," open="(" close=")">
  450. #{item}
  451. </foreach>
  452. </if>
  453. and ${ew.sqlSegment}
  454. </select>
  455. <select id="transRechargeExcel"
  456. resultType="com.poteviohealth.cgp.common.integrated.finance.model.CardAccTransRecharge">
  457. select t.id, t.build_time,
  458. d.name,
  459. d.id_number,
  460. TRUNCATE(t.amount/100,2) as amount,
  461. d.type_name
  462. from ${dbName}_finance.c_card_acc_detail d
  463. <if test="queryParam.stationIds.size()>0">
  464. left join (SELECT d.id,
  465. SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
  466. FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN ${dbName}_finance.t_number b ON b.id &lt;(
  467. LENGTH( d.station_ids ) - LENGTH( REPLACE(d.station_ids,',','') ) + 1
  468. )
  469. where d.yn = 0 and d.type = 1 and d.station_ids != '' and ${ew.sqlSegment} ) a
  470. on d.id = a.id
  471. </if>
  472. left join ${dbName}_finance.c_card_acc_trans t on t.detail_id = d.id
  473. where d.yn = 0 and t.yn = 0 and d.type = 1
  474. and t.trans_type = 0
  475. and t.id > #{start}
  476. <if test="queryParam.startDate != null">
  477. and t.build_time between #{queryParam.startDate} and #{queryParam.endDate}
  478. </if>
  479. and d.station_ids != ''
  480. <if test="queryParam.stationIds.size()>0">
  481. and a.stationId in
  482. <foreach collection="queryParam.stationIds" item="item" separator="," open="(" close=")">
  483. #{item}
  484. </foreach>
  485. </if>
  486. and ${ew.sqlSegment}
  487. order by t.id
  488. limit 10000
  489. </select>
  490. <select id="goldSendListSize" resultType="int">
  491. select count(*)
  492. from ${dbName}_customer.c_gold_send_${yearTime} d where d.yn = 0
  493. and ${ew.sqlSegment}
  494. </select>
  495. <select id="goldSendList" resultType="com.poteviohealth.cgp.statistics.model.outdto.GoldSendExcelDTO">
  496. select d.id, d.send_month,
  497. d.name,
  498. d.id_number,
  499. TRUNCATE(d.money/100,2) as moneyStr,
  500. d.country_name,
  501. d.street_name,
  502. d.community_name,
  503. d.bank_name,
  504. d.bank_card,
  505. d.bank_holder,
  506. case when d.gold_type = 0 then '80-89周岁'
  507. when d.gold_type = 1 then '90-99周岁'
  508. when d.gold_type = 2 then '100周岁以上' end as goldTypeStr
  509. from ${dbName}_customer.c_gold_send_${yearTime} d
  510. where d.yn = 0
  511. and d.id > #{start}
  512. and ${ew.sqlSegment}
  513. order by d.id
  514. limit 10000
  515. </select>
  516. <select id="goldSendBankList" resultType="com.poteviohealth.cgp.statistics.model.outdto.GoldSendBankExcelDTO">
  517. select d.id,d.name,d.id_number,'1' as idNumberType,TRUNCATE(d.money/100,2) as moneyStr,d.area_code,d.link_mobile,
  518. d.now_address,d.bank_code,d.bank_card,d.bank_holder
  519. from ${dbName}_customer.c_gold_send_${yearTime} d
  520. where d.yn = 0
  521. and d.id > #{start}
  522. and ${ew.sqlSegment}
  523. order by d.id
  524. limit 10000
  525. </select>
  526. </mapper>