GoodsDao.xml 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  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="productId"/>
  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. </resultMap>
  72. <select id="queryObject" resultType="com.kmall.admin.entity.GoodsEntity">
  73. SELECT
  74. a.*, CASE
  75. when g.id > 0 then 2 else 0 end as goodsType,
  76. mb.third_party_merch_code,
  77. mb.is_stock_share isStockShare,
  78. mb.is_supplier_goods 'isSupplierGoods'
  79. FROM
  80. mall_goods a
  81. LEFT JOIN mall_goods_group g ON g.goods_id = a.id AND g.open_status != 3
  82. LEFT JOIN third_merchant_biz mb ON a.third_party_merch_code = mb.third_party_merch_code
  83. WHERE a.id = #{value}
  84. </select>
  85. <select id="queryObjectByStoreId" resultMap="goodsMap">
  86. select
  87. a.sku,
  88. a.id,
  89. psr1.category_id,
  90. a.goods_sn,
  91. a.name,
  92. psr1.brand_id,
  93. a.goods_number,
  94. a.keywords,
  95. a.goods_brief,
  96. a.is_on_sale,
  97. a.add_time,
  98. a.sort_order,
  99. a.is_delete,
  100. psr1.attribute_category,
  101. a.counter_price,
  102. a.extra_price,
  103. a.is_new,
  104. a.goods_unit,
  105. a.primary_pic_url,
  106. a.list_pic_url,
  107. psr1.retail_price,
  108. psr1.sell_volume,
  109. a.primary_product_id,
  110. a.unit_price,
  111. a.promotion_desc,
  112. a.promotion_tag,
  113. a.app_exclusive_price,
  114. a.is_app_exclusive,
  115. a.is_limited,
  116. a.is_hot,
  117. a.merch_sn,
  118. m.merch_name,
  119. psr1.store_id,
  120. psr1.market_price,
  121. psr1.stock_num,
  122. a.goods_desc,a.goods_biz_type,a.goods_rate,
  123. a.sell_volume goods_sell_volume,
  124. mb.third_party_merch_code,
  125. mb.is_stock_share isStockShare,
  126. mb.is_supplier_goods 'isSupplierGoods',
  127. mb2.third_party_merch_code 'supplierThirdMerchCode',
  128. mb2.is_stock_share 'isStockShareBySuppler'
  129. from mall_goods a left join mall_merch m on a.merch_sn = m.merch_sn
  130. LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
  131. LEFT JOIN mall_store s ON s.id = psr1.store_id
  132. LEFT JOIN third_merchant_biz mb on s.third_party_merch_code = mb.third_party_merch_code
  133. LEFT JOIN third_merchant_biz mb2 ON a.third_party_merch_code = mb2.third_party_merch_code
  134. where a.id = #{id} and psr1.store_id = #{storeId}
  135. </select>
  136. <select id="queryGoodsByGoodsSnAndStoreId" resultMap="goodsMap">
  137. select
  138. a.sku,
  139. a.id,
  140. psr1.category_id,
  141. a.goods_sn,
  142. a.name,
  143. psr1.brand_id,
  144. a.goods_number,
  145. a.keywords,
  146. a.goods_brief,
  147. a.is_on_sale,
  148. a.add_time,
  149. a.sort_order,
  150. a.is_delete,
  151. psr1.attribute_category,
  152. a.counter_price,
  153. a.extra_price,
  154. a.is_new,
  155. a.goods_unit,
  156. a.primary_pic_url,
  157. a.list_pic_url,
  158. psr1.retail_price,
  159. psr1.sell_volume,
  160. a.primary_product_id,
  161. a.unit_price,
  162. a.promotion_desc,
  163. a.promotion_tag,
  164. a.app_exclusive_price,
  165. a.is_app_exclusive,
  166. a.is_limited,
  167. a.is_hot,
  168. a.merch_sn,
  169. m.merch_name,
  170. psr1.store_id,
  171. psr1.market_price,
  172. psr1.stock_num,
  173. a.goods_desc,a.goods_biz_type,a.goods_rate,
  174. a.sell_volume goods_sell_volume,
  175. mb.third_party_merch_code,
  176. mb.is_stock_share isStockShare,
  177. mb.is_supplier_goods 'isSupplierGoods',
  178. mb2.third_party_merch_code 'supplierThirdMerchCode',
  179. mb2.is_stock_share 'isStockShareBySuppler'
  180. from mall_goods a left join mall_merch m on a.merch_sn = m.merch_sn
  181. LEFT JOIN mall_product_store_rela psr1 ON a.id = psr1.goods_id and a.merch_sn = psr1.merch_sn
  182. LEFT JOIN mall_store s ON s.id = psr1.store_id
  183. LEFT JOIN third_merchant_biz mb on s.third_party_merch_code = mb.third_party_merch_code
  184. LEFT JOIN third_merchant_biz mb2 ON a.third_party_merch_code = mb2.third_party_merch_code
  185. where a.goods_sn = #{goodsSn} and psr1.store_id = #{storeId}
  186. </select>
  187. <select id="queryObjectByProdBarcodeAndBizType" resultType="com.kmall.admin.entity.GoodsEntity">
  188. SELECT
  189. 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'
  190. FROM
  191. mall_goods a
  192. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  193. inner join mall_store s on r.store_id=s.id
  194. where a.prod_barcode = #{prodBarcode} and a.goods_biz_type = 11 and r.store_id = #{storeId}
  195. </select>
  196. <select id="queryObjectByProdBarcodeAndStore" resultType="com.kmall.admin.entity.GoodsEntity">
  197. SELECT
  198. 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
  199. FROM
  200. mall_goods a
  201. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  202. inner join mall_store s on r.store_id=s.id
  203. where a.prod_barcode = #{prodBarcode} and r.store_id = #{storeId}
  204. and r.stock_num > 0
  205. limit 1
  206. </select>
  207. <select id="queryObjectByProdBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
  208. SELECT
  209. 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'
  210. FROM
  211. mall_goods a
  212. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  213. inner join mall_store s on r.store_id=s.id
  214. where a.prod_barcode = #{prodBarcode} and a.is_delete = 0
  215. <if test="goodsId != null and goodsId != ''">
  216. AND a.id != #{goodsId}
  217. </if>
  218. <if test="merchSn != null and merchSn != ''">
  219. AND a.merch_sn = #{merchSn}
  220. </if>
  221. </select>
  222. <select id="queryGoodsDetailsByProdBarcode" resultType="com.kmall.admin.dto.GoodsDetailsDto">
  223. SELECT distinct
  224. a.goods_sn as GoodsSn,m.retail_price as retailPrice,a.prod_barcode as prodBarcode,a.name,a.brand,a.goods_desc as goodsDesc,a.goods_unit as goodsUnit,a.goods_rate as goodsRate,a.primary_pic_url ,m.stock_num as stockNum,r.value as specification
  225. FROM
  226. mall_goods a
  227. LEFT JOIN mall_goods_specification r ON r.goods_id = a.id
  228. left join mall_product_store_rela m on m.goods_id = a.id and r.goods_id = m.goods_id
  229. where a.prod_barcode = #{prodBarcode} and m.store_id = #{storeId}
  230. and m.stock_num > 0
  231. limit 1
  232. </select>
  233. <select id="queryObjectBySn" resultType="com.kmall.admin.entity.GoodsEntity">
  234. SELECT
  235. a.*, CASE
  236. when g.id > 0 then 2 else 0 end as goodsType
  237. FROM
  238. mall_goods a
  239. LEFT JOIN mall_goods_group g ON g.goods_id = a.id
  240. AND g.open_status != 3
  241. where a.goods_sn = #{goodsSn}
  242. </select>
  243. <select id="queryList" resultType="com.kmall.admin.entity.GoodsEntity">
  244. select * from (
  245. select
  246. mall_goods.*,
  247. case when mall_goods_group.id > 0 then 2 else 0 end as goodsType,
  248. m.merch_name merchName, mb.is_stock_share isStockShare,
  249. catagory.keywords as categoryName
  250. from mall_goods
  251. left join mall_merch m on mall_goods.merch_sn = m.merch_sn
  252. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  253. left join third_merchant_biz mb on mb.third_party_merch_code = mall_goods.third_party_merch_code and
  254. mb.merch_sn=mall_goods.merch_sn
  255. left join mall_category catagory on catagory.id = mall_goods.category_id
  256. WHERE 1=1
  257. <!-- 数据过滤 -->
  258. ${filterSql}
  259. <if test="merchSn != null and merchSn.trim() != ''">
  260. AND mall_goods.merch_sn = #{merchSn}
  261. </if>
  262. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  263. AND mall_goods.prod_barcode = #{prodBarcode}
  264. </if>
  265. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  266. AND mall_goods.third_party_merch_code = #{thirdPartyMerchCode}
  267. </if>
  268. <if test="thirdMerchSn != null and thirdMerchSn.trim() != ''">
  269. AND mb.third_merch_sn = #{thirdMerchSn}
  270. </if>
  271. <if test="goodsSn != null and goodsSn != ''">
  272. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  273. </if>
  274. <if test="name != null and name != ''">
  275. AND mall_goods.name LIKE concat('%',#{name},'%')
  276. </if>
  277. <if test="englishName != null and englishName != ''">
  278. AND mall_goods.english_name LIKE concat('%',#{englishName},'%')
  279. </if>
  280. <!--<if test="brandId != null and brandId != ''">
  281. AND mall_goods.brand_id = #{brandId}
  282. </if>
  283. <if test="freightId != null and freightId != ''">
  284. AND mall_goods.freight_id = #{freightId}
  285. </if>
  286. <if test="categoryId != null and categoryId != ''">
  287. AND mall_goods.category_id = #{categoryId}
  288. </if>
  289. <if test="category != null and category != ''">
  290. AND mall_goods.category_id IN (select id from mall_category where parent_id = #{category})
  291. </if>
  292. <if test="categoryTwo != null and categoryTwo != ''">
  293. AND mall_goods.category_id = #{categoryTwo}
  294. </if>-->
  295. <if test="sku != null and sku != ''">
  296. AND mall_goods.sku LIKE concat('%',#{sku},'%')
  297. </if>
  298. <if test="plu != null and plu != ''">
  299. AND mall_goods.plu LIKE concat('%',#{plu},'%')
  300. </if>
  301. <if test="isDelete != null">
  302. AND mall_goods.is_Delete = #{isDelete}
  303. </if>
  304. <if test="isOnSale != null">
  305. AND mall_goods.is_on_sale = #{isOnSale}
  306. </if>
  307. <if test="goodsBizType != null and goodsBizType != ''">
  308. AND mall_goods.goods_biz_type = #{goodsBizType}
  309. </if>
  310. <if test="id != null and id != ''">
  311. AND mall_goods.id = #{id}
  312. </if>
  313. <if test="storeId != null and storeId != ''">
  314. AND mall_goods.third_party_merch_code = ( SELECT third_party_merch_code FROM mall_store WHERE id =
  315. #{storeId} )
  316. AND mall_goods.id NOT IN (
  317. SELECT
  318. goods_id
  319. FROM
  320. mall_product_store_rela pp
  321. WHERE
  322. store_id = #{storeId}
  323. )
  324. </if>
  325. <if test="storeIdBySupplier != null and storeIdBySupplier != ''">
  326. AND mall_goods.id NOT IN (
  327. SELECT
  328. goods_id
  329. FROM
  330. mall_product_store_rela pp
  331. WHERE
  332. store_id = #{storeIdBySupplier} and supplier_third_id = #{thirdMerchSn}
  333. )
  334. </if>
  335. ) temp where 1=1
  336. <if test="lastSaleTime != null and lastSaleTime != ''">
  337. AND temp.last_sale_time &gt;= #{lastSaleTime} or temp.last_sale_time is null
  338. </if>
  339. <choose>
  340. <when test="sidx != null and sidx.trim() != ''">
  341. order by ${sidx} ${order}
  342. </when>
  343. <otherwise>
  344. order by temp.id desc
  345. </otherwise>
  346. </choose>
  347. <if test="offset != null and limit != null">
  348. limit #{offset}, #{limit}
  349. </if>
  350. </select>
  351. <select id="querySame" resultType="com.kmall.admin.entity.GoodsEntity">
  352. select
  353. mall_goods.*,
  354. case when mall_goods_group.id > 0 then 2 else 0 end as goodsType
  355. from mall_goods
  356. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  357. WHERE 1=1
  358. <!-- 数据过滤 -->
  359. ${filterSql}
  360. <if test="isSame != null and isSame != ''">
  361. AND ((mall_goods.sku = #{sku} AND mall_goods.goods_biz_type = #{goodsBizType}) OR mall_goods.goods_sn =
  362. #{goodsSn})
  363. <if test="id != null and id != ''">
  364. AND mall_goods.id != #{id}
  365. </if>
  366. </if>
  367. <choose>
  368. <when test="sidx != null and sidx.trim() != ''">
  369. order by ${sidx} ${order}
  370. </when>
  371. <otherwise>
  372. order by mall_goods.id desc
  373. </otherwise>
  374. </choose>
  375. <if test="offset != null and limit != null">
  376. limit #{offset}, #{limit}
  377. </if>
  378. </select>
  379. <select id="queryTotal" resultType="int">
  380. select count(*) from mall_goods
  381. left join mall_merch m on mall_goods.merch_sn = m.merch_sn
  382. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  383. WHERE 1=1
  384. <!-- 数据过滤 -->
  385. ${filterSql}
  386. <if test="merchSn != null and merchSn.trim() != ''">
  387. AND mall_goods.merch_sn = #{merchSn}
  388. </if>
  389. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  390. AND mall_goods.prod_barcode = #{prodBarcode}
  391. </if>
  392. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  393. AND mall_goods.third_party_merch_code = #{thirdPartyMerchCode}
  394. </if>
  395. <if test="goodsSn != null and goodsSn != ''">
  396. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  397. </if>
  398. <if test="name != null and name != ''">
  399. AND mall_goods.name LIKE concat('%',#{name},'%')
  400. </if>
  401. <if test="sku != null and sku != ''">
  402. AND mall_goods.sku LIKE concat('%',#{sku},'%')
  403. </if>
  404. <if test="isDelete != null">
  405. AND mall_goods.is_Delete = #{isDelete}
  406. </if>
  407. <if test="isOnSale != null">
  408. AND mall_goods.is_on_sale = #{isOnSale}
  409. </if>
  410. <if test="goodsBizType != null and goodsBizType != ''">
  411. AND mall_goods.goods_biz_type = #{goodsBizType}
  412. </if>
  413. <if test="storeId != null and storeId != ''">
  414. AND mall_goods.third_party_merch_code = ( SELECT third_party_merch_code FROM mall_store WHERE id =
  415. #{storeId} )
  416. AND mall_goods.id NOT IN (
  417. SELECT
  418. goods_id
  419. FROM
  420. mall_product_store_rela pp
  421. LEFT JOIN mall_goods gg ON pp.goods_id = gg.id
  422. AND pp.merch_sn = gg.merch_sn
  423. AND pp.merch_sn
  424. LEFT JOIN mall_store s ON pp.store_id = s.id
  425. AND s.third_party_merch_code = gg.third_party_merch_code
  426. WHERE
  427. store_id = #{storeId}
  428. )
  429. </if>
  430. </select>
  431. <insert id="save" parameterType="com.kmall.admin.entity.GoodsEntity" useGeneratedKeys="true" keyProperty="id">
  432. insert into mall_goods(
  433. `merch_sn`,
  434. third_party_merch_code,
  435. `supplier_id`,
  436. `goods_sn`,
  437. `prod_barcode`,
  438. `sku`,
  439. `plu`,
  440. `english_name`,
  441. `cost_price`,
  442. `daily_price`,
  443. `goods_biz_type`,
  444. `name`,
  445. `unit_code`,
  446. `brand`,
  447. `goods_number`,
  448. `keywords`,
  449. `goods_brief`,
  450. `goods_desc`,
  451. `cus_goods_code`,
  452. `ciq_prod_model`,
  453. `ori_cnt_code`,
  454. `cus_decl_ele`,
  455. `cus_rec_code`,
  456. `is_on_sale`,
  457. `add_time`,
  458. `sort_order`,
  459. `is_delete`,
  460. `counter_price`,
  461. `extra_price`,
  462. `is_new`,
  463. `goods_unit`,
  464. `primary_pic_url`,
  465. `list_pic_url`,
  466. `goods_rate`,
  467. `sell_volume`,
  468. `primary_product_id`,
  469. `unit_price`,
  470. `promotion_desc`,
  471. `promotion_tag`,
  472. `app_exclusive_price`,
  473. `is_app_exclusive`,
  474. `gross_weight`,
  475. `net_weight`,
  476. is_goods_share_stock,
  477. `is_limited`,
  478. `is_hot`,
  479. `creater_sn`,
  480. `create_time`,
  481. `moder_sn`,
  482. `mod_time`,
  483. `tstm`)
  484. values(
  485. #{merchSn},
  486. #{thirdPartyMerchCode},
  487. #{supplierId},
  488. #{goodsSn},
  489. #{prodBarcode},
  490. #{sku},
  491. #{plu},
  492. #{englishName},
  493. #{costPrice},
  494. #{dailyPrice},
  495. #{goodsBizType},
  496. #{name},
  497. #{unitCode},
  498. #{brand},
  499. #{goodsNumber},
  500. #{keywords},
  501. #{goodsBrief},
  502. #{goodsDesc},
  503. #{cusGoodsCode},
  504. #{ciqProdModel},
  505. #{oriCntCode},
  506. #{cusDeclEle},
  507. #{cusRecCode},
  508. #{isOnSale},
  509. #{addTime},
  510. #{sortOrder},
  511. #{isDelete},
  512. #{counterPrice},
  513. #{extraPrice},
  514. #{isNew},
  515. #{goodsUnit},
  516. #{primaryPicUrl},
  517. #{listPicUrl},
  518. #{goodsRate},
  519. #{sellVolume},
  520. #{primaryProductId},
  521. #{unitPrice},
  522. #{promotionDesc},
  523. #{promotionTag},
  524. #{appExclusivePrice},
  525. #{isAppExclusive},
  526. #{grossWeight},
  527. #{netWeight},
  528. #{isGoodsShareStock},
  529. #{isLimited},
  530. #{isHot},
  531. #{createrSn},
  532. #{createTime},
  533. #{moderSn},
  534. #{modTime},
  535. #{tstm})
  536. </insert>
  537. <update id="update" parameterType="com.kmall.admin.entity.GoodsEntity">
  538. update mall_goods
  539. <set>
  540. <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
  541. <if test="thirdPartyMerchCode != null">`third_party_merch_code` = #{thirdPartyMerchCode},</if>
  542. <if test="supplierId != null">`supplier_id` = #{supplierId},</if>
  543. <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
  544. <if test="prodBarcode != null">`prod_barcode` = #{prodBarcode},</if>
  545. <if test="sku != null">`sku` = #{sku},</if>
  546. <if test="plu != null">`plu` = #{plu},</if>
  547. <if test="englishName != null">`english_name` = #{englishName},</if>
  548. <if test="costPrice != null">`cost_price` = #{costPrice},</if>
  549. <if test="dailyPrice != null">`daily_price` = #{dailyPrice},</if>
  550. <if test="goodsBizType != null">`goods_biz_type` = #{goodsBizType},</if>
  551. <if test="name != null">`name` = #{name},</if>
  552. <if test="unitCode != null">`unit_code` = #{unitCode},</if>
  553. <if test="brand != null">`brand` = #{brand},</if>
  554. <if test="goodsNumber != null">`goods_number` = #{goodsNumber},</if>
  555. <if test="keywords != null">`keywords` = #{keywords},</if>
  556. <if test="goodsBrief != null">`goods_brief` = #{goodsBrief},</if>
  557. <if test="goodsDesc != null">`goods_desc` = #{goodsDesc},</if>
  558. <if test="cusGoodsCode != null">`cus_goods_code` = #{cusGoodsCode},</if>
  559. <if test="ciqProdModel != null">`ciq_prod_model` = #{ciqProdModel},</if>
  560. <if test="oriCntCode != null">`ori_cnt_code` = #{oriCntCode},</if>
  561. <if test="cusDeclEle != null">`cus_decl_ele` = #{cusDeclEle},</if>
  562. <if test="cusRecCode != null">`cus_rec_code` = #{cusRecCode},</if>
  563. <if test="isOnSale != null">`is_on_sale` = #{isOnSale},</if>
  564. <if test="addTime != null">`add_time` = #{addTime},</if>
  565. <if test="sortOrder != null">`sort_order` = #{sortOrder},</if>
  566. <if test="isDelete != null">`is_delete` = #{isDelete},</if>
  567. <if test="counterPrice != null">`counter_price` = #{counterPrice},</if>
  568. <if test="extraPrice != null">`extra_price` = #{extraPrice},</if>
  569. <if test="isNew != null">`is_new` = #{isNew},</if>
  570. <if test="goodsUnit != null">`goods_unit` = #{goodsUnit},</if>
  571. <if test="primaryPicUrl != null">`primary_pic_url` = #{primaryPicUrl},</if>
  572. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl},</if>
  573. <if test="goodsRate != null">`goods_rate` = #{goodsRate},</if>
  574. <if test="sellVolume != null">`sell_volume` = #{sellVolume},</if>
  575. <if test="primaryProductId != null">`primary_product_id` = #{primaryProductId},</if>
  576. <if test="unitPrice != null">`unit_price` = #{unitPrice},</if>
  577. <if test="promotionDesc != null">`promotion_desc` = #{promotionDesc},</if>
  578. <if test="promotionTag != null">`promotion_tag` = #{promotionTag},</if>
  579. <if test="appExclusivePrice != null">`app_exclusive_price` = #{appExclusivePrice},</if>
  580. <if test="isAppExclusive != null">`is_app_exclusive` = #{isAppExclusive},</if>
  581. <if test="grossWeight != null">`gross_weight` = #{grossWeight},</if>
  582. <if test="netWeight != null">`net_weight` = #{netWeight},</if>
  583. <if test="isGoodsShareStock != null">`is_goods_share_stock` = #{isGoodsShareStock},</if>
  584. <if test="isLimited != null">`is_limited` = #{isLimited},</if>
  585. <if test="isHot != null">`is_hot` = #{isHot},</if>
  586. <if test="createrSn != null">`creater_sn` = #{createrSn},</if>
  587. <if test="createTime != null">`create_time` = #{createTime},</if>
  588. <if test="moderSn != null">`moder_sn` = #{moderSn},</if>
  589. <if test="modTime != null">`mod_time` = #{modTime},</if>
  590. <if test="tstm != null">`tstm` = #{tstm},</if>
  591. <if test="lastSaleTime != null">`last_sale_time` = #{lastSaleTime}</if>
  592. </set>
  593. where id = #{id}
  594. </update>
  595. <delete id="delete">
  596. delete from mall_goods where id = #{value}
  597. </delete>
  598. <delete id="deleteBatch">
  599. delete from mall_goods where id in
  600. <foreach item="id" collection="array" open="(" separator="," close=")">
  601. #{id}
  602. </foreach>
  603. </delete>
  604. <select id="queryMaxId" resultType="java.lang.Long" parameterType="map">
  605. SELECT MAX(id) FROM mall_goods
  606. </select>
  607. <select id="searchGoodsPanoramaDtoByKeyword" resultType="com.kmall.admin.dto.GoodsPanoramaDto">
  608. SELECT
  609. g.id id,g.name `name`,g.name simpleName,g.ciq_prod_model ciqProdModel,
  610. g.goods_unit goodsBasicUnit,g.category_id categoryId,c.name categoryName,
  611. g.goods_unit goodsPurchaseUnit,g.supplier_id supplierId,s.child_supplier_name supplierName,
  612. g.prod_barcode prodBarcode,g.plu plu,g.goods_sn goodsSn,g.brand brand
  613. FROM
  614. mall_goods g
  615. INNER JOIN mall_category c
  616. INNER JOIN mall_supplier s
  617. WHERE
  618. g.category_id = c.id
  619. and g.supplier_id = s.id
  620. AND (g.goods_sn=#{keyword} OR g.prod_barcode=#{keyword})
  621. </select>
  622. <select id="queryExportList" resultType="com.kmall.admin.entity.GoodsEntity">
  623. select * from (
  624. select
  625. mall_goods.*,
  626. case when mall_goods_group.id > 0 then 2 else 0 end as goodsType,
  627. m.merch_name merchName, mb.is_stock_share isStockShare,
  628. catagory.keywords as categoryName,
  629. scnc.`name` as oriCntName
  630. from mall_goods
  631. left join mall_merch m on mall_goods.merch_sn = m.merch_sn
  632. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  633. left join third_merchant_biz mb on mb.third_party_merch_code = mall_goods.third_party_merch_code and
  634. mb.merch_sn=mall_goods.merch_sn
  635. left join mall_category catagory on catagory.id = mall_goods.category_id
  636. left join sys_cus_nation_code scnc on mall_goods.ori_cnt_code = scnc.code
  637. WHERE 1=1
  638. <!-- 数据过滤 -->
  639. ${filterSql}
  640. <if test="merchSn != null and merchSn.trim() != ''">
  641. AND mall_goods.merch_sn = #{merchSn}
  642. </if>
  643. <if test="prodBarcode != null and prodBarcode.trim() != ''">
  644. AND mall_goods.prod_barcode = #{prodBarcode}
  645. </if>
  646. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  647. AND mall_goods.third_party_merch_code = #{thirdPartyMerchCode}
  648. </if>
  649. <if test="goodsSn != null and goodsSn != ''">
  650. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  651. </if>
  652. <if test="name != null and name != ''">
  653. AND mall_goods.name LIKE concat('%',#{name},'%')
  654. </if>
  655. <if test="englishName != null and englishName != ''">
  656. AND mall_goods.english_name LIKE concat('%',#{englishName},'%')
  657. </if>
  658. <if test="goodsBizType != null and goodsBizType != ''">
  659. AND mall_goods.goods_biz_type = #{goodsBizType}
  660. </if>
  661. <if test="isDelete != null">
  662. AND mall_goods.is_Delete = #{isDelete}
  663. </if>
  664. ) temp
  665. where 1=1
  666. <if test="lastSaleTime != null and lastSaleTime != ''">
  667. AND temp.last_sale_time &gt;= #{lastSaleTime} or temp.last_sale_time is null
  668. </if>
  669. </select>
  670. <select id="queryForPDFData" resultType="com.kmall.api.entity.exportpdf.PDFGoodsDto">
  671. select
  672. g.name as productName,
  673. g.english_name as englishName,
  674. rela.retail_price as price,
  675. IFNULL((rela.market_price - rela.retail_price ),0) as savings,
  676. g.goods_rate as startFax,
  677. g.goods_rate as endFax,
  678. g.plu as plu,
  679. g.prod_barcode as barCode
  680. from
  681. mall_goods g
  682. left join mall_product_store_rela rela on g.id = rela.goods_id
  683. <where>
  684. <if test="sku != null and sku != ''">
  685. and g.sku = #{sku}
  686. </if>
  687. <if test="prodBarcode != null and prodBarcode != ''">
  688. and g.prod_barcode = #{prodBarcode}
  689. </if>
  690. <if test="storeId != null and storeId != ''">
  691. and rela.store_id = #{storeId}
  692. </if>
  693. </where>
  694. </select>
  695. <select id="queryByBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
  696. select *
  697. from mall_goods
  698. where prod_barcode = #{barCode}
  699. </select>
  700. <select id="queryBySku" resultType="com.kmall.admin.entity.GoodsEntity">
  701. select *
  702. from mall_goods
  703. where sku = #{sku}
  704. </select>
  705. <select id="queryListByBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
  706. SELECT
  707. 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
  708. FROM
  709. mall_goods a
  710. LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
  711. inner join mall_store s on r.store_id=s.id
  712. where a.prod_barcode = #{prodBarcode} and r.store_id = #{storeId}
  713. and r.stock_num > 0
  714. </select>
  715. </mapper>