GoodsDao.xml 15 KB

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