1
0

MkDistSellStatisDao.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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.mk.dist.MkDistSellStatisDao">
  4. <resultMap type="com.kmall.admin.entity.mk.dist.MkDistSellStatisEntity" id="mkDistSellStatisMap">
  5. <result property="id" column="id"/>
  6. <result property="distFlag" column="dist_flag"/>
  7. <result property="thirdMerchSn" column="third_merch_sn"/>
  8. <result property="supplierId" column="supplier_id"/>
  9. <result property="distId" column="dist_id"/>
  10. <result property="goodsId" column="goods_id"/>
  11. <result property="goodsPrice" column="goods_price"/>
  12. <result property="allocType" column="alloc_type"/>
  13. <result property="sellAllocHistoryId" column="sell_alloc_history_id"/>
  14. <result property="expendDistId" column="expend_dist_id"/>
  15. <result property="expendDistPrice" column="expend_dist_price"/>
  16. <result property="expendDistLevel" column="expend_dist_level"/>
  17. <result property="expendSource" column="expend_source"/>
  18. <result property="isValid" column="is_valid"/>
  19. <result property="note" column="note"/>
  20. <result property="createrSn" column="creater_sn"/>
  21. <result property="createTime" column="create_time"/>
  22. <result property="moderSn" column="moder_sn"/>
  23. <result property="modTime" column="mod_time"/>
  24. <result property="tstm" column="tstm"/>
  25. <result property="orderSn" column="order_sn"/>
  26. <result property="actualPrice" column="actual_price"/>
  27. </resultMap>
  28. <select id="queryObject" resultType="com.kmall.admin.entity.mk.dist.MkDistSellStatisEntity">
  29. select
  30. `id`,
  31. `dist_flag`,
  32. `third_merch_sn`,
  33. `supplier_id`,
  34. `dist_id`,
  35. `goods_id`,
  36. `goods_price`,
  37. `sell_alloc_history_id`,
  38. `expend_dist_id`,
  39. `expend_dist_price`,
  40. `expend_dist_level`,
  41. `expend_source`,
  42. `is_valid`,
  43. `note`,
  44. `creater_sn`,
  45. `create_time`,
  46. `moder_sn`,
  47. `mod_time`,
  48. `tstm`,order_sn
  49. from mk_dist_sell_statis
  50. where id = #{id}
  51. </select>
  52. <select id="queryList" resultType="com.kmall.admin.entity.mk.dist.MkDistSellStatisEntity">
  53. SELECT * FROM (
  54. select
  55. a.`id`,
  56. a.`dist_flag`,
  57. a.`third_merch_sn`,
  58. a.`supplier_id`,
  59. a.`dist_id`,
  60. a.`goods_id`,
  61. a.`goods_price`,
  62. a.`sell_alloc_history_id`,
  63. a.`expend_dist_id`,
  64. a.`expend_dist_price`,
  65. a.`expend_dist_level`,
  66. a.`expend_source`,
  67. a.`is_valid`,
  68. a.`note`,
  69. a.`creater_sn`,
  70. a.`create_time`,
  71. a.`moder_sn`,
  72. a.`mod_time`,
  73. a.`tstm`,o.order_sn,
  74. d.dist_name goodsDistName,d2.dist_name expendDistName,g.name goodsName,
  75. t.third_party_merch_name thirdPartyMerchName,ss.child_supplier_name childSupplierName,
  76. sa.expend_dist_ids expendDistIds,sa.expend_dist_lines expendDistLines,sa.alloc_type,s1.store_name storeName,s2.store_name childStoreName
  77. from mk_dist_sell_statis a
  78. left join mk_dist_sell_allocation_history sa on a.sell_alloc_history_id = sa.sell_alloc_history_id
  79. left join mk_dist_chnl c on a.dist_chnl_id = c.dist_chnl_id
  80. left join mk_dist d on a.dist_id = d.dist_id
  81. left join mk_dist d2 on a.expend_dist_id = d2.dist_id
  82. left join mall_goods g on a.goods_id = g.id
  83. left join third_merchant_biz t on a.third_merch_sn = t.third_merch_sn
  84. left join mall_supplier ss on a.supplier_id = ss.id
  85. left join mall_order o on o.order_sn = a.order_sn
  86. left join mall_store s1 on d.store_id = s1.id
  87. left join mall_store s2 on d2.store_id = s2.id
  88. WHERE 1=1
  89. <if test="distChnlId != null and distChnlId != ''">
  90. AND a.dist_chnl_id = #{distChnlId}
  91. </if>
  92. <if test="storeId != null and storeId != ''">
  93. AND a.store_id = #{storeId}
  94. </if>
  95. <if test="distId != null and distId != ''">
  96. AND a.dist_id = #{distId}
  97. </if>
  98. <if test="goodsId != null and goodsId != ''">
  99. AND a.goods_id = #{goodsId}
  100. </if>
  101. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  102. AND a.third_merch_sn = #{thirdMerchSn}
  103. </if>
  104. <if test="merchSn != null and merchSn != ''">
  105. AND t.merch_sn = #{merchSn}
  106. </if>
  107. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode != ''">
  108. AND t.third_party_merch_code = #{thirdPartyMerchCode}
  109. </if>
  110. <if test="startTime != null and startTime != ''">
  111. AND a.create_time <![CDATA[ > ]]> #{startTime}
  112. </if>
  113. <if test="endTime != null and endTime != ''">
  114. AND a.create_time <![CDATA[ < ]]> #{endTime}
  115. </if>
  116. <choose>
  117. <when test="sidx != null and sidx.trim() != ''">
  118. order by ${sidx} ${order}
  119. </when>
  120. <otherwise>
  121. order by a.id desc
  122. </otherwise>
  123. </choose>
  124. )a
  125. GROUP BY
  126. a.dist_id ,a.expend_dist_level
  127. <if test="offset != null and limit != null">
  128. limit #{offset}, #{limit}
  129. </if>
  130. </select>
  131. <select id="queryTotal" resultType="int">
  132. select count(*) from mk_dist_sell_statis a
  133. left join mk_dist_sell_allocation_history sa on a.sell_alloc_history_id = sa.sell_alloc_history_id
  134. left join mk_dist_chnl c on a.dist_chnl_id = c.dist_chnl_id
  135. left join mk_dist d on a.dist_id = d.dist_id
  136. left join mk_dist d2 on a.expend_dist_id = d2.dist_id
  137. left join mall_goods g on a.goods_id = g.id
  138. left join third_merchant_biz t on a.third_merch_sn = t.third_merch_sn
  139. left join mall_supplier ss on a.supplier_id = ss.id
  140. left join mall_order o on o.order_sn = a.order_sn
  141. left join mall_store s1 on d.store_id = s1.id
  142. left join mall_store s2 on d2.store_id = s2.id
  143. WHERE 1=1
  144. <if test="distChnlId != null and distChnlId != ''">
  145. AND a.dist_chnl_id = #{distChnlId}
  146. </if>
  147. <if test="storeId != null and storeId != ''">
  148. AND a.store_id = #{storeId}
  149. </if>
  150. <if test="distId != null and distId != ''">
  151. AND a.dist_id = #{distId}
  152. </if>
  153. <if test="goodsId != null and goodsId != ''">
  154. AND a.goods_id = #{goodsId}
  155. </if>
  156. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  157. AND a.third_merch_sn = #{thirdMerchSn}
  158. </if>
  159. <if test="merchSn != null and merchSn != ''">
  160. AND t.merch_sn = #{merchSn}
  161. </if>
  162. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode != ''">
  163. AND t.third_party_merch_code = #{thirdPartyMerchCode}
  164. </if>
  165. <if test="startTime != null and startTime != ''">
  166. AND a.create_time <![CDATA[ > ]]> #{startTime}
  167. </if>
  168. <if test="endTime != null and endTime != ''">
  169. AND a.create_time <![CDATA[ < ]]> #{endTime}
  170. </if>
  171. </select>
  172. <select id="queryStatisExportList" resultType="com.kmall.admin.entity.mk.dist.MkDistSellStatisEntity">
  173. SELECT * FROM (
  174. select
  175. a.`id`,
  176. a.`dist_flag`,
  177. a.`third_merch_sn`,
  178. a.`supplier_id`,
  179. a.`dist_id`,
  180. a.`goods_id`,
  181. a.`goods_price`,
  182. a.`sell_alloc_history_id`,
  183. a.`expend_dist_id`,
  184. a.`expend_dist_price`,
  185. a.`expend_dist_level`,
  186. a.`expend_source`,
  187. a.`is_valid`,
  188. a.`note`,
  189. a.`creater_sn`,
  190. a.`create_time`,
  191. a.`moder_sn`,
  192. a.`mod_time`,
  193. a.`tstm`,o.order_sn,o.actual_price,
  194. d.dist_name goodsDistName,d2.dist_name expendDistName,g.name goodsName,
  195. t.third_party_merch_name thirdPartyMerchName,ss.child_supplier_name childSupplierName,
  196. sa.expend_dist_ids expendDistIds,sa.expend_dist_lines expendDistLines,sa.alloc_type,s1.store_name storeName,s2.store_name childStoreName
  197. from mk_dist_sell_statis a
  198. left join mk_dist_sell_allocation_history sa on a.sell_alloc_history_id = sa.sell_alloc_history_id
  199. left join mk_dist_chnl c on a.dist_chnl_id = c.dist_chnl_id
  200. left join mk_dist d on a.dist_id = d.dist_id
  201. left join mk_dist d2 on a.expend_dist_id = d2.dist_id
  202. left join mall_goods g on a.goods_id = g.id
  203. left join third_merchant_biz t on a.third_merch_sn = t.third_merch_sn
  204. left join mall_supplier ss on a.supplier_id = ss.id
  205. left join mall_order o on o.order_sn = a.order_sn
  206. left join mall_store s1 on d.store_id = s1.id
  207. left join mall_store s2 on d2.store_id = s2.id
  208. WHERE 1=1
  209. <if test="distChnlId != null and distChnlId != ''">
  210. AND a.dist_chnl_id = #{distChnlId}
  211. </if>
  212. <if test="storeId != null and storeId != ''">
  213. AND a.store_id = #{storeId}
  214. </if>
  215. <if test="distId != null and distId != ''">
  216. AND a.dist_id = #{distId}
  217. </if>
  218. <if test="goodsId != null and goodsId != ''">
  219. AND a.goods_id = #{goodsId}
  220. </if>
  221. <if test="thirdMerchSn != null and thirdMerchSn != ''">
  222. AND a.third_merch_sn = #{thirdMerchSn}
  223. </if>
  224. <if test="merchSn != null and merchSn != ''">
  225. AND t.merch_sn = #{merchSn}
  226. </if>
  227. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode != ''">
  228. AND t.third_party_merch_code = #{thirdPartyMerchCode}
  229. </if>
  230. <if test="startTime != null and startTime != ''">
  231. AND a.create_time <![CDATA[ > ]]> #{startTime}
  232. </if>
  233. <if test="endTime != null and endTime != ''">
  234. AND a.create_time <![CDATA[ < ]]> #{endTime}
  235. </if>
  236. ORDER BY a.id
  237. )a
  238. GROUP BY
  239. a.dist_id ,a.expend_dist_level
  240. </select>
  241. <insert id="save" parameterType="com.kmall.admin.entity.mk.dist.MkDistSellStatisEntity" useGeneratedKeys="true" keyProperty="id">
  242. insert into mk_dist_sell_statis(
  243. `dist_flag`,
  244. `third_merch_sn`,
  245. `supplier_id`,
  246. `dist_id`,
  247. order_sn,
  248. `goods_id`,
  249. `goods_price`,
  250. `sell_alloc_history_id`,
  251. `expend_dist_id`,
  252. `expend_dist_price`,
  253. `expend_dist_level`,
  254. `expend_source`,
  255. `is_valid`,
  256. `note`,
  257. `creater_sn`,
  258. `create_time`,
  259. `moder_sn`,
  260. `mod_time`,
  261. `tstm`)
  262. values(
  263. #{distFlag},
  264. #{thirdMerchSn},
  265. #{supplierId},
  266. #{distId},
  267. #{orderSn},
  268. #{goodsId},
  269. #{goodsPrice},
  270. #{sellAllocHistoryId},
  271. #{expendDistId},
  272. #{expendDistPrice},
  273. #{expendDistLevel},
  274. #{expendSource},
  275. #{isValid},
  276. #{note},
  277. #{createrSn},
  278. #{createTime},
  279. #{moderSn},
  280. #{modTime},
  281. #{tstm})
  282. </insert>
  283. <update id="update" parameterType="com.kmall.admin.entity.mk.dist.MkDistSellStatisEntity">
  284. update mk_dist_sell_statis
  285. <set>
  286. <if test="distFlag != null">`dist_flag` = #{distFlag}, </if>
  287. <if test="thirdMerchSn != null">`third_merch_sn` = #{thirdMerchSn}, </if>
  288. <if test="supplierId != null">`supplier_id` = #{supplierId}, </if>
  289. <if test="distId != null">`dist_id` = #{distId}, </if>
  290. <if test="orderSn != null">`order_sn` = #{orderSn}, </if>
  291. <if test="goodsId != null">`goods_id` = #{goodsId}, </if>
  292. <if test="goodsPrice != null">`goods_price` = #{goodsPrice}, </if>
  293. <if test="sellAllocHistoryId != null">`sell_alloc_history_id` = #{sellAllocHistoryId}, </if>
  294. <if test="expendDistId != null">`expend_dist_id` = #{expendDistId}, </if>
  295. <if test="expendDistPrice != null">`expend_dist_price` = #{expendDistPrice}, </if>
  296. <if test="expendDistLevel != null">`expend_dist_level` = #{expendDistLevel}, </if>
  297. <if test="expendSource != null">`expend_source` = #{expendSource}, </if>
  298. <if test="isValid != null">`is_valid` = #{isValid}, </if>
  299. <if test="note != null">`note` = #{note}, </if>
  300. <if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
  301. <if test="createTime != null">`create_time` = #{createTime}, </if>
  302. <if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
  303. <if test="modTime != null">`mod_time` = #{modTime}, </if>
  304. <if test="tstm != null">`tstm` = #{tstm}</if>
  305. </set>
  306. where id = #{id}
  307. </update>
  308. <delete id="delete">
  309. delete from mk_dist_sell_statis where id = #{value}
  310. </delete>
  311. <delete id="deleteBatch">
  312. delete from mk_dist_sell_statis where id in
  313. <foreach item="id" collection="array" open="(" separator="," close=")">
  314. #{id}
  315. </foreach>
  316. </delete>
  317. </mapper>