SellOrderMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  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.ym.mec.biz.dal.dao.SellOrderDao">
  4. <resultMap id="SellOrder" type="com.ym.mec.biz.dal.entity.SellOrder">
  5. <!--@mbg.generated-->
  6. <!--@Table sell_order-->
  7. <id column="id_" property="id"/>
  8. <result column="organ_id_" property="organId"/>
  9. <result column="edu_teacher_id_" property="eduTeacherId"/>
  10. <result column="eduTeacher" property="eduTeacher"/>
  11. <result column="cooperation_organ_id_" property="cooperationOrganId"/>
  12. <result column="school_name_" property="schoolName"/>
  13. <result column="trans_no_" property="transNo"/>
  14. <result column="order_no_" property="orderNo"/>
  15. <result column="order_id_" property="orderId"/>
  16. <result column="expect_amount_" property="expectAmount"/>
  17. <result column="actual_amount_" property="actualAmount"/>
  18. <result column="balance_amount_" property="balanceAmount"/>
  19. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  20. <result column="parent_goods_id_" property="parentGoodsId"/>
  21. <result column="goods_id_" property="goodsId"/>
  22. <result column="goods_name_" property="goodsName"/>
  23. <result column="sell_cost_" property="sellCost"/>
  24. <result column="sell_cost2_" property="sellCost2"/>
  25. <result column="num_" property="num"/>
  26. <result column="user_id_" property="userId"/>
  27. <result column="user_name_" property="userName"/>
  28. <result column="phone_" property="phone"/>
  29. <result column="organ_name_" property="organName"/>
  30. <result column="user_id_" property="userId"/>
  31. <result column="payment_channel_" property="paymentChannel"/>
  32. <result column="mer_no_" property="merNo"/>
  33. <result column="batch_no_" property="batchNo"/>
  34. <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  35. <result column="sell_time_" property="sellTime"/>
  36. <result column="create_ime_" property="createIme"/>
  37. <result column="update_time_" property="updateTime"/>
  38. <result column="receive_status_" property="receiveStatus"/>
  39. <result column="stock_type_" property="stockType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
  40. <result column="account_type_" property="accountType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
  41. </resultMap>
  42. <sql id="Base_Column_List">
  43. <!--@mbg.generated-->
  44. id_, edu_teacher_id_,organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_, expect_amount_,
  45. actual_amount_,balance_amount_, sell_cost_, sell_cost2_, type_,parent_goods_id_, goods_id_,goods_name_, num_,
  46. user_id_,
  47. payment_channel_,mer_no_,batch_no_,stock_type_,account_type_,status_, sell_time_, create_ime_, update_time_
  48. </sql>
  49. <select id="get" parameterType="java.lang.Integer" resultMap="SellOrder">
  50. <!--@mbg.generated-->
  51. select
  52. <include refid="Base_Column_List"/>
  53. from sell_order
  54. where id_ = #{id}
  55. </select>
  56. <delete id="delete" parameterType="java.lang.Integer">
  57. <!--@mbg.generated-->
  58. delete from sell_order
  59. where id_ = #{id}
  60. </delete>
  61. <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.SellOrder"
  62. useGeneratedKeys="true">
  63. <!--@mbg.generated-->
  64. insert into sell_order (edu_teacher_id_,organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_,
  65. expect_amount_,actual_amount_,balance_amount_, type_,parent_goods_id_, goods_id_,goods_name_, sell_cost_,
  66. sell_cost2_, num_, user_id_, payment_channel_,
  67. mer_no_,batch_no_,stock_type_,account_type_, sell_time_, create_ime_, update_time_)
  68. values (#{eduTeacherId},#{organId}, #{cooperationOrganId}, #{transNo}, #{orderNo},#{orderId}, #{expectAmount},
  69. #{actualAmount}, #{balanceAmount}, #{type},#{parentGoodsId}, #{goodsId}, #{goodsName}, #{sellCost},
  70. #{sellCost2}, #{num}, #{userId},
  71. #{paymentChannel}, #{merNo},#{batchNo},
  72. #{stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{accountType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  73. #{sellTime}, #{createIme}, #{updateTime})
  74. </insert>
  75. <update id="update" parameterType="com.ym.mec.biz.dal.entity.SellOrder">
  76. <!--@mbg.generated-->
  77. update sell_order
  78. <set>
  79. <if test="eduTeacherId != null">
  80. edu_teacher_id_ = #{eduTeacherId},
  81. </if>
  82. <if test="organId != null">
  83. organ_id_ = #{organId},
  84. </if>
  85. <if test="cooperationOrganId != null">
  86. cooperation_organ_id_ = #{cooperationOrganId},
  87. </if>
  88. <if test="transNo != null">
  89. trans_no_ = #{transNo},
  90. </if>
  91. <if test="orderId != null">
  92. order_id_ = #{orderId},
  93. </if>
  94. <if test="orderNo != null">
  95. order_no_ = #{orderNo},
  96. </if>
  97. <if test="expectAmount != null">
  98. expect_amount_ = #{expectAmount},
  99. </if>
  100. <if test="actualAmount != null">
  101. actual_amount_ = #{actualAmount},
  102. </if>
  103. <if test="balanceAmount != null">
  104. balance_amount_ = #{balanceAmount},
  105. </if>
  106. <if test="type != null">
  107. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  108. </if>
  109. <if test="parentGoodsId != null">
  110. parent_goods_id_ = #{parentGoodsId},
  111. </if>
  112. <if test="goodsId != null">
  113. goods_id_ = #{goodsId},
  114. </if>
  115. <if test="goodsName != null">
  116. goods_name_ = #{goodsName},
  117. </if>
  118. <if test="sellCost != null">
  119. sell_cost_ = #{sellCost},
  120. </if>
  121. <if test="sellCost2 != null">
  122. sell_cost2_ = #{sellCost2},
  123. </if>
  124. <if test="num != null">
  125. num_ = #{num},
  126. </if>
  127. <if test="userId != null">
  128. user_id_ = #{userId},
  129. </if>
  130. <if test="paymentChannel != null">
  131. payment_channel_ = #{paymentChannel},
  132. </if>
  133. <if test="merNo != null">
  134. mer_no_ = #{merNo},
  135. </if>
  136. <if test="batchNo != null">
  137. batch_no_ = #{batchNo},
  138. </if>
  139. <if test="stockType != null">
  140. stock_type_ = #{stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  141. </if>
  142. <if test="accountType != null">
  143. account_type_ = #{accountType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  144. </if>
  145. <if test="status != null">
  146. status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  147. </if>
  148. <if test="sellTime != null">
  149. sell_time_ = #{sellTime},
  150. </if>
  151. <if test="createIme != null">
  152. create_ime_ = #{createIme},
  153. </if>
  154. <if test="updateTime != null">
  155. update_time_ = #{updateTime},
  156. </if>
  157. </set>
  158. where id_ = #{id}
  159. </update>
  160. <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.SellOrder">
  161. <foreach collection="sellOrders" item="sellOrder" separator=";">
  162. update sell_order
  163. <set>
  164. <if test="sellOrder.eduTeacherId != null">
  165. edu_teacher_id_ = #{sellOrder.eduTeacherId},
  166. </if>
  167. <if test="sellOrder.organId != null">
  168. organ_id_ = #{sellOrder.organId},
  169. </if>
  170. <if test="sellOrder.cooperationOrganId != null">
  171. cooperation_organ_id_ = #{sellOrder.cooperationOrganId},
  172. </if>
  173. <if test="sellOrder.transNo != null">
  174. trans_no_ = #{sellOrder.transNo},
  175. </if>
  176. <if test="sellOrder.orderId != null">
  177. order_id_ = #{sellOrder.orderId},
  178. </if>
  179. <if test="sellOrder.orderNo != null">
  180. order_no_ = #{sellOrder.orderNo},
  181. </if>
  182. <if test="sellOrder.expectAmount != null">
  183. expect_amount_ = #{sellOrder.expectAmount},
  184. </if>
  185. <if test="sellOrder.actualAmount != null">
  186. actual_amount_ = #{sellOrder.actualAmount},
  187. </if>
  188. <if test="sellOrder.balanceAmount != null">
  189. balance_amount_ = #{sellOrder.balanceAmount},
  190. </if>
  191. <if test="sellOrder.type != null">
  192. type_ = #{sellOrder.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  193. </if>
  194. <if test="sellOrder.parentGoodsId != null">
  195. parent_goods_id_ = #{sellOrder.parentGoodsId},
  196. </if>
  197. <if test="sellOrder.goodsId != null">
  198. goods_id_ = #{sellOrder.goodsId},
  199. </if>
  200. <if test="sellOrder.goodsName != null">
  201. goods_name_ = #{sellOrder.goodsName},
  202. </if>
  203. <if test="sellOrder.sellCost != null">
  204. sell_cost_ = #{sellOrder.sellCost},
  205. </if>
  206. <if test="sellOrder.sellCost2 != null">
  207. sell_cost2_ = #{sellOrder.sellCost2},
  208. </if>
  209. <if test="sellOrder.num != null">
  210. num_ = #{sellOrder.num},
  211. </if>
  212. <if test="sellOrder.userId != null">
  213. user_id_ = #{sellOrder.userId},
  214. </if>
  215. <if test="sellOrder.paymentChannel != null">
  216. payment_channel_ = #{sellOrder.paymentChannel},
  217. </if>
  218. <if test="sellOrder.merNo != null">
  219. mer_no_ = #{sellOrder.merNo},
  220. </if>
  221. <if test="sellOrder.batchNo != null">
  222. batch_no_ = #{sellOrder.batchNo},
  223. </if>
  224. <if test="sellOrder.stockType != null">
  225. stock_type_ = #{sellOrder.stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  226. </if>
  227. <if test="sellOrder.accountType != null">
  228. account_type_ = #{sellOrder.accountType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  229. </if>
  230. <if test="sellOrder.status != null">
  231. status_ = #{sellOrder.status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  232. </if>
  233. <if test="sellOrder.sellTime != null">
  234. sell_time_ = #{sellOrder.sellTime},
  235. </if>
  236. <if test="sellOrder.createIme != null">
  237. create_ime_ = #{sellOrder.createIme},
  238. </if>
  239. update_time_ = NOW()
  240. </set>
  241. where id_ = #{sellOrder.id}
  242. </foreach>
  243. </update>
  244. <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
  245. insert into sell_order (organ_id_, cooperation_organ_id_, trans_no_,order_id_, order_no_, expect_amount_,
  246. actual_amount_,balance_amount_, type_, parent_goods_id_, goods_id_,goods_name_, sell_cost_, sell_cost2_, num_,
  247. user_id_, payment_channel_,
  248. mer_no_,batch_no_,stock_type_,account_type_, sell_time_,edu_teacher_id_, create_ime_, update_time_)
  249. VALUE
  250. <foreach collection="sellOrders" separator="," item="sellOrder">
  251. (#{sellOrder.organId},#{sellOrder.cooperationOrganId},#{sellOrder.transNo},#{sellOrder.orderId},#{sellOrder.orderNo},
  252. #{sellOrder.expectAmount},#{sellOrder.actualAmount},#{sellOrder.balanceAmount},#{sellOrder.type},#{sellOrder.parentGoodsId},#{sellOrder.goodsId},
  253. #{sellOrder.goodsName},#{sellOrder.sellCost},#{sellOrder.sellCost2},#{sellOrder.num},#{sellOrder.userId},
  254. #{sellOrder.paymentChannel},#{sellOrder.merNo},#{sellOrder.batchNo},
  255. #{sellOrder.stockType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{sellOrder.accountType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  256. #{sellOrder.sellTime},#{sellOrder.eduTeacherId},NOW(),NOW())
  257. </foreach>
  258. </insert>
  259. <!-- 分页查询 -->
  260. <select id="queryPage" resultMap="SellOrder" parameterType="map">
  261. SELECT so.*,su.username_ user_name_,su.phone_,o.name_ organ_name_,co.name_ school_name_,t.real_name_
  262. eduTeacher,spo.receive_status_
  263. FROM sell_order so
  264. LEFT JOIN sys_user su ON so.user_id_ = su.id_
  265. LEFT JOIN organization o ON o.id_ = so.organ_id_
  266. LEFT JOIN cooperation_organ co ON co.id_= so.cooperation_organ_id_
  267. LEFT JOIN sys_user t ON t.id_ = so.edu_teacher_id_
  268. LEFT JOIN student_payment_order spo ON so.order_id_ = spo.id_
  269. <include refid="queryPageSql"/>
  270. ORDER BY so.create_ime_ DESC
  271. <include refid="global.limit"/>
  272. </select>
  273. <!-- 查询当前表的总记录数 -->
  274. <select id="queryCount" resultType="int">
  275. SELECT COUNT(*) FROM sell_order so
  276. LEFT JOIN student_payment_order spo ON so.order_id_ = spo.id_
  277. <include refid="queryPageSql"/>
  278. </select>
  279. <sql id="queryPageSql">
  280. <where>
  281. <if test="search != null and search != ''">
  282. AND (so.order_no_ = #{search} OR so.trans_no_ = #{search})
  283. </if>
  284. <if test="organIdList != null and organIdList != ''">
  285. AND FIND_IN_SET(so.organ_id_,#{organIdList})
  286. </if>
  287. <if test="goodsName != null and goodsName != ''">
  288. AND so.goods_name_ LIKE CONCAT('%',#{goodsName},'%')
  289. </if>
  290. <if test="cooperationOrganId != null">
  291. AND so.cooperation_organ_id_ = #{cooperationOrganId}
  292. </if>
  293. <if test="status != null">
  294. AND so.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  295. </if>
  296. <if test="type != null">
  297. AND so.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  298. </if>
  299. <if test="receiveStatus != null and receiveStatus != ''">
  300. AND spo.receive_status_ = #{receiveStatus}
  301. </if>
  302. <if test="startTime != null">
  303. AND so.sell_time_ >= #{startTime}
  304. </if>
  305. <if test="endTime != null">
  306. AND so.sell_time_ &lt;= #{endTime}
  307. </if>
  308. </where>
  309. </sql>
  310. <!-- 获取分部学校的收入支出(乐团订单) -->
  311. <select id="getMusicGroupMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
  312. SELECT spo.organ_id_,
  313. co.id_ cooperation_organ_id_,
  314. SUM(so.actual_amount_) sell_amount_,
  315. SUM(so.sell_cost_ * so.num_) sell_cost_
  316. FROM student_payment_order spo
  317. LEFT JOIN sell_order so on so.order_id_ = spo.id_
  318. LEFT JOIN music_group mg ON mg.id_ = spo.music_group_id_
  319. LEFT JOIN cooperation_organ co ON co.id_ = mg.cooperation_organ_id_
  320. WHERE spo.status_ = 'SUCCESS'
  321. AND spo.group_type_ = 'MUSIC'
  322. AND spo.create_time_ >= #{startTime}
  323. AND spo.create_time_ <= #{endTime}
  324. GROUP BY spo.organ_id_, co.id_
  325. ]]></select>
  326. <select id="getMusicGroupIncome" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
  327. SELECT spo.organ_id_,
  328. co.id_ cooperation_organ_id_,
  329. SUM(spo.actual_amount_) income_total_
  330. FROM student_payment_order spo
  331. LEFT JOIN music_group mg ON mg.id_ = spo.music_group_id_
  332. LEFT JOIN cooperation_organ co ON co.id_ = mg.cooperation_organ_id_
  333. WHERE spo.status_ = 'SUCCESS'
  334. AND spo.group_type_ = 'MUSIC'
  335. AND spo.create_time_ >= #{startTime}
  336. AND spo.create_time_ <= #{endTime}
  337. GROUP BY spo.organ_id_, co.id_
  338. ]]></select>
  339. <!-- 获取分部学校的收入支出(VIP,网管课) -->
  340. <select id="getMusicVipPracticeMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
  341. SELECT spo.organ_id_,
  342. co.id_ cooperation_organ_id_,
  343. SUM(spo.actual_amount_) income_total_
  344. FROM student_payment_order spo
  345. LEFT JOIN
  346. (SELECT MIN(music_group_id_) music_group_id_, user_id_
  347. FROM student_registration
  348. WHERE music_group_status_ = 'NORMAL'
  349. GROUP BY user_id_) sr
  350. ON sr.user_id_ = spo.user_id_
  351. LEFT JOIN music_group mg ON mg.id_ = sr.music_group_id_
  352. LEFT JOIN cooperation_organ co ON co.id_ = mg.cooperation_organ_id_
  353. WHERE spo.status_ = 'SUCCESS'
  354. AND spo.group_type_ IN ('VIP', 'PRACTICE')
  355. AND spo.create_time_ >= #{startTime}
  356. AND spo.create_time_ <= #{endTime}
  357. GROUP BY spo.organ_id_, co.id_
  358. ]]></select>
  359. <!-- 获取分部学校的收入支出(外部添加订单) -->
  360. <select id="getOutOrderMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
  361. SELECT spo.organ_id_,
  362. co.id_ cooperation_organ_id_,
  363. SUM(so.actual_amount_) sell_amount_,
  364. SUM(so.sell_cost_ * so.num_) sell_cost_
  365. FROM student_payment_order spo
  366. LEFT JOIN sell_order so on so.order_id_ = spo.id_
  367. LEFT JOIN cooperation_organ co ON co.id_ = spo.music_group_id_
  368. WHERE spo.status_ = 'SUCCESS'
  369. AND spo.group_type_ = 'OUTORDER'
  370. AND spo.create_time_ >= #{startTime}
  371. AND spo.create_time_ <= #{endTime}
  372. GROUP BY spo.organ_id_, co.id_
  373. ]]></select>
  374. <!-- 获取分部学校的收入支出(外部添加订单) -->
  375. <select id="getOutOrderIncome" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
  376. SELECT spo.organ_id_,
  377. co.id_ cooperation_organ_id_,
  378. SUM(spo.actual_amount_) income_total_
  379. FROM student_payment_order spo
  380. LEFT JOIN cooperation_organ co ON co.id_ = spo.music_group_id_
  381. WHERE spo.status_ = 'SUCCESS'
  382. AND spo.group_type_ = 'OUTORDER'
  383. AND spo.create_time_ >= #{startTime}
  384. AND spo.create_time_ <= #{endTime}
  385. GROUP BY spo.organ_id_, co.id_
  386. ]]></select>
  387. <!-- 获取分部学校的收入(充值) -->
  388. <select id="getRechargeMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
  389. SELECT spo.organ_id_,
  390. co.id_ cooperation_organ_id_,
  391. SUM(spo.actual_amount_) income_total_,
  392. SUM(spo.actual_amount_) other_income_
  393. FROM student_payment_order spo
  394. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  395. LEFT JOIN music_group mg ON mg.id_ = sci.music_group_id_
  396. LEFT JOIN cooperation_organ co ON co.id_ = mg.cooperation_organ_id_
  397. WHERE spo.status_ = 'SUCCESS'
  398. AND spo.group_type_ = 'SPORADIC'
  399. AND sci.charge_type_ = '9'
  400. AND spo.create_time_ >= #{startTime}
  401. AND spo.create_time_ <= #{endTime}
  402. GROUP BY spo.organ_id_, co.id_
  403. ]]></select>
  404. <!-- 获取分部学校的收入(零星支付) -->
  405. <select id="getSporadicMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
  406. SELECT spo.organ_id_,
  407. co.id_ cooperation_organ_id_,
  408. SUM(spo.actual_amount_) income_total_
  409. FROM student_payment_order spo
  410. LEFT JOIN sporadic_charge_info sci ON sci.id_ = spo.music_group_id_
  411. LEFT JOIN music_group mg ON mg.id_ = sci.music_group_id_
  412. LEFT JOIN cooperation_organ co ON co.id_ = mg.cooperation_organ_id_
  413. WHERE spo.status_ = 'SUCCESS'
  414. AND spo.group_type_ = 'SPORADIC'
  415. AND sci.charge_type_ != '9'
  416. AND spo.create_time_ >= #{startTime}
  417. AND spo.create_time_ <= #{endTime}
  418. GROUP BY spo.organ_id_, co.id_
  419. ]]></select>
  420. <!-- 获取分部学校的收入支出(声部更改、维修、商品销售订单) -->
  421. <select id="getRepairGoodsSellGroupMonthReport"
  422. resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
  423. SELECT spo.organ_id_,
  424. SUM(so.actual_amount_) sell_amount_,
  425. SUM(so.sell_cost_ * so.num_) sell_cost_
  426. FROM student_payment_order spo
  427. LEFT JOIN sell_order so on so.order_id_ = spo.id_
  428. WHERE spo.status_ = 'SUCCESS'
  429. AND spo.group_type_ IN ('REPAIR', 'GOODS_SELL','SUBJECT_CHANGE')
  430. AND spo.create_time_ >= #{startTime}
  431. AND spo.create_time_ <= #{endTime}
  432. GROUP BY spo.organ_id_
  433. ]]></select>
  434. <!-- 获取分部学校的收入支出(声部更改、维修、商品销售订单) -->
  435. <select id="getRepairGoodsSellGroupIncome"
  436. resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
  437. SELECT spo.organ_id_,
  438. SUM(spo.actual_amount_) income_total_
  439. FROM student_payment_order spo
  440. WHERE spo.status_ = 'SUCCESS'
  441. AND spo.group_type_ IN ('REPAIR', 'GOODS_SELL','SUBJECT_CHANGE')
  442. AND spo.create_time_ >= #{startTime}
  443. AND spo.create_time_ <= #{endTime}
  444. GROUP BY spo.organ_id_
  445. ]]></select>
  446. <!-- 获取订单的销售列表 -->
  447. <select id="getOrderSellOrder" resultMap="SellOrder">
  448. SELECT *
  449. FROM sell_order
  450. WHERE order_id_ = #{orderId}
  451. </select>
  452. <delete id="deleteByOrderId">
  453. DELETE
  454. FROM sell_order
  455. WHERE order_id_ = #{orderId}
  456. </delete>
  457. <select id="getOrderSellCost" resultType="decimal">
  458. SELECT SUM(sell_cost_ * num_)
  459. FROM sell_order
  460. WHERE order_id_ = #{orderId}
  461. </select>
  462. <select id="getSubjectChangeMonthReport" resultMap="com.ym.mec.biz.dal.dao.OperatingReportDao.OperatingReport"><![CDATA[
  463. SELECT sc.organ_id_,
  464. sc.cooperation_organ_id_,
  465. SUM(spo.actual_amount_) income_total_,
  466. SUM(sc.sell_amount_) sell_amount_,
  467. SUM(sc.cost_margin_) sell_cost_
  468. FROM subject_change sc
  469. LEFT JOIN student_payment_order spo ON spo.id_ = sc.order_id_
  470. WHERE sc.status_ = 2
  471. AND sc.sell_time_ >= #{startTime}
  472. AND sc.sell_time_ <= #{endTime}
  473. GROUP BY sc.organ_id_, sc.cooperation_organ_id_
  474. ]]></select>
  475. <select id="getSellOrders" resultMap="SellOrder">
  476. SELECT * FROM sell_order WHERE id_ IN
  477. <foreach collection="sellOrderIds" item="id" open="(" close=")" separator=",">
  478. #{id}
  479. </foreach>
  480. </select>
  481. <select id="getSellOrderByParentGoodsId" resultMap="SellOrder">
  482. SELECT * FROM sell_order WHERE order_id_ = #{orderId}
  483. <if test="parentGoodsId != null">
  484. AND parent_goods_id_ = #{parentGoodsId}
  485. </if>
  486. </select>
  487. <select id="getNoneBatchNoSellOrders" resultMap="SellOrder">
  488. SELECT * FROM sell_order WHERE status_ = 0 AND stock_type_ IS NOT NULL AND batch_no_ IS NULL
  489. </select>
  490. </mapper>