MaterialMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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.manager.commonmapper.MaterialMapper">
  4. <select id="partsBasePage" resultType="com.gree.mall.manager.bean.material.base.PartsBaseVO">
  5. SELECT
  6. ${ex.selected}
  7. FROM websit_parts_base a
  8. ${ex.query}
  9. <if test="ex.orderBy == null or ex.orderBy ==''">
  10. ORDER BY a.create_time DESC
  11. </if>
  12. ${ex.orderBy}
  13. </select>
  14. <select id="materialCategoryPage" resultType="com.gree.mall.manager.bean.material.base.MaterialCategoryVO">
  15. SELECT
  16. ${ex.selected}
  17. FROM websit_goods_category a
  18. ${ex.query}
  19. <if test="ex.orderBy == null or ex.orderBy ==''">
  20. ORDER BY a.parent_category_id, a.sort, a.create_time DESC
  21. </if>
  22. ${ex.orderBy}
  23. </select>
  24. <select id="mPage" resultType="com.gree.mall.manager.bean.material.base.WebsitGoodsMVO">
  25. SELECT
  26. ${ex.selected}
  27. FROM websit_goods a LEFT JOIN websit_goods_category b ON a.goods_category_id = b.category_id
  28. ${ex.query}
  29. AND a.goods_type = 'M'
  30. <if test="ex.orderBy == null or ex.orderBy ==''">
  31. ORDER BY a.create_time DESC
  32. </if>
  33. ${ex.orderBy}
  34. </select>
  35. <select id="pPage" resultType="com.gree.mall.manager.bean.material.base.WebsitGoodsPVO">
  36. SELECT
  37. ${ex.selected}
  38. FROM websit_goods a
  39. ${ex.query}
  40. AND a.goods_type = 'P'
  41. <if test="ex.orderBy == null or ex.orderBy ==''">
  42. ORDER BY a.create_time DESC
  43. </if>
  44. ${ex.orderBy}
  45. </select>
  46. <select id="workGoodsPage" resultType="com.gree.mall.manager.bean.material.base.WorkerGoodsVO">
  47. SELECT
  48. ${ex.selected}
  49. FROM worker_goods a LEFT JOIN websit_goods_category b ON a.category_id = b.category_id
  50. ${ex.query}
  51. <if test="ex.orderBy == null or ex.orderBy ==''">
  52. ORDER BY a.create_time DESC
  53. </if>
  54. ${ex.orderBy}
  55. </select>
  56. <select id="websitGoodsPricePage"
  57. resultType="com.gree.mall.manager.bean.material.manage.WebsitGoodsPriceVO">
  58. SELECT
  59. ${ex.selected}
  60. FROM websit_goods_price a LEFT JOIN websit_goods b ON a.goods_id = b.goods_id
  61. ${ex.query}
  62. <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
  63. AND a.websit_id IN
  64. <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
  65. #{item}
  66. </foreach>
  67. </if>
  68. <if test="ex.orderBy == null or ex.orderBy ==''">
  69. ORDER BY a.create_time DESC
  70. </if>
  71. ${ex.orderBy}
  72. </select>
  73. <select id="websitPriceUpdPage" resultType="com.gree.mall.manager.bean.material.manage.WebsitPriceUpdVO">
  74. SELECT
  75. ${ex.selected}
  76. FROM websit_price_upd a
  77. <!-- LEFT JOIN websit_price_upd_item b ON a.sheet_id = b.sheet_id -->
  78. ${ex.query}
  79. <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
  80. AND a.websit_id IN
  81. <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
  82. #{item}
  83. </foreach>
  84. </if>
  85. <if test="ex.orderBy == null or ex.orderBy ==''">
  86. ORDER BY a.create_time DESC
  87. </if>
  88. ${ex.orderBy}
  89. </select>
  90. <select id="websitPurchasePage" resultType="com.gree.mall.manager.bean.material.manage.WebsitPurchaseVO">
  91. SELECT
  92. ${ex.selected}
  93. FROM websit_purchase a LEFT JOIN storage b ON a.storage_id = b.storage_id
  94. ${ex.query}
  95. <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
  96. AND a.websit_id IN
  97. <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
  98. #{item}
  99. </foreach>
  100. </if>
  101. <if test="ex.orderBy == null or ex.orderBy ==''">
  102. ORDER BY a.create_time DESC
  103. </if>
  104. ${ex.orderBy}
  105. </select>
  106. <select id="websitPurchaseRetPage"
  107. resultType="com.gree.mall.manager.bean.material.manage.WebsitPurchaseRetVO">
  108. SELECT
  109. ${ex.selected}
  110. FROM websit_purchase_ret a LEFT JOIN storage b ON a.storage_id = b.storage_id
  111. ${ex.query}
  112. <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
  113. AND a.websit_id IN
  114. <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
  115. #{item}
  116. </foreach>
  117. </if>
  118. <if test="ex.orderBy == null or ex.orderBy ==''">
  119. ORDER BY a.create_time DESC
  120. </if>
  121. ${ex.orderBy}
  122. </select>
  123. <select id="websitVenderPage" resultType="com.gree.mall.manager.bean.material.vender.WebsitVenderVO">
  124. SELECT
  125. ${ex.selected}
  126. FROM websit_vender a
  127. ${ex.query}
  128. <if test="ex.orderBy == null or ex.orderBy ==''">
  129. ORDER BY a.create_time DESC
  130. </if>
  131. ${ex.orderBy}
  132. </select>
  133. <select id="websitNormChargePage" resultType="com.gree.mall.manager.bean.material.base.WebsitNormChargeVO">
  134. SELECT
  135. ${ex.selected}
  136. FROM websit_norm_charge a LEFT JOIN websit_goods_category b ON a.category_id = b.category_id
  137. ${ex.query}
  138. <if test="ex.orderBy == null or ex.orderBy ==''">
  139. ORDER BY a.create_time DESC
  140. </if>
  141. ${ex.orderBy}
  142. </select>
  143. <select id="websitSalesPage" resultType="com.gree.mall.manager.bean.material.manage.WebsitSalesVO">
  144. SELECT
  145. ${ex.selected}
  146. FROM websit_sales a
  147. join websit_sales_item b on a.sales_id = b.sales_id
  148. LEFT JOIN storage c on a.storage_id = c.storage_id
  149. ${ex.query}
  150. <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
  151. AND a.websit_id IN
  152. <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
  153. #{item}
  154. </foreach>
  155. </if>
  156. <if test="goodsName != null and goodsName != ''">
  157. AND b.goods_name = #{goodsName}
  158. </if>
  159. <if test="goodsSpecification != null and goodsSpecification != ''">
  160. AND b.goods_specification = #{goodsSpecification}
  161. </if>
  162. <if test="isFilter != null and isFilter != ''">
  163. AND ( (a.goods_Type = 'M' and b.sales_qty != b.ret_qty) or
  164. (a.goods_Type = 'P' and (b.sales_qty != (b.ret_qty+ b.old_refund_qty)))
  165. )
  166. </if>
  167. GROUP BY a.sales_id
  168. <if test="ex.orderBy == null or ex.orderBy ==''">
  169. ORDER BY a.create_time DESC
  170. </if>
  171. ${ex.orderBy}
  172. </select>
  173. <select id="existStockCategory" resultType="com.gree.mall.manager.bean.material.stock.WebsitSalesCategoryVO">
  174. SELECT
  175. c.category_id,
  176. c.category_name,
  177. c.parent_category_id,
  178. c.parent_category_name
  179. FROM
  180. websit_stock a
  181. LEFT JOIN websit_goods b ON a.goods_id = b.goods_id
  182. LEFT JOIN websit_goods_category c ON b.goods_category_id = c.category_id
  183. WHERE
  184. a.company_wechat_id = #{companyWechatId}
  185. AND a.websit_id = #{websitId}
  186. AND a.goods_type = 'M'
  187. <!-- AND a.qty > 0 -->
  188. GROUP BY b.goods_category_id
  189. </select>
  190. <select id="existStockGoods" resultType="com.gree.mall.manager.bean.material.stock.WebsitSalesGoodsVO">
  191. SELECT
  192. a.goods_id,
  193. b.goods_name,
  194. <if test="goodsType=='M'.toString()">
  195. c.price,
  196. </if>
  197. <if test="goodsType=='P'.toString()">
  198. b.market_price AS price,
  199. </if>
  200. b.goods_code,
  201. b.goods_spell,
  202. b.goods_specification,
  203. b.goods_stock_unit,
  204. b.goods_sales_unit,
  205. b.brand_rela_name,
  206. b.product_rela_name,
  207. SUM(a.qty) AS qty,
  208. 'BASE' AS itemSourceType,
  209. a.goods_id AS itemSourceId,
  210. b.norm_type
  211. FROM
  212. websit_stock a
  213. JOIN websit_goods b ON a.goods_id = b.goods_id
  214. <if test="goodsType=='M'.toString()">
  215. LEFT JOIN websit_goods_price c ON a.goods_id = c.goods_id AND a.websit_id = c.websit_id
  216. </if>
  217. WHERE
  218. a.company_wechat_id = #{companyWechatId}
  219. <if test="goodsType=='M'.toString() and categoryId!=null and categoryId!=''">
  220. AND b.goods_category_id = #{categoryId}
  221. </if>
  222. <if test="goodsName!=null and goodsName!=''">
  223. AND b.goods_name LIKE CONCAT('%',#{goodsName},'%')
  224. </if>
  225. <if test="goodsSpecification!=null and goodsSpecification!=''">
  226. AND b.goods_specification LIKE CONCAT('%',#{goodsSpecification},'%')
  227. </if>
  228. AND a.websit_id = #{websitId}
  229. <if test="goodsType!=null and goodsType!=''">
  230. AND a.goods_type = #{goodsType}
  231. </if>
  232. <!-- AND a.qty > 0 -->
  233. GROUP BY a.goods_id
  234. LIMIT 100
  235. </select>
  236. <select id="notStockGoods" resultType="com.gree.mall.manager.bean.material.stock.WebsitSalesGoodsVO">
  237. SELECT
  238. b.goods_id,
  239. b.goods_name,
  240. b.market_price AS price,
  241. b.goods_code,
  242. b.goods_spell,
  243. b.goods_specification,
  244. b.goods_stock_unit,
  245. b.goods_sales_unit,
  246. b.brand_rela_name,
  247. b.product_rela_name,
  248. b.convert_bit_scale,
  249. b.goods_sales_convert_qty,
  250. b.manage_worker_stock,
  251. 0 AS qty
  252. FROM
  253. websit_goods b
  254. WHERE
  255. b.company_wechat_id = #{companyWechatId}
  256. <if test="goodsName!=null and goodsName!=''">
  257. AND b.goods_name LIKE CONCAT('%',#{goodsName},'%')
  258. </if>
  259. AND b.goods_type = #{goodsType}
  260. AND b.norm_type = 'M'
  261. </select>
  262. <select id="websitTradePage" resultType="com.gree.mall.manager.bean.material.manage.WebsitTradeVO">
  263. SELECT
  264. ${ex.selected}
  265. FROM websit_sales_pay_order a
  266. ${ex.query}
  267. <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
  268. AND a.websit_id IN
  269. <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
  270. #{item}
  271. </foreach>
  272. </if>
  273. <if test="ex.orderBy == null or ex.orderBy ==''">
  274. ORDER BY a.create_time DESC
  275. </if>
  276. ${ex.orderBy}
  277. </select>
  278. <select id="mAlonePage" resultType="com.gree.mall.manager.bean.material.base.WebsitGoodsAloneMVO">
  279. SELECT
  280. ${ex.selected}
  281. FROM websit_goods_alone a
  282. ${ex.query}
  283. AND a.goods_type = 'M'
  284. <if test="ex.orderBy == null or ex.orderBy ==''">
  285. ORDER BY a.create_time DESC
  286. </if>
  287. ${ex.orderBy}
  288. </select>
  289. <select id="pAlonePage" resultType="com.gree.mall.manager.bean.material.base.WebsitGoodsAlonePVO">
  290. SELECT
  291. ${ex.selected}
  292. FROM websit_goods_alone a
  293. ${ex.query}
  294. AND a.goods_type = 'P'
  295. <if test="ex.orderBy == null or ex.orderBy ==''">
  296. ORDER BY a.create_time DESC
  297. </if>
  298. ${ex.orderBy}
  299. </select>
  300. <select id="enginPayManageList" resultType="com.gree.mall.manager.bean.engin.EnginPayManageVO">
  301. SELECT
  302. ${ex.selected},
  303. IF((a.total_sales_amount - a.total_pay_amount) <![CDATA[ < ]]> 0, 0, (a.total_sales_amount - a.total_pay_amount)) AS totalNotPayAmount
  304. FROM engin_pay_manage a
  305. ${ex.query}
  306. <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
  307. AND a.websit_id IN
  308. <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
  309. #{item}
  310. </foreach>
  311. </if>
  312. <if test="ex.orderBy == null or ex.orderBy ==''">
  313. ORDER BY a.create_time DESC
  314. </if>
  315. ${ex.orderBy}
  316. </select>
  317. <select id="enginPayManageGatherList" resultType="com.gree.mall.manager.bean.engin.EnginPayManageGatherVO">
  318. SELECT
  319. ${ex.selected},
  320. SUM(a.total_sales_amount) AS totalSalesAmount,
  321. SUM(a.total_pay_amount) AS totalPayAmount,
  322. IF((SUM(a.total_sales_amount) - SUM(a.total_pay_amount)) <![CDATA[ < ]]> 0, 0, (SUM(a.total_sales_amount) - SUM(a.total_pay_amount))) AS totalNotPayAmount
  323. FROM engin_pay_manage a
  324. ${ex.query}
  325. <if test="adminWebsitIds != null and adminWebsitIds.size > 0">
  326. AND a.websit_id IN
  327. <foreach item="item" index="index" collection="adminWebsitIds" open="(" separator="," close=")">
  328. #{item}
  329. </foreach>
  330. </if>
  331. GROUP BY a.company_wechat_id, a.project_no
  332. </select>
  333. <select id="enginPayManageGatherLastUpdate" resultType="com.gree.mall.manager.bean.engin.EnginPayManageGatherVO">
  334. SELECT a.project_no, a.last_update_time, a.last_update_by
  335. FROM engin_pay_manage a
  336. INNER JOIN (SELECT project_no, MAX(last_update_time) AS max_time
  337. FROM engin_pay_manage
  338. WHERE
  339. company_wechat_id = #{companyWechatId}
  340. AND project_no IN
  341. <foreach item="item" index="index" collection="projectList" open="(" separator=","
  342. close=")">
  343. #{item}
  344. </foreach>
  345. GROUP BY project_no) b
  346. ON a.project_no = b.project_no AND a.last_update_time = b.max_time AND a.company_wechat_id = #{companyWechatId}
  347. </select>
  348. </mapper>