MaterialMapper.xml 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015
  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. <resultMap id="newRefundManageAppList" type="com.gree.mall.miniapp.bean.material.parts.NewRefundManageBean">
  5. <id column="applyNo" jdbcType="VARCHAR" property="applyNo"/>
  6. <result column="sales_Id" jdbcType="VARCHAR" property="salesId"/>
  7. <result column="apply_category" jdbcType="VARCHAR" property="applyCategory"/>
  8. <result column="apply_category_name" jdbcType="VARCHAR" property="applyCategoryName"/>
  9. <result column="apply_type" jdbcType="VARCHAR" property="applyType"/>
  10. <result column="apply_type_name" jdbcType="VARCHAR" property="applyTypeName"/>
  11. <result column="refund_mode" jdbcType="VARCHAR" property="refundMode"/>
  12. <result column="refund_mode_name" jdbcType="VARCHAR" property="refundModeName"/>
  13. <result column="express_no" jdbcType="VARCHAR" property="expressNo"/>
  14. <result column="receive_address" jdbcType="VARCHAR" property="receiveAddress"/>
  15. <result column="receive_websit_id" jdbcType="VARCHAR" property="receiveWebsitId"/>
  16. <result column="receive_websit_Name" jdbcType="VARCHAR" property="receiveWebsitName"/>
  17. <result column="receive_parts_websit_id" jdbcType="VARCHAR" property="receivePartsWebsitId"/>
  18. <result column="websit_Address" jdbcType="VARCHAR" property="websitAddress"/>
  19. <result column="identity" jdbcType="VARCHAR" property="identity"/>
  20. <result column="worker_id" jdbcType="VARCHAR" property="workerId"/>
  21. <result column="worker_name" jdbcType="VARCHAR" property="workerName"/>
  22. <result column="refund_amount" jdbcType="DECIMAL" property="refundAmount"/>
  23. <result column="refund_amount_mode" jdbcType="VARCHAR" property="refundAmountMode"/>
  24. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  25. <result column="examine_remark" jdbcType="VARCHAR" property="examineRemark"/>
  26. <result column="flag" jdbcType="VARCHAR" property="flag"/>
  27. <result column="flag_name" jdbcType="VARCHAR" property="flagName"/>
  28. <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
  29. <result column="create_time" jdbcType="DATE" property="createTime"/>
  30. <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
  31. <result column="update_time" jdbcType="DATE" property="updateTime"/>
  32. <result column="submit_by" jdbcType="VARCHAR" property="submitBy"/>
  33. <result column="submit_time" jdbcType="DATE" property="submitTime"/>
  34. <result column="examine_by" jdbcType="VARCHAR" property="examineBy"/>
  35. <result column="examine_time" jdbcType="DATE" property="examineTime"/>
  36. <result column="refunded_by" jdbcType="VARCHAR" property="refundedBy"/>
  37. <result column="refunded_time" jdbcType="DATE" property="refundedTime"/>
  38. <collection property="newRefundManageItemBeanList" ofType="com.gree.mall.miniapp.bean.material.parts.NewRefundManageItemBean"
  39. column="apply_no" javaType="java.util.List"
  40. select="selectNewRefundManageItemByApplyNo">
  41. </collection>
  42. <collection property="partsNewRefundManageRecordList" ofType="com.gree.mall.miniapp.bean.material.parts.NewRefundManageRecordBean"
  43. column="apply_no" javaType="java.util.List"
  44. select="selectNewRefundManageRecordByApplyNo">
  45. </collection>
  46. </resultMap>
  47. <resultMap id="newRefundManageItemResultMap" type="com.gree.mall.miniapp.bean.material.parts.NewRefundManageItemBean">
  48. <id column="id" jdbcType="VARCHAR" property="id"/>
  49. <result column="apply_no" jdbcType="VARCHAR" property="applyNo"/>
  50. <result column="sales_Id" jdbcType="VARCHAR" property="salesId"/>
  51. <result column="parts_number" jdbcType="VARCHAR" property="partsNumber"/>
  52. <result column="parts_name" jdbcType="VARCHAR" property="partsName"/>
  53. <result column="material_group_name" jdbcType="VARCHAR" property="materialGroupName"/>
  54. <result column="goods_stock_unit" jdbcType="VARCHAR" property="goodsStockUnit"/>
  55. <result column="qty" jdbcType="DECIMAL" property="qty"/>
  56. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  57. <result column="image" jdbcType="VARCHAR" property="image"/>
  58. <result column="custom_no" jdbcType="VARCHAR" property="customNo"/>
  59. <result column="create_time" jdbcType="DATE" property="createTime"/>
  60. </resultMap>
  61. <resultMap id="newRefundManageRecordResultMap" type="com.gree.mall.miniapp.bean.material.parts.NewRefundManageRecordBean">
  62. <id column="id" jdbcType="VARCHAR" property="id"/>
  63. <result column="item_id" jdbcType="VARCHAR" property="itemId"/>
  64. <result column="apply_no" jdbcType="VARCHAR" property="applyNo"/>
  65. <result column="sales_Id" jdbcType="VARCHAR" property="salesId"/>
  66. <result column="parts_number" jdbcType="VARCHAR" property="partsNumber"/>
  67. <result column="parts_name" jdbcType="VARCHAR" property="partsName"/>
  68. <result column="sales_price" jdbcType="DECIMAL" property="salesPrice"/>
  69. <result column="market_price" jdbcType="DECIMAL" property="marketPrice"/>
  70. <result column="second_price" jdbcType="DECIMAL" property="secondPrice"/>
  71. <result column="qty" jdbcType="DECIMAL" property="qty"/>
  72. <result column="total_amount" jdbcType="DECIMAL" property="totalAmount"/>
  73. <result column="refund_amount" jdbcType="DECIMAL" property="refundAmount"/>
  74. <result column="refund_time" jdbcType="DATE" property="refundTime"/>
  75. <result column="refund_state" jdbcType="VARCHAR" property="refundState"/>
  76. <result column="refund_state_name" jdbcType="VARCHAR" property="refundStateName"/>
  77. <result column="refund_mch_no" jdbcType="VARCHAR" property="refundMchNo"/>
  78. <result column="refund_account_no" jdbcType="VARCHAR" property="refundAccountNo"/>
  79. <result column="refund_serialnumber" jdbcType="VARCHAR" property="refundSerialnumber"/>
  80. <result column="create_time" jdbcType="DATE" property="createTime"/>
  81. </resultMap>
  82. <resultMap id="oldRefundManageAppList" type="com.gree.mall.miniapp.bean.material.parts.OldRefundManageBean">
  83. <id column="applyNo" jdbcType="VARCHAR" property="applyNo"/>
  84. <result column="apply_category" jdbcType="VARCHAR" property="applyCategory"/>
  85. <result column="apply_category_name" jdbcType="VARCHAR" property="applyCategoryName"/>
  86. <result column="apply_type" jdbcType="VARCHAR" property="applyType"/>
  87. <result column="apply_type_name" jdbcType="VARCHAR" property="applyTypeName"/>
  88. <result column="refund_mode" jdbcType="VARCHAR" property="refundMode"/>
  89. <result column="refund_mode_name" jdbcType="VARCHAR" property="refundModeName"/>
  90. <result column="repair_flag" jdbcType="VARCHAR" property="repairFlag"/>
  91. <result column="repair_flag_name" jdbcType="VARCHAR" property="repairFlagName"/>
  92. <result column="express_no" jdbcType="VARCHAR" property="expressNo"/>
  93. <result column="receive_address" jdbcType="VARCHAR" property="receiveAddress"/>
  94. <result column="receive_websit_id" jdbcType="VARCHAR" property="receiveWebsitId"/>
  95. <result column="receive_websit_name" jdbcType="VARCHAR" property="receiveWebsitName"/>
  96. <result column="receiveParts_websit_id" jdbcType="VARCHAR" property="receivePartsWebsitId"/>
  97. <result column="websit_address" jdbcType="VARCHAR" property="websitAddress"/>
  98. <result column="identity" jdbcType="VARCHAR" property="identity"/>
  99. <result column="worker_id" jdbcType="VARCHAR" property="workerId"/>
  100. <result column="worker_name" jdbcType="VARCHAR" property="workerName"/>
  101. <result column="work_order_no" jdbcType="VARCHAR" property="workOrderNo"/>
  102. <result column="pg_id" jdbcType="VARCHAR" property="pgId"/>
  103. <result column="refund_amount" jdbcType="DECIMAL" property="refundAmount"/>
  104. <result column="refund_amount_mode" jdbcType="VARCHAR" property="refundAmountMode"/>
  105. <result column="settlement_state" jdbcType="BOOLEAN" property="settlementState"/>
  106. <result column="settlement_state_name" jdbcType="VARCHAR" property="settlementStateName"/>
  107. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  108. <result column="examine_remark" jdbcType="VARCHAR" property="examineRemark"/>
  109. <result column="flag" jdbcType="VARCHAR" property="flag"/>
  110. <result column="flag_name" jdbcType="VARCHAR" property="flagName"/>
  111. <result column="create_by" jdbcType="VARCHAR" property="createBy"/>
  112. <result column="create_time" jdbcType="DATE" property="createTime"/>
  113. <result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
  114. <result column="update_time" jdbcType="DATE" property="updateTime"/>
  115. <result column="submit_by" jdbcType="VARCHAR" property="submitBy"/>
  116. <result column="submit_time" jdbcType="DATE" property="submitTime"/>
  117. <result column="examine_by" jdbcType="VARCHAR" property="examineBy"/>
  118. <result column="examine_time" jdbcType="DATE" property="examineTime"/>
  119. <result column="refunded_by" jdbcType="VARCHAR" property="refundedBy"/>
  120. <result column="refunded_time" jdbcType="DATE" property="refundedTime"/>
  121. <collection property="oldRefundManageItemBeanList" ofType="com.gree.mall.miniapp.bean.material.parts.OldRefundManageItemBean"
  122. column="apply_no"
  123. select="selectOldRefundManageItemByApplyNo">
  124. </collection>
  125. <collection property="partsOldRefundManageRecordList" ofType="com.gree.mall.miniapp.bean.material.parts.OldRefundManageRecordBean"
  126. column="apply_no"
  127. select="selectOldRefundManageRecordByApplyNo">
  128. </collection>
  129. </resultMap>
  130. <resultMap id="oldRefundManageItemResultMap" type="com.gree.mall.miniapp.bean.material.parts.OldRefundManageItemBean">
  131. <id column="id" jdbcType="VARCHAR" property="id"/>
  132. <result column="apply_no" jdbcType="VARCHAR" property="applyNo"/>
  133. <result column="old_parts_number" jdbcType="VARCHAR" property="oldPartsNumber"/>
  134. <result column="old_parts_name" jdbcType="VARCHAR" property="oldPartsName"/>
  135. <result column="qty" jdbcType="DECIMAL" property="qty"/>
  136. <result column="old_image" jdbcType="VARCHAR" property="oldImage"/>
  137. <result column="tab" jdbcType="VARCHAR" property="tab"/>
  138. <result column="new_parts_number" jdbcType="VARCHAR" property="newPartsNumber"/>
  139. <result column="new_parts_name" jdbcType="VARCHAR" property="newPartsName"/>
  140. <result column="newMaterialGroupName" jdbcType="VARCHAR" property="newMaterialGroupName"/>
  141. <result column="new_goods_stock_unit" jdbcType="VARCHAR" property="newGoodsStockUnit"/>
  142. <result column="repair_record_number" jdbcType="VARCHAR" property="repairRecordNumber"/>
  143. <result column="machine_barcode" jdbcType="VARCHAR" property="machineBarcode"/>
  144. <result column="repair_time" jdbcType="DATE" property="repairTime"/>
  145. <result column="old_compress_number" jdbcType="VARCHAR" property="oldCompressNumber"/>
  146. <result column="new_compress_number" jdbcType="VARCHAR" property="newCompressNumber"/>
  147. <result column="parts_barcode" jdbcType="VARCHAR" property="partsBarcode"/>
  148. <result column="install_time" jdbcType="DATE" property="installTime"/>
  149. <result column="custom_no" jdbcType="VARCHAR" property="customNo"/>
  150. <result column="is_backup" jdbcType="BOOLEAN" property="isBackup"/>
  151. <result column="is_backup_name" jdbcType="VARCHAR" property="isBackupName"/>
  152. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  153. <result column="create_time" jdbcType="DATE" property="createTime"/>
  154. </resultMap>
  155. <resultMap id="oldRefundManageRecordResultMap" type="com.gree.mall.miniapp.bean.material.parts.OldRefundManageRecordBean">
  156. <id column="id" jdbcType="VARCHAR" property="id"/>
  157. <result column="item_id" jdbcType="VARCHAR" property="itemId"/>
  158. <result column="apply_no" jdbcType="VARCHAR" property="applyNo"/>
  159. <result column="sales_id" jdbcType="VARCHAR" property="salesId"/>
  160. <result column="sales_item_id" jdbcType="VARCHAR" property="salesItemId"/>
  161. <result column="parts_number" jdbcType="VARCHAR" property="partsNumber"/>
  162. <result column="parts_name" jdbcType="VARCHAR" property="partsName"/>
  163. <result column="sales_price" jdbcType="DECIMAL" property="salesPrice"/>
  164. <result column="market_price" jdbcType="DECIMAL" property="marketPrice"/>
  165. <result column="second_price" jdbcType="DECIMAL" property="secondPrice"/>
  166. <result column="qty" jdbcType="DECIMAL" property="qty"/>
  167. <result column="total_amount" jdbcType="DECIMAL" property="totalAmount"/>
  168. <result column="refund_amount" jdbcType="DECIMAL" property="refundAmount"/>
  169. <result column="refund_time" jdbcType="DATE" property="refundTime"/>
  170. <result column="refund_state" jdbcType="VARCHAR" property="refundState"/>
  171. <result column="refund_state_name" jdbcType="VARCHAR" property="refundStateName"/>
  172. <result column="refund_mch_no" jdbcType="VARCHAR" property="refundMchNo"/>
  173. <result column="refund_account_no" jdbcType="VARCHAR" property="refundAccountNo"/>
  174. <result column="refund_serialnumber" jdbcType="VARCHAR" property="refundSerialnumber"/>
  175. <result column="repair_flag" jdbcType="VARCHAR" property="repairFlag"/>
  176. <result column="repair_flag_name" jdbcType="VARCHAR" property="repairFlagName"/>
  177. <result column="work_order_no" jdbcType="VARCHAR" property="workOrderNo"/>
  178. <result column="pg_id" jdbcType="VARCHAR" property="pgId"/>
  179. <result column="customer_name" jdbcType="VARCHAR" property="customerName"/>
  180. <result column="customer_tel" jdbcType="VARCHAR" property="customerTel"/>
  181. <result column="is_backup" jdbcType="BOOLEAN" property="isBackup"/>
  182. <result column="is_backup_name" jdbcType="VARCHAR" property="isBackupName"/>
  183. <result column="create_time" jdbcType="DATE" property="createTime"/>
  184. </resultMap>
  185. <select id="buyList" resultType="com.gree.mall.miniapp.bean.material.SalesOrderBean">
  186. SELECT
  187. a.*
  188. FROM
  189. websit_sales a
  190. <where>
  191. a.company_wechat_id = #{companyWechatId}
  192. AND worker_id = #{userId}
  193. <if test="flag!=null and flag!=''">
  194. AND a.flag = #{flag}
  195. </if>
  196. <if test="flag==null or flag==''">
  197. AND a.flag IN ('SAVE', 'SUBMIT', 'PAY_NOT_TAKE', 'PAY_TAKE')
  198. </if>
  199. </where>
  200. ORDER BY a.create_time DESC
  201. </select>
  202. <select id="existStockCategory" resultType="com.gree.mall.miniapp.bean.material.WebsitSalesCategoryVO">
  203. SELECT
  204. c.category_id,
  205. c.category_name
  206. FROM
  207. websit_stock a
  208. LEFT JOIN websit_goods b ON a.goods_id = b.goods_id
  209. LEFT JOIN websit_goods_category c ON b.goods_category_id = c.category_id
  210. WHERE
  211. a.company_wechat_id = #{companyWechatId}
  212. AND a.websit_id = #{websitId}
  213. AND a.goods_type = 'M'
  214. AND a.qty > 0
  215. GROUP BY b.goods_category_id
  216. </select>
  217. <select id="existStockGoods" resultType="com.gree.mall.miniapp.bean.material.WebsitSalesGoodsVO">
  218. SELECT
  219. a.goods_id,
  220. b.goods_name,
  221. <if test="goodsType=='M'.toString()">
  222. c.price,
  223. </if>
  224. <if test="goodsType=='P'.toString()">
  225. b.market_price AS price,
  226. </if>
  227. b.goods_code,
  228. b.goods_spell,
  229. b.goods_specification,
  230. b.goods_stock_unit,
  231. b.goods_sales_unit,
  232. b.brand_rela_name,
  233. b.product_rela_name,
  234. b.convert_bit_scale,
  235. b.goods_sales_convert_qty,
  236. b.manage_worker_stock,
  237. a.qty
  238. FROM
  239. websit_stock a
  240. JOIN websit_goods b ON a.goods_id = b.goods_id
  241. <if test="goodsType=='M'.toString()">
  242. LEFT JOIN websit_goods_price c ON a.websit_id = c.websit_id AND a.goods_id = c.goods_id
  243. </if>
  244. WHERE
  245. a.company_wechat_id = #{companyWechatId}
  246. <if test="goodsType=='M'.toString() and categoryId!=null and categoryId!=''">
  247. AND b.goods_category_id = #{categoryId}
  248. </if>
  249. <if test="goodsName!=null and goodsName!=''">
  250. AND b.goods_name LIKE CONCAT('%',#{goodsName},'%')
  251. </if>
  252. AND a.websit_id = #{websitId}
  253. AND a.goods_type = #{goodsType}
  254. AND a.qty > 0
  255. GROUP BY a.goods_id
  256. LIMIT 100
  257. </select>
  258. <select id="notStockGoods" resultType="com.gree.mall.miniapp.bean.material.WebsitSalesGoodsVO">
  259. SELECT
  260. b.goods_id,
  261. b.goods_name,
  262. b.market_price AS price,
  263. b.goods_code,
  264. b.goods_spell,
  265. b.goods_specification,
  266. b.goods_stock_unit,
  267. b.goods_sales_unit,
  268. b.brand_rela_name,
  269. b.product_rela_name,
  270. b.convert_bit_scale,
  271. b.goods_sales_convert_qty,
  272. b.manage_worker_stock,
  273. b.part_type,
  274. 0 AS qty
  275. FROM
  276. websit_goods b
  277. WHERE
  278. b.company_wechat_id = #{companyWechatId}
  279. <if test="goodsName!=null and goodsName!=''">
  280. AND b.goods_name LIKE CONCAT('%',#{goodsName},'%')
  281. </if>
  282. AND b.goods_type = #{goodsType}
  283. AND b.status = 'ON'
  284. AND b.norm_type = 'M'
  285. </select>
  286. <select id="normRecordList" resultType="com.gree.mall.miniapp.bean.material.NormRecordVO">
  287. SELECT
  288. a.*
  289. FROM
  290. websit_norm_record a
  291. WHERE
  292. a.company_wechat_id = #{companyWechatId}
  293. AND a.worker_id = #{userId}
  294. <if test="orderId!=null and orderId!=''">
  295. AND a.order_id LIKE CONCAT ('%', #{orderId}, '%')
  296. </if>
  297. <if test="goodsType!=null and goodsType!=''">
  298. AND a.goods_type = #{goodsType}
  299. </if>
  300. <if test="startTime!=null and startTime!=''">
  301. AND a.use_time BETWEEN #{startTime} AND #{endTime}
  302. </if>
  303. ORDER BY a.use_time DESC
  304. </select>
  305. <select id="partsRefundList" resultType="com.gree.mall.miniapp.bean.material.PartsRefundVO">
  306. SELECT
  307. a.*
  308. FROM
  309. websit_parts_ret a
  310. WHERE
  311. a.company_wechat_id = #{companyWechatId}
  312. AND a.worker_id = #{userId}
  313. <if test="type!=null and type!=''">
  314. AND a.type = #{type}
  315. </if>
  316. <if test="status!=null and status!=''">
  317. AND a.flag = #{status}
  318. </if>
  319. </select>
  320. <select id="queryShoppingCartList" resultType="com.gree.mall.miniapp.bean.material.WebsitShoppingCartList">
  321. SELECT
  322. a.*
  323. FROM
  324. websit_shopping_cart a
  325. WHERE
  326. a.worker_id = #{workerId}
  327. AND a.websit_id = #{websitId}
  328. AND a.goods_type = #{goodsType}
  329. </select>
  330. <select id="queryWorkerStockQty"
  331. resultType="com.gree.mall.miniapp.bean.material.stock.WorkerNormStockBean">
  332. SELECT
  333. a.norm_id,
  334. a.worker_goods_id,
  335. a.qty,
  336. b.goods_name,
  337. b.is_small,
  338. b.sales_unit,
  339. c.qty AS stock_qty
  340. FROM
  341. websit_norm_rela a
  342. JOIN
  343. worker_goods b
  344. ON a.company_wechat_id = b.company_wechat_id AND a.worker_goods_id = b.goods_id
  345. LEFT JOIN
  346. worker_stock c
  347. ON c.worker_id = #{workerId} AND a.company_wechat_id = c.company_wechat_id AND a.worker_goods_id = c.goods_id
  348. WHERE
  349. a.norm_id = #{goodsId}
  350. </select>
  351. <select id="appList" resultMap="newRefundManageAppList">
  352. SELECT
  353. a.company_wechat_id,
  354. a.company_wechat_name,
  355. a.apply_no,
  356. a.sales_id,
  357. a.apply_category,
  358. CASE a.apply_category WHEN 'HOME' THEN '家用空调'
  359. WHEN 'TRADE' THEN '商用空调'
  360. WHEN 'ELEC' THEN '生活电器(小家电)'
  361. ELSE '' END AS applyCategoryName,
  362. a.apply_type,
  363. CASE a.apply_type WHEN 'NEW' THEN '新件返还'
  364. WHEN 'LOST' THEN '破损返还'
  365. WHEN 'BUG' THEN '故障返还'
  366. ELSE '' END AS applyTypeName,
  367. a.refund_mode,
  368. CASE a.refund_mode WHEN 'EXPRESS' THEN '快递'
  369. WHEN 'SELF' THEN '网点自还'
  370. ELSE '' END AS refundModeName,
  371. a.express_no,
  372. a.receive_address,
  373. a.receive_websit_id,
  374. a.receive_websit_name,
  375. a.receive_parts_websit_id,
  376. a.websit_Address,
  377. a.identity,
  378. a.worker_id,
  379. a.worker_name,
  380. a.refund_amount,
  381. a.refund_amount_mode,
  382. IF(refund_amount_mode = 'CASH', '现金', '微信') AS refundAmountModeName,
  383. a.remark,
  384. a.examine_remark,
  385. a.flag,
  386. CASE a.flag WHEN 'SAVE' THEN '保存'
  387. WHEN 'SUBMIT' THEN '待审批'
  388. WHEN 'AGREE' THEN '待返还'
  389. WHEN 'REJECT' THEN '驳回'
  390. WHEN 'REFUNDED' THEN '已返还'
  391. ELSE '' END AS flagName,
  392. a.create_by,
  393. a.create_time,
  394. a.update_by,
  395. a.update_time,
  396. a.submit_by,
  397. a.submit_time,
  398. a.examine_by,
  399. a.examine_time,
  400. a.refunded_by,
  401. a.refunded_time
  402. FROM
  403. websit_parts_new_refund_manage a
  404. LEFT JOIN websit_parts_new_refund_manage_item b ON a.apply_no = b.apply_no
  405. <where>
  406. a.company_wechat_id = #{companyWechatId}
  407. <if test="applyNo != null and applyNo != ''">
  408. AND a.apply_no = #{applyNo}
  409. </if>
  410. <if test="flag != null and flag != ''">
  411. AND a.flag = #{flag}
  412. </if>
  413. <if test="identity != null and identity != ''">
  414. AND a.identity = #{identity}
  415. </if>
  416. <if test="partsNumber != null and partsNumber != ''">
  417. AND b.parts_number = #{partsNumber}
  418. </if>
  419. </where>
  420. GROUP BY a.apply_no, a.create_time
  421. ORDER BY a.create_time DESC
  422. </select>
  423. <select id="querySalesPushFlagItem" resultType="com.gree.mall.miniapp.plus.entity.WebsitPartsSalesItem">
  424. SELECT
  425. id,
  426. identity,
  427. websit_id,
  428. parts_websit_id,
  429. parts_id,
  430. parts_number,
  431. parts_name,
  432. material_group_name,
  433. goods_stock_unit,
  434. sales_id,
  435. sales_price,
  436. market_price,
  437. second_price,
  438. qty,
  439. examine_qty,
  440. new_refund_qty,
  441. old_refund_qty,
  442. total_amount,
  443. refund_amount_mode,
  444. push_flag,
  445. create_by,
  446. create_time,
  447. update_by,
  448. update_time,
  449. examine_time
  450. FROM
  451. websit_parts_sales_item
  452. WHERE
  453. identity = #{identity}
  454. AND websit_id = #{websitId}
  455. AND parts_websit_id = #{partsWebsitId}
  456. <if test="pushFlag != null and pushFlag != ''">
  457. AND push_flag = #{pushFlag}
  458. </if>
  459. <if test="salesId != null and salesId != ''">
  460. AND sales_id = #{salesId}
  461. </if>
  462. AND parts_number IN
  463. <foreach item="item" index="index" collection="records" open="(" separator=","
  464. close=")">
  465. #{item.partsNumber}
  466. </foreach>
  467. ORDER BY
  468. examine_time
  469. FOR UPDATE
  470. </select>
  471. <select id="appSalesList" resultType="com.gree.mall.miniapp.bean.material.parts.PartsSalesOrderBean">
  472. SELECT
  473. a.*,
  474. CASE a.order_source WHEN 'SELF' THEN '自建订单'
  475. WHEN 'ONLINE' THEN '在线订单'
  476. ELSE '' END AS buyTypeName,
  477. CASE a.status WHEN 'SAVE' THEN '保存未提交'
  478. WHEN 'SUBMIT' THEN '已提交'
  479. <!-- WHEN '2' THEN '已支付' -->
  480. WHEN 'PAYED' THEN
  481. <!-- WHEN '3' THEN '已提货' -->
  482. (case when a.worker_confirm_date is not null and a.websit_confirm_date is not null then '已提货'
  483. when a.worker_confirm_date is not null then '师傅已提货'
  484. when a.websit_confirm_date is not null then '网点已提货' else '已支付' end)
  485. WHEN 'END' THEN '已完成'
  486. WHEN 'CANCEL' THEN '已取消'
  487. ELSE '' END AS stateName,
  488. CASE a.pushFlag WHEN 'SALES' THEN '销售'
  489. WHEN 'TRANS' THEN '转销售'
  490. WHEN 'END' THEN '完结'
  491. ELSE '' END AS pushFlagName
  492. FROM
  493. websit_parts_sales a, websit_parts_sales_item b
  494. WHERE
  495. a.company_wechat_id = #{companyWechatId}
  496. AND a.id = b.sales_id
  497. AND a.del = 0
  498. AND a.identity = #{identity}
  499. <if test="salesId != null and salesId != ''">
  500. AND a.id = #{salesId}
  501. </if>
  502. <if test="status != null and status != ''">
  503. <!-- and 1 = 0 -->
  504. <if test="status == 'SAVE'.toString() or status == 'SUBMIT'.toString() or status == 'END'.toString() or status == 'CANCEL'.toString()">
  505. AND a.status = #{status}
  506. </if>
  507. <if test="status == 'PAYED'.toString()">
  508. AND a.status = 'PAYED' AND (a.worker_confirm_date is null and a.websit_confirm_date is null)
  509. </if>
  510. </if>
  511. <if test="pushFlag != null and pushFlag != ''">
  512. AND a.pushFlag = #{pushFlag}
  513. AND b.qty > 0
  514. </if>
  515. <if test="partsNumber != null and partsNumber != ''">
  516. AND b.parts_number = #{partsNumber}
  517. </if>
  518. GROUP BY
  519. a.identity, a.id, a.create_time
  520. ORDER BY
  521. a.create_time DESC
  522. </select>
  523. <select id="selectItemBySalesOrderId"
  524. resultType="com.gree.mall.miniapp.bean.material.parts.PartsSalesOrderItemBean">
  525. select
  526. a.id ,
  527. a.identity ,
  528. a.websit_id,
  529. a.parts_websit_id,
  530. a.parts_id,
  531. a.parts_number,
  532. a.parts_name,
  533. a.material_group_name,
  534. a.goods_stock_unit,
  535. a.sales_id,
  536. a.sales_price,
  537. a.market_price,
  538. a.second_price,
  539. IF(d.status = 'END', a.examine_qty, a.qty) AS qty,
  540. a.examine_qty,
  541. a.new_refund_qty,
  542. a.old_refund_qty ,
  543. a.total_amount,
  544. a.push_flag ,
  545. a.create_by ,
  546. a.create_time,
  547. a.update_by,
  548. a.update_time,
  549. IFNULL(c.qty, 0) stockQty
  550. FROM websit_parts_sales_item a JOIN websit_goods b ON a.parts_id = b.goods_id
  551. 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
  552. JOIN websit_parts_sales d ON a.sales_id = d.id
  553. WHERE a.sales_id = #{id}
  554. </select>
  555. <select id="queryOldRefundRecordById"
  556. resultType="com.gree.mall.miniapp.bean.material.parts.OldRefundManageRecordBean">
  557. SELECT
  558. a.*
  559. FROM
  560. websit_parts_old_refund_manage_record a
  561. WHERE
  562. sales_id = #{id}
  563. </select>
  564. <select id="websitGroupList" resultType="java.lang.String">
  565. SELECT
  566. material_group_name
  567. FROM
  568. websit_stock
  569. WHERE
  570. company_wechat_id = #{companyWechatId}
  571. AND websit_id = #{websitId}
  572. AND parts_websit_id = #{partsWebsitId}
  573. AND qty > 0
  574. GROUP BY
  575. material_group_name
  576. </select>
  577. <select id="existWebsitStockList"
  578. resultType="com.gree.mall.miniapp.bean.material.parts.WebsitPartsStockBean">
  579. SELECT
  580. a.id,
  581. a.websit_id,
  582. a.websit_name,
  583. a.parts_websit_id,
  584. a.goods_id,
  585. a.goods_name,
  586. b.material_group_name,
  587. b.part_type,
  588. b.market_price,
  589. b.goods_stock_unit,
  590. a.qty,
  591. a.old_qty
  592. FROM
  593. websit_stock a LEFT JOIN websit_goods b ON a.company_wechat_id = b.company_wechat_id AND a.goods_id = b.goods_code
  594. WHERE
  595. a.company_wechat_id = #{companyWechatId}
  596. AND a.websit_id = #{websitId}
  597. AND a.parts_websit_id = #{partsWebsitId}
  598. <if test="partsNumber != null and partsNumber != ''">
  599. AND a.goods_id = #{partsNumber}
  600. </if>
  601. <if test="partsName != null and partsName != ''">
  602. AND a.goods_name LIKE CONCAT('%', #{partsName}, '%')
  603. </if>
  604. <if test="materialGroupName != null and materialGroupName != ''">
  605. AND a.goods_stock_unit = #{materialGroupName}
  606. </if>
  607. AND a.goods_type = 'P'
  608. AND a.qty > 0
  609. </select>
  610. <select id="existWebsitList" resultType="com.gree.mall.miniapp.plus.entity.AdminWebsit">
  611. SELECT
  612. websit_id, websit_name AS name, parts_websit_id
  613. FROM
  614. worker_stock
  615. WHERE
  616. company_wechat_id = #{companyWechatId}
  617. AND identity = #{identity}
  618. AND goods_type = 'P'
  619. GROUP BY
  620. websit_id, parts_websit_id
  621. </select>
  622. <select id="existWebsitGroupList" resultType="java.lang.String">
  623. SELECT
  624. material_group_name
  625. FROM
  626. worker_stock
  627. WHERE
  628. company_wechat_id = #{companyWechatId}
  629. AND identity = #{identity}
  630. AND websit_id = #{websitId}
  631. AND parts_websit_id = #{partsWebsitId}
  632. AND goods_type = 'P'
  633. <choose>
  634. <when test="partsAttr != null and partsAttr == 'NEW'">
  635. AND qty > 0
  636. </when>
  637. <when test="partsAttr != null and partsAttr == 'OLD'">
  638. AND old_qty > 0
  639. </when>
  640. <when test="partsAttr != null and partsAttr == 'WAY'">
  641. AND way_qty > 0
  642. </when>
  643. <otherwise>
  644. AND id = 0
  645. </otherwise>
  646. </choose>
  647. GROUP BY
  648. material_group_name
  649. </select>
  650. <select id="existWorkerStockList"
  651. resultType="com.gree.mall.miniapp.bean.material.parts.PartsWorkerStockBean">
  652. SELECT
  653. a.*,
  654. b.market_price
  655. FROM
  656. worker_stock a LEFT JOIN websit_goods b ON a.company_wechat_id = b.company_wechat_id AND a.goods_id = b.goods_code
  657. WHERE
  658. a.company_wechat_id = #{companyWechatId}
  659. AND a.goods_type = 'P'
  660. AND a.identity = #{identity}
  661. AND a.websit_id = #{websitId}
  662. AND a.parts_websit_id = #{partsWebsitId}
  663. <if test="partsNumber != null and partsNumber != ''">
  664. AND a.goods_id = #{partsNumber}
  665. </if>
  666. <if test="partsName != null and partsName != ''">
  667. AND a.goods_name LIKE CONCAT('%',#{partsName},'%')
  668. </if>
  669. <if test="materialGroupName != null and materialGroupName != ''">
  670. AND a.material_group_name = #{materialGroupName}
  671. </if>
  672. <if test="productRelaId != null and productRelaId != ''">
  673. AND b.product_rela_id LIKE CONCAT('%',#{productRelaId},'%')
  674. </if>
  675. <choose>
  676. <when test="partsAttr != null and partsAttr == 'NEW'">
  677. AND a.qty > 0
  678. </when>
  679. <when test="partsAttr != null and partsAttr == 'OLD'">
  680. AND a.old_qty > 0
  681. </when>
  682. <when test="partsAttr != null and partsAttr == 'WAY'">
  683. AND a.way_qty > 0
  684. </when>
  685. <otherwise>
  686. AND a.id = 0
  687. </otherwise>
  688. </choose>
  689. </select>
  690. <select id="querySalesEndTimeByIdentity"
  691. resultType="com.gree.mall.miniapp.plus.entity.WebsitPartsSalesItem">
  692. SELECT
  693. b.parts_number,
  694. b.qty,
  695. a.end_time AS examineTime
  696. FROM
  697. websit_parts_sales a, websit_parts_sales_item b
  698. WHERE
  699. a.id = b.sales_id
  700. AND a.company_wechat_id = #{companyWechatId}
  701. AND a.pushFlag = 'SALES'
  702. AND a.identity = #{identity}
  703. AND a.websit_id = #{websitId}
  704. AND a.parts_websit_id = #{partsWebsitId}
  705. AND b.qty > 0
  706. GROUP BY b.parts_number
  707. </select>
  708. <select id="workerStockStatistics"
  709. resultType="com.gree.mall.miniapp.bean.material.parts.WorkerStockCensusBean">
  710. SELECT t.worker_id, t.identity,
  711. SUM(IFNULL(qty,0)) as newQty,
  712. SUM(IFNULL(old_qty,0)) as oldQty
  713. FROM worker_stock t
  714. WHERE identity = #{identity}
  715. AND goods_type = 'P'
  716. <if test="websitId != null and websitId != ''">
  717. AND t.websit_id = #{websitId}
  718. </if>
  719. GROUP BY t.identity
  720. </select>
  721. <select id="workerNewStockStatistics"
  722. resultType="com.gree.mall.miniapp.bean.material.parts.WorkerStockCensusBean">
  723. SELECT
  724. SUM(
  725. IFNULL( b.qty, 0 )) AS newRefundQty,
  726. SUM(
  727. IFNULL( b.total_amount, 0 )) AS newRefundAmount
  728. FROM
  729. websit_parts_new_refund_manage a
  730. INNER JOIN websit_parts_new_refund_manage_record b ON a.apply_no = b.apply_no
  731. WHERE
  732. a.flag IN ( 'SAVE', 'SUBMIT', 'AGREE' )
  733. AND a.identity = #{identity}
  734. <if test="websitId != null and websitId != ''">
  735. AND a.receive_websit_id = #{websitId}
  736. </if>
  737. GROUP BY
  738. a.identity
  739. </select>
  740. <select id="workerOldStockStatistics"
  741. resultType="com.gree.mall.miniapp.bean.material.parts.WorkerStockCensusBean">
  742. SELECT
  743. SUM(
  744. IFNULL( b.qty, 0 )) AS oldRefundQty,
  745. SUM(
  746. IFNULL( b.total_amount, 0 )) AS oldRefundAmount
  747. FROM
  748. websit_parts_old_refund_manage a
  749. INNER JOIN websit_parts_old_refund_manage_record b ON a.apply_no = b.apply_no
  750. WHERE
  751. a.flag IN ( 'SAVE', 'SUBMIT' )
  752. AND a.identity = #{identity}
  753. <if test="websitId != null and websitId != ''">
  754. AND a.receive_websit_id = #{websitId}
  755. </if>
  756. GROUP BY
  757. a.identity
  758. </select>
  759. <select id="appOldRefundList" resultMap="oldRefundManageAppList">
  760. SELECT
  761. a.company_wechat_id,
  762. a.company_wechat_name,
  763. a.apply_no,
  764. a.apply_category,
  765. CASE a.apply_category WHEN 'HOME' THEN '家用空调'
  766. WHEN 'TRADE' THEN '商用空调'
  767. WHEN 'ELEC' THEN '生活电器(小家电)'
  768. ELSE '' END AS applyCategoryName,
  769. a.apply_type,
  770. CASE a.apply_type WHEN 'NEW' THEN '新件返还'
  771. WHEN 'LOST' THEN '破损返还'
  772. WHEN 'BUG' THEN '故障返还'
  773. ELSE '' END AS applyTypeName,
  774. a.refund_mode,
  775. CASE a.refund_mode WHEN 'EXPRESS' THEN '快递'
  776. WHEN 'SELF' THEN '网点自还'
  777. ELSE '' END AS refundModeName,
  778. a.repair_flag,
  779. CASE a.repair_flag WHEN 'INNER' THEN '保内'
  780. WHEN 'OUTSIDE' THEN '保外'
  781. ELSE '' END AS repairFlagName,
  782. a.express_no,
  783. a.receive_address,
  784. a.receive_websit_id,
  785. a.receive_websit_name,
  786. a.receive_parts_websit_id,
  787. a.websit_Address,
  788. a.identity,
  789. a.worker_id,
  790. a.worker_name,
  791. a.work_order_no,
  792. a.pg_id,
  793. a.customer_name,
  794. a.customer_tel,
  795. a.refund_amount,
  796. a.refund_amount_mode,
  797. a.settlement_state,
  798. CASE a.settlement_state WHEN 0 THEN '未结算'
  799. WHEN 1 THEN '已结算'
  800. ELSE '' END AS settlementStateName,
  801. a.remark,
  802. a.examine_remark,
  803. a.flag,
  804. CASE WHEN a.flag = 'SAVE' THEN '保存'
  805. WHEN a.flag = 'SUBMIT' THEN '待审批'
  806. WHEN a.flag = 'AGREE' and a.repair_flag = 'INNER' THEN '待返还'
  807. WHEN a.flag = 'AGREE' and a.repair_flag = 'OUTSIDE' THEN '通过'
  808. WHEN a.flag = 'REJECT' THEN '驳回'
  809. WHEN a.flag = 'REFUNDED' THEN '已返还'
  810. ELSE a.flag = '' END AS flagName,
  811. a.create_by,
  812. a.create_time,
  813. a.update_by,
  814. a.update_time,
  815. a.submit_by,
  816. a.submit_time,
  817. a.examine_by,
  818. a.examine_time,
  819. a.refunded_by,
  820. a.refunded_time
  821. FROM
  822. websit_parts_old_refund_manage a
  823. LEFT JOIN websit_parts_old_refund_manage_item b ON a.apply_no = b.apply_no
  824. <where>
  825. a.company_wechat_id = #{companyWechatId}
  826. <if test="applyNo != null and applyNo != ''">
  827. AND a.apply_no = #{applyNo}
  828. </if>
  829. <if test="flag != null and flag != ''">
  830. AND a.flag = #{flag}
  831. </if>
  832. <if test="identity != null and identity != ''">
  833. AND a.identity = #{identity}
  834. </if>
  835. <if test="partsNumber != null and partsNumber != ''">
  836. AND b.new_parts_number = #{partsNumber}
  837. </if>
  838. <if test="repairFlag != null and repairFlag != ''">
  839. AND a.repair_flag = #{repairFlag}
  840. </if>
  841. </where>
  842. GROUP BY a.apply_no, a.create_time
  843. ORDER BY a.create_time DESC
  844. </select>
  845. <select id="selectOldRefundManageItemByApplyNo" resultMap="oldRefundManageItemResultMap">
  846. SELECT
  847. id,
  848. apply_no,
  849. old_parts_number,
  850. old_parts_name,
  851. old_material_group_name,
  852. old_unit_name,
  853. qty,
  854. old_image,
  855. tab,
  856. new_parts_number,
  857. new_parts_name,
  858. new_material_group_name,
  859. new_unit_name,
  860. work_old_parts_number,
  861. work_old_parts_name,
  862. repair_record_number,
  863. machine_barcode,
  864. repair_time,
  865. old_compress_number,
  866. new_compress_number,
  867. parts_barcode,
  868. install_time,
  869. custom_no,
  870. is_backup,
  871. remark,
  872. create_time,
  873. CASE is_backup WHEN 0 THEN '否'
  874. WHEN 1 THEN '是'
  875. ELSE '' END AS isBackupName
  876. FROM
  877. websit_parts_old_refund_manage_item
  878. WHERE
  879. apply_no = #{applyNo}
  880. </select>
  881. <select id="selectOldRefundManageRecordByApplyNo" resultMap="oldRefundManageRecordResultMap">
  882. SELECT
  883. id,
  884. item_id,
  885. apply_no,
  886. sales_id,
  887. sales_item_id,
  888. parts_number,
  889. parts_name,
  890. sales_price,
  891. market_price,
  892. second_price,
  893. qty,
  894. total_amount,
  895. refund_amount_mode,
  896. refund_amount,
  897. refund_time,
  898. refund_state,
  899. refund_mch_no,
  900. refund_account_no,
  901. refund_serialnumber,
  902. repair_flag,
  903. work_order_no,
  904. pg_id,
  905. customer_name,
  906. customer_tel,
  907. is_backup,
  908. create_time
  909. FROM
  910. websit_parts_old_refund_manage_record
  911. WHERE
  912. apply_no = #{applyNo}
  913. </select>
  914. <select id="queryWebsitList" resultType="com.gree.mall.miniapp.bean.material.parts.WebsitExtends">
  915. SELECT
  916. a.*,
  917. <!-- 按距离排序计算 -->
  918. TRUNCATE(ACOS(
  919. SIN((PI() / 180) * lat) * SIN((PI() / 180) * #{latitude})
  920. + COS((PI() / 180) * lat) * COS((PI() / 180) * #{latitude}) * COS((PI() / 180) * #{longitude} - (PI() / 180) * lng)
  921. ) * 6371,0) as distance
  922. from admin_websit a
  923. <where>
  924. a.company_wechat_id = #{companyWechatId}
  925. AND a.type = 'C'
  926. AND a.parts_websit_id IS NOT NULL
  927. AND a.status = 1
  928. <if test="websitId != null and websitId != ''">
  929. AND a.websit_id = #{websitId}
  930. </if>
  931. </where>
  932. order by distance asc, websit_id
  933. </select>
  934. <select id="selectNewRefundManageItemByApplyNo" resultMap="newRefundManageItemResultMap">
  935. SELECT
  936. id,
  937. apply_no,
  938. sales_id,
  939. parts_number,
  940. parts_name,
  941. material_group_name,
  942. goods_stock_unit,
  943. qty,
  944. remark,
  945. image,
  946. custom_no,
  947. create_time
  948. FROM
  949. websit_parts_new_refund_manage_item
  950. WHERE
  951. apply_no = #{applyNo}
  952. </select>
  953. <select id="selectNewRefundManageRecordByApplyNo" resultMap="newRefundManageRecordResultMap">
  954. SELECT
  955. id,
  956. item_id,
  957. apply_no,
  958. sales_id,
  959. sales_item_id,
  960. parts_number,
  961. parts_name,
  962. sales_price,
  963. market_price,
  964. second_price,
  965. qty,
  966. total_amount,
  967. refund_amount,
  968. refund_time,
  969. refund_state,
  970. CASE refund_state WHEN 'OK' THEN '成功'
  971. WHEN 'FAIL' THEN '失败'
  972. WHEN 'WAIT' THEN '等待'
  973. ELSE '' END AS refundStateName,
  974. refund_mch_no,
  975. refund_account_no,
  976. refund_serialnumber,
  977. create_time
  978. FROM
  979. websit_parts_new_refund_manage_record
  980. WHERE
  981. apply_no = #{applyNo}
  982. </select>
  983. </mapper>