GoodsDao.xml 54 KB

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