GoodsDao.xml 30 KB

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