GoodsDao.xml 17 KB

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