1
0

GoodsDao.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. <if test="isSame != null and isSame != ''">
  112. AND (mall_goods.sku = #{sku} AND mall_goods.goods_biz_type = #{goodsBizType}) OR mall_goods.goods_sn = #{goodsSn}
  113. </if>
  114. <choose>
  115. <when test="sidx != null and sidx.trim() != ''">
  116. order by ${sidx} ${order}
  117. </when>
  118. <otherwise>
  119. order by mall_goods.id desc
  120. </otherwise>
  121. </choose>
  122. <if test="offset != null and limit != null">
  123. limit #{offset}, #{limit}
  124. </if>
  125. </select>
  126. <select id="queryTotal" resultType="int">
  127. select count(*) from mall_goods WHERE 1=1
  128. <!-- 数据过滤 -->
  129. ${filterSql}
  130. <if test="goodsSn != null and goodsSn != ''">
  131. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  132. </if>
  133. <if test="name != null and name != ''">
  134. AND mall_goods.name LIKE concat('%',#{name},'%')
  135. </if>
  136. <if test="sku != null and sku != ''">
  137. AND mall_goods.sku LIKE concat('%',#{sku},'%')
  138. </if>
  139. AND mall_goods.is_Delete = #{isDelete}
  140. </select>
  141. <insert id="save" parameterType="com.kmall.admin.entity.GoodsEntity" useGeneratedKeys="true" keyProperty="id">
  142. insert into mall_goods(
  143. `category_id`,
  144. `goods_sn`,
  145. `prod_barcode`,
  146. `sku`,
  147. `goods_biz_type`,
  148. `name`,
  149. `unit_code`,
  150. `brand_id`,
  151. `brand`,
  152. `freight_id`,
  153. `goods_number`,
  154. `keywords`,
  155. `goods_brief`,
  156. `goods_desc`,
  157. `cus_goods_code`,
  158. `ciq_prod_model`,
  159. `ori_cnt_code`,
  160. `cus_decl_ele`,
  161. `cus_rec_code`,
  162. `is_on_sale`,
  163. `add_time`,
  164. `sort_order`,
  165. `is_delete`,
  166. `attribute_category`,
  167. `counter_price`,
  168. `extra_price`,
  169. `is_new`,
  170. `goods_unit`,
  171. `primary_pic_url`,
  172. `list_pic_url`,
  173. `goods_rate`,
  174. `retail_price`,
  175. `sell_volume`,
  176. `primary_product_id`,
  177. `unit_price`,
  178. `promotion_desc`,
  179. `promotion_tag`,
  180. `app_exclusive_price`,
  181. `is_app_exclusive`,
  182. `is_limited`,
  183. `is_hot`,
  184. `market_price`,
  185. `creater_sn`,
  186. `create_time`,
  187. `moder_sn`,
  188. `mod_time`,
  189. `tstm`)
  190. values(
  191. #{categoryId},
  192. #{goodsSn},
  193. #{prodBarcode},
  194. #{sku},
  195. #{goodsBizType},
  196. #{name},
  197. #{unitCode},
  198. #{brandId},
  199. #{brand},
  200. #{freightId},
  201. #{goodsNumber},
  202. #{keywords},
  203. #{goodsBrief},
  204. #{goodsDesc},
  205. #{cusGoodsCode},
  206. #{ciqProdModel},
  207. #{oriCntCode},
  208. #{cusDeclEle},
  209. #{cusRecCode},
  210. #{isOnSale},
  211. #{addTime},
  212. #{sortOrder},
  213. #{isDelete},
  214. #{attributeCategory},
  215. #{counterPrice},
  216. #{extraPrice},
  217. #{isNew},
  218. #{goodsUnit},
  219. #{primaryPicUrl},
  220. #{listPicUrl},
  221. #{goodsRate},
  222. #{retailPrice},
  223. #{sellVolume},
  224. #{primaryProductId},
  225. #{unitPrice},
  226. #{promotionDesc},
  227. #{promotionTag},
  228. #{appExclusivePrice},
  229. #{isAppExclusive},
  230. #{isLimited},
  231. #{isHot},
  232. #{marketPrice},
  233. #{createrSn},
  234. #{createTime},
  235. #{moderSn},
  236. #{modTime},
  237. #{tstm})
  238. </insert>
  239. <update id="update" parameterType="com.kmall.admin.entity.GoodsEntity">
  240. update mall_goods
  241. <set>
  242. <if test="categoryId != null">`category_id` = #{categoryId}, </if>
  243. <if test="goodsSn != null">`goods_sn` = #{goodsSn}, </if>
  244. <if test="prodBarcode != null">`prod_barcode` = #{prodBarcode}, </if>
  245. <if test="sku != null">`sku` = #{sku}, </if>
  246. <if test="goodsBizType != null">`goods_biz_type` = #{goodsBizType}, </if>
  247. <if test="name != null">`name` = #{name}, </if>
  248. <if test="unitCode != null">`unit_code` = #{unitCode}, </if>
  249. <if test="brandId != null">`brand_id` = #{brandId}, </if>
  250. <if test="brand != null">`brand` = #{brand}, </if>
  251. <if test="freightId != null">`freight_id` = #{freightId}, </if>
  252. <if test="goodsNumber != null">`goods_number` = #{goodsNumber}, </if>
  253. <if test="keywords != null">`keywords` = #{keywords}, </if>
  254. <if test="goodsBrief != null">`goods_brief` = #{goodsBrief}, </if>
  255. <if test="goodsDesc != null">`goods_desc` = #{goodsDesc}, </if>
  256. <if test="cusGoodsCode != null">`cus_goods_code` = #{cusGoodsCode}, </if>
  257. <if test="ciqProdModel != null">`ciq_prod_model` = #{ciqProdModel}, </if>
  258. <if test="oriCntCode != null">`ori_cnt_code` = #{oriCntCode}, </if>
  259. <if test="cusDeclEle != null">`cus_decl_ele` = #{cusDeclEle}, </if>
  260. <if test="cusRecCode != null">`cus_rec_code` = #{cusRecCode}, </if>
  261. <if test="isOnSale != null">`is_on_sale` = #{isOnSale}, </if>
  262. <if test="addTime != null">`add_time` = #{addTime}, </if>
  263. <if test="sortOrder != null">`sort_order` = #{sortOrder}, </if>
  264. <if test="isDelete != null">`is_delete` = #{isDelete}, </if>
  265. <if test="attributeCategory != null">`attribute_category` = #{attributeCategory}, </if>
  266. <if test="counterPrice != null">`counter_price` = #{counterPrice}, </if>
  267. <if test="extraPrice != null">`extra_price` = #{extraPrice}, </if>
  268. <if test="isNew != null">`is_new` = #{isNew}, </if>
  269. <if test="goodsUnit != null">`goods_unit` = #{goodsUnit}, </if>
  270. <if test="primaryPicUrl != null">`primary_pic_url` = #{primaryPicUrl}, </if>
  271. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl}, </if>
  272. <if test="goodsRate != null">`goods_rate` = #{goodsRate}, </if>
  273. <if test="retailPrice != null">`retail_price` = #{retailPrice}, </if>
  274. <if test="sellVolume != null">`sell_volume` = #{sellVolume}, </if>
  275. <if test="primaryProductId != null">`primary_product_id` = #{primaryProductId}, </if>
  276. <if test="unitPrice != null">`unit_price` = #{unitPrice}, </if>
  277. <if test="promotionDesc != null">`promotion_desc` = #{promotionDesc}, </if>
  278. <if test="promotionTag != null">`promotion_tag` = #{promotionTag}, </if>
  279. <if test="appExclusivePrice != null">`app_exclusive_price` = #{appExclusivePrice}, </if>
  280. <if test="isAppExclusive != null">`is_app_exclusive` = #{isAppExclusive}, </if>
  281. <if test="isLimited != null">`is_limited` = #{isLimited}, </if>
  282. <if test="isHot != null">`is_hot` = #{isHot}, </if>
  283. <if test="marketPrice != null">`market_price` = #{marketPrice}, </if>
  284. <if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
  285. <if test="createTime != null">`create_time` = #{createTime}, </if>
  286. <if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
  287. <if test="modTime != null">`mod_time` = #{modTime}, </if>
  288. <if test="tstm != null">`tstm` = #{tstm}</if>
  289. </set>
  290. where id = #{id}
  291. </update>
  292. <delete id="delete">
  293. delete from mall_goods where id = #{value}
  294. </delete>
  295. <delete id="deleteBatch">
  296. delete from mall_goods where id in
  297. <foreach item="id" collection="array" open="(" separator="," close=")">
  298. #{id}
  299. </foreach>
  300. </delete>
  301. <select id="queryMaxId" resultType="java.lang.Long" parameterType="map">
  302. SELECT MAX(id) FROM mall_goods
  303. </select>
  304. </mapper>