GoodsDao.xml 51 KB

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