GoodsDao.xml 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192
  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. warehouse_sn,
  538. consignor_sn,
  539. warehous_sys_good_id,
  540. inventory_type,
  541. defective_products_grade
  542. )
  543. values(
  544. #{merchSn},
  545. #{thirdPartyMerchCode},
  546. #{supplierId},
  547. #{goodsSn},
  548. #{prodBarcode},
  549. #{sku},
  550. #{plu},
  551. #{englishName},
  552. #{costPrice},
  553. #{dailyPrice},
  554. #{goodsBizType},
  555. #{name},
  556. #{unitCode},
  557. #{brand},
  558. #{brandId},
  559. #{categoryId},
  560. #{goodsNumber},
  561. #{keywords},
  562. #{goodsBrief},
  563. #{goodsDesc},
  564. #{cusGoodsCode},
  565. #{ciqProdModel},
  566. #{oriCntCode},
  567. #{cusDeclEle},
  568. #{cusRecCode},
  569. #{isOnSale},
  570. #{addTime},
  571. #{sortOrder},
  572. #{isDelete},
  573. #{counterPrice},
  574. #{extraPrice},
  575. #{isNew},
  576. #{goodsUnit},
  577. #{primaryPicUrl},
  578. #{listPicUrl},
  579. #{goodsRate},
  580. #{sellVolume},
  581. #{primaryProductId},
  582. #{unitPrice},
  583. #{promotionDesc},
  584. #{promotionTag},
  585. #{appExclusivePrice},
  586. #{isAppExclusive},
  587. #{grossWeight},
  588. #{netWeight},
  589. #{isGoodsShareStock},
  590. #{isLimited},
  591. #{isHot},
  592. #{createrSn},
  593. #{createTime},
  594. #{moderSn},
  595. #{modTime},
  596. #{mychemId},
  597. #{hsCode},
  598. #{hsCodeName},
  599. '0',
  600. '0',
  601. #{impConsumTaxRate},
  602. #{valueAddedTaxRate},
  603. #{legalUnit1Qty},
  604. #{legalUnit2Qty},
  605. #{cosmThresholdValue},
  606. 0,
  607. #{tstm},
  608. #{warehouseSn},
  609. #{consignorSn},
  610. #{warehousSysGoodId},
  611. #{inventoryType},
  612. #{defectiveProductsGrade}
  613. )
  614. </insert>
  615. <update id="update" parameterType="com.kmall.admin.entity.GoodsEntity">
  616. update mall_goods
  617. <set>
  618. <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
  619. <if test="thirdPartyMerchCode != null">`third_party_merch_code` = #{thirdPartyMerchCode},</if>
  620. <if test="supplierId != null">`supplier_id` = #{supplierId},</if>
  621. <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
  622. <if test="prodBarcode != null">`prod_barcode` = #{prodBarcode},</if>
  623. <if test="sku != null">`sku` = #{sku},</if>
  624. <if test="plu != null">`plu` = #{plu},</if>
  625. <if test="englishName != null">`english_name` = #{englishName},</if>
  626. <if test="costPrice != null">`cost_price` = #{costPrice},</if>
  627. <if test="dailyPrice != null">`daily_price` = #{dailyPrice},</if>
  628. <if test="goodsBizType != null">`goods_biz_type` = #{goodsBizType},</if>
  629. <if test="name != null">`name` = #{name},</if>
  630. <if test="unitCode != null">`unit_code` = #{unitCode},</if>
  631. <if test="brand != null">`brand` = #{brand},</if>
  632. <if test="brandId != null">`brand_id` = #{brandId},</if>
  633. <if test="categoryId != null">`category_id` = #{categoryId},</if>
  634. <if test="goodsNumber != null">`goods_number` = #{goodsNumber},</if>
  635. <if test="keywords != null">`keywords` = #{keywords},</if>
  636. <if test="goodsBrief != null">`goods_brief` = #{goodsBrief},</if>
  637. <if test="goodsDesc != null">`goods_desc` = #{goodsDesc},</if>
  638. <if test="cusGoodsCode != null">`cus_goods_code` = #{cusGoodsCode},</if>
  639. <if test="ciqProdModel != null">`ciq_prod_model` = #{ciqProdModel},</if>
  640. <if test="oriCntCode != null">`ori_cnt_code` = #{oriCntCode},</if>
  641. <if test="cusDeclEle != null">`cus_decl_ele` = #{cusDeclEle},</if>
  642. <if test="cusRecCode != null">`cus_rec_code` = #{cusRecCode},</if>
  643. <if test="isOnSale != null">`is_on_sale` = #{isOnSale},</if>
  644. <if test="addTime != null">`add_time` = #{addTime},</if>
  645. <if test="sortOrder != null">`sort_order` = #{sortOrder},</if>
  646. <if test="isDelete != null">`is_delete` = #{isDelete},</if>
  647. <if test="counterPrice != null">`counter_price` = #{counterPrice},</if>
  648. <if test="extraPrice != null">`extra_price` = #{extraPrice},</if>
  649. <if test="isNew != null">`is_new` = #{isNew},</if>
  650. <if test="goodsUnit != null">`goods_unit` = #{goodsUnit},</if>
  651. <if test="primaryPicUrl != null">`primary_pic_url` = #{primaryPicUrl},</if>
  652. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl},</if>
  653. <if test="goodsRate != null">`goods_rate` = #{goodsRate},</if>
  654. <if test="sellVolume != null">`sell_volume` = #{sellVolume},</if>
  655. <if test="primaryProductId != null">`primary_product_id` = #{primaryProductId},</if>
  656. <if test="unitPrice != null">`unit_price` = #{unitPrice},</if>
  657. <if test="promotionDesc != null">`promotion_desc` = #{promotionDesc},</if>
  658. <if test="promotionTag != null">`promotion_tag` = #{promotionTag},</if>
  659. <if test="appExclusivePrice != null">`app_exclusive_price` = #{appExclusivePrice},</if>
  660. <if test="isAppExclusive != null">`is_app_exclusive` = #{isAppExclusive},</if>
  661. <if test="grossWeight != null">`gross_weight` = #{grossWeight},</if>
  662. <if test="netWeight != null">`net_weight` = #{netWeight},</if>
  663. <if test="isGoodsShareStock != null">`is_goods_share_stock` = #{isGoodsShareStock},</if>
  664. <if test="isLimited != null">`is_limited` = #{isLimited},</if>
  665. <if test="isHot != null">`is_hot` = #{isHot},</if>
  666. <if test="createrSn != null">`creater_sn` = #{createrSn},</if>
  667. <if test="createTime != null">`create_time` = #{createTime},</if>
  668. <if test="moderSn != null">`moder_sn` = #{moderSn},</if>
  669. <if test="modTime != null">`mod_time` = #{modTime},</if>
  670. <if test="tstm != null">`tstm` = #{tstm},</if>
  671. <if test="lastSaleTime != null">`last_sale_time` = #{lastSaleTime},</if>
  672. <if test="mychemId != null">`mychem_id` = #{mychemId},</if>
  673. <if test="hsCode != null">`hs_code` = #{hsCode},</if>
  674. <if test="hsCodeName != null">`hs_code_name` = #{hsCodeName},</if>
  675. <if test="isSyncHsCode != null">`is_sync_hs_code` = #{isSyncHsCode},</if>
  676. <if test="isSyncGoodsRate != null">`is_sync_goods_rate` = #{isSyncGoodsRate},</if>
  677. <if test="impConsumTaxRate != null">`imp_consum_tax_rate` = #{impConsumTaxRate},</if>
  678. <if test="valueAddedTaxRate != null">`value_added_tax_rate` = #{valueAddedTaxRate},</if>
  679. <if test="legalUnit1Qty != null">`legal_unit1_qty` = #{legalUnit1Qty},</if>
  680. <if test="legalUnit2Qty != null">`legal_unit2_qty` = #{legalUnit2Qty},</if>
  681. <if test="cosmThresholdValue != null">`cosm_threshold_value` = #{cosmThresholdValue},</if>
  682. <if test="toBeRestored != null">`to_be_restored` = #{toBeRestored},</if>
  683. <if test="warehouseSn != null">`warehouse_sn` = #{warehouseSn},</if>
  684. <if test="consignorSn != null">`consignor_sn` = #{consignorSn},</if>
  685. <if test="warehousSysGoodId != null">`warehous_sys_good_id` = #{warehousSysGoodId},</if>
  686. <if test="inventoryType != null">`inventory_type` = #{inventoryType},</if>
  687. <if test="defectiveProductsGrade != null">`defective_products_grade` = #{defectiveProductsGrade}</if>
  688. </set>
  689. where id = #{id}
  690. </update>
  691. <delete id="delete">
  692. delete from mall_goods where id = #{value}
  693. </delete>
  694. <delete id="deleteBatch">
  695. delete from mall_goods where id in
  696. <foreach item="id" collection="array" open="(" separator="," close=")">
  697. #{id}
  698. </foreach>
  699. </delete>
  700. <select id="queryMaxId" resultType="java.lang.Long" parameterType="map">
  701. SELECT MAX(id) FROM mall_goods
  702. </select>
  703. <select id="searchGoodsPanoramaDtoByKeyword" resultType="com.kmall.admin.dto.GoodsPanoramaDto">
  704. SELECT
  705. g.id id,g.name `name`,g.name simpleName,g.ciq_prod_model ciqProdModel,
  706. g.goods_unit goodsBasicUnit,g.category_id categoryId,c.name categoryName,
  707. g.goods_unit goodsPurchaseUnit,g.supplier_id supplierId,s.child_supplier_name supplierName,
  708. g.prod_barcode prodBarcode,g.plu plu,g.goods_sn goodsSn,g.brand brand
  709. FROM
  710. mall_goods g
  711. INNER JOIN mall_category c
  712. INNER JOIN mall_supplier s
  713. WHERE
  714. g.category_id = c.id
  715. and g.supplier_id = s.id
  716. AND (g.goods_sn=#{keyword} OR g.prod_barcode=#{keyword})
  717. </select>
  718. <select id="queryExportList" resultType="com.kmall.admin.entity.GoodsEntity">
  719. select * from (
  720. select
  721. mall_goods.*,
  722. case when mall_goods_group.id > 0 then 2 else 0 end as goodsType,
  723. m.merch_name merchName, mb.is_stock_share isStockShare,
  724. catagory.keywords as categoryName,
  725. scnc.`name` as oriCntName
  726. from mall_goods
  727. left join mall_merch m on mall_goods.merch_sn = m.merch_sn
  728. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  729. left join third_merchant_biz mb on mb.third_party_merch_code = mall_goods.third_party_merch_code and
  730. mb.merch_sn=mall_goods.merch_sn
  731. left join mall_category catagory on catagory.id = mall_goods.category_id
  732. left join sys_cus_nation_code scnc on mall_goods.ori_cnt_code = scnc.code
  733. WHERE 1=1
  734. <!-- 数据过滤 -->
  735. ${filterSql}
  736. <if test="merchSn != null and merchSn.trim() != ''">
  737. AND mall_goods.merch_sn = #{merchSn}
  738. </if>
  739. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  740. AND mall_goods.prod_barcode = #{prodBarcode}
  741. </if>
  742. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  743. AND mall_goods.third_party_merch_code = #{thirdPartyMerchCode}
  744. </if>
  745. <if test="goodsSn != null and goodsSn != ''">
  746. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  747. </if>
  748. <if test="name != null and name != ''">
  749. AND mall_goods.name LIKE concat('%',#{name},'%')
  750. </if>
  751. <if test="englishName != null and englishName != ''">
  752. AND mall_goods.english_name LIKE concat('%',#{englishName},'%')
  753. </if>
  754. <if test="goodsBizType != null and goodsBizType != ''">
  755. AND mall_goods.goods_biz_type = #{goodsBizType}
  756. </if>
  757. <if test="isDelete != null">
  758. AND mall_goods.is_Delete = #{isDelete}
  759. </if>
  760. ) temp
  761. where 1=1
  762. <if test="lastSaleTime != null and lastSaleTime != ''">
  763. AND temp.last_sale_time &gt;= #{lastSaleTime} or temp.last_sale_time is null
  764. </if>
  765. </select>
  766. <select id="queryForPDFData" resultType="com.kmall.api.entity.exportpdf.PDFGoodsDto">
  767. select
  768. g.name as productName,
  769. g.english_name as englishName,
  770. rela.retail_price as price,
  771. IFNULL((rela.market_price - rela.retail_price ),0) as savings,
  772. g.goods_rate as startFax,
  773. g.goods_rate as endFax,
  774. g.plu as plu,
  775. g.prod_barcode as barCode
  776. from
  777. mall_goods g
  778. left join mall_product_store_rela rela on g.id = rela.goods_id
  779. <where>
  780. <if test="sku != null and sku != ''">
  781. and g.sku = #{sku}
  782. </if>
  783. <if test="prodBarcode != null and prodBarcode != ''">
  784. and g.prod_barcode = #{prodBarcode}
  785. </if>
  786. <if test="storeId != null and storeId != ''">
  787. and rela.store_id = #{storeId}
  788. </if>
  789. </where>
  790. </select>
  791. <select id="queryByBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
  792. select *
  793. from mall_goods
  794. where prod_barcode = #{barCode}
  795. </select>
  796. <select id="queryBySku" resultType="com.kmall.admin.entity.GoodsEntity">
  797. select *
  798. from mall_goods
  799. where sku = #{sku}
  800. </select>
  801. <select id="queryListByBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
  802. SELECT
  803. 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,
  804. 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
  805. FROM
  806. mall_goods a
  807. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  808. inner join mall_store s on r.store_id=s.id
  809. where a.prod_barcode = #{prodBarcode} and r.store_id = #{storeId} and a.sku = #{sku} and a.is_on_sale = 1
  810. and r.stock_num > 0 order by r.stock_num desc
  811. </select>
  812. <select id="queryByName" resultType="com.kmall.admin.entity.GoodsEntity">
  813. SELECT DISTINCT
  814. g.id,
  815. g.NAME,
  816. g.sku,
  817. g.prod_barcode
  818. FROM
  819. mall_product_store_rela r
  820. LEFT JOIN mall_goods g ON g.id = r.goods_id
  821. WHERE
  822. r.store_id = #{storeId}
  823. <if test="goodsName != null and goodsName != ''">
  824. AND g.NAME LIKE concat('%',#{goodsName},'%');
  825. </if>
  826. </select>
  827. <select id="queryNonSyncOmsHsCodeSkuList" resultType="java.lang.String">
  828. select sku
  829. from mall_goods
  830. where is_sync_hs_code = '0'
  831. </select>
  832. <select id="queryListBySku" resultType="com.kmall.admin.entity.GoodsEntity">
  833. select *
  834. from mall_goods
  835. where sku = #{sku}
  836. </select>
  837. <select id="queryNonSyncOmsGoodsRateSkuList" resultType="com.kmall.admin.entity.GoodsEntity">
  838. select *
  839. from mall_goods
  840. where is_sync_goods_rate = '0'
  841. </select>
  842. <select id="queryAllList" resultType="com.kmall.admin.entity.GoodsEntity">
  843. select * from mall_goods where is_delete = 0
  844. <if test="page != null and pageSize != null">
  845. limit #{page}, #{pageSize}
  846. </if>
  847. </select>
  848. <select id="queryByBarcodeAndSku" resultType="com.kmall.admin.entity.GoodsEntity">
  849. select * from mall_goods where
  850. goods_sn = #{goodsSn} and prod_barcode = #{prodBarcode}
  851. </select>
  852. <select id="querySpecialCosmetics" resultType="com.kmall.admin.entity.GoodsEntity">
  853. SELECT distinct
  854. a.*,
  855. m.retail_price as retailPrice,
  856. m.stock_num as stockNum,
  857. m.store_id as storeId
  858. FROM
  859. mall_goods a
  860. left join mall_product_store_rela m on m.goods_id = a.id
  861. <where>
  862. a.cus_rec_code in
  863. <foreach collection="hdCodeSet" item="item" open="(" close=")" separator=",">
  864. #{item}
  865. </foreach>
  866. </where>
  867. </select>
  868. <insert id="saveBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
  869. insert into mall_goods(
  870. `merch_sn`,
  871. third_party_merch_code,
  872. `supplier_id`,
  873. `goods_sn`,
  874. `prod_barcode`,
  875. `sku`,
  876. `plu`,
  877. `english_name`,
  878. `cost_price`,
  879. `daily_price`,
  880. `goods_biz_type`,
  881. `name`,
  882. `unit_code`,
  883. `brand`,
  884. `brand_id`,
  885. `category_id`,
  886. `goods_number`,
  887. `keywords`,
  888. `goods_brief`,
  889. `goods_desc`,
  890. `cus_goods_code`,
  891. `ciq_prod_model`,
  892. `ori_cnt_code`,
  893. `cus_decl_ele`,
  894. `cus_rec_code`,
  895. `is_on_sale`,
  896. `add_time`,
  897. `sort_order`,
  898. `is_delete`,
  899. `counter_price`,
  900. `extra_price`,
  901. `is_new`,
  902. `goods_unit`,
  903. `primary_pic_url`,
  904. `list_pic_url`,
  905. `goods_rate`,
  906. `sell_volume`,
  907. `primary_product_id`,
  908. `unit_price`,
  909. `promotion_desc`,
  910. `promotion_tag`,
  911. `app_exclusive_price`,
  912. `is_app_exclusive`,
  913. `gross_weight`,
  914. `net_weight`,
  915. is_goods_share_stock,
  916. `is_limited`,
  917. `is_hot`,
  918. `creater_sn`,
  919. `create_time`,
  920. `moder_sn`,
  921. `mod_time`,
  922. `mychem_id`,
  923. `hs_code`,
  924. `hs_code_name`,
  925. `is_sync_hs_code`,
  926. `is_sync_goods_rate`,
  927. `imp_consum_tax_rate`,
  928. `value_added_tax_rate`,
  929. `legal_unit1_qty`,
  930. `legal_unit2_qty`,
  931. `cosm_threshold_value`,
  932. `to_be_restored`,
  933. `tstm`)
  934. values
  935. <foreach collection="list" index="index" item="item" separator=",">
  936. (
  937. #{item.merchSn},
  938. #{item.thirdPartyMerchCode},
  939. #{item.supplierId},
  940. #{item.goodsSn},
  941. #{item.prodBarcode},
  942. #{item.sku},
  943. #{item.plu},
  944. #{item.englishName},
  945. #{item.costPrice},
  946. #{item.dailyPrice},
  947. #{item.goodsBizType},
  948. #{item.name},
  949. #{item.unitCode},
  950. #{item.brand},
  951. #{item.brandId},
  952. #{item.categoryId},
  953. #{item.goodsNumber},
  954. #{item.keywords},
  955. #{item.goodsBrief},
  956. #{item.goodsDesc},
  957. #{item.cusGoodsCode},
  958. #{item.ciqProdModel},
  959. #{item.oriCntCode},
  960. #{item.cusDeclEle},
  961. #{item.cusRecCode},
  962. #{item.isOnSale},
  963. #{item.addTime},
  964. #{item.sortOrder},
  965. #{item.isDelete},
  966. #{item.counterPrice},
  967. #{item.extraPrice},
  968. #{item.isNew},
  969. #{item.goodsUnit},
  970. #{item.primaryPicUrl},
  971. #{item.listPicUrl},
  972. #{item.goodsRate},
  973. #{item.sellVolume},
  974. #{item.primaryProductId},
  975. #{item.unitPrice},
  976. #{item.promotionDesc},
  977. #{item.promotionTag},
  978. #{item.appExclusivePrice},
  979. #{item.isAppExclusive},
  980. #{item.grossWeight},
  981. #{item.netWeight},
  982. #{item.isGoodsShareStock},
  983. #{item.isLimited},
  984. #{item.isHot},
  985. #{item.createrSn},
  986. #{item.createTime},
  987. #{item.moderSn},
  988. #{item.modTime},
  989. #{item.mychemId},
  990. #{item.hsCode},
  991. #{item.hsCodeName},
  992. '0',
  993. '0',
  994. #{item.impConsumTaxRate},
  995. #{item.valueAddedTaxRate},
  996. #{item.legalUnit1Qty},
  997. #{item.legalUnit2Qty},
  998. #{item.cosmThresholdValue},
  999. #{item.toBeRestored},
  1000. #{item.tstm})
  1001. </foreach>
  1002. </insert>
  1003. <update id="updateBatch" parameterType="java.util.List">
  1004. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  1005. update mall_goods
  1006. <set>
  1007. <if test="item.merchSn != null">`merch_sn` = #{item.merchSn},</if>
  1008. <if test="item.thirdPartyMerchCode != null">`third_party_merch_code` = #{item.thirdPartyMerchCode},</if>
  1009. <if test="item.supplierId != null">`supplier_id` = #{item.supplierId},</if>
  1010. <if test="item.goodsSn != null">`goods_sn` = #{item.goodsSn},</if>
  1011. <if test="item.prodBarcode != null">`prod_barcode` = #{item.prodBarcode},</if>
  1012. <if test="item.sku != null">`sku` = #{item.sku},</if>
  1013. <if test="item.plu != null">`plu` = #{item.plu},</if>
  1014. <if test="item.englishName != null">`english_name` = #{item.englishName},</if>
  1015. <if test="item.costPrice != null">`cost_price` = #{item.costPrice},</if>
  1016. <if test="item.dailyPrice != null">`daily_price` = #{item.dailyPrice},</if>
  1017. <if test="item.goodsBizType != null">`goods_biz_type` = #{item.goodsBizType},</if>
  1018. <if test="item.name != null">`name` = #{item.name},</if>
  1019. <if test="item.unitCode != null">`unit_code` = #{item.unitCode},</if>
  1020. <if test="item.brand != null">`brand` = #{item.brand},</if>
  1021. <if test="item.brandId != null">`brand_id` = #{item.brandId},</if>
  1022. <if test="item.categoryId != null">`category_id` = #{item.categoryId},</if>
  1023. <if test="item.goodsNumber != null">`goods_number` = #{item.goodsNumber},</if>
  1024. <if test="item.keywords != null">`keywords` = #{item.keywords},</if>
  1025. <if test="item.goodsBrief != null">`goods_brief` = #{item.goodsBrief},</if>
  1026. <if test="item.goodsDesc != null">`goods_desc` = #{item.goodsDesc},</if>
  1027. <if test="item.cusGoodsCode != null">`cus_goods_code` = #{item.cusGoodsCode},</if>
  1028. <if test="item.ciqProdModel != null">`ciq_prod_model` = #{item.ciqProdModel},</if>
  1029. <if test="item.oriCntCode != null">`ori_cnt_code` = #{item.oriCntCode},</if>
  1030. <if test="item.cusDeclEle != null">`cus_decl_ele` = #{item.cusDeclEle},</if>
  1031. <if test="item.cusRecCode != null">`cus_rec_code` = #{item.cusRecCode},</if>
  1032. <if test="item.isOnSale != null">`is_on_sale` = #{item.isOnSale},</if>
  1033. <if test="item.addTime != null">`add_time` = #{item.addTime},</if>
  1034. <if test="item.sortOrder != null">`sort_order` = #{item.sortOrder},</if>
  1035. <if test="item.isDelete != null">`is_delete` = #{item.isDelete},</if>
  1036. <if test="item.counterPrice != null">`counter_price` = #{item.counterPrice},</if>
  1037. <if test="item.extraPrice != null">`extra_price` = #{item.extraPrice},</if>
  1038. <if test="item.isNew != null">`is_new` = #{item.isNew},</if>
  1039. <if test="item.goodsUnit != null">`goods_unit` = #{item.goodsUnit},</if>
  1040. <if test="item.primaryPicUrl != null">`primary_pic_url` = #{item.primaryPicUrl},</if>
  1041. <if test="item.listPicUrl != null">`list_pic_url` = #{item.listPicUrl},</if>
  1042. <if test="item.goodsRate != null">`goods_rate` = #{item.goodsRate},</if>
  1043. <if test="item.sellVolume != null">`sell_volume` = #{item.sellVolume},</if>
  1044. <if test="item.primaryProductId != null">`primary_product_id` = #{item.primaryProductId},</if>
  1045. <if test="item.unitPrice != null">`unit_price` = #{item.unitPrice},</if>
  1046. <if test="item.promotionDesc != null">`promotion_desc` = #{item.promotionDesc},</if>
  1047. <if test="item.promotionTag != null">`promotion_tag` = #{item.promotionTag},</if>
  1048. <if test="item.appExclusivePrice != null">`app_exclusive_price` = #{item.appExclusivePrice},</if>
  1049. <if test="item.isAppExclusive != null">`is_app_exclusive` = #{item.isAppExclusive},</if>
  1050. <if test="item.grossWeight != null">`gross_weight` = #{item.grossWeight},</if>
  1051. <if test="item.netWeight != null">`net_weight` = #{item.netWeight},</if>
  1052. <if test="item.isGoodsShareStock != null">`is_goods_share_stock` = #{item.isGoodsShareStock},</if>
  1053. <if test="item.isLimited != null">`is_limited` = #{item.isLimited},</if>
  1054. <if test="item.isHot != null">`is_hot` = #{item.isHot},</if>
  1055. <if test="item.createrSn != null">`creater_sn` = #{item.createrSn},</if>
  1056. <if test="item.createTime != null">`create_time` = #{item.createTime},</if>
  1057. <if test="item.moderSn != null">`moder_sn` = #{item.moderSn},</if>
  1058. <if test="item.modTime != null">`mod_time` = #{item.modTime},</if>
  1059. <if test="item.tstm != null">`tstm` = #{item.tstm},</if>
  1060. <if test="item.lastSaleTime != null">`last_sale_time` = #{item.lastSaleTime},</if>
  1061. <if test="item.mychemId != null">`mychem_id` = #{item.mychemId},</if>
  1062. <if test="item.hsCode != null">`hs_code` = #{item.hsCode},</if>
  1063. <if test="item.hsCodeName != null">`hs_code_name` = #{item.hsCodeName},</if>
  1064. <if test="item.isSyncHsCode != null">`is_sync_hs_code` = #{item.isSyncHsCode},</if>
  1065. <if test="item.isSyncGoodsRate != null">`is_sync_goods_rate` = #{item.isSyncGoodsRate},</if>
  1066. <if test="item.impConsumTaxRate != null">`imp_consum_tax_rate` = #{item.impConsumTaxRate},</if>
  1067. <if test="item.valueAddedTaxRate != null">`value_added_tax_rate` = #{item.valueAddedTaxRate},</if>
  1068. <if test="item.legalUnit1Qty != null">`legal_unit1_qty` = #{item.legalUnit1Qty},</if>
  1069. <if test="item.legalUnit2Qty != null">`legal_unit2_qty` = #{item.legalUnit2Qty},</if>
  1070. <if test="item.cosmThresholdValue != null">`cosm_threshold_value` = #{item.cosmThresholdValue},</if>
  1071. <if test="item.toBeRestored != null">`to_be_restored` = #{item.toBeRestored}</if>
  1072. </set>
  1073. where id = #{item.id}
  1074. </foreach>
  1075. </update>
  1076. <update id="restoreBatch" parameterType="java.util.List">
  1077. update mall_goods
  1078. <trim prefix="set" suffixOverrides=",">
  1079. goods_number=
  1080. <foreach collection="list" item="item" open="case" close=" end,">
  1081. when sku=#{item.sku} then goods_number+#{item.goodsNumber}
  1082. </foreach>
  1083. </trim>
  1084. where
  1085. <foreach collection="list" item="item" open="( " separator=" ) or ( " close=" )">
  1086. sku=#{item.sku}
  1087. </foreach>
  1088. </update>
  1089. <update id="updateStockNumberByProductCodeAndSku">
  1090. update mall_goods
  1091. set goods_number = #{goodsNumber}
  1092. where
  1093. prod_barcode = #{prodBarcode} and sku = #{sku}
  1094. </update>
  1095. <select id="syncOmsHsCodeGoode" resultType="java.lang.String">
  1096. select sku from mall_goods where id in
  1097. <foreach collection="list" item="id" index="index"
  1098. open="(" close=")" separator=",">
  1099. #{id}
  1100. </foreach>
  1101. </select>
  1102. <select id="syncGoodsRateGoode" resultType="com.kmall.admin.entity.GoodsEntity">
  1103. select * from mall_goods where is_delete = 0 and id in
  1104. <foreach collection="list" item="id" index="index"
  1105. open="(" close=")" separator=",">
  1106. #{id}
  1107. </foreach>
  1108. </select>
  1109. <select id="queryGoodsStockByBarcodeAndStoreIdAndSku" resultType="com.kmall.admin.entity.GoodsEntity">
  1110. SELECT
  1111. 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,
  1112. 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
  1113. FROM
  1114. mall_goods a
  1115. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  1116. inner join mall_store s on r.store_id=s.id
  1117. where a.prod_barcode = #{prodBarcode} and r.store_id = #{storeId} and a.sku = #{sku} and a.is_on_sale = 1
  1118. and r.stock_num > 0 order by r.stock_num desc
  1119. </select>
  1120. <select id="queryGoodsStockByQueryGoodsVoList" resultType="com.kmall.admin.entity.GoodsEntity">
  1121. SELECT
  1122. 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,
  1123. 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,
  1124. a.category_id as categoryId, a.brand_id as brandId
  1125. FROM
  1126. mall_goods a
  1127. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  1128. inner join mall_store s on r.store_id=s.id
  1129. where
  1130. a.is_on_sale = 1
  1131. and
  1132. <foreach collection="list" item="item" open="(" separator=" or " close=")">
  1133. (a.prod_barcode = #{item.prodBarcode} and r.store_id = #{item.storeId} and a.sku = #{item.sku})
  1134. </foreach>
  1135. and r.stock_num > 0
  1136. </select>
  1137. <!-- 根据产品条码和sku查询保税展示补货的商品 -->
  1138. <select id="queryGoodsInfoByProductBarcodeAndSku" resultMap="goodsMap">
  1139. select mg.*,
  1140. from mall_goods mg
  1141. where mg.goods_biz_type = '02' and mg.prod_barcode = #{prodBarcode} and mg.sku = #{sku}
  1142. </select>
  1143. </mapper>