Bläddra i källkod

增加財務訂單管理

周箭河 5 år sedan
förälder
incheckning
fa476a5c88

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -259,8 +259,9 @@ public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrde
 
     /**
      * 统计收款金额
+     *
      * @param merNo
      * @return
      */
-    BigDecimal sumPerAccountAmount(String merNo);
+    BigDecimal sumPerAccountAmount(@Param("merNo") String merNo, @Param("firstDate") Date firstDate);
 }

+ 7 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysAccountServiceImpl.java

@@ -7,11 +7,13 @@ import com.ym.mec.biz.dal.entity.SysArea;
 import com.ym.mec.biz.service.SysAccountService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.date.DateUtil;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.Date;
 import java.util.List;
 
 @Service
@@ -40,7 +42,10 @@ public class SysAccountServiceImpl extends BaseServiceImpl<Integer, SysAccount>
     @Override
     public SysAccount getPerAccount(String channel, SysAccount account) {
         BigDecimal maxReceive = new BigDecimal("75000");
-        BigDecimal amount = studentPaymentOrderDao.sumPerAccountAmount(account.getRoutingMerNo());
+        Date nowDate = new Date();
+        Date firstDayOfMonth = DateUtil.getFirstDayOfMonth(nowDate);
+
+        BigDecimal amount = studentPaymentOrderDao.sumPerAccountAmount(account.getRoutingMerNo(),firstDayOfMonth);
 
         if (amount == null || amount.compareTo(maxReceive) < 0) {
             return account;
@@ -49,7 +54,7 @@ public class SysAccountServiceImpl extends BaseServiceImpl<Integer, SysAccount>
         SysAccount newAccount = null;
         List<SysAccount> perAccounts = sysAccountDao.getPerAccount(channel);
         for (SysAccount perAccount : perAccounts) {
-            amount = studentPaymentOrderDao.sumPerAccountAmount(perAccount.getRoutingMerNo());
+            amount = studentPaymentOrderDao.sumPerAccountAmount(perAccount.getRoutingMerNo(),firstDayOfMonth);
             if (amount == null || amount.compareTo(maxReceive) < 0) {
                 newAccount = perAccount;
                 break;

+ 65 - 34
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -83,16 +83,19 @@
     <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.StudentPaymentOrder" useGeneratedKeys="true"
             keyColumn="id" keyProperty="id">
         INSERT INTO student_payment_order
-        (id_, group_type_, user_id_,organ_id_,routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_, per_amount_,
+        (id_, group_type_, user_id_, organ_id_, routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_,
+         per_amount_,
          balance_payment_amount_, remit_fee_, trans_no_,
          status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
          payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_)
         VALUES (#{id}, #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-                #{userId},#{organId},#{routingOrganId}, #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+                #{userId}, #{organId}, #{routingOrganId},
+                #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
                 #{expectAmount}, #{actualAmount}, #{comAmount}, #{perAmount}, #{balancePaymentAmount},
                 #{remitFee}, #{transNo},
                 #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, now(), now(),
-                #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo}, #{musicGroupId},
+                #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo},
+                #{musicGroupId},
                 #{classGroupId})
     </insert>
 
@@ -251,15 +254,13 @@
                               #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler})
     </select>
     <select id="queryByCondition" resultMap="StudentPaymentOrder" parameterType="map">
-        SELECT
-        spo.*
-        FROM
-        student_payment_order spo
-        WHERE spo.user_id_=#{userId}
-        AND spo.music_group_id_=#{musicGroupId}
-        AND spo.status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-        AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-        and spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        SELECT spo.*
+        FROM student_payment_order spo
+        WHERE spo.user_id_ = #{userId}
+          AND spo.music_group_id_ = #{musicGroupId}
+          AND spo.status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+          AND spo.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+          and spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
     </select>
     <select id="findByStudentVipGroup" resultMap="StudentPaymentOrder">
         SELECT
@@ -347,9 +348,11 @@
     </select>
 
     <select id="findOrdersByStatus" resultMap="StudentPaymentOrder">
-        SELECT * FROM student_payment_order
+        SELECT *
+        FROM student_payment_order
         WHERE status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-        AND payment_channel_ = #{paymentChannel} LIMIT 100
+          AND payment_channel_ = #{paymentChannel}
+        LIMIT 100
     </select>
 
     <!-- 查询支付中超时订单 -->
@@ -382,7 +385,7 @@
         FROM student_payment_order
         WHERE group_type_ = #{groupType}
           AND music_group_id_ = #{musicGroupId}
-          AND status_='SUCCESS'
+          AND status_ = 'SUCCESS'
     </select>
     <select id="findStudentPaymentOrder" resultMap="StudentPaymentOrder">
         SELECT *
@@ -416,7 +419,13 @@
     </select>
 
     <select id="findFixOrder" resultMap="StudentPaymentOrder">
-        SELECT * FROM student_payment_order where status_ ='SUCCESS' AND type_='APPLY' AND actual_amount_> 0 and mer_nos_ IS NULL LIMIT 100
+        SELECT *
+        FROM student_payment_order
+        where status_ = 'SUCCESS'
+          AND type_ = 'APPLY'
+          AND actual_amount_ > 0
+          and mer_nos_ IS NULL
+        LIMIT 100
     </select>
 
 
@@ -439,7 +448,8 @@
 
     <!-- 分页查询 -->
     <select id="ExportQueryPage" resultMap="orderAndDetail" parameterType="map">
-        SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_ detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
+        SELECT spo.*,u.username_,spod.id_ detail_id_,spod.type_ detail_type_,spod.price_
+        detail_price_,spod.kit_group_purchase_type_ detail_kit_group_purchase_type_,
         o.name_ organ_name,sci.charge_type_,g.id_ goods_id, g.name_ goods_name FROM student_payment_order spo
         LEFT JOIN sys_user u on spo.user_id_ = u.id_
         LEFT JOIN student_payment_order_detail spod on spo.id_ = spod.payment_order_id_
@@ -500,22 +510,37 @@
         <result property="money" column="money"/>
     </resultMap>
     <select id="getLuckStatis" resultMap="luckStatis">
-        SELECT o.name_ organName, SUM(spo.actual_amount_) money ,COUNT(spo.id_) nums FROM student_payment_order spo LEFT JOIN organization o ON o.id_=spo.organ_id_
-        WHERE spo.type_='LUCK' AND spo.status_='SUCCESS' GROUP BY spo.organ_id_ ORDER BY nums DESC;
+        SELECT o.name_ organName, SUM(spo.actual_amount_) money, COUNT(spo.id_) nums
+        FROM student_payment_order spo
+                 LEFT JOIN organization o ON o.id_ = spo.organ_id_
+        WHERE spo.type_ = 'LUCK'
+          AND spo.status_ = 'SUCCESS'
+        GROUP BY spo.organ_id_
+        ORDER BY nums DESC;
     </select>
-    
+
     <select id="queryIncomeStatisticsWithCurrentMonth" resultType="map">
-    	select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
-    	where actual_amount_ &gt; 0 and DATE_FORMAT(create_time_, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' )  AND status_ = 'SUCCESS'
-   		<if test="organId != null">
-   			and FIND_IN_SET(organ_id_,#{organId})
-   		</if>
-  	</select>
+        select count(*) total,sum(actual_amount_) total_num_ from student_payment_order
+        where actual_amount_ &gt; 0 and DATE_FORMAT(create_time_, '%Y%m' ) = DATE_FORMAT( CURDATE() , '%Y%m' ) AND
+        status_ = 'SUCCESS'
+        <if test="organId != null">
+            and FIND_IN_SET(organ_id_,#{organId})
+        </if>
+    </select>
     <select id="countUserBuyVipGroupSuccessOrder" resultType="int">
-      select count(*) from student_payment_order where  user_id_=#{userId} and music_group_id_=#{vipGroupId} and group_type_='VIP' and status_='SUCCESS'
+        select count(*)
+        from student_payment_order
+        where user_id_ = #{userId}
+          and music_group_id_ = #{vipGroupId}
+          and group_type_ = 'VIP'
+          and status_ = 'SUCCESS'
     </select>
     <select id="findUserBuyVipGroupOrder" resultMap="StudentPaymentOrder">
-      select * from student_payment_order where  user_id_=#{userId} and music_group_id_=#{vipGroupId} and group_type_='VIP'
+        select *
+        from student_payment_order
+        where user_id_ = #{userId}
+          and music_group_id_ = #{vipGroupId}
+          and group_type_ = 'VIP'
     </select>
     <select id="findUserGroupOrders" resultMap="StudentPaymentOrder">
         select * from student_payment_order
@@ -543,13 +568,19 @@
     <select id="findOrderByGroup" resultMap="StudentPaymentOrder">
         SELECT * FROM student_payment_order
         WHERE music_group_id_=#{groupId}
-            and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-            <if test="status!=null">
-                and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-            </if>
+        and group_type_=#{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        <if test="status!=null">
+            and status_=#{status, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        </if>
     </select>
 
-    <select id="sumPerAccountAmount" resultType="java.math.BigDecimal">
-        SELECT SUM(per_amount_) FROM student_payment_order WHERE FIND_IN_SET(status_,'SUCCESS,ING') AND FIND_IN_SET(#{merNo},mer_nos_)
+    <select id="sumPerAccountAmount" resultType="java.math.BigDecimal"><![CDATA[
+        SELECT SUM(per_amount_)
+        FROM student_payment_order
+        WHERE FIND_IN_SET(status_, 'SUCCESS,ING')
+          AND create_time_ >= #{firstDate}
+          AND create_time_ <= NOW()
+          AND FIND_IN_SET(#{merNo}, mer_nos_)
+        ]]>
     </select>
 </mapper>