GoodsDao.xml 31 KB

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