GoodsDao.xml 33 KB

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