OrderMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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.build_time AS buildTime
  23. FROM
  24. ${dbName}_finance.c_card_acc_trans t
  25. LEFT JOIN ${dbName}_finance.c_card_acc_detail d ON t.detail_id = d.id
  26. LEFT JOIN ${dbName}_order.o_order_detail_${operatorId} od ON od.order_detail_id = t.trans_id
  27. LEFT JOIN ${dbName}_customer.c_customer_subsidy_${operatorId} c ON c.subsidy_customer_id = d.subsidy_customer_id
  28. LEFT JOIN ${dbName}_common.f_category g ON g.id = od.product_category_id
  29. WHERE
  30. d.yn = 0
  31. AND t.yn = 0
  32. AND d.ENABLE = 1
  33. AND d.type = 2
  34. AND t.trans_type IN (0,1)
  35. and ${ew.sqlSegment}
  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. and ${ew.sqlSegment}
  61. </select>
  62. <select id="areaList" resultType="com.poteviohealth.cgp.common.integrated.partner.model.AreaDTO">
  63. select id,parent as parentId,name,tree_path, region_area_code,
  64. (LENGTH(tree_path) - LENGTH(replace(tree_path,',','')))-1 as `level`
  65. from ${dbName}_common.f_area
  66. where yn = 0
  67. and parent is not null
  68. and length(tree_path)-length(replace(tree_path,',','')) &lt;=4
  69. and (region_area_code like '37%' or
  70. region_area_code like '32%' or
  71. region_area_code like '11%' or
  72. region_area_code like '21%' or
  73. region_area_code like '51%')
  74. </select>
  75. <select id="supplierStationEmployeeList"
  76. resultType="com.poteviohealth.cgp.statistics.model.outdto.SupplierStationEmployee">
  77. select station_id,employee_id from ${dbName}_common.f_supplier_station_employee where yn = 0
  78. </select>
  79. <select id="supplierStationList" resultType="com.poteviohealth.cgp.statistics.model.outdto.SupplierStation">
  80. select id,city,country,street from ${dbName}_common.f_supplier_station
  81. where yn = 0 and `level` >=2 and status = 1 and type = 1 and LENGTH(region_code) = 12
  82. </select>
  83. <select id="employeeList" resultType="com.poteviohealth.cgp.statistics.model.outdto.Employee">
  84. select id,age,gender from ${dbName}_common.f_employee
  85. where yn = 0
  86. and role_id_str like '%25%'
  87. and status = 1
  88. and age is not null
  89. and gender is not null
  90. </select>
  91. <select id="getOperatorList" resultType="java.lang.Integer">
  92. select id from ${dbName}_common.f_operator
  93. where yn = 0 and id>0 and enabled = 1 and check_status = 2
  94. </select>
  95. <select id="getSubsidyCustomerList"
  96. resultType="com.poteviohealth.cgp.common.integrated.customer.model.CustomerSubsidyDTO">
  97. SELECT
  98. c.subsidy_customer_id as subsidyCustomerId,
  99. c.customer_id as customerId,
  100. IFNULL(c.now_city_id,(select p.address_city_id from ${dbName}_common.f_operator p where p.id = c.operator_id)) as nowCityId,
  101. IFNULL(c.now_city_name,(select p.address_city_name from ${dbName}_common.f_operator p where p.id = c.operator_id)) as nowCityName,
  102. c.now_country_id as nowCountryId,
  103. c.now_country_name as nowCountryName,
  104. c.now_street_id as nowStreetId,
  105. c.now_street_name as nowStreetName,
  106. c.customer_sign_id as customerSignId,
  107. c.customer_type_id as customerTypeId,
  108. c.customer_type as customerType,
  109. c.age as age,
  110. c.sex as sex,
  111. if(sum(IF( d.settlement = 1, 1, 0 ) )>0,1,0) as category
  112. FROM
  113. ${dbName}_finance.c_card_acc_detail d
  114. ,${dbName}_customer.c_customer_subsidy_${operatorId} c
  115. where c.subsidy_customer_id = d.subsidy_customer_id
  116. and c.yn = 0 AND d.yn = 0
  117. and c.customer_type_id is not null
  118. and c.customer_type is not null
  119. and c.enabled = 1
  120. and ${ew.sqlSegment}
  121. GROUP BY c.subsidy_customer_id
  122. </select>
  123. <select id="orderServiceCustomerList"
  124. resultType="com.poteviohealth.cgp.common.integrated.customer.model.CustomerServiceParams">
  125. SELECT
  126. IFNULL(c.now_city_id,(select p.address_city_id from ${dbName}_common.f_operator p where p.id = c.operator_id)) as cityId,
  127. IFNULL(c.now_country_id,-1) AS countryId,
  128. IFNULL(c.now_street_id,-1) AS streetId,
  129. count(DISTINCT c.customer_id) as customerNum,
  130. CONCAT(',',c.customer_type_id,',') as customerTypeId
  131. FROM
  132. ${dbName}_customer.c_customer_subsidy_${operatorId} c
  133. LEFT JOIN ${dbName}_order.o_order_${operatorId} o ON o.customer_id = c.customer_id
  134. WHERE
  135. o.order_status = 6
  136. AND o.order_type = 2
  137. and c.yn =0
  138. and o.yn = 0
  139. and c.enabled = 1
  140. GROUP BY c.now_street_id,c.customer_type_id;
  141. </select>
  142. <select id="getSubsidyCustomerMealList" resultType="com.poteviohealth.cgp.statistics.model.outdto.Customer">
  143. select IFNULL(now_city_id,(select p.address_city_id from ${dbName}_common.f_operator p where p.id = operator_id)) as nowCityId,
  144. IFNULL(now_country_id,-1) AS nowCountryId,
  145. IFNULL(now_street_id,-1) AS nowStreetId
  146. from ${dbName}_customer.c_customer_subsidy_${operatorId}
  147. where yn = 0
  148. and ${ew.sqlSegment}
  149. </select>
  150. <select id="queryOrderIntegrationData"
  151. resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderIntegrationData">
  152. 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
  153. ,o.customer_id as customerId,o.finish_time as finishTime,od.product_category_id as productCategoryId,v.qualified as qualified,
  154. v.result as result FROM ${dbName}_order.o_order_${operatorId} o,${dbName}_order.o_order_detail_${operatorId} od,${dbName}_order.o_visit_${operatorId} v
  155. where o.order_id = od.order_id
  156. and v.order_id = o.order_id
  157. and o.yn= 0 and v.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. and ${ew.sqlSegment}
  166. group by o.order_id
  167. </select>
  168. <select id="getAllCategory" resultType="com.poteviohealth.cgp.common.integrated.ListParams">
  169. select id,name,parent_id as `key` from ${dbName}_common.f_category where yn = 0
  170. </select>
  171. <select id="integralTransactionList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralTransaction">
  172. select num,integral,merchant_id,merchant_name from ${dbName}_customer.c_integral_transaction_${operatorId} where yn =0 and type = 0
  173. </select>
  174. <select id="integralProductList" resultType="com.poteviohealth.cgp.statistics.model.outdto.IntegralProduct">
  175. select merchant_id from ${dbName}_customer.c_integral_product where yn =0 and type = 0 and own_review = 1
  176. </select>
  177. <select id="getStationMerchantList"
  178. resultType="com.poteviohealth.cgp.statistics.model.outdto.StationMerchant">
  179. select id,name,status,type,city,country,street,supplier_id,country_name,street_name from ${dbName}_common.f_station_merchant where yn = 0
  180. </select>
  181. <select id="queryIntegralProduct" resultType="com.poteviohealth.cgp.statistics.model.outdto.Product">
  182. 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%'
  183. </select>
  184. <select id="getIntegralCardAccOperatorIdList" resultType="java.lang.Integer">
  185. 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
  186. </select>
  187. <select id="getIntegralCardDetailOperatorIdList" resultType="java.lang.Integer">
  188. select operator_id from ${dbName}_finance.c_card_acc_detail where yn = 0 and type = 2 and enable = 1 group by operator_id
  189. </select>
  190. <select id="orderExcel" resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderExcelDTO">
  191. SELECT
  192. o.supplier_name as supplierName,
  193. o.order_id as orderId,
  194. o.sn as sn,
  195. o.customer_name as customerName,
  196. o.id_number as idNumber,
  197. o.name as name,
  198. o.phone as phone,
  199. o.address as address,
  200. o.product_string as productString,
  201. o.service_name as serviceName,
  202. o.service_sku_name as serviceSkuName,
  203. o.service_num as serviceNum,
  204. TRUNCATE(IFNULL(o.sum_order_price,0)/100.0,2) as sumOrderPrice,
  205. TRUNCATE(IFNULL(o.sum_coupon_price,0)/100.0,2) as sumCouponPrice,
  206. TRUNCATE(IFNULL(o.sum_price,0)/100.0,2) as sumPrice,
  207. o.pay_style as payStyle,
  208. o.reservation_time as reservationTime,
  209. o.pay_status as payStatus,
  210. o.order_style as orderStyle,
  211. o.order_status as orderStatus,
  212. DATE_FORMAT(o.order_time, '%Y-%m-%d %H:%i') as orderTime,
  213. o.home_time as homeTime,
  214. o.send_time as sendTime,
  215. o.pickup_time as pickupTime,
  216. o.employee_name as employeeName,
  217. DATE_FORMAT(o.start_time, '%Y-%m-%d %H:%i') as startTime,
  218. DATE_FORMAT(o.end_time, '%Y-%m-%d %H:%i') as endTime,
  219. TRUNCATE(IFNULL(o.settlement_price_sum,0)/100.0,2) as settlementPriceSum,
  220. o.pay_account as payAccount,
  221. o.service_station_name as serviceStationName,
  222. o.group_leader_name as groupLeaderName,
  223. o.visit_reserve_date as visitReserveDate,
  224. o.station_name as stationName,
  225. o.belong as belong,
  226. o.supplier_one_name as supplierOneName,
  227. o.contract_no as contractNo,
  228. TRUNCATE(IFNULL(o.consignment_price_sum,0)/100.0,2) as consignmentPriceSum,
  229. o.review_reason as reviewReason,
  230. TRUNCATE(IFNULL(o.pay_price,0)/100.0,2) as payPrice,
  231. TRUNCATE(IFNULL(o.card_price,0)/100.0,2) as cardPrice,
  232. TRUNCATE(IFNULL(o.subsidy_price,0)/100.0,2) as subsidyPrice,
  233. o.fund_price as fundPrice,
  234. od.tracking_code,
  235. od.tracking_company,
  236. od.man_hour,
  237. o.card_names as cardNameStr
  238. FROM
  239. ${dbName}_order.o_order_${operatorId} o
  240. left join ${dbName}_order.o_order_detail_${operatorId} od on o.order_id = od.order_id and od.yn=0
  241. WHERE
  242. o.yn=0
  243. and ${ew.sqlSegment}
  244. order by o.id
  245. limit #{start},#{end}
  246. </select>
  247. <select id="orderPageListSize" resultType="java.lang.Integer">
  248. SELECT count(*)
  249. FROM
  250. ${dbName}_order.o_order_${operatorId} o
  251. WHERE o.yn = 0
  252. and ${ew.sqlSegment}
  253. </select>
  254. <select id="orderPageListAllSize" resultType="java.lang.Integer">
  255. SELECT count(*)
  256. FROM
  257. ${dbName}_order.o_order_${operatorId} o
  258. left join ${dbName}_order.o_order_detail_${operatorId} od on o.order_id = od.order_id
  259. WHERE o.yn = 0
  260. AND od.yn = 0
  261. and ${ew.sqlSegment}
  262. </select>
  263. <select id="dishesOrderPageListAllSize" resultType="java.lang.Integer">
  264. SELECT count(*)
  265. FROM
  266. ${dbName}_order.o_dishes_order_${operatorId} o
  267. WHERE o.yn = 0
  268. and ${ew.sqlSegment}
  269. </select>
  270. <select id="dishesOrderExcel" resultType="com.poteviohealth.cgp.statistics.model.outdto.DishesOrderWebOutDTO">
  271. SELECT
  272. customer_name,
  273. sn,
  274. customer_phone,
  275. product_string,
  276. DATE_FORMAT(order_time,'%Y-%m-%d %H:%i') AS orderTime,
  277. TRUNCATE ( sum_price/ 100.0, 2 ) AS sumPrice,
  278. TRUNCATE ( card_price/ 100.0, 2 ) AS cardPrice,
  279. TRUNCATE ( subsidy_price/ 100.0, 2 ) AS subsidyPrice,
  280. TRUNCATE ( pay_price/ 100.0, 2 ) AS payPrice,
  281. fund_price,
  282. '已支付' as payStatusStr,
  283. pay_account as payAccountStr,
  284. service_station_name
  285. FROM
  286. ${dbName}_order.o_dishes_order_${operatorId} o
  287. WHERE o.yn = 0
  288. and ${ew.sqlSegment}
  289. limit #{start},#{end}
  290. </select>
  291. <select id="costOrderPageListAllSize" resultType="java.lang.Integer">
  292. SELECT count(*)
  293. FROM
  294. ${dbName}_order.o_order_cost_${operatorId} o
  295. WHERE o.yn = 0
  296. and ${ew.sqlSegment}
  297. </select>
  298. <select id="costOrderExcel" resultType="com.poteviohealth.cgp.statistics.model.outdto.OrderCostWebOutDTO">
  299. SELECT
  300. o.sn,
  301. o.category_name,
  302. o.cost_year,
  303. o.customer_name,
  304. o.customer_type,
  305. o.station_name,
  306. o.settlement_attribution,
  307. o.service_station_name,
  308. o.country_name,
  309. o.address,
  310. o.employee_name,
  311. o.service_name,
  312. DATE_FORMAT(o.order_time,'%Y-%m-%d %H:%i') AS orderTime,
  313. DATE_FORMAT(o.end_time,'%Y-%m-%d %H:%i') AS end_time,
  314. case when o.revenue_status = 1 then '未核算' else '已核算' end as revenueStatusStr,
  315. TRUNCATE (o.sign_price/ 100.0, 2 ) AS signPrice,
  316. o.man_hour,
  317. o.num,
  318. TRUNCATE (o.price/ 100.0, 2 ) AS price,
  319. TRUNCATE (o.labor/ 100.0, 2 ) as labor,
  320. TRUNCATE (o.standard/ 100.0, 2 ) as standard,
  321. TRUNCATE (o.adjustment/ 100.0, 2 ) as adjustment,
  322. TRUNCATE (o.actual/ 100.0, 2 ) as actual,
  323. TRUNCATE (o.income/ 100.0, 2 ) as income,
  324. TRUNCATE (o.money/ 100.0, 2 ) as money,
  325. DATE_FORMAT(o.revenue_date,'%Y-%m-%d %H:%i') AS revenueDate,
  326. o.remark,
  327. o.transaction_id,
  328. TRUNCATE (o.pay_price/ 100.0, 2 ) as payPrice
  329. FROM
  330. ${dbName}_order.o_order_cost_${operatorId} o
  331. WHERE o.yn = 0
  332. and ${ew.sqlSegment}
  333. limit #{start},#{end}
  334. </select>
  335. </mapper>