GoodsDao.xml 51 KB

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