GoodsDao.xml 16 KB

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