1
0

GoodsDao.xml 16 KB

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