GoodsDao.xml 52 KB

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