GoodsDao.xml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  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="stockNum" 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. <result column="gross_weight" property="grossWeight"/>
  66. <result column="net_weight" property="netWeight"/>
  67. <result property="isGoodsShareStock" column="is_goods_share_stock"/>
  68. <result column="cost_price" property="costPrice"/>
  69. <result property="dailyPrice" column="daily_price"/>
  70. <result column="last_sale_time" property="lastSaleTime" jdbcType="TIMESTAMP"/>
  71. <result column="mychem_id" property="mychemId"/>
  72. </resultMap>
  73. <select id="queryObject" resultType="com.kmall.admin.entity.GoodsEntity">
  74. SELECT
  75. a.*, CASE
  76. when g.id > 0 then 2 else 0 end as goodsType,
  77. mb.third_party_merch_code,
  78. mb.is_stock_share isStockShare,
  79. mb.is_supplier_goods 'isSupplierGoods'
  80. FROM
  81. mall_goods a
  82. LEFT JOIN mall_goods_group g ON g.goods_id = a.id AND g.open_status != 3
  83. LEFT JOIN third_merchant_biz mb ON a.third_party_merch_code = mb.third_party_merch_code
  84. WHERE a.id = #{value}
  85. </select>
  86. <select id="queryObjectByStoreId" resultMap="goodsMap">
  87. select
  88. a.sku,
  89. a.id,
  90. psr1.category_id,
  91. a.goods_sn,
  92. a.name,
  93. psr1.brand_id,
  94. a.goods_number,
  95. a.keywords,
  96. a.goods_brief,
  97. a.is_on_sale,
  98. a.add_time,
  99. a.sort_order,
  100. a.is_delete,
  101. psr1.attribute_category,
  102. a.counter_price,
  103. a.extra_price,
  104. a.is_new,
  105. a.goods_unit,
  106. a.primary_pic_url,
  107. a.list_pic_url,
  108. psr1.retail_price,
  109. psr1.sell_volume,
  110. a.primary_product_id,
  111. a.unit_price,
  112. a.promotion_desc,
  113. a.promotion_tag,
  114. a.app_exclusive_price,
  115. a.is_app_exclusive,
  116. a.is_limited,
  117. a.is_hot,
  118. a.merch_sn,
  119. m.merch_name,
  120. psr1.store_id,
  121. psr1.market_price,
  122. psr1.stock_num,
  123. a.goods_desc,a.goods_biz_type,a.goods_rate,
  124. a.sell_volume goods_sell_volume,
  125. mb.third_party_merch_code,
  126. mb.is_stock_share isStockShare,
  127. mb.is_supplier_goods 'isSupplierGoods',
  128. mb2.third_party_merch_code 'supplierThirdMerchCode',
  129. mb2.is_stock_share 'isStockShareBySuppler'
  130. from mall_goods a left join mall_merch m on a.merch_sn = m.merch_sn
  131. LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
  132. LEFT JOIN mall_store s ON s.id = psr1.store_id
  133. LEFT JOIN third_merchant_biz mb on s.third_party_merch_code = mb.third_party_merch_code
  134. LEFT JOIN third_merchant_biz mb2 ON a.third_party_merch_code = mb2.third_party_merch_code
  135. where a.id = #{id} and psr1.store_id = #{storeId}
  136. </select>
  137. <select id="queryGoodsByGoodsSnAndStoreId" resultMap="goodsMap">
  138. select
  139. a.sku,
  140. a.id,
  141. psr1.category_id,
  142. a.goods_sn,
  143. a.name,
  144. psr1.brand_id,
  145. a.goods_number,
  146. a.keywords,
  147. a.goods_brief,
  148. a.is_on_sale,
  149. a.add_time,
  150. a.sort_order,
  151. a.is_delete,
  152. psr1.attribute_category,
  153. a.counter_price,
  154. a.extra_price,
  155. a.is_new,
  156. a.goods_unit,
  157. a.primary_pic_url,
  158. a.list_pic_url,
  159. psr1.retail_price,
  160. psr1.sell_volume,
  161. a.primary_product_id,
  162. a.unit_price,
  163. a.promotion_desc,
  164. a.promotion_tag,
  165. a.app_exclusive_price,
  166. a.is_app_exclusive,
  167. a.is_limited,
  168. a.is_hot,
  169. a.merch_sn,
  170. m.merch_name,
  171. psr1.store_id,
  172. psr1.market_price,
  173. psr1.stock_num,
  174. a.goods_desc,a.goods_biz_type,a.goods_rate,
  175. a.sell_volume goods_sell_volume,
  176. mb.third_party_merch_code,
  177. mb.is_stock_share isStockShare,
  178. mb.is_supplier_goods 'isSupplierGoods',
  179. mb2.third_party_merch_code 'supplierThirdMerchCode',
  180. mb2.is_stock_share 'isStockShareBySuppler'
  181. from mall_goods a left join mall_merch m on a.merch_sn = m.merch_sn
  182. LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
  183. LEFT JOIN mall_store s ON s.id = psr1.store_id
  184. LEFT JOIN third_merchant_biz mb on s.third_party_merch_code = mb.third_party_merch_code
  185. LEFT JOIN third_merchant_biz mb2 ON a.third_party_merch_code = mb2.third_party_merch_code
  186. where a.goods_sn = #{goodsSn} and psr1.store_id = #{storeId}
  187. </select>
  188. <select id="queryObjectByProdBarcodeAndBizType" resultType="com.kmall.admin.entity.GoodsEntity">
  189. SELECT
  190. 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'
  191. FROM
  192. mall_goods a
  193. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  194. inner join mall_store s on r.store_id=s.id
  195. where a.prod_barcode = #{prodBarcode} and a.goods_biz_type = 11 and r.store_id = #{storeId}
  196. </select>
  197. <select id="queryObjectByProdBarcodeAndStore" resultType="com.kmall.admin.entity.GoodsEntity">
  198. SELECT
  199. a.id,a.sku,a.goods_number,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',a.goods_rate as goodsRate
  200. FROM
  201. mall_goods a
  202. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  203. inner join mall_store s on r.store_id=s.id
  204. where a.prod_barcode = #{prodBarcode} and r.store_id = #{storeId}
  205. and r.stock_num > 0
  206. limit 1
  207. </select>
  208. <select id="queryObjectByProdBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
  209. SELECT
  210. 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'
  211. FROM
  212. mall_goods a
  213. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  214. inner join mall_store s on r.store_id=s.id
  215. where a.prod_barcode = #{prodBarcode} and a.is_delete = 0
  216. <if test="goodsId != null and goodsId != ''">
  217. AND a.id != #{goodsId}
  218. </if>
  219. <if test="merchSn != null and merchSn != ''">
  220. AND a.merch_sn = #{merchSn}
  221. </if>
  222. </select>
  223. <select id="queryGoodsDetailsByProdBarcode" resultType="com.kmall.admin.dto.GoodsDetailsDto">
  224. SELECT distinct
  225. a.goods_sn as GoodsSn,m.retail_price as retailPrice,a.prod_barcode as prodBarcode,a.name,a.brand,a.goods_desc as goodsDesc,a.goods_unit as goodsUnit,a.goods_rate as goodsRate,a.primary_pic_url ,m.stock_num as stockNum,r.value as specification
  226. FROM
  227. mall_goods a
  228. LEFT JOIN mall_goods_specification r ON r.goods_id = a.id
  229. left join mall_product_store_rela m on m.goods_id = a.id and r.goods_id = m.goods_id
  230. where a.prod_barcode = #{prodBarcode} and m.store_id = #{storeId}
  231. and m.stock_num > 0 order by m.stock_num desc
  232. limit 1
  233. </select>
  234. <select id="queryObjectBySn" resultType="com.kmall.admin.entity.GoodsEntity">
  235. SELECT
  236. a.*, CASE
  237. when g.id > 0 then 2 else 0 end as goodsType
  238. FROM
  239. mall_goods a
  240. LEFT JOIN mall_goods_group g ON g.goods_id = a.id
  241. AND g.open_status != 3
  242. where a.goods_sn = #{goodsSn}
  243. </select>
  244. <select id="queryList" resultType="com.kmall.admin.entity.GoodsEntity">
  245. select * from (
  246. select
  247. mall_goods.*,
  248. case when mall_goods_group.id > 0 then 2 else 0 end as goodsType,
  249. m.merch_name merchName, mb.is_stock_share isStockShare,
  250. catagory.keywords as categoryName
  251. from mall_goods
  252. left join mall_merch m on mall_goods.merch_sn = m.merch_sn
  253. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  254. left join third_merchant_biz mb on mb.third_party_merch_code = mall_goods.third_party_merch_code and
  255. mb.merch_sn=mall_goods.merch_sn
  256. left join mall_category catagory on catagory.id = mall_goods.category_id
  257. WHERE 1=1
  258. <!-- 数据过滤 -->
  259. ${filterSql}
  260. <if test="merchSn != null and merchSn.trim() != ''">
  261. AND mall_goods.merch_sn = #{merchSn}
  262. </if>
  263. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  264. AND mall_goods.prod_barcode = #{prodBarcode}
  265. </if>
  266. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  267. AND mall_goods.third_party_merch_code = #{thirdPartyMerchCode}
  268. </if>
  269. <if test="thirdMerchSn != null and thirdMerchSn.trim() != ''">
  270. AND mb.third_merch_sn = #{thirdMerchSn}
  271. </if>
  272. <if test="goodsSn != null and goodsSn != ''">
  273. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  274. </if>
  275. <if test="name != null and name != ''">
  276. AND mall_goods.name LIKE concat('%',#{name},'%')
  277. </if>
  278. <if test="englishName != null and englishName != ''">
  279. AND mall_goods.english_name LIKE concat('%',#{englishName},'%')
  280. </if>
  281. <!--<if test="brandId != null and brandId != ''">
  282. AND mall_goods.brand_id = #{brandId}
  283. </if>
  284. <if test="freightId != null and freightId != ''">
  285. AND mall_goods.freight_id = #{freightId}
  286. </if>
  287. <if test="categoryId != null and categoryId != ''">
  288. AND mall_goods.category_id = #{categoryId}
  289. </if>
  290. <if test="category != null and category != ''">
  291. AND mall_goods.category_id IN (select id from mall_category where parent_id = #{category})
  292. </if>
  293. <if test="categoryTwo != null and categoryTwo != ''">
  294. AND mall_goods.category_id = #{categoryTwo}
  295. </if>-->
  296. <if test="sku != null and sku != ''">
  297. AND mall_goods.sku LIKE concat('%',#{sku},'%')
  298. </if>
  299. <if test="plu != null and plu != ''">
  300. AND mall_goods.plu LIKE concat('%',#{plu},'%')
  301. </if>
  302. <if test="isDelete != null">
  303. AND mall_goods.is_Delete = #{isDelete}
  304. </if>
  305. <if test="isOnSale != null">
  306. AND mall_goods.is_on_sale = #{isOnSale}
  307. </if>
  308. <if test="goodsBizType != null and goodsBizType != ''">
  309. AND mall_goods.goods_biz_type = #{goodsBizType}
  310. </if>
  311. <if test="id != null and id != ''">
  312. AND mall_goods.id = #{id}
  313. </if>
  314. <if test="storeId != null and storeId != ''">
  315. AND mall_goods.third_party_merch_code = ( SELECT third_party_merch_code FROM mall_store WHERE id =
  316. #{storeId} )
  317. AND mall_goods.id NOT IN (
  318. SELECT
  319. goods_id
  320. FROM
  321. mall_product_store_rela pp
  322. WHERE
  323. store_id = #{storeId}
  324. )
  325. </if>
  326. <if test="storeIdBySupplier != null and storeIdBySupplier != ''">
  327. AND mall_goods.id NOT IN (
  328. SELECT
  329. goods_id
  330. FROM
  331. mall_product_store_rela pp
  332. WHERE
  333. store_id = #{storeIdBySupplier} and supplier_third_id = #{thirdMerchSn}
  334. )
  335. </if>
  336. ) temp where 1=1
  337. <if test="lastSaleTime != null and lastSaleTime != ''">
  338. AND temp.last_sale_time &gt;= #{lastSaleTime} or temp.last_sale_time is null
  339. </if>
  340. <choose>
  341. <when test="sidx != null and sidx.trim() != ''">
  342. order by ${sidx} ${order}
  343. </when>
  344. <otherwise>
  345. order by temp.id desc
  346. </otherwise>
  347. </choose>
  348. <if test="offset != null and limit != null">
  349. limit #{offset}, #{limit}
  350. </if>
  351. </select>
  352. <select id="querySame" resultType="com.kmall.admin.entity.GoodsEntity">
  353. select
  354. mall_goods.*,
  355. case when mall_goods_group.id > 0 then 2 else 0 end as goodsType
  356. from mall_goods
  357. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  358. WHERE 1=1
  359. <!-- 数据过滤 -->
  360. ${filterSql}
  361. <if test="isSame != null and isSame != ''">
  362. AND ((mall_goods.sku = #{sku} AND mall_goods.goods_biz_type = #{goodsBizType}) OR mall_goods.goods_sn =
  363. #{goodsSn})
  364. <if test="id != null and id != ''">
  365. AND mall_goods.id != #{id}
  366. </if>
  367. </if>
  368. <choose>
  369. <when test="sidx != null and sidx.trim() != ''">
  370. order by ${sidx} ${order}
  371. </when>
  372. <otherwise>
  373. order by mall_goods.id desc
  374. </otherwise>
  375. </choose>
  376. <if test="offset != null and limit != null">
  377. limit #{offset}, #{limit}
  378. </if>
  379. </select>
  380. <select id="queryTotal" resultType="int">
  381. select count(*) from mall_goods
  382. left join mall_merch m on mall_goods.merch_sn = m.merch_sn
  383. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  384. WHERE 1=1
  385. <!-- 数据过滤 -->
  386. ${filterSql}
  387. <if test="merchSn != null and merchSn.trim() != ''">
  388. AND mall_goods.merch_sn = #{merchSn}
  389. </if>
  390. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  391. AND mall_goods.prod_barcode = #{prodBarcode}
  392. </if>
  393. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  394. AND mall_goods.third_party_merch_code = #{thirdPartyMerchCode}
  395. </if>
  396. <if test="goodsSn != null and goodsSn != ''">
  397. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  398. </if>
  399. <if test="name != null and name != ''">
  400. AND mall_goods.name LIKE concat('%',#{name},'%')
  401. </if>
  402. <if test="sku != null and sku != ''">
  403. AND mall_goods.sku LIKE concat('%',#{sku},'%')
  404. </if>
  405. <if test="isDelete != null">
  406. AND mall_goods.is_Delete = #{isDelete}
  407. </if>
  408. <if test="isOnSale != null">
  409. AND mall_goods.is_on_sale = #{isOnSale}
  410. </if>
  411. <if test="goodsBizType != null and goodsBizType != ''">
  412. AND mall_goods.goods_biz_type = #{goodsBizType}
  413. </if>
  414. <if test="storeId != null and storeId != ''">
  415. AND mall_goods.third_party_merch_code = ( SELECT third_party_merch_code FROM mall_store WHERE id =
  416. #{storeId} )
  417. AND mall_goods.id NOT IN (
  418. SELECT
  419. goods_id
  420. FROM
  421. mall_product_store_rela pp
  422. LEFT JOIN mall_goods gg ON pp.goods_id = gg.id
  423. AND pp.merch_sn = gg.merch_sn
  424. AND pp.merch_sn
  425. LEFT JOIN mall_store s ON pp.store_id = s.id
  426. AND s.third_party_merch_code = gg.third_party_merch_code
  427. WHERE
  428. store_id = #{storeId}
  429. )
  430. </if>
  431. </select>
  432. <insert id="save" parameterType="com.kmall.admin.entity.GoodsEntity" useGeneratedKeys="true" keyProperty="id">
  433. insert into mall_goods(
  434. `merch_sn`,
  435. third_party_merch_code,
  436. `supplier_id`,
  437. `goods_sn`,
  438. `prod_barcode`,
  439. `sku`,
  440. `plu`,
  441. `english_name`,
  442. `cost_price`,
  443. `daily_price`,
  444. `goods_biz_type`,
  445. `name`,
  446. `unit_code`,
  447. `brand`,
  448. `goods_number`,
  449. `keywords`,
  450. `goods_brief`,
  451. `goods_desc`,
  452. `cus_goods_code`,
  453. `ciq_prod_model`,
  454. `ori_cnt_code`,
  455. `cus_decl_ele`,
  456. `cus_rec_code`,
  457. `is_on_sale`,
  458. `add_time`,
  459. `sort_order`,
  460. `is_delete`,
  461. `counter_price`,
  462. `extra_price`,
  463. `is_new`,
  464. `goods_unit`,
  465. `primary_pic_url`,
  466. `list_pic_url`,
  467. `goods_rate`,
  468. `sell_volume`,
  469. `primary_product_id`,
  470. `unit_price`,
  471. `promotion_desc`,
  472. `promotion_tag`,
  473. `app_exclusive_price`,
  474. `is_app_exclusive`,
  475. `gross_weight`,
  476. `net_weight`,
  477. is_goods_share_stock,
  478. `is_limited`,
  479. `is_hot`,
  480. `creater_sn`,
  481. `create_time`,
  482. `moder_sn`,
  483. `mod_time`,
  484. `tstm`)
  485. values(
  486. #{merchSn},
  487. #{thirdPartyMerchCode},
  488. #{supplierId},
  489. #{goodsSn},
  490. #{prodBarcode},
  491. #{sku},
  492. #{plu},
  493. #{englishName},
  494. #{costPrice},
  495. #{dailyPrice},
  496. #{goodsBizType},
  497. #{name},
  498. #{unitCode},
  499. #{brand},
  500. #{goodsNumber},
  501. #{keywords},
  502. #{goodsBrief},
  503. #{goodsDesc},
  504. #{cusGoodsCode},
  505. #{ciqProdModel},
  506. #{oriCntCode},
  507. #{cusDeclEle},
  508. #{cusRecCode},
  509. #{isOnSale},
  510. #{addTime},
  511. #{sortOrder},
  512. #{isDelete},
  513. #{counterPrice},
  514. #{extraPrice},
  515. #{isNew},
  516. #{goodsUnit},
  517. #{primaryPicUrl},
  518. #{listPicUrl},
  519. #{goodsRate},
  520. #{sellVolume},
  521. #{primaryProductId},
  522. #{unitPrice},
  523. #{promotionDesc},
  524. #{promotionTag},
  525. #{appExclusivePrice},
  526. #{isAppExclusive},
  527. #{grossWeight},
  528. #{netWeight},
  529. #{isGoodsShareStock},
  530. #{isLimited},
  531. #{isHot},
  532. #{createrSn},
  533. #{createTime},
  534. #{moderSn},
  535. #{modTime},
  536. #{tstm})
  537. </insert>
  538. <update id="update" parameterType="com.kmall.admin.entity.GoodsEntity">
  539. update mall_goods
  540. <set>
  541. <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
  542. <if test="thirdPartyMerchCode != null">`third_party_merch_code` = #{thirdPartyMerchCode},</if>
  543. <if test="supplierId != null">`supplier_id` = #{supplierId},</if>
  544. <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
  545. <if test="prodBarcode != null">`prod_barcode` = #{prodBarcode},</if>
  546. <if test="sku != null">`sku` = #{sku},</if>
  547. <if test="plu != null">`plu` = #{plu},</if>
  548. <if test="englishName != null">`english_name` = #{englishName},</if>
  549. <if test="costPrice != null">`cost_price` = #{costPrice},</if>
  550. <if test="dailyPrice != null">`daily_price` = #{dailyPrice},</if>
  551. <if test="goodsBizType != null">`goods_biz_type` = #{goodsBizType},</if>
  552. <if test="name != null">`name` = #{name},</if>
  553. <if test="unitCode != null">`unit_code` = #{unitCode},</if>
  554. <if test="brand != null">`brand` = #{brand},</if>
  555. <if test="goodsNumber != null">`goods_number` = #{goodsNumber},</if>
  556. <if test="keywords != null">`keywords` = #{keywords},</if>
  557. <if test="goodsBrief != null">`goods_brief` = #{goodsBrief},</if>
  558. <if test="goodsDesc != null">`goods_desc` = #{goodsDesc},</if>
  559. <if test="cusGoodsCode != null">`cus_goods_code` = #{cusGoodsCode},</if>
  560. <if test="ciqProdModel != null">`ciq_prod_model` = #{ciqProdModel},</if>
  561. <if test="oriCntCode != null">`ori_cnt_code` = #{oriCntCode},</if>
  562. <if test="cusDeclEle != null">`cus_decl_ele` = #{cusDeclEle},</if>
  563. <if test="cusRecCode != null">`cus_rec_code` = #{cusRecCode},</if>
  564. <if test="isOnSale != null">`is_on_sale` = #{isOnSale},</if>
  565. <if test="addTime != null">`add_time` = #{addTime},</if>
  566. <if test="sortOrder != null">`sort_order` = #{sortOrder},</if>
  567. <if test="isDelete != null">`is_delete` = #{isDelete},</if>
  568. <if test="counterPrice != null">`counter_price` = #{counterPrice},</if>
  569. <if test="extraPrice != null">`extra_price` = #{extraPrice},</if>
  570. <if test="isNew != null">`is_new` = #{isNew},</if>
  571. <if test="goodsUnit != null">`goods_unit` = #{goodsUnit},</if>
  572. <if test="primaryPicUrl != null">`primary_pic_url` = #{primaryPicUrl},</if>
  573. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl},</if>
  574. <if test="goodsRate != null">`goods_rate` = #{goodsRate},</if>
  575. <if test="sellVolume != null">`sell_volume` = #{sellVolume},</if>
  576. <if test="primaryProductId != null">`primary_product_id` = #{primaryProductId},</if>
  577. <if test="unitPrice != null">`unit_price` = #{unitPrice},</if>
  578. <if test="promotionDesc != null">`promotion_desc` = #{promotionDesc},</if>
  579. <if test="promotionTag != null">`promotion_tag` = #{promotionTag},</if>
  580. <if test="appExclusivePrice != null">`app_exclusive_price` = #{appExclusivePrice},</if>
  581. <if test="isAppExclusive != null">`is_app_exclusive` = #{isAppExclusive},</if>
  582. <if test="grossWeight != null">`gross_weight` = #{grossWeight},</if>
  583. <if test="netWeight != null">`net_weight` = #{netWeight},</if>
  584. <if test="isGoodsShareStock != null">`is_goods_share_stock` = #{isGoodsShareStock},</if>
  585. <if test="isLimited != null">`is_limited` = #{isLimited},</if>
  586. <if test="isHot != null">`is_hot` = #{isHot},</if>
  587. <if test="createrSn != null">`creater_sn` = #{createrSn},</if>
  588. <if test="createTime != null">`create_time` = #{createTime},</if>
  589. <if test="moderSn != null">`moder_sn` = #{moderSn},</if>
  590. <if test="modTime != null">`mod_time` = #{modTime},</if>
  591. <if test="tstm != null">`tstm` = #{tstm},</if>
  592. <if test="lastSaleTime != null">`last_sale_time` = #{lastSaleTime},</if>
  593. <if test="mychemId != null">`mychem_id` = #{mychemId}</if>
  594. </set>
  595. where id = #{id}
  596. </update>
  597. <delete id="delete">
  598. delete from mall_goods where id = #{value}
  599. </delete>
  600. <delete id="deleteBatch">
  601. delete from mall_goods where id in
  602. <foreach item="id" collection="array" open="(" separator="," close=")">
  603. #{id}
  604. </foreach>
  605. </delete>
  606. <select id="queryMaxId" resultType="java.lang.Long" parameterType="map">
  607. SELECT MAX(id) FROM mall_goods
  608. </select>
  609. <select id="searchGoodsPanoramaDtoByKeyword" resultType="com.kmall.admin.dto.GoodsPanoramaDto">
  610. SELECT
  611. g.id id,g.name `name`,g.name simpleName,g.ciq_prod_model ciqProdModel,
  612. g.goods_unit goodsBasicUnit,g.category_id categoryId,c.name categoryName,
  613. g.goods_unit goodsPurchaseUnit,g.supplier_id supplierId,s.child_supplier_name supplierName,
  614. g.prod_barcode prodBarcode,g.plu plu,g.goods_sn goodsSn,g.brand brand
  615. FROM
  616. mall_goods g
  617. INNER JOIN mall_category c
  618. INNER JOIN mall_supplier s
  619. WHERE
  620. g.category_id = c.id
  621. and g.supplier_id = s.id
  622. AND (g.goods_sn=#{keyword} OR g.prod_barcode=#{keyword})
  623. </select>
  624. <select id="queryExportList" resultType="com.kmall.admin.entity.GoodsEntity">
  625. select * from (
  626. select
  627. mall_goods.*,
  628. case when mall_goods_group.id > 0 then 2 else 0 end as goodsType,
  629. m.merch_name merchName, mb.is_stock_share isStockShare,
  630. catagory.keywords as categoryName,
  631. scnc.`name` as oriCntName
  632. from mall_goods
  633. left join mall_merch m on mall_goods.merch_sn = m.merch_sn
  634. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  635. left join third_merchant_biz mb on mb.third_party_merch_code = mall_goods.third_party_merch_code and
  636. mb.merch_sn=mall_goods.merch_sn
  637. left join mall_category catagory on catagory.id = mall_goods.category_id
  638. left join sys_cus_nation_code scnc on mall_goods.ori_cnt_code = scnc.code
  639. WHERE 1=1
  640. <!-- 数据过滤 -->
  641. ${filterSql}
  642. <if test="merchSn != null and merchSn.trim() != ''">
  643. AND mall_goods.merch_sn = #{merchSn}
  644. </if>
  645. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  646. AND mall_goods.prod_barcode = #{prodBarcode}
  647. </if>
  648. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  649. AND mall_goods.third_party_merch_code = #{thirdPartyMerchCode}
  650. </if>
  651. <if test="goodsSn != null and goodsSn != ''">
  652. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  653. </if>
  654. <if test="name != null and name != ''">
  655. AND mall_goods.name LIKE concat('%',#{name},'%')
  656. </if>
  657. <if test="englishName != null and englishName != ''">
  658. AND mall_goods.english_name LIKE concat('%',#{englishName},'%')
  659. </if>
  660. <if test="goodsBizType != null and goodsBizType != ''">
  661. AND mall_goods.goods_biz_type = #{goodsBizType}
  662. </if>
  663. <if test="isDelete != null">
  664. AND mall_goods.is_Delete = #{isDelete}
  665. </if>
  666. ) temp
  667. where 1=1
  668. <if test="lastSaleTime != null and lastSaleTime != ''">
  669. AND temp.last_sale_time &gt;= #{lastSaleTime} or temp.last_sale_time is null
  670. </if>
  671. </select>
  672. <select id="queryForPDFData" resultType="com.kmall.api.entity.exportpdf.PDFGoodsDto">
  673. select
  674. g.name as productName,
  675. g.english_name as englishName,
  676. rela.retail_price as price,
  677. IFNULL((rela.market_price - rela.retail_price ),0) as savings,
  678. g.goods_rate as startFax,
  679. g.goods_rate as endFax,
  680. g.plu as plu,
  681. g.prod_barcode as barCode
  682. from
  683. mall_goods g
  684. left join mall_product_store_rela rela on g.id = rela.goods_id
  685. <where>
  686. <if test="sku != null and sku != ''">
  687. and g.sku = #{sku}
  688. </if>
  689. <if test="prodBarcode != null and prodBarcode != ''">
  690. and g.prod_barcode = #{prodBarcode}
  691. </if>
  692. <if test="storeId != null and storeId != ''">
  693. and rela.store_id = #{storeId}
  694. </if>
  695. </where>
  696. </select>
  697. <select id="queryByBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
  698. select *
  699. from mall_goods
  700. where prod_barcode = #{barCode}
  701. </select>
  702. <select id="queryBySku" resultType="com.kmall.admin.entity.GoodsEntity">
  703. select *
  704. from mall_goods
  705. where sku = #{sku}
  706. </select>
  707. <select id="queryListByBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
  708. SELECT
  709. a.id,a.sku,a.goods_number,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',a.goods_rate as goodsRate
  710. FROM
  711. mall_goods a
  712. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  713. inner join mall_store s on r.store_id=s.id
  714. where a.prod_barcode = #{prodBarcode} and r.store_id = #{storeId}
  715. and r.stock_num > 0 order by r.stock_num desc
  716. </select>
  717. </mapper>