GoodsDao.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  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.kmall.admin.dao.GoodsDao">
  4. <resultMap type="com.kmall.admin.entity.GoodsEntity" id="goodsMap">
  5. <result property="id" column="id"/>
  6. <result property="merchSn" column="merch_sn"/>
  7. <result property="categoryId" column="category_id"/>
  8. <result property="goodsSn" column="goods_sn"/>
  9. <result property="name" column="name"/>
  10. <result property="brandId" column="brand_id"/>
  11. <result property="freightId" column="freight_id"/>
  12. <result property="brand" column="brand"/>
  13. <result property="goodsNumber" column="goods_number"/>
  14. <result property="keywords" column="keywords"/>
  15. <result property="goodsBrief" column="goods_brief"/>
  16. <result property="goodsDesc" column="goods_desc"/>
  17. <result property="isOnSale" column="is_on_sale"/>
  18. <result property="addTime" column="add_time"/>
  19. <result property="sortOrder" column="sort_order"/>
  20. <result property="isDelete" column="is_delete"/>
  21. <result property="attributeCategory" column="attribute_category"/>
  22. <result property="counterPrice" column="counter_price"/>
  23. <result property="extraPrice" column="extra_price"/>
  24. <result property="isNew" column="is_new"/>
  25. <result property="goodsUnit" column="goods_unit"/>
  26. <result property="primaryPicUrl" column="primary_pic_url"/>
  27. <result property="listPicUrl" column="list_pic_url"/>
  28. <result property="retailPrice" column="retail_price"/>
  29. <result property="sellVolume" column="sell_volume"/>
  30. <result property="primaryProductId" column="primary_product_id"/>
  31. <result property="unitPrice" column="unit_price"/>
  32. <result property="promotionDesc" column="promotion_desc"/>
  33. <result property="promotionTag" column="promotion_tag"/>
  34. <result property="appExclusivePrice" column="app_exclusive_price"/>
  35. <result property="isAppExclusive" column="is_app_exclusive"/>
  36. <result property="isLimited" column="is_limited"/>
  37. <result property="isHot" column="is_hot"/>
  38. <result property="marketPrice" column="market_price"/>
  39. <result property="goodsType" column="goodsType"/>
  40. <result property="sku" column="sku"/>
  41. <result property="goodsBizType" column="goods_biz_type"/>
  42. <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
  43. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  44. <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
  45. <result column="mod_time" property="modTime" jdbcType="TIMESTAMP" />
  46. <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
  47. <result property="prodBarcode" column="prod_barcode"/>
  48. <result property="unitCode" column="unit_code"/>
  49. <result property="goodsDesc" column="goods_desc"/>
  50. <result property="cusGoodsCode" column="cus_goods_code"/>
  51. <result property="ciqProdModel" column="ciq_prod_model"/>
  52. <result property="oriCntCode" column="ori_cnt_code"/>
  53. <result property="cusDeclEle" column="cus_decl_ele"/>
  54. <result property="cusRecCode" column="cus_rec_code"/>
  55. <result property="supplierId" column="supplier_id"/>
  56. <result property="stockNums" column="stock_num"/>
  57. <result property="storeName" column="store_name"/>
  58. <result property="productId" column="productId"/>
  59. <result property="storeId" column="storeId"/>
  60. </resultMap>
  61. <select id="queryObject" resultType="com.kmall.admin.entity.GoodsEntity">
  62. SELECT
  63. a.*, CASE
  64. when g.id > 0 then 2 else 0 end as goodsType
  65. FROM
  66. mall_goods a
  67. LEFT JOIN mall_goods_group g ON g.goods_id = a.id
  68. AND g.open_status != 3
  69. WHERE a.id = #{value}
  70. </select>
  71. <select id="queryObjectByProdBarcodeAndBizType" resultType="com.kmall.admin.entity.GoodsEntity">
  72. SELECT
  73. a.id,a.sku,a.goods_sn,a.name,a.list_pic_url,a.prod_barcode,r.market_price,r.retail_price,r.stock_num,s.store_name,r.product_id,s.id 'storeId'
  74. FROM
  75. mall_goods a
  76. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  77. inner join mall_store s on r.store_id=s.id
  78. where a.prod_barcode = #{prodBarcode} and a.goods_biz_type = 11
  79. </select>
  80. <select id="queryObjectByProdBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
  81. SELECT
  82. a.id,a.sku,a.goods_sn,a.name,a.list_pic_url,a.prod_barcode
  83. FROM
  84. mall_goods a
  85. where a.prod_barcode = #{prodBarcode}
  86. <if test="goodsId != null and goodsId != ''">
  87. AND a.id != #{goodsId}
  88. </if>
  89. </select>
  90. <select id="queryObjectBySn" resultType="com.kmall.admin.entity.GoodsEntity">
  91. SELECT
  92. a.*, CASE
  93. when g.id > 0 then 2 else 0 end as goodsType
  94. FROM
  95. mall_goods a
  96. LEFT JOIN mall_goods_group g ON g.goods_id = a.id
  97. AND g.open_status != 3
  98. where a.goods_sn = #{goodsSn}
  99. </select>
  100. <select id="queryList" resultType="com.kmall.admin.entity.GoodsEntity">
  101. select
  102. mall_goods.*,
  103. mall_category.name category_name,
  104. mall_brand.name brand_name,
  105. mall_freight.name freight_name,
  106. case when mall_goods_group.id > 0 then 2 else 0 end as goodsType
  107. from mall_goods
  108. LEFT JOIN mall_category ON mall_goods.category_id = mall_category.id
  109. LEFT JOIN mall_brand ON mall_brand.id = mall_goods.brand_id
  110. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  111. left join mall_freight on mall_goods.freight_id = mall_freight.id
  112. WHERE 1=1
  113. <!-- 数据过滤 -->
  114. ${filterSql}
  115. <if test="merchSn != null and merchSn.trim() != ''">
  116. AND mall_goods.merch_sn = #{merchSn}
  117. </if>
  118. <if test="goodsSn != null and goodsSn != ''">
  119. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  120. </if>
  121. <if test="name != null and name != ''">
  122. AND mall_goods.name LIKE concat('%',#{name},'%')
  123. </if>
  124. <if test="freightId != null and freightId != ''">
  125. AND mall_goods.freight_id = #{freightId}
  126. </if>
  127. <if test="brandId != null and brandId != ''">
  128. AND mall_goods.brand_id = #{brandId}
  129. </if>
  130. <if test="categoryId != null and categoryId != ''">
  131. AND mall_goods.category_id = #{categoryId}
  132. </if>
  133. <if test="sku != null and sku != ''">
  134. AND mall_goods.sku LIKE concat('%',#{sku},'%')
  135. </if>
  136. <if test="category != null and category != ''">
  137. AND mall_goods.category_id IN (select id from mall_category where parent_id = #{category})
  138. </if>
  139. <if test="categoryTwo != null and categoryTwo != ''">
  140. AND mall_goods.category_id = #{categoryTwo}
  141. </if>
  142. <if test="isDelete != null and isDelete != ''">
  143. AND mall_goods.is_Delete = #{isDelete}
  144. </if>
  145. <if test="goodsBizType != null and goodsBizType != ''">
  146. AND mall_goods.goods_biz_type = #{goodsBizType}
  147. </if>
  148. <choose>
  149. <when test="sidx != null and sidx.trim() != ''">
  150. order by ${sidx} ${order}
  151. </when>
  152. <otherwise>
  153. order by mall_goods.id desc
  154. </otherwise>
  155. </choose>
  156. <if test="offset != null and limit != null">
  157. limit #{offset}, #{limit}
  158. </if>
  159. </select>
  160. <select id="querySame" resultType="com.kmall.admin.entity.GoodsEntity">
  161. select
  162. mall_goods.*,
  163. mall_category.name category_name,
  164. mall_brand.name brand_name,
  165. mall_freight.name freight_name,
  166. case when mall_goods_group.id > 0 then 2 else 0 end as goodsType
  167. from mall_goods
  168. LEFT JOIN mall_category ON mall_goods.category_id = mall_category.id
  169. LEFT JOIN mall_brand ON mall_brand.id = mall_goods.brand_id
  170. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  171. left join mall_freight on mall_goods.freight_id = mall_freight.id
  172. WHERE 1=1
  173. <!-- 数据过滤 -->
  174. ${filterSql}
  175. <if test="isSame != null and isSame != ''">
  176. AND ((mall_goods.sku = #{sku} AND mall_goods.goods_biz_type = #{goodsBizType}) OR mall_goods.goods_sn = #{goodsSn})
  177. <if test="id != null and id != ''">
  178. AND mall_goods.id != #{id}
  179. </if>
  180. </if>
  181. <choose>
  182. <when test="sidx != null and sidx.trim() != ''">
  183. order by ${sidx} ${order}
  184. </when>
  185. <otherwise>
  186. order by mall_goods.id desc
  187. </otherwise>
  188. </choose>
  189. <if test="offset != null and limit != null">
  190. limit #{offset}, #{limit}
  191. </if>
  192. </select>
  193. <select id="queryTotal" resultType="int">
  194. select count(*) from mall_goods WHERE 1=1
  195. <!-- 数据过滤 -->
  196. ${filterSql}
  197. <if test="goodsSn != null and goodsSn != ''">
  198. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  199. </if>
  200. <if test="name != null and name != ''">
  201. AND mall_goods.name LIKE concat('%',#{name},'%')
  202. </if>
  203. <if test="freightId != null and freightId != ''">
  204. AND mall_goods.freight_id = #{freightId}
  205. </if>
  206. <if test="brandId != null and brandId != ''">
  207. AND mall_goods.brand_id = #{brandId}
  208. </if>
  209. <if test="categoryId != null and categoryId != ''">
  210. AND mall_goods.category_id = #{categoryId}
  211. </if>
  212. <if test="sku != null and sku != ''">
  213. AND mall_goods.sku LIKE concat('%',#{sku},'%')
  214. </if>
  215. <if test="category != null and category != ''">
  216. AND mall_goods.category_id IN (select id from mall_category where parent_id = #{category})
  217. </if>
  218. <if test="categoryTwo != null and categoryTwo != ''">
  219. AND mall_goods.category_id = #{categoryTwo}
  220. </if>
  221. <if test="isDelete != null and isDelete != ''">
  222. AND mall_goods.is_Delete = #{isDelete}
  223. </if>
  224. </select>
  225. <insert id="save" parameterType="com.kmall.admin.entity.GoodsEntity" useGeneratedKeys="true" keyProperty="id">
  226. insert into mall_goods(
  227. `merch_sn`,
  228. `category_id`,
  229. `supplier_id`,
  230. `goods_sn`,
  231. `prod_barcode`,
  232. `sku`,
  233. `goods_biz_type`,
  234. `name`,
  235. `unit_code`,
  236. `brand_id`,
  237. `brand`,
  238. `freight_id`,
  239. `goods_number`,
  240. `keywords`,
  241. `goods_brief`,
  242. `goods_desc`,
  243. `cus_goods_code`,
  244. `ciq_prod_model`,
  245. `ori_cnt_code`,
  246. `cus_decl_ele`,
  247. `cus_rec_code`,
  248. `is_on_sale`,
  249. `add_time`,
  250. `sort_order`,
  251. `is_delete`,
  252. `attribute_category`,
  253. `counter_price`,
  254. `extra_price`,
  255. `is_new`,
  256. `goods_unit`,
  257. `primary_pic_url`,
  258. `list_pic_url`,
  259. `goods_rate`,
  260. `retail_price`,
  261. `sell_volume`,
  262. `primary_product_id`,
  263. `unit_price`,
  264. `promotion_desc`,
  265. `promotion_tag`,
  266. `app_exclusive_price`,
  267. `is_app_exclusive`,
  268. `is_limited`,
  269. `is_hot`,
  270. `market_price`,
  271. `creater_sn`,
  272. `create_time`,
  273. `moder_sn`,
  274. `mod_time`,
  275. `tstm`)
  276. values(
  277. #{merchSn},
  278. #{categoryId},
  279. #{supplierId},
  280. #{goodsSn},
  281. #{prodBarcode},
  282. #{sku},
  283. #{goodsBizType},
  284. #{name},
  285. #{unitCode},
  286. #{brandId},
  287. #{brand},
  288. #{freightId},
  289. #{goodsNumber},
  290. #{keywords},
  291. #{goodsBrief},
  292. #{goodsDesc},
  293. #{cusGoodsCode},
  294. #{ciqProdModel},
  295. #{oriCntCode},
  296. #{cusDeclEle},
  297. #{cusRecCode},
  298. #{isOnSale},
  299. #{addTime},
  300. #{sortOrder},
  301. #{isDelete},
  302. #{attributeCategory},
  303. #{counterPrice},
  304. #{extraPrice},
  305. #{isNew},
  306. #{goodsUnit},
  307. #{primaryPicUrl},
  308. #{listPicUrl},
  309. #{goodsRate},
  310. #{retailPrice},
  311. #{sellVolume},
  312. #{primaryProductId},
  313. #{unitPrice},
  314. #{promotionDesc},
  315. #{promotionTag},
  316. #{appExclusivePrice},
  317. #{isAppExclusive},
  318. #{isLimited},
  319. #{isHot},
  320. #{marketPrice},
  321. #{createrSn},
  322. #{createTime},
  323. #{moderSn},
  324. #{modTime},
  325. #{tstm})
  326. </insert>
  327. <update id="update" parameterType="com.kmall.admin.entity.GoodsEntity">
  328. update mall_goods
  329. <set>
  330. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  331. <if test="categoryId != null">`category_id` = #{categoryId}, </if>
  332. <if test="supplierId != null">`supplier_id` = #{supplierId}, </if>
  333. <if test="goodsSn != null">`goods_sn` = #{goodsSn}, </if>
  334. <if test="prodBarcode != null">`prod_barcode` = #{prodBarcode}, </if>
  335. <if test="sku != null">`sku` = #{sku}, </if>
  336. <if test="goodsBizType != null">`goods_biz_type` = #{goodsBizType}, </if>
  337. <if test="name != null">`name` = #{name}, </if>
  338. <if test="unitCode != null">`unit_code` = #{unitCode}, </if>
  339. <if test="brandId != null">`brand_id` = #{brandId}, </if>
  340. <if test="brand != null">`brand` = #{brand}, </if>
  341. <if test="freightId != null">`freight_id` = #{freightId}, </if>
  342. <if test="goodsNumber != null">`goods_number` = #{goodsNumber}, </if>
  343. <if test="keywords != null">`keywords` = #{keywords}, </if>
  344. <if test="goodsBrief != null">`goods_brief` = #{goodsBrief}, </if>
  345. <if test="goodsDesc != null">`goods_desc` = #{goodsDesc}, </if>
  346. <if test="cusGoodsCode != null">`cus_goods_code` = #{cusGoodsCode}, </if>
  347. <if test="ciqProdModel != null">`ciq_prod_model` = #{ciqProdModel}, </if>
  348. <if test="oriCntCode != null">`ori_cnt_code` = #{oriCntCode}, </if>
  349. <if test="cusDeclEle != null">`cus_decl_ele` = #{cusDeclEle}, </if>
  350. <if test="cusRecCode != null">`cus_rec_code` = #{cusRecCode}, </if>
  351. <if test="isOnSale != null">`is_on_sale` = #{isOnSale}, </if>
  352. <if test="addTime != null">`add_time` = #{addTime}, </if>
  353. <if test="sortOrder != null">`sort_order` = #{sortOrder}, </if>
  354. <if test="isDelete != null">`is_delete` = #{isDelete}, </if>
  355. <if test="attributeCategory != null">`attribute_category` = #{attributeCategory}, </if>
  356. <if test="counterPrice != null">`counter_price` = #{counterPrice}, </if>
  357. <if test="extraPrice != null">`extra_price` = #{extraPrice}, </if>
  358. <if test="isNew != null">`is_new` = #{isNew}, </if>
  359. <if test="goodsUnit != null">`goods_unit` = #{goodsUnit}, </if>
  360. <if test="primaryPicUrl != null">`primary_pic_url` = #{primaryPicUrl}, </if>
  361. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl}, </if>
  362. <if test="goodsRate != null">`goods_rate` = #{goodsRate}, </if>
  363. <if test="retailPrice != null">`retail_price` = #{retailPrice}, </if>
  364. <if test="sellVolume != null">`sell_volume` = #{sellVolume}, </if>
  365. <if test="primaryProductId != null">`primary_product_id` = #{primaryProductId}, </if>
  366. <if test="unitPrice != null">`unit_price` = #{unitPrice}, </if>
  367. <if test="promotionDesc != null">`promotion_desc` = #{promotionDesc}, </if>
  368. <if test="promotionTag != null">`promotion_tag` = #{promotionTag}, </if>
  369. <if test="appExclusivePrice != null">`app_exclusive_price` = #{appExclusivePrice}, </if>
  370. <if test="isAppExclusive != null">`is_app_exclusive` = #{isAppExclusive}, </if>
  371. <if test="isLimited != null">`is_limited` = #{isLimited}, </if>
  372. <if test="isHot != null">`is_hot` = #{isHot}, </if>
  373. <if test="marketPrice != null">`market_price` = #{marketPrice}, </if>
  374. <if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
  375. <if test="createTime != null">`create_time` = #{createTime}, </if>
  376. <if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
  377. <if test="modTime != null">`mod_time` = #{modTime}, </if>
  378. <if test="tstm != null">`tstm` = #{tstm}</if>
  379. </set>
  380. where id = #{id}
  381. </update>
  382. <delete id="delete">
  383. delete from mall_goods where id = #{value}
  384. </delete>
  385. <delete id="deleteBatch">
  386. delete from mall_goods where id in
  387. <foreach item="id" collection="array" open="(" separator="," close=")">
  388. #{id}
  389. </foreach>
  390. </delete>
  391. <select id="queryMaxId" resultType="java.lang.Long" parameterType="map">
  392. SELECT MAX(id) FROM mall_goods
  393. </select>
  394. </mapper>