1
0

GoodsDao.xml 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  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="product_id"/>
  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. <result column="to_be_restored" property="toBeRestored" />
  82. <result column="prod_name" property="prodName" />
  83. <result column="prod_record_name" property="prodRecordName" />
  84. <result column="exit_region_number" property="exitRegionNumber"/>
  85. </resultMap>
  86. <select id="queryObject" resultType="com.kmall.admin.entity.GoodsEntity">
  87. SELECT
  88. a.*, CASE
  89. when g.id > 0 then 2 else 0 end as goodsType,
  90. mb.third_party_merch_code,
  91. mb.is_stock_share isStockShare,
  92. mb.is_supplier_goods 'isSupplierGoods'
  93. FROM
  94. mall_goods a
  95. LEFT JOIN mall_goods_group g ON g.goods_id = a.id AND g.open_status != 3
  96. LEFT JOIN third_merchant_biz mb ON a.third_party_merch_code = mb.third_party_merch_code
  97. WHERE a.id = #{value}
  98. </select>
  99. <select id="queryObjectByStoreId" resultMap="goodsMap">
  100. select
  101. a.sku,
  102. a.id,
  103. psr1.category_id,
  104. a.goods_sn,
  105. a.name,
  106. psr1.brand_id,
  107. a.goods_number,
  108. a.keywords,
  109. a.goods_brief,
  110. a.is_on_sale,
  111. a.add_time,
  112. a.sort_order,
  113. a.is_delete,
  114. psr1.attribute_category,
  115. a.counter_price,
  116. a.extra_price,
  117. a.is_new,
  118. a.goods_unit,
  119. a.primary_pic_url,
  120. a.list_pic_url,
  121. psr1.retail_price,
  122. psr1.sell_volume,
  123. a.primary_product_id,
  124. a.unit_price,
  125. a.promotion_desc,
  126. a.promotion_tag,
  127. a.app_exclusive_price,
  128. a.is_app_exclusive,
  129. a.is_limited,
  130. a.is_hot,
  131. a.merch_sn,
  132. a.to_be_restored,
  133. m.merch_name,
  134. psr1.store_id,
  135. psr1.market_price,
  136. psr1.stock_num,
  137. a.goods_desc,a.goods_biz_type,a.goods_rate,
  138. a.sell_volume goods_sell_volume,
  139. mb.third_party_merch_code,
  140. mb.is_stock_share isStockShare,
  141. mb.is_supplier_goods 'isSupplierGoods',
  142. mb2.third_party_merch_code 'supplierThirdMerchCode',
  143. mb2.is_stock_share 'isStockShareBySuppler',
  144. a.hs_code, a.legal_unit1_qty, a.legal_unit2_qty,a.ciq_prod_model
  145. from mall_goods a left join mall_merch m on a.merch_sn = m.merch_sn
  146. LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
  147. LEFT JOIN mall_store s ON s.id = psr1.store_id
  148. LEFT JOIN third_merchant_biz mb on s.third_party_merch_code = mb.third_party_merch_code
  149. LEFT JOIN third_merchant_biz mb2 ON a.third_party_merch_code = mb2.third_party_merch_code
  150. where a.id = #{id} and psr1.store_id = #{storeId}
  151. </select>
  152. <select id="queryGoodsByGoodsSnAndStoreId" resultMap="goodsMap">
  153. select
  154. a.sku,
  155. a.id,
  156. psr1.category_id,
  157. a.goods_sn,
  158. a.name,
  159. psr1.brand_id,
  160. a.goods_number,
  161. a.keywords,
  162. a.goods_brief,
  163. a.is_on_sale,
  164. a.add_time,
  165. a.sort_order,
  166. a.is_delete,
  167. psr1.attribute_category,
  168. a.counter_price,
  169. a.extra_price,
  170. a.is_new,
  171. a.goods_unit,
  172. a.primary_pic_url,
  173. a.list_pic_url,
  174. psr1.retail_price,
  175. psr1.sell_volume,
  176. a.primary_product_id,
  177. a.unit_price,
  178. a.promotion_desc,
  179. a.promotion_tag,
  180. a.app_exclusive_price,
  181. a.is_app_exclusive,
  182. a.is_limited,
  183. a.is_hot,
  184. a.merch_sn,
  185. a.to_be_restored,
  186. m.merch_name,
  187. psr1.store_id,
  188. psr1.market_price,
  189. psr1.stock_num,
  190. a.goods_desc,a.goods_biz_type,a.goods_rate,
  191. a.sell_volume goods_sell_volume,
  192. mb.third_party_merch_code,
  193. mb.is_stock_share isStockShare,
  194. mb.is_supplier_goods 'isSupplierGoods',
  195. mb2.third_party_merch_code 'supplierThirdMerchCode',
  196. mb2.is_stock_share 'isStockShareBySuppler',
  197. a.hs_code, a.legal_unit1_qty, a.legal_unit2_qty,a.ciq_prod_model
  198. from mall_goods a left join mall_merch m on a.merch_sn = m.merch_sn
  199. LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
  200. LEFT JOIN mall_store s ON s.id = psr1.store_id
  201. LEFT JOIN third_merchant_biz mb on s.third_party_merch_code = mb.third_party_merch_code
  202. LEFT JOIN third_merchant_biz mb2 ON a.third_party_merch_code = mb2.third_party_merch_code
  203. where a.goods_sn = #{goodsSn} and psr1.store_id = #{storeId}
  204. </select>
  205. <select id="queryObjectByProdBarcodeAndBizType" resultType="com.kmall.admin.entity.GoodsEntity">
  206. SELECT
  207. 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',
  208. a.hs_code as hsCode , a.legal_unit1_qty as legalUnit1Qty , a.legal_unit2_qty as legalUnit2Qty,a.ciq_prod_model as ciqProdModel,a.to_be_restored
  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 a.goods_biz_type = 11 and r.store_id = #{storeId}
  214. </select>
  215. <select id="queryObjectByProdBarcodeAndStore" resultType="com.kmall.admin.entity.GoodsEntity">
  216. SELECT
  217. 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,
  218. a.hs_code as hsCode , a.legal_unit1_qty as legalUnit1Qty , a.legal_unit2_qty as legalUnit2Qty,a.ciq_prod_model as ciqProdModel,a.to_be_restored
  219. FROM
  220. mall_goods a
  221. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  222. inner join mall_store s on r.store_id=s.id
  223. where a.prod_barcode = #{prodBarcode} and r.store_id = #{storeId}
  224. and r.stock_num > 0
  225. limit 1
  226. </select>
  227. <select id="queryObjectByProdBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
  228. SELECT
  229. 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',
  230. a.hs_code as hsCode , a.legal_unit1_qty as legalUnit1Qty , a.legal_unit2_qty as legalUnit2Qty,a.ciq_prod_model as ciqProdModel,a.to_be_restored
  231. FROM
  232. mall_goods a
  233. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  234. inner join mall_store s on r.store_id=s.id
  235. where a.prod_barcode = #{prodBarcode} and a.is_delete = 0
  236. <if test="goodsId != null and goodsId != ''">
  237. AND a.id != #{goodsId}
  238. </if>
  239. <if test="merchSn != null and merchSn != ''">
  240. AND a.merch_sn = #{merchSn}
  241. </if>
  242. </select>
  243. <select id="queryGoodsDetailsByProdBarcode" resultType="com.kmall.admin.dto.GoodsDetailsDto">
  244. SELECT distinct
  245. a.goods_sn as GoodsSn, a.goods_sn as sku, 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
  246. ,a.hs_code as hsCode , a.legal_unit1_qty as legalUnit1Qty , a.legal_unit2_qty as legalUnit2Qty,a.ciq_prod_model as ciqProdModel,a.to_be_restored, m.exit_region_number as exitRegionNumber
  247. FROM
  248. mall_goods a
  249. LEFT JOIN mall_goods_specification r ON r.goods_id = a.id
  250. left join mall_product_store_rela m on m.goods_id = a.id and r.goods_id = m.goods_id and a.is_on_sale = 1
  251. where a.prod_barcode = #{prodBarcode} and m.store_id = #{storeId}
  252. <if test="sku != null and sku != ''">
  253. and a.sku=#{sku}
  254. </if>
  255. and m.stock_num > 0 order by m.stock_num desc
  256. limit 1
  257. </select>
  258. <select id="queryGoodsSkuList" resultType="com.kmall.admin.dto.GoodsDetailsDto">
  259. SELECT distinct
  260. a.goods_sn as GoodsSn,m.retail_price as retailPrice,a.prod_barcode as prodBarcode,a.name,
  261. a.brand,a.goods_desc as goodsDesc,a.goods_unit as goodsUnit,a.goods_rate as goodsRate,a.primary_pic_url ,
  262. m.stock_num as stockNum,r.value as specification
  263. ,a.hs_code as hsCode , a.legal_unit1_qty as legalUnit1Qty , a.legal_unit2_qty as legalUnit2Qty,
  264. a.ciq_prod_model as ciqProdModel,a.to_be_restored,a.sku as sku,a.name,a.market_price as marketPrice
  265. FROM
  266. mall_goods a
  267. LEFT JOIN mall_goods_specification r ON r.goods_id = a.id
  268. left join mall_product_store_rela m on m.goods_id = a.id and r.goods_id = m.goods_id
  269. where a.prod_barcode = #{prodBarcode} and m.store_id = #{storeId}
  270. and m.stock_num > 0 and a.is_on_sale = 1 order by m.stock_num desc
  271. </select>
  272. <select id="queryObjectBySn" resultType="com.kmall.admin.entity.GoodsEntity">
  273. SELECT
  274. a.*, CASE
  275. when g.id > 0 then 2 else 0 end as goodsType
  276. FROM
  277. mall_goods a
  278. LEFT JOIN mall_goods_group g ON g.goods_id = a.id
  279. AND g.open_status != 3
  280. where a.goods_sn = #{goodsSn}
  281. </select>
  282. <select id="queryList" resultType="com.kmall.admin.entity.GoodsEntity">
  283. select * from (
  284. select
  285. mall_goods.*,
  286. case when mall_goods_group.id > 0 then 2 else 0 end as goodsType,
  287. m.merch_name merchName,
  288. mb.is_stock_share isStockShare,
  289. catagory.keywords as categoryName
  290. from mall_goods
  291. left join mall_merch m on mall_goods.merch_sn = m.merch_sn
  292. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  293. left join third_merchant_biz mb on mb.third_party_merch_code = mall_goods.third_party_merch_code and
  294. mb.merch_sn=mall_goods.merch_sn
  295. left join mall_category catagory on catagory.id = mall_goods.category_id
  296. WHERE 1=1
  297. <!-- 数据过滤 -->
  298. ${filterSql}
  299. <if test="merchSn != null and merchSn.trim() != ''">
  300. AND mall_goods.merch_sn = #{merchSn}
  301. </if>
  302. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  303. AND mall_goods.prod_barcode = #{prodBarcode}
  304. </if>
  305. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  306. AND mall_goods.third_party_merch_code = #{thirdPartyMerchCode}
  307. </if>
  308. <if test="thirdMerchSn != null and thirdMerchSn.trim() != ''">
  309. AND mb.third_merch_sn = #{thirdMerchSn}
  310. </if>
  311. <if test="goodsSn != null and goodsSn != ''">
  312. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  313. </if>
  314. <if test="name != null and name != ''">
  315. AND mall_goods.name LIKE concat('%',#{name},'%')
  316. </if>
  317. <if test="englishName != null and englishName != ''">
  318. AND mall_goods.english_name LIKE concat('%',#{englishName},'%')
  319. </if>
  320. <!--<if test="brandId != null and brandId != ''">
  321. AND mall_goods.brand_id = #{brandId}
  322. </if>
  323. <if test="freightId != null and freightId != ''">
  324. AND mall_goods.freight_id = #{freightId}
  325. </if>
  326. <if test="categoryId != null and categoryId != ''">
  327. AND mall_goods.category_id = #{categoryId}
  328. </if>
  329. <if test="category != null and category != ''">
  330. AND mall_goods.category_id IN (select id from mall_category where parent_id = #{category})
  331. </if>
  332. <if test="categoryTwo != null and categoryTwo != ''">
  333. AND mall_goods.category_id = #{categoryTwo}
  334. </if>-->
  335. <if test="sku != null and sku != ''">
  336. AND mall_goods.sku LIKE concat('%',#{sku},'%')
  337. </if>
  338. <if test="plu != null and plu != ''">
  339. AND mall_goods.plu LIKE concat('%',#{plu},'%')
  340. </if>
  341. <if test="isDelete != null">
  342. AND mall_goods.is_Delete = #{isDelete}
  343. </if>
  344. <if test="isOnSale != null">
  345. AND mall_goods.is_on_sale = #{isOnSale}
  346. </if>
  347. <if test="goodsBizType != null and goodsBizType != ''">
  348. AND mall_goods.goods_biz_type = #{goodsBizType}
  349. </if>
  350. <if test="id != null and id != ''">
  351. AND mall_goods.id = #{id}
  352. </if>
  353. <if test="storeId != null and storeId != ''">
  354. AND mall_goods.third_party_merch_code = ( SELECT third_party_merch_code FROM mall_store WHERE id =
  355. #{storeId} )
  356. AND mall_goods.id NOT IN (
  357. SELECT
  358. goods_id
  359. FROM
  360. mall_product_store_rela pp
  361. WHERE
  362. store_id = #{storeId}
  363. )
  364. </if>
  365. <if test="storeIdBySupplier != null and storeIdBySupplier != ''">
  366. AND mall_goods.id NOT IN (
  367. SELECT
  368. goods_id
  369. FROM
  370. mall_product_store_rela pp
  371. WHERE
  372. store_id = #{storeIdBySupplier} and supplier_third_id = #{thirdMerchSn}
  373. )
  374. </if>
  375. ) temp where 1=1
  376. <if test="lastSaleTime != null and lastSaleTime != ''">
  377. AND temp.last_sale_time &gt;= #{lastSaleTime} or temp.last_sale_time is null
  378. </if>
  379. <choose>
  380. <when test="sidx != null and sidx.trim() != ''">
  381. order by ${sidx} ${order}
  382. </when>
  383. <otherwise>
  384. order by temp.id desc
  385. </otherwise>
  386. </choose>
  387. <if test="offset != null and limit != null">
  388. limit #{offset}, #{limit}
  389. </if>
  390. </select>
  391. <select id="querySame" resultType="com.kmall.admin.entity.GoodsEntity">
  392. select
  393. mall_goods.*,
  394. case when mall_goods_group.id > 0 then 2 else 0 end as goodsType
  395. from mall_goods
  396. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  397. WHERE 1=1
  398. <!-- 数据过滤 -->
  399. ${filterSql}
  400. <if test="isSame != null and isSame != ''">
  401. AND ((mall_goods.sku = #{sku} AND mall_goods.goods_biz_type = #{goodsBizType}) OR mall_goods.goods_sn =
  402. #{goodsSn})
  403. <if test="id != null and id != ''">
  404. AND mall_goods.id != #{id}
  405. </if>
  406. </if>
  407. <choose>
  408. <when test="sidx != null and sidx.trim() != ''">
  409. order by ${sidx} ${order}
  410. </when>
  411. <otherwise>
  412. order by mall_goods.id desc
  413. </otherwise>
  414. </choose>
  415. <if test="offset != null and limit != null">
  416. limit #{offset}, #{limit}
  417. </if>
  418. </select>
  419. <select id="queryTotal" resultType="int">
  420. select count(*) from mall_goods
  421. left join mall_merch m on mall_goods.merch_sn = m.merch_sn
  422. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  423. WHERE 1=1
  424. <!-- 数据过滤 -->
  425. ${filterSql}
  426. <if test="merchSn != null and merchSn.trim() != ''">
  427. AND mall_goods.merch_sn = #{merchSn}
  428. </if>
  429. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  430. AND mall_goods.prod_barcode = #{prodBarcode}
  431. </if>
  432. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  433. AND mall_goods.third_party_merch_code = #{thirdPartyMerchCode}
  434. </if>
  435. <if test="goodsSn != null and goodsSn != ''">
  436. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  437. </if>
  438. <if test="name != null and name != ''">
  439. AND mall_goods.name LIKE concat('%',#{name},'%')
  440. </if>
  441. <if test="sku != null and sku != ''">
  442. AND mall_goods.sku LIKE concat('%',#{sku},'%')
  443. </if>
  444. <if test="isDelete != null">
  445. AND mall_goods.is_Delete = #{isDelete}
  446. </if>
  447. <if test="isOnSale != null">
  448. AND mall_goods.is_on_sale = #{isOnSale}
  449. </if>
  450. <if test="goodsBizType != null and goodsBizType != ''">
  451. AND mall_goods.goods_biz_type = #{goodsBizType}
  452. </if>
  453. <if test="storeId != null and storeId != ''">
  454. AND mall_goods.third_party_merch_code = ( SELECT third_party_merch_code FROM mall_store WHERE id =
  455. #{storeId} )
  456. AND mall_goods.id NOT IN (
  457. SELECT
  458. goods_id
  459. FROM
  460. mall_product_store_rela pp
  461. LEFT JOIN mall_goods gg ON pp.goods_id = gg.id
  462. AND pp.merch_sn = gg.merch_sn
  463. AND pp.merch_sn
  464. LEFT JOIN mall_store s ON pp.store_id = s.id
  465. AND s.third_party_merch_code = gg.third_party_merch_code
  466. WHERE
  467. store_id = #{storeId}
  468. )
  469. </if>
  470. </select>
  471. <insert id="save" parameterType="com.kmall.admin.entity.GoodsEntity" useGeneratedKeys="true" keyProperty="id">
  472. insert into mall_goods(
  473. `merch_sn`,
  474. third_party_merch_code,
  475. `supplier_id`,
  476. `goods_sn`,
  477. `prod_barcode`,
  478. `sku`,
  479. `plu`,
  480. `english_name`,
  481. `cost_price`,
  482. `daily_price`,
  483. `goods_biz_type`,
  484. `name`,
  485. `unit_code`,
  486. `brand`,
  487. `brand_id`,
  488. `category_id`,
  489. `goods_number`,
  490. `keywords`,
  491. `goods_brief`,
  492. `goods_desc`,
  493. `cus_goods_code`,
  494. `ciq_prod_model`,
  495. `ori_cnt_code`,
  496. `cus_decl_ele`,
  497. `cus_rec_code`,
  498. `is_on_sale`,
  499. `add_time`,
  500. `sort_order`,
  501. `is_delete`,
  502. `counter_price`,
  503. `extra_price`,
  504. `is_new`,
  505. `goods_unit`,
  506. `primary_pic_url`,
  507. `list_pic_url`,
  508. `goods_rate`,
  509. `sell_volume`,
  510. `primary_product_id`,
  511. `unit_price`,
  512. `promotion_desc`,
  513. `promotion_tag`,
  514. `app_exclusive_price`,
  515. `is_app_exclusive`,
  516. `gross_weight`,
  517. `net_weight`,
  518. is_goods_share_stock,
  519. `is_limited`,
  520. `is_hot`,
  521. `creater_sn`,
  522. `create_time`,
  523. `moder_sn`,
  524. `mod_time`,
  525. `mychem_id`,
  526. `hs_code`,
  527. `hs_code_name`,
  528. `is_sync_hs_code`,
  529. `is_sync_goods_rate`,
  530. `imp_consum_tax_rate`,
  531. `value_added_tax_rate`,
  532. `legal_unit1_qty`,
  533. `legal_unit2_qty`,
  534. `cosm_threshold_value`,
  535. `to_be_restored`,
  536. `tstm`)
  537. values(
  538. #{merchSn},
  539. #{thirdPartyMerchCode},
  540. #{supplierId},
  541. #{goodsSn},
  542. #{prodBarcode},
  543. #{sku},
  544. #{plu},
  545. #{englishName},
  546. #{costPrice},
  547. #{dailyPrice},
  548. #{goodsBizType},
  549. #{name},
  550. #{unitCode},
  551. #{brand},
  552. #{brandId},
  553. #{categoryId},
  554. #{goodsNumber},
  555. #{keywords},
  556. #{goodsBrief},
  557. #{goodsDesc},
  558. #{cusGoodsCode},
  559. #{ciqProdModel},
  560. #{oriCntCode},
  561. #{cusDeclEle},
  562. #{cusRecCode},
  563. #{isOnSale},
  564. #{addTime},
  565. #{sortOrder},
  566. #{isDelete},
  567. #{counterPrice},
  568. #{extraPrice},
  569. #{isNew},
  570. #{goodsUnit},
  571. #{primaryPicUrl},
  572. #{listPicUrl},
  573. #{goodsRate},
  574. #{sellVolume},
  575. #{primaryProductId},
  576. #{unitPrice},
  577. #{promotionDesc},
  578. #{promotionTag},
  579. #{appExclusivePrice},
  580. #{isAppExclusive},
  581. #{grossWeight},
  582. #{netWeight},
  583. #{isGoodsShareStock},
  584. #{isLimited},
  585. #{isHot},
  586. #{createrSn},
  587. #{createTime},
  588. #{moderSn},
  589. #{modTime},
  590. #{mychemId},
  591. #{hsCode},
  592. #{hsCodeName},
  593. '0',
  594. '0',
  595. #{impConsumTaxRate},
  596. #{valueAddedTaxRate},
  597. #{legalUnit1Qty},
  598. #{legalUnit2Qty},
  599. #{cosmThresholdValue},
  600. 0,
  601. #{tstm})
  602. </insert>
  603. <update id="update" parameterType="com.kmall.admin.entity.GoodsEntity">
  604. update mall_goods
  605. <set>
  606. <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
  607. <if test="thirdPartyMerchCode != null">`third_party_merch_code` = #{thirdPartyMerchCode},</if>
  608. <if test="supplierId != null">`supplier_id` = #{supplierId},</if>
  609. <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
  610. <if test="prodBarcode != null">`prod_barcode` = #{prodBarcode},</if>
  611. <if test="sku != null">`sku` = #{sku},</if>
  612. <if test="plu != null">`plu` = #{plu},</if>
  613. <if test="englishName != null">`english_name` = #{englishName},</if>
  614. <if test="costPrice != null">`cost_price` = #{costPrice},</if>
  615. <if test="dailyPrice != null">`daily_price` = #{dailyPrice},</if>
  616. <if test="goodsBizType != null">`goods_biz_type` = #{goodsBizType},</if>
  617. <if test="name != null">`name` = #{name},</if>
  618. <if test="unitCode != null">`unit_code` = #{unitCode},</if>
  619. <if test="brand != null">`brand` = #{brand},</if>
  620. <if test="brandId != null">`brand_id` = #{brandId},</if>
  621. <if test="categoryId != null">`category_id` = #{categoryId},</if>
  622. <if test="goodsNumber != null">`goods_number` = #{goodsNumber},</if>
  623. <if test="keywords != null">`keywords` = #{keywords},</if>
  624. <if test="goodsBrief != null">`goods_brief` = #{goodsBrief},</if>
  625. <if test="goodsDesc != null">`goods_desc` = #{goodsDesc},</if>
  626. <if test="cusGoodsCode != null">`cus_goods_code` = #{cusGoodsCode},</if>
  627. <if test="ciqProdModel != null">`ciq_prod_model` = #{ciqProdModel},</if>
  628. <if test="oriCntCode != null">`ori_cnt_code` = #{oriCntCode},</if>
  629. <if test="cusDeclEle != null">`cus_decl_ele` = #{cusDeclEle},</if>
  630. <if test="cusRecCode != null">`cus_rec_code` = #{cusRecCode},</if>
  631. <if test="isOnSale != null">`is_on_sale` = #{isOnSale},</if>
  632. <if test="addTime != null">`add_time` = #{addTime},</if>
  633. <if test="sortOrder != null">`sort_order` = #{sortOrder},</if>
  634. <if test="isDelete != null">`is_delete` = #{isDelete},</if>
  635. <if test="counterPrice != null">`counter_price` = #{counterPrice},</if>
  636. <if test="extraPrice != null">`extra_price` = #{extraPrice},</if>
  637. <if test="isNew != null">`is_new` = #{isNew},</if>
  638. <if test="goodsUnit != null">`goods_unit` = #{goodsUnit},</if>
  639. <if test="primaryPicUrl != null">`primary_pic_url` = #{primaryPicUrl},</if>
  640. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl},</if>
  641. <if test="goodsRate != null">`goods_rate` = #{goodsRate},</if>
  642. <if test="sellVolume != null">`sell_volume` = #{sellVolume},</if>
  643. <if test="primaryProductId != null">`primary_product_id` = #{primaryProductId},</if>
  644. <if test="unitPrice != null">`unit_price` = #{unitPrice},</if>
  645. <if test="promotionDesc != null">`promotion_desc` = #{promotionDesc},</if>
  646. <if test="promotionTag != null">`promotion_tag` = #{promotionTag},</if>
  647. <if test="appExclusivePrice != null">`app_exclusive_price` = #{appExclusivePrice},</if>
  648. <if test="isAppExclusive != null">`is_app_exclusive` = #{isAppExclusive},</if>
  649. <if test="grossWeight != null">`gross_weight` = #{grossWeight},</if>
  650. <if test="netWeight != null">`net_weight` = #{netWeight},</if>
  651. <if test="isGoodsShareStock != null">`is_goods_share_stock` = #{isGoodsShareStock},</if>
  652. <if test="isLimited != null">`is_limited` = #{isLimited},</if>
  653. <if test="isHot != null">`is_hot` = #{isHot},</if>
  654. <if test="createrSn != null">`creater_sn` = #{createrSn},</if>
  655. <if test="createTime != null">`create_time` = #{createTime},</if>
  656. <if test="moderSn != null">`moder_sn` = #{moderSn},</if>
  657. <if test="modTime != null">`mod_time` = #{modTime},</if>
  658. <if test="tstm != null">`tstm` = #{tstm},</if>
  659. <if test="lastSaleTime != null">`last_sale_time` = #{lastSaleTime},</if>
  660. <if test="mychemId != null">`mychem_id` = #{mychemId},</if>
  661. <if test="hsCode != null">`hs_code` = #{hsCode},</if>
  662. <if test="hsCodeName != null">`hs_code_name` = #{hsCodeName},</if>
  663. <if test="isSyncHsCode != null">`is_sync_hs_code` = #{isSyncHsCode},</if>
  664. <if test="isSyncGoodsRate != null">`is_sync_goods_rate` = #{isSyncGoodsRate},</if>
  665. <if test="impConsumTaxRate != null">`imp_consum_tax_rate` = #{impConsumTaxRate},</if>
  666. <if test="valueAddedTaxRate != null">`value_added_tax_rate` = #{valueAddedTaxRate},</if>
  667. <if test="legalUnit1Qty != null">`legal_unit1_qty` = #{legalUnit1Qty},</if>
  668. <if test="legalUnit2Qty != null">`legal_unit2_qty` = #{legalUnit2Qty},</if>
  669. <if test="cosmThresholdValue != null">`cosm_threshold_value` = #{cosmThresholdValue},</if>
  670. <if test="toBeRestored != null">`to_be_restored` = #{toBeRestored}</if>
  671. </set>
  672. where id = #{id}
  673. </update>
  674. <delete id="delete">
  675. delete from mall_goods where id = #{value}
  676. </delete>
  677. <delete id="deleteBatch">
  678. delete from mall_goods where id in
  679. <foreach item="id" collection="array" open="(" separator="," close=")">
  680. #{id}
  681. </foreach>
  682. </delete>
  683. <select id="queryMaxId" resultType="java.lang.Long" parameterType="map">
  684. SELECT MAX(id) FROM mall_goods
  685. </select>
  686. <select id="searchGoodsPanoramaDtoByKeyword" resultType="com.kmall.admin.dto.GoodsPanoramaDto">
  687. SELECT
  688. g.id id,g.name `name`,g.name simpleName,g.ciq_prod_model ciqProdModel,
  689. g.goods_unit goodsBasicUnit,g.category_id categoryId,c.name categoryName,
  690. g.goods_unit goodsPurchaseUnit,g.supplier_id supplierId,s.child_supplier_name supplierName,
  691. g.prod_barcode prodBarcode,g.plu plu,g.goods_sn goodsSn,g.brand brand
  692. FROM
  693. mall_goods g
  694. INNER JOIN mall_category c
  695. INNER JOIN mall_supplier s
  696. WHERE
  697. g.category_id = c.id
  698. and g.supplier_id = s.id
  699. AND (g.goods_sn=#{keyword} OR g.prod_barcode=#{keyword})
  700. </select>
  701. <select id="queryExportList" resultType="com.kmall.admin.entity.GoodsEntity">
  702. select * from (
  703. select
  704. mall_goods.*,
  705. case when mall_goods_group.id > 0 then 2 else 0 end as goodsType,
  706. m.merch_name merchName, mb.is_stock_share isStockShare,
  707. catagory.keywords as categoryName,
  708. scnc.`name` as oriCntName
  709. from mall_goods
  710. left join mall_merch m on mall_goods.merch_sn = m.merch_sn
  711. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  712. left join third_merchant_biz mb on mb.third_party_merch_code = mall_goods.third_party_merch_code and
  713. mb.merch_sn=mall_goods.merch_sn
  714. left join mall_category catagory on catagory.id = mall_goods.category_id
  715. left join sys_cus_nation_code scnc on mall_goods.ori_cnt_code = scnc.code
  716. WHERE 1=1
  717. <!-- 数据过滤 -->
  718. ${filterSql}
  719. <if test="merchSn != null and merchSn.trim() != ''">
  720. AND mall_goods.merch_sn = #{merchSn}
  721. </if>
  722. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  723. AND mall_goods.prod_barcode = #{prodBarcode}
  724. </if>
  725. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  726. AND mall_goods.third_party_merch_code = #{thirdPartyMerchCode}
  727. </if>
  728. <if test="goodsSn != null and goodsSn != ''">
  729. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  730. </if>
  731. <if test="name != null and name != ''">
  732. AND mall_goods.name LIKE concat('%',#{name},'%')
  733. </if>
  734. <if test="englishName != null and englishName != ''">
  735. AND mall_goods.english_name LIKE concat('%',#{englishName},'%')
  736. </if>
  737. <if test="goodsBizType != null and goodsBizType != ''">
  738. AND mall_goods.goods_biz_type = #{goodsBizType}
  739. </if>
  740. <if test="isDelete != null">
  741. AND mall_goods.is_Delete = #{isDelete}
  742. </if>
  743. ) temp
  744. where 1=1
  745. <if test="lastSaleTime != null and lastSaleTime != ''">
  746. AND temp.last_sale_time &gt;= #{lastSaleTime} or temp.last_sale_time is null
  747. </if>
  748. </select>
  749. <select id="queryForPDFData" resultType="com.kmall.api.entity.exportpdf.PDFGoodsDto">
  750. select
  751. g.name as productName,
  752. g.english_name as englishName,
  753. rela.retail_price as price,
  754. IFNULL((rela.market_price - rela.retail_price ),0) as savings,
  755. g.goods_rate as startFax,
  756. g.goods_rate as endFax,
  757. g.plu as plu,
  758. g.prod_barcode as barCode
  759. from
  760. mall_goods g
  761. left join mall_product_store_rela rela on g.id = rela.goods_id
  762. <where>
  763. <if test="sku != null and sku != ''">
  764. and g.sku = #{sku}
  765. </if>
  766. <if test="prodBarcode != null and prodBarcode != ''">
  767. and g.prod_barcode = #{prodBarcode}
  768. </if>
  769. <if test="storeId != null and storeId != ''">
  770. and rela.store_id = #{storeId}
  771. </if>
  772. </where>
  773. </select>
  774. <select id="queryByBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
  775. select *
  776. from mall_goods
  777. where prod_barcode = #{barCode}
  778. </select>
  779. <select id="queryBySku" resultType="com.kmall.admin.entity.GoodsEntity">
  780. select *
  781. from mall_goods
  782. where sku = #{sku}
  783. </select>
  784. <select id="queryListByBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
  785. SELECT
  786. 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,
  787. a.hs_code as hsCode , a.legal_unit1_qty as legalUnit1Qty , a.legal_unit2_qty as legalUnit2Qty,a.ciq_prod_model as ciqProdModel,a.to_be_restored, r.stock_num
  788. FROM
  789. mall_goods a
  790. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  791. inner join mall_store s on r.store_id=s.id
  792. where a.prod_barcode = #{prodBarcode} and r.store_id = #{storeId} and a.sku = #{sku} and a.is_on_sale = 1
  793. and r.stock_num > 0 order by r.stock_num desc
  794. </select>
  795. <select id="queryByName" resultType="com.kmall.admin.entity.GoodsEntity">
  796. SELECT DISTINCT
  797. g.id,
  798. g.NAME,
  799. g.sku,
  800. g.prod_barcode
  801. FROM
  802. mall_product_store_rela r
  803. LEFT JOIN mall_goods g ON g.id = r.goods_id
  804. WHERE
  805. r.store_id = #{storeId}
  806. <if test="goodsName != null and goodsName != ''">
  807. AND g.NAME LIKE concat('%',#{goodsName},'%');
  808. </if>
  809. </select>
  810. <select id="queryNonSyncOmsHsCodeSkuList" resultType="java.lang.String">
  811. select sku
  812. from mall_goods
  813. where is_sync_hs_code = '0'
  814. </select>
  815. <select id="queryListBySku" resultType="com.kmall.admin.entity.GoodsEntity">
  816. select *
  817. from mall_goods
  818. where sku = #{sku}
  819. </select>
  820. <select id="queryNonSyncOmsGoodsRateSkuList" resultType="com.kmall.admin.entity.GoodsEntity">
  821. select *
  822. from mall_goods
  823. where is_sync_goods_rate = '0'
  824. </select>
  825. <select id="queryAllList" resultType="com.kmall.admin.entity.GoodsEntity">
  826. select * from mall_goods where is_delete = 0
  827. <if test="page != null and pageSize != null">
  828. limit #{page}, #{pageSize}
  829. </if>
  830. </select>
  831. <select id="queryByBarcodeAndSku" resultType="com.kmall.admin.entity.GoodsEntity">
  832. select * from mall_goods where
  833. goods_sn = #{goodsSn} and prod_barcode = #{prodBarcode}
  834. </select>
  835. <select id="querySpecialCosmetics" resultType="com.kmall.admin.entity.GoodsEntity">
  836. SELECT distinct
  837. a.*,
  838. m.retail_price as retailPrice,
  839. m.stock_num as stockNum,
  840. m.store_id as storeId
  841. FROM
  842. mall_goods a
  843. left join mall_product_store_rela m on m.goods_id = a.id
  844. <where>
  845. a.cus_rec_code in
  846. <foreach collection="hdCodeSet" item="item" open="(" close=")" separator=",">
  847. #{item}
  848. </foreach>
  849. </where>
  850. </select>
  851. <insert id="saveBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
  852. insert into mall_goods(
  853. `merch_sn`,
  854. third_party_merch_code,
  855. `supplier_id`,
  856. `goods_sn`,
  857. `prod_barcode`,
  858. `sku`,
  859. `plu`,
  860. `english_name`,
  861. `cost_price`,
  862. `daily_price`,
  863. `goods_biz_type`,
  864. `name`,
  865. `unit_code`,
  866. `brand`,
  867. `brand_id`,
  868. `category_id`,
  869. `goods_number`,
  870. `keywords`,
  871. `goods_brief`,
  872. `goods_desc`,
  873. `cus_goods_code`,
  874. `ciq_prod_model`,
  875. `ori_cnt_code`,
  876. `cus_decl_ele`,
  877. `cus_rec_code`,
  878. `is_on_sale`,
  879. `add_time`,
  880. `sort_order`,
  881. `is_delete`,
  882. `counter_price`,
  883. `extra_price`,
  884. `is_new`,
  885. `goods_unit`,
  886. `primary_pic_url`,
  887. `list_pic_url`,
  888. `goods_rate`,
  889. `sell_volume`,
  890. `primary_product_id`,
  891. `unit_price`,
  892. `promotion_desc`,
  893. `promotion_tag`,
  894. `app_exclusive_price`,
  895. `is_app_exclusive`,
  896. `gross_weight`,
  897. `net_weight`,
  898. is_goods_share_stock,
  899. `is_limited`,
  900. `is_hot`,
  901. `creater_sn`,
  902. `create_time`,
  903. `moder_sn`,
  904. `mod_time`,
  905. `mychem_id`,
  906. `hs_code`,
  907. `hs_code_name`,
  908. `is_sync_hs_code`,
  909. `is_sync_goods_rate`,
  910. `imp_consum_tax_rate`,
  911. `value_added_tax_rate`,
  912. `legal_unit1_qty`,
  913. `legal_unit2_qty`,
  914. `cosm_threshold_value`,
  915. `to_be_restored`,
  916. `tstm`)
  917. values
  918. <foreach collection="list" index="index" item="item" separator=",">
  919. (
  920. #{item.merchSn},
  921. #{item.thirdPartyMerchCode},
  922. #{item.supplierId},
  923. #{item.goodsSn},
  924. #{item.prodBarcode},
  925. #{item.sku},
  926. #{item.plu},
  927. #{item.englishName},
  928. #{item.costPrice},
  929. #{item.dailyPrice},
  930. #{item.goodsBizType},
  931. #{item.name},
  932. #{item.unitCode},
  933. #{item.brand},
  934. #{item.brandId},
  935. #{item.categoryId},
  936. #{item.goodsNumber},
  937. #{item.keywords},
  938. #{item.goodsBrief},
  939. #{item.goodsDesc},
  940. #{item.cusGoodsCode},
  941. #{item.ciqProdModel},
  942. #{item.oriCntCode},
  943. #{item.cusDeclEle},
  944. #{item.cusRecCode},
  945. #{item.isOnSale},
  946. #{item.addTime},
  947. #{item.sortOrder},
  948. #{item.isDelete},
  949. #{item.counterPrice},
  950. #{item.extraPrice},
  951. #{item.isNew},
  952. #{item.goodsUnit},
  953. #{item.primaryPicUrl},
  954. #{item.listPicUrl},
  955. #{item.goodsRate},
  956. #{item.sellVolume},
  957. #{item.primaryProductId},
  958. #{item.unitPrice},
  959. #{item.promotionDesc},
  960. #{item.promotionTag},
  961. #{item.appExclusivePrice},
  962. #{item.isAppExclusive},
  963. #{item.grossWeight},
  964. #{item.netWeight},
  965. #{item.isGoodsShareStock},
  966. #{item.isLimited},
  967. #{item.isHot},
  968. #{item.createrSn},
  969. #{item.createTime},
  970. #{item.moderSn},
  971. #{item.modTime},
  972. #{item.mychemId},
  973. #{item.hsCode},
  974. #{item.hsCodeName},
  975. '0',
  976. '0',
  977. #{item.impConsumTaxRate},
  978. #{item.valueAddedTaxRate},
  979. #{item.legalUnit1Qty},
  980. #{item.legalUnit2Qty},
  981. #{item.cosmThresholdValue},
  982. #{item.toBeRestored},
  983. #{item.tstm})
  984. </foreach>
  985. </insert>
  986. <update id="updateBatch" parameterType="java.util.List">
  987. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  988. update mall_goods
  989. <set>
  990. <if test="item.merchSn != null">`merch_sn` = #{item.merchSn},</if>
  991. <if test="item.thirdPartyMerchCode != null">`third_party_merch_code` = #{item.thirdPartyMerchCode},</if>
  992. <if test="item.supplierId != null">`supplier_id` = #{item.supplierId},</if>
  993. <if test="item.goodsSn != null">`goods_sn` = #{item.goodsSn},</if>
  994. <if test="item.prodBarcode != null">`prod_barcode` = #{item.prodBarcode},</if>
  995. <if test="item.sku != null">`sku` = #{item.sku},</if>
  996. <if test="item.plu != null">`plu` = #{item.plu},</if>
  997. <if test="item.englishName != null">`english_name` = #{item.englishName},</if>
  998. <if test="item.costPrice != null">`cost_price` = #{item.costPrice},</if>
  999. <if test="item.dailyPrice != null">`daily_price` = #{item.dailyPrice},</if>
  1000. <if test="item.goodsBizType != null">`goods_biz_type` = #{item.goodsBizType},</if>
  1001. <if test="item.name != null">`name` = #{item.name},</if>
  1002. <if test="item.unitCode != null">`unit_code` = #{item.unitCode},</if>
  1003. <if test="item.brand != null">`brand` = #{item.brand},</if>
  1004. <if test="item.brandId != null">`brand_id` = #{item.brandId},</if>
  1005. <if test="item.categoryId != null">`category_id` = #{item.categoryId},</if>
  1006. <if test="item.goodsNumber != null">`goods_number` = #{item.goodsNumber},</if>
  1007. <if test="item.keywords != null">`keywords` = #{item.keywords},</if>
  1008. <if test="item.goodsBrief != null">`goods_brief` = #{item.goodsBrief},</if>
  1009. <if test="item.goodsDesc != null">`goods_desc` = #{item.goodsDesc},</if>
  1010. <if test="item.cusGoodsCode != null">`cus_goods_code` = #{item.cusGoodsCode},</if>
  1011. <if test="item.ciqProdModel != null">`ciq_prod_model` = #{item.ciqProdModel},</if>
  1012. <if test="item.oriCntCode != null">`ori_cnt_code` = #{item.oriCntCode},</if>
  1013. <if test="item.cusDeclEle != null">`cus_decl_ele` = #{item.cusDeclEle},</if>
  1014. <if test="item.cusRecCode != null">`cus_rec_code` = #{item.cusRecCode},</if>
  1015. <if test="item.isOnSale != null">`is_on_sale` = #{item.isOnSale},</if>
  1016. <if test="item.addTime != null">`add_time` = #{item.addTime},</if>
  1017. <if test="item.sortOrder != null">`sort_order` = #{item.sortOrder},</if>
  1018. <if test="item.isDelete != null">`is_delete` = #{item.isDelete},</if>
  1019. <if test="item.counterPrice != null">`counter_price` = #{item.counterPrice},</if>
  1020. <if test="item.extraPrice != null">`extra_price` = #{item.extraPrice},</if>
  1021. <if test="item.isNew != null">`is_new` = #{item.isNew},</if>
  1022. <if test="item.goodsUnit != null">`goods_unit` = #{item.goodsUnit},</if>
  1023. <if test="item.primaryPicUrl != null">`primary_pic_url` = #{item.primaryPicUrl},</if>
  1024. <if test="item.listPicUrl != null">`list_pic_url` = #{item.listPicUrl},</if>
  1025. <if test="item.goodsRate != null">`goods_rate` = #{item.goodsRate},</if>
  1026. <if test="item.sellVolume != null">`sell_volume` = #{item.sellVolume},</if>
  1027. <if test="item.primaryProductId != null">`primary_product_id` = #{item.primaryProductId},</if>
  1028. <if test="item.unitPrice != null">`unit_price` = #{item.unitPrice},</if>
  1029. <if test="item.promotionDesc != null">`promotion_desc` = #{item.promotionDesc},</if>
  1030. <if test="item.promotionTag != null">`promotion_tag` = #{item.promotionTag},</if>
  1031. <if test="item.appExclusivePrice != null">`app_exclusive_price` = #{item.appExclusivePrice},</if>
  1032. <if test="item.isAppExclusive != null">`is_app_exclusive` = #{item.isAppExclusive},</if>
  1033. <if test="item.grossWeight != null">`gross_weight` = #{item.grossWeight},</if>
  1034. <if test="item.netWeight != null">`net_weight` = #{item.netWeight},</if>
  1035. <if test="item.isGoodsShareStock != null">`is_goods_share_stock` = #{item.isGoodsShareStock},</if>
  1036. <if test="item.isLimited != null">`is_limited` = #{item.isLimited},</if>
  1037. <if test="item.isHot != null">`is_hot` = #{item.isHot},</if>
  1038. <if test="item.createrSn != null">`creater_sn` = #{item.createrSn},</if>
  1039. <if test="item.createTime != null">`create_time` = #{item.createTime},</if>
  1040. <if test="item.moderSn != null">`moder_sn` = #{item.moderSn},</if>
  1041. <if test="item.modTime != null">`mod_time` = #{item.modTime},</if>
  1042. <if test="item.tstm != null">`tstm` = #{item.tstm},</if>
  1043. <if test="item.lastSaleTime != null">`last_sale_time` = #{item.lastSaleTime},</if>
  1044. <if test="item.mychemId != null">`mychem_id` = #{item.mychemId},</if>
  1045. <if test="item.hsCode != null">`hs_code` = #{item.hsCode},</if>
  1046. <if test="item.hsCodeName != null">`hs_code_name` = #{item.hsCodeName},</if>
  1047. <if test="item.isSyncHsCode != null">`is_sync_hs_code` = #{item.isSyncHsCode},</if>
  1048. <if test="item.isSyncGoodsRate != null">`is_sync_goods_rate` = #{item.isSyncGoodsRate},</if>
  1049. <if test="item.impConsumTaxRate != null">`imp_consum_tax_rate` = #{item.impConsumTaxRate},</if>
  1050. <if test="item.valueAddedTaxRate != null">`value_added_tax_rate` = #{item.valueAddedTaxRate},</if>
  1051. <if test="item.legalUnit1Qty != null">`legal_unit1_qty` = #{item.legalUnit1Qty},</if>
  1052. <if test="item.legalUnit2Qty != null">`legal_unit2_qty` = #{item.legalUnit2Qty},</if>
  1053. <if test="item.cosmThresholdValue != null">`cosm_threshold_value` = #{item.cosmThresholdValue},</if>
  1054. <if test="item.toBeRestored != null">`to_be_restored` = #{item.toBeRestored}</if>
  1055. </set>
  1056. where id = #{item.id}
  1057. </foreach>
  1058. </update>
  1059. <update id="restoreBatch" parameterType="java.util.List">
  1060. update mall_goods
  1061. <trim prefix="set" suffixOverrides=",">
  1062. goods_number=
  1063. <foreach collection="list" item="item" open="case" close=" end,">
  1064. when sku=#{item.sku} then goods_number+#{item.goodsNumber}
  1065. </foreach>
  1066. </trim>
  1067. where
  1068. <foreach collection="list" item="item" open="( " separator=" ) or ( " close=" )">
  1069. sku=#{item.sku}
  1070. </foreach>
  1071. </update>
  1072. <update id="updateStockNumberByProductCodeAndSku">
  1073. update mall_goods
  1074. set goods_number = #{goodsNumber}
  1075. where
  1076. prod_barcode = #{prodBarcode} and sku = #{sku}
  1077. </update>
  1078. <select id="syncOmsHsCodeGoode" resultType="java.lang.String">
  1079. select sku from mall_goods where id in
  1080. <foreach collection="list" item="id" index="index"
  1081. open="(" close=")" separator=",">
  1082. #{id}
  1083. </foreach>
  1084. </select>
  1085. <select id="syncGoodsRateGoode" resultType="com.kmall.admin.entity.GoodsEntity">
  1086. select * from mall_goods where is_delete = 0 and id in
  1087. <foreach collection="list" item="id" index="index"
  1088. open="(" close=")" separator=",">
  1089. #{id}
  1090. </foreach>
  1091. </select>
  1092. <select id="queryGoodsStockByBarcodeAndStoreIdAndSku" resultType="com.kmall.admin.entity.GoodsEntity">
  1093. SELECT
  1094. 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,
  1095. a.hs_code as hsCode , a.legal_unit1_qty as legalUnit1Qty , a.legal_unit2_qty as legalUnit2Qty,a.ciq_prod_model as ciqProdModel,a.to_be_restored, r.stock_num, r.exit_region_number as exitRegionNumber
  1096. FROM
  1097. mall_goods a
  1098. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  1099. inner join mall_store s on r.store_id=s.id
  1100. where a.prod_barcode = #{prodBarcode} and r.store_id = #{storeId} and a.sku = #{sku} and a.is_on_sale = 1
  1101. and r.stock_num > 0 order by r.stock_num desc
  1102. </select>
  1103. <select id="queryGoodsStockByQueryGoodsVoList" resultType="com.kmall.admin.entity.GoodsEntity">
  1104. SELECT
  1105. 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 as retailPrice,r.retail_price storeRetailPrice ,r.stock_num,s.store_name,r.product_id as productId,s.id 'storeId',a.goods_rate as goodsRate,
  1106. a.hs_code as hsCode , a.legal_unit1_qty as legalUnit1Qty , a.legal_unit2_qty as legalUnit2Qty,a.ciq_prod_model as ciqProdModel,a.to_be_restored, r.stock_num, r.exit_region_number as exitRegionNumber,
  1107. a.category_id as categoryId, a.brand_id as brandId
  1108. FROM
  1109. mall_goods a
  1110. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  1111. inner join mall_store s on r.store_id=s.id
  1112. where
  1113. a.is_on_sale = 1
  1114. and
  1115. <foreach collection="list" item="item" open="(" separator=" or " close=")">
  1116. (a.prod_barcode = #{item.prodBarcode} and r.store_id = #{item.storeId} and a.sku = #{item.sku})
  1117. </foreach>
  1118. and r.stock_num > 0
  1119. </select>
  1120. <!-- 根据产品条码和sku查询保税展示补货的商品 -->
  1121. <select id="queryGoodsInfoByProductBarcodeAndSku" resultMap="goodsMap">
  1122. select mg.*,
  1123. from mall_goods mg
  1124. where mg.goods_biz_type = '02' and mg.prod_barcode = #{prodBarcode} and mg.sku = #{sku}
  1125. </select>
  1126. </mapper>