1
0

GoodsDao.xml 28 KB

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