GoodsDao.xml 51 KB

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