MaterialMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  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.gree.mall.miniapp.commonmapper.MaterialMapper">
  4. <select id="buyList" resultType="com.gree.mall.miniapp.bean.material.SalesOrderBean">
  5. SELECT
  6. a.*
  7. FROM
  8. websit_sales a
  9. <where>
  10. a.company_wechat_id = #{companyWechatId}
  11. AND worker_id = #{userId}
  12. <if test="flag!=null and flag!=''">
  13. AND a.flag = #{flag}
  14. </if>
  15. <if test="flag==null or flag==''">
  16. AND a.flag IN ('SAVE', 'SUBMIT', 'PAY_NOT_TAKE', 'PAY_TAKE')
  17. </if>
  18. </where>
  19. ORDER BY a.create_time DESC
  20. </select>
  21. <select id="existStockCategory" resultType="com.gree.mall.miniapp.bean.material.WebsitSalesCategoryVO">
  22. SELECT
  23. c.category_id,
  24. c.category_name
  25. FROM
  26. websit_stock a
  27. LEFT JOIN websit_goods b ON a.goods_id = b.goods_id
  28. LEFT JOIN websit_goods_category c ON b.goods_category_id = c.category_id
  29. WHERE
  30. a.company_wechat_id = #{companyWechatId}
  31. AND a.websit_id = #{websitId}
  32. AND a.goods_type = 'M'
  33. AND a.qty > 0
  34. GROUP BY b.goods_category_id
  35. </select>
  36. <select id="existStockGoods" resultType="com.gree.mall.miniapp.bean.material.WebsitSalesGoodsVO">
  37. SELECT
  38. a.goods_id,
  39. b.goods_name,
  40. <if test="goodsType=='M'.toString()">
  41. c.price,
  42. </if>
  43. <if test="goodsType=='P'.toString()">
  44. b.market_price AS price,
  45. </if>
  46. b.goods_code,
  47. b.goods_spell,
  48. b.goods_specification,
  49. b.goods_stock_unit,
  50. b.goods_sales_unit,
  51. b.brand_rela_name,
  52. b.product_rela_name,
  53. b.convert_bit_scale,
  54. b.goods_sales_convert_qty,
  55. b.manage_worker_stock,
  56. a.qty
  57. FROM
  58. websit_stock a
  59. JOIN websit_goods b ON a.goods_id = b.goods_id
  60. <if test="goodsType=='M'.toString()">
  61. LEFT JOIN websit_goods_price c ON a.websit_id = c.websit_id AND a.goods_id = c.goods_id
  62. </if>
  63. WHERE
  64. a.company_wechat_id = #{companyWechatId}
  65. <if test="goodsType=='M'.toString() and categoryId!=null and categoryId!=''">
  66. AND b.goods_category_id = #{categoryId}
  67. </if>
  68. <if test="goodsName!=null and goodsName!=''">
  69. AND b.goods_name LIKE CONCAT('%',#{goodsName},'%')
  70. </if>
  71. AND a.websit_id = #{websitId}
  72. AND a.goods_type = #{goodsType}
  73. AND a.qty > 0
  74. GROUP BY a.goods_id
  75. LIMIT 100
  76. </select>
  77. <select id="notStockGoods" resultType="com.gree.mall.miniapp.bean.material.WebsitSalesGoodsVO">
  78. SELECT
  79. b.goods_id,
  80. b.goods_name,
  81. b.market_price AS price,
  82. b.goods_code,
  83. b.goods_spell,
  84. b.goods_specification,
  85. b.goods_stock_unit,
  86. b.goods_sales_unit,
  87. b.brand_rela_name,
  88. b.product_rela_name,
  89. b.convert_bit_scale,
  90. b.goods_sales_convert_qty,
  91. b.manage_worker_stock,
  92. b.part_type,
  93. 0 AS qty
  94. FROM
  95. websit_goods b
  96. WHERE
  97. b.company_wechat_id = #{companyWechatId}
  98. <if test="goodsName!=null and goodsName!=''">
  99. AND b.goods_name LIKE CONCAT('%',#{goodsName},'%')
  100. </if>
  101. AND b.goods_type = #{goodsType}
  102. AND b.status = 'ON'
  103. AND b.norm_type = 'M'
  104. </select>
  105. <select id="normRecordList" resultType="com.gree.mall.miniapp.bean.material.NormRecordVO">
  106. SELECT
  107. a.*
  108. FROM
  109. websit_norm_record a
  110. WHERE
  111. a.company_wechat_id = #{companyWechatId}
  112. AND a.worker_id = #{userId}
  113. <if test="orderId!=null and orderId!=''">
  114. AND a.order_id LIKE CONCAT ('%', #{orderId}, '%')
  115. </if>
  116. <if test="goodsType!=null and goodsType!=''">
  117. AND a.goods_type = #{goodsType}
  118. </if>
  119. <if test="startTime!=null and startTime!=''">
  120. AND a.use_time BETWEEN #{startTime} AND #{endTime}
  121. </if>
  122. ORDER BY a.use_time DESC
  123. </select>
  124. <select id="partsRefundList" resultType="com.gree.mall.miniapp.bean.material.PartsRefundVO">
  125. SELECT
  126. a.*
  127. FROM
  128. websit_parts_ret a
  129. WHERE
  130. a.company_wechat_id = #{companyWechatId}
  131. AND a.worker_id = #{userId}
  132. <if test="type!=null and type!=''">
  133. AND a.type = #{type}
  134. </if>
  135. <if test="status!=null and status!=''">
  136. AND a.flag = #{status}
  137. </if>
  138. </select>
  139. <select id="queryShoppingCartList" resultType="com.gree.mall.miniapp.bean.material.WebsitShoppingCartList">
  140. SELECT
  141. a.*
  142. FROM
  143. websit_shopping_cart a
  144. WHERE
  145. a.worker_id = #{workerId}
  146. AND a.websit_id = #{websitId}
  147. AND a.goods_type = #{goodsType}
  148. </select>
  149. <select id="queryWorkerStockQty"
  150. resultType="com.gree.mall.miniapp.bean.material.stock.WorkerNormStockBean">
  151. SELECT
  152. a.norm_id,
  153. a.worker_goods_id,
  154. a.qty,
  155. b.goods_name,
  156. b.is_small,
  157. b.sales_unit,
  158. c.qty AS stock_qty
  159. FROM
  160. websit_norm_rela a
  161. JOIN
  162. worker_goods b
  163. ON a.company_wechat_id = b.company_wechat_id AND a.worker_goods_id = b.goods_id
  164. LEFT JOIN
  165. worker_stock c
  166. ON c.worker_id = #{workerId} AND a.company_wechat_id = c.company_wechat_id AND a.worker_goods_id = c.goods_id
  167. WHERE
  168. a.norm_id = #{goodsId}
  169. </select>
  170. <select id="appList" resultType="com.gree.mall.miniapp.bean.material.parts.NewRefundManageBean">
  171. SELECT
  172. a.company_wechat_id,
  173. a.company_wechat_name,
  174. a.apply_no,
  175. a.sales_id,
  176. a.apply_category,
  177. CASE a.apply_category WHEN 'HOME' THEN '家用空调'
  178. WHEN 'TRADE' THEN '商用空调'
  179. WHEN 'ELEC' THEN '生活电器(小家电)'
  180. ELSE '' END AS applyCategoryName,
  181. a.apply_type,
  182. CASE a.apply_type WHEN 'NEW' THEN '新件返还'
  183. WHEN 'LOST' THEN '破损返还'
  184. WHEN 'BUG' THEN '故障返还'
  185. ELSE '' END AS applyTypeName,
  186. a.refund_mode,
  187. CASE a.refund_mode WHEN 'EXPRESS' THEN '快递'
  188. WHEN 'SELF' THEN '网点自还'
  189. ELSE '' END AS refundModeName,
  190. a.express_no,
  191. a.receive_address,
  192. a.receive_websit_id,
  193. a.receive_websit_name,
  194. a.receive_parts_websit_id,
  195. a.websit_Address,
  196. a.identity,
  197. a.worker_id,
  198. a.worker_name,
  199. a.refund_amount,
  200. a.refund_amount_mode,
  201. IF(refund_amount_mode = 'CASH', '现金', '微信') AS refundAmountModeName,
  202. a.remark,
  203. a.examine_remark,
  204. a.flag,
  205. CASE a.flag WHEN 'SAVE' THEN '保存'
  206. WHEN 'SUBMIT' THEN '待审批'
  207. WHEN 'AGREE' THEN '待返还'
  208. WHEN 'REJECT' THEN '驳回'
  209. WHEN 'REFUNDED' THEN '已返还'
  210. ELSE '' END AS flagName,
  211. a.create_by,
  212. a.create_time,
  213. a.update_by,
  214. a.update_time,
  215. a.submit_by,
  216. a.submit_time,
  217. a.examine_by,
  218. a.examine_time,
  219. a.refunded_by,
  220. a.refunded_time
  221. FROM
  222. websit_parts_new_refund_manage a
  223. LEFT JOIN websit_parts_new_refund_manage_item b ON a.apply_no = b.apply_no
  224. <where>
  225. a.company_wechat_id = #{companyWechatId}
  226. <if test="applyNo != null and applyNo != ''">
  227. AND a.apply_no = #{applyNo}
  228. </if>
  229. <if test="flag != null and flag != ''">
  230. AND a.flag = #{flag}
  231. </if>
  232. <if test="identity != null and identity != ''">
  233. AND a.identity = #{identity}
  234. </if>
  235. <if test="partsNumber != null and partsNumber != ''">
  236. AND b.parts_number = #{partsNumber}
  237. </if>
  238. </where>
  239. GROUP BY a.apply_no, a.create_time
  240. ORDER BY a.create_time DESC
  241. </select>
  242. <select id="querySalesPushFlagItem" resultType="com.gree.mall.miniapp.plus.entity.WebsitPartsSalesItem">
  243. SELECT
  244. id,
  245. identity,
  246. websit_id,
  247. parts_websit_id,
  248. parts_id,
  249. parts_number,
  250. parts_name,
  251. material_group_name,
  252. goods_stock_unit,
  253. sales_id,
  254. sales_price,
  255. market_price,
  256. second_price,
  257. qty,
  258. examine_qty,
  259. new_refund_qty,
  260. old_refund_qty,
  261. total_amount,
  262. refund_amount_mode,
  263. push_flag,
  264. create_by,
  265. create_time,
  266. update_by,
  267. update_time,
  268. examine_time
  269. FROM
  270. websit_parts_sales_item
  271. WHERE
  272. identity = #{identity}
  273. AND websit_id = #{websitId}
  274. AND parts_websit_id = #{partsWebsitId}
  275. <if test="pushFlag != null and pushFlag != ''">
  276. AND push_flag = #{pushFlag}
  277. </if>
  278. <if test="salesId != null and salesId != ''">
  279. AND sales_id = #{salesId}
  280. </if>
  281. AND parts_number IN
  282. <foreach item="item" index="index" collection="records" open="(" separator=","
  283. close=")">
  284. #{item.partsNumber}
  285. </foreach>
  286. ORDER BY
  287. examine_time
  288. FOR UPDATE
  289. </select>
  290. <select id="appSalesList" resultType="com.gree.mall.miniapp.bean.material.parts.PartsSalesOrderBean">
  291. SELECT
  292. a.*,
  293. CASE a.order_source WHEN 'SELF' THEN '自建订单'
  294. WHEN 'ONLINE' THEN '在线订单'
  295. ELSE '' END AS buyTypeName,
  296. CASE a.status WHEN 'SAVE' THEN '保存未提交'
  297. WHEN 'SUBMIT' THEN '已提交'
  298. <!-- WHEN '2' THEN '已支付' -->
  299. WHEN 'PAYED' THEN
  300. <!-- WHEN '3' THEN '已提货' -->
  301. (case when a.worker_confirm_date is not null and a.websit_confirm_date is not null then '已提货'
  302. when a.worker_confirm_date is not null then '师傅已提货'
  303. when a.websit_confirm_date is not null then '网点已提货' else '已支付' end)
  304. WHEN 'END' THEN '已完成'
  305. WHEN 'CANCEL' THEN '已取消'
  306. ELSE '' END AS stateName,
  307. CASE a.pushFlag WHEN 'SALES' THEN '销售'
  308. WHEN 'TRANS' THEN '转销售'
  309. WHEN 'END' THEN '完结'
  310. ELSE '' END AS pushFlagName
  311. FROM
  312. websit_parts_sales a, websit_parts_sales_item b
  313. WHERE
  314. a.company_wechat_id = #{companyWechatId}
  315. AND a.id = b.sales_id
  316. AND a.del = 0
  317. AND a.identity = #{identity}
  318. <if test="salesId != null and salesId != ''">
  319. AND a.id = #{salesId}
  320. </if>
  321. <if test="status != null and status != ''">
  322. <!-- and 1 = 0 -->
  323. <if test="status == 'SAVE'.toString() or status == 'SUBMIT'.toString() or status == 'END'.toString() or status == 'CANCEL'.toString()">
  324. AND a.status = #{state}
  325. </if>
  326. <if test="state == 'PAYED'.toString()">
  327. AND a.status = 'PAYED' AND (a.worker_confirm_date is null and a.websit_confirm_date is null)
  328. </if>
  329. </if>
  330. <if test="pushFlag != null and pushFlag != ''">
  331. AND a.pushFlag = #{pushFlag}
  332. AND b.qty > 0
  333. </if>
  334. <if test="partsNumber != null and partsNumber != ''">
  335. AND b.parts_number = #{partsNumber}
  336. </if>
  337. GROUP BY
  338. a.identity, a.id, a.create_time
  339. ORDER BY
  340. a.create_time DESC
  341. </select>
  342. <select id="selectItemBySalesOrderId"
  343. resultType="com.gree.mall.miniapp.bean.material.parts.PartsSalesOrderItemBean">
  344. select
  345. a.id ,
  346. a.identity ,
  347. a.websit_id,
  348. a.parts_websit_id,
  349. a.parts_id,
  350. a.parts_number,
  351. a.parts_name,
  352. a.material_group_name,
  353. a.goods_stock_unit,
  354. a.sales_id,
  355. a.sales_price,
  356. a.market_price,
  357. a.second_price,
  358. IF(d.status = 'END', a.examine_qty, a.qty) AS qty,
  359. a.examine_qty,
  360. a.new_refund_qty,
  361. a.old_refund_qty ,
  362. a.total_amount,
  363. a.push_flag ,
  364. a.create_by ,
  365. a.create_time,
  366. a.update_by,
  367. a.update_time,
  368. IFNULL(c.qty, 0) stockQty
  369. FROM websit_parts_sales_item a JOIN websit_goods b ON a.parts_id = b.goods_id
  370. LEFT JOIN websit_stock c ON a.websit_id = c.websit_id AND a.parts_number = c.goods_id AND a.parts_websit_id = c.parts_websit_id
  371. JOIN websit_parts_sales d ON a.sales_id = d.id
  372. WHERE a.sales_id = #{id}
  373. </select>
  374. <select id="queryOldRefundRecordById"
  375. resultType="com.gree.mall.miniapp.bean.material.parts.OldRefundManageRecordBean">
  376. SELECT
  377. a.*
  378. FROM
  379. websit_parts_old_refund_manage_record a
  380. WHERE
  381. sales_id = #{id}
  382. </select>
  383. <select id="websitGroupList" resultType="java.lang.String">
  384. SELECT
  385. material_group_name
  386. FROM
  387. websit_stock
  388. WHERE
  389. company_wechat_id = #{companyWechatId}
  390. AND websit_id = #{websitId}
  391. AND parts_websit_id = #{partsWebsitId}
  392. AND qty > 0
  393. GROUP BY
  394. material_group_name
  395. </select>
  396. <select id="existWebsitStockList"
  397. resultType="com.gree.mall.miniapp.bean.material.parts.WebsitPartsStockBean">
  398. SELECT
  399. a.id,
  400. a.websit_id,
  401. a.websit_name,
  402. a.parts_websit_id,
  403. a.goods_id,
  404. a.goods_name,
  405. b.material_group_name,
  406. b.part_type,
  407. b.market_price,
  408. b.goods_stock_unit,
  409. a.qty,
  410. a.old_qty
  411. FROM
  412. websit_stock a LEFT JOIN websit_goods b ON a.company_wechat_id = b.company_wechat_id AND a.goods_id = b.goods_code
  413. WHERE
  414. a.company_wechat_id = #{companyWechatId}
  415. AND a.websit_id = #{websitId}
  416. AND a.parts_websit_id = #{partsWebsitId}
  417. <if test="partsNumber != null and partsNumber != ''">
  418. AND a.goods_id = #{partsNumber}
  419. </if>
  420. <if test="partsName != null and partsName != ''">
  421. AND a.goods_name LIKE CONCAT('%', #{partsName}, '%')
  422. </if>
  423. <if test="materialGroupName != null and materialGroupName != ''">
  424. AND a.goods_stock_unit = #{materialGroupName}
  425. </if>
  426. AND a.goods_type = 'P'
  427. AND a.qty > 0
  428. </select>
  429. <select id="existWebsitList" resultType="com.gree.mall.miniapp.plus.entity.AdminWebsit">
  430. SELECT
  431. websit_id, websit_name AS name, parts_websit_id
  432. FROM
  433. worker_stock
  434. WHERE
  435. company_wechat_id = #{companyWechatId}
  436. AND identity = #{identity}
  437. GROUP BY
  438. websit_id, parts_websit_id
  439. </select>
  440. <select id="existWebsitGroupList" resultType="java.lang.String">
  441. SELECT
  442. material_group_name
  443. FROM
  444. worker_stock
  445. WHERE
  446. company_wechat_id = #{companyWechatId}
  447. AND identity = #{identity}
  448. AND websit_id = #{websitId}
  449. AND parts_websit_id = #{partsWebsitId}
  450. <choose>
  451. <when test="partsAttr != null and partsAttr == 'NEW'">
  452. AND qty > 0
  453. </when>
  454. <when test="partsAttr != null and partsAttr == 'OLD'">
  455. AND old_qty > 0
  456. </when>
  457. <when test="partsAttr != null and partsAttr == 'WAY'">
  458. AND way_qty > 0
  459. </when>
  460. <otherwise>
  461. AND id = 0
  462. </otherwise>
  463. </choose>
  464. GROUP BY
  465. material_group_name
  466. </select>
  467. <select id="existWorkerStockList"
  468. resultType="com.gree.mall.miniapp.bean.material.parts.PartsWorkerStockBean">
  469. SELECT
  470. a.*,
  471. b.market_price
  472. FROM
  473. worker_stock a LEFT JOIN websit_goods b ON a.company_wechat_id = b.company_wechat_id AND a.goods_id = b.goods_code
  474. WHERE
  475. a.company_wechat_id = #{companyWechatId}
  476. AND a.goods_type = 'P'
  477. AND a.identity = #{identity}
  478. AND a.websit_id = #{websitId}
  479. AND a.parts_websit_id = #{partsWebsitId}
  480. <if test="partsNumber != null and partsNumber != ''">
  481. AND a.goods_id = #{partsNumber}
  482. </if>
  483. <if test="partsName != null and partsName != ''">
  484. AND a.goods_name LIKE CONCAT('%',#{partsName},'%')
  485. </if>
  486. <if test="materialGroupId != null and materialGroupId != ''">
  487. AND a.material_group_name = #{materialGroupName}
  488. </if>
  489. <choose>
  490. <when test="partsAttr != null and partsAttr == 'NEW'">
  491. AND a.qty > 0
  492. </when>
  493. <when test="partsAttr != null and partsAttr == 'OLD'">
  494. AND a.old_qty > 0
  495. </when>
  496. <when test="partsAttr != null and partsAttr == 'WAY'">
  497. AND a.way_qty > 0
  498. </when>
  499. <otherwise>
  500. AND a.id = 0
  501. </otherwise>
  502. </choose>
  503. </select>
  504. <select id="querySalesEndTimeByIdentity"
  505. resultType="com.gree.mall.miniapp.plus.entity.WebsitPartsSalesItem">
  506. SELECT
  507. b.parts_number,
  508. b.qty,
  509. a.end_time AS examineTime
  510. FROM
  511. websit_parts_sales a, websit_parts_sales_item b
  512. WHERE
  513. a.id = b.sales_id
  514. AND a.company_wechat_id = #{companyWechatId}
  515. AND a.pushFlag = 'SALES'
  516. AND a.identity = #{identity}
  517. AND a.websit_id = #{websitId}
  518. AND a.parts_websit_id = #{partsWebsitId}
  519. AND b.qty > 0
  520. GROUP BY b.parts_number
  521. </select>
  522. <select id="workerStockStatistics"
  523. resultType="com.gree.mall.miniapp.bean.material.parts.WorkerStockCensusBean">
  524. SELECT t.worker_id, t.identity,
  525. SUM(IFNULL(qty,0)) as newQty,
  526. SUM(IFNULL(old_qty,0)) as oldQty
  527. FROM worker_stock t
  528. WHERE identity = #{identity}
  529. AND goods_type = 'P'
  530. <if test="websitId != null and websitId != ''">
  531. AND t.websit_id = #{websitId}
  532. </if>
  533. GROUP BY t.identity
  534. </select>
  535. <select id="workerNewStockStatistics"
  536. resultType="com.gree.mall.miniapp.bean.material.parts.WorkerStockCensusBean">
  537. SELECT
  538. SUM(
  539. IFNULL( b.qty, 0 )) AS newRefundQty,
  540. SUM(
  541. IFNULL( b.total_amount, 0 )) AS newRefundAmount
  542. FROM
  543. websit_parts_new_refund_manage a
  544. INNER JOIN websit_parts_new_refund_manage_record b ON a.apply_no = b.apply_no
  545. WHERE
  546. a.flag IN ( 'SAVE', 'SUBMIT', 'AGREE' )
  547. AND a.identity = #{identity}
  548. <if test="websitId != null and websitId != ''">
  549. AND a.receive_websit_id = #{websitId}
  550. </if>
  551. GROUP BY
  552. a.identity
  553. </select>
  554. <select id="workerOldStockStatistics"
  555. resultType="com.gree.mall.miniapp.bean.material.parts.WorkerStockCensusBean">
  556. SELECT
  557. SUM(
  558. IFNULL( b.qty, 0 )) AS oldRefundQty,
  559. SUM(
  560. IFNULL( b.total_amount, 0 )) AS oldRefundAmount
  561. FROM
  562. websit_parts_old_refund_manage a
  563. INNER JOIN websit_parts_old_refund_manage_record b ON a.apply_no = b.apply_no
  564. WHERE
  565. a.flag IN ( 'SAVE', 'SUBMIT' )
  566. AND a.identity = #{identity}
  567. <if test="websitId != null and websitId != ''">
  568. AND a.receive_websit_id = #{websitId}
  569. </if>
  570. GROUP BY
  571. a.identity
  572. </select>
  573. <select id="appOldRefundList" resultType="com.gree.mall.miniapp.bean.material.parts.OldRefundManageBean">
  574. SELECT
  575. a.apply_no,
  576. a.apply_category,
  577. CASE a.apply_category WHEN 'HOME' THEN '家用空调'
  578. WHEN 'TRADE' THEN '商用空调'
  579. WHEN 'ELEC' THEN '生活电器(小家电)'
  580. ELSE '' END AS applyCategoryName,
  581. a.apply_type,
  582. CASE a.apply_type WHEN 'NEW' THEN '新件返还'
  583. WHEN 'LOST' THEN '破损返还'
  584. WHEN 'BUG' THEN '故障返还'
  585. ELSE '' END AS applyTypeName,
  586. a.refund_mode,
  587. CASE a.refund_mode WHEN 'EXPRESS' THEN '快递'
  588. WHEN 'SELF' THEN '网点自还'
  589. ELSE '' END AS refundModeName,
  590. a.repair_flag,
  591. CASE a.repair_flag WHEN 'INNER' THEN '保内'
  592. WHEN 'OUTSIDE' THEN '保外'
  593. ELSE '' END AS repairFlagName,
  594. a.express_no,
  595. a.receive_address,
  596. a.receive_websit_id,
  597. a.receive_websit_name,
  598. a.receive_parts_websit_id,
  599. a.websit_Address,
  600. a.identity,
  601. a.worker_id,
  602. a.worker_name,
  603. a.work_order_no,
  604. a.pg_id,
  605. a.customer_name,
  606. a.customer_tel,
  607. a.refund_amount,
  608. a.refund_amount_mode,
  609. a.settlement_state,
  610. CASE a.settlement_state WHEN 0 THEN '未结算'
  611. WHEN 1 THEN '已结算'
  612. ELSE '' END AS settlementStateName,
  613. a.remark,
  614. a.examine_remark,
  615. a.flag,
  616. CASE WHEN a.flag = 'SAVE' THEN '保存'
  617. WHEN a.flag = 'SUBMIT' THEN '待审批'
  618. WHEN a.flag = 'AGREE' and a.repair_flag = 'INNER' THEN '待返还'
  619. WHEN a.flag = 'AGREE' and a.repair_flag = 'OUTSIDE' THEN '通过'
  620. WHEN a.flag = 'REJECT' THEN '驳回'
  621. WHEN a.flag = 'REFUNDED' THEN '已返还'
  622. ELSE a.flag = '' END AS flagName,
  623. a.create_by,
  624. a.create_time,
  625. a.update_by,
  626. a.update_time,
  627. a.submit_by,
  628. a.submit_time,
  629. a.examine_by,
  630. a.examine_time,
  631. a.refunded_by,
  632. a.refunded_time
  633. FROM
  634. websit_parts_old_refund_manage a
  635. LEFT JOIN websit_parts_old_refund_manage_item b ON a.apply_no = b.apply_no
  636. <where>
  637. a.company_wechat_id = #{companyWechatId}
  638. <if test="applyNo != null and applyNo != ''">
  639. AND a.apply_no = #{applyNo}
  640. </if>
  641. <if test="flag != null and flag != ''">
  642. AND a.flag = #{flag}
  643. </if>
  644. <if test="identity != null and identity != ''">
  645. AND a.identity = #{identity}
  646. </if>
  647. <if test="partsNumber != null and partsNumber != ''">
  648. AND b.new_parts_number = #{partsNumber}
  649. </if>
  650. <if test="repairFlag != null and repairFlag != ''">
  651. AND a.repair_flag = #{repairFlag}
  652. </if>
  653. </where>
  654. GROUP BY a.apply_no, a.create_time
  655. ORDER BY a.create_time DESC
  656. </select>
  657. <select id="queryWebsitList" resultType="com.gree.mall.miniapp.bean.material.parts.WebsitExtends">
  658. SELECT
  659. a.*,
  660. <!-- 按距离排序计算 -->
  661. TRUNCATE(ACOS(
  662. SIN((PI() / 180) * lat) * SIN((PI() / 180) * #{latitude})
  663. + COS((PI() / 180) * lat) * COS((PI() / 180) * #{latitude}) * COS((PI() / 180) * #{longitude} - (PI() / 180) * lng)
  664. ) * 6371,0) as distance
  665. from admin_websit a
  666. <where>
  667. <if test="websitId == null">
  668. AND a.status = 1
  669. </if>
  670. </where>
  671. order by distance asc, websit_id
  672. </select>
  673. </mapper>