1
0

GoodsDao.xml 28 KB

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