1
0

GoodsDao.xml 14 KB

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