GoodsDao.xml 16 KB

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