|
|
@@ -317,7 +317,7 @@
|
|
|
</update>
|
|
|
<!-- 定时插入上月的签单数据 -->
|
|
|
<insert id="insertLastMonthOrderData" parameterType="java.lang.String">
|
|
|
- INSERT INTO t_order_month_report(`type`,`month`,amount,proof_count,salemans_id)
|
|
|
+ REPLACE INTO t_order_month_report(`type`,`month`,amount,proof_count,salemans_id)
|
|
|
select o.order_type, date_format(DATE_ADD(NOW(),INTERVAL -1 MONTH),'%Y%m'),sum(o.total_amount), sum(o.proof_count), o.salesman_id
|
|
|
from t_order_new o
|
|
|
where 1 = 1
|
|
|
@@ -327,9 +327,9 @@
|
|
|
</insert>
|
|
|
<!-- 定时插入上一年的数据 -->
|
|
|
<insert id="insertLastYearOrderData" parameterType="java.lang.String">
|
|
|
- INSERT INTO t_order_year_report(`type`,`year`,amount,proof_count,salemans_id)
|
|
|
- select m.`type`, m.`year`, sum(amount), sum(proof_count), salemans_id from t_order_month_report m
|
|
|
- where m.`year` = year(date_sub(now(),interval 1 year))
|
|
|
+ REPLACE INTO t_order_year_report(`type`,`year`,amount,proof_count,salemans_id)
|
|
|
+ select m.`type`, year(date_sub(now(),interval 1 year)), sum(amount), sum(proof_count), salemans_id from t_order_month_report m
|
|
|
+ where CAST(`month` as CHAR) like concat (year(date_sub(now(),interval 1 year)),'%')
|
|
|
group by m.salemans_id , m.`type`
|
|
|
</insert>
|
|
|
<!-- 查看订单统计数据 -->
|
|
|
@@ -459,4 +459,33 @@
|
|
|
|
|
|
WHERE y.salemans_id = m.salemans_id and y.type = m.type and year = date_format(now(),'%Y')
|
|
|
</update>
|
|
|
+
|
|
|
+ <!-- 新增某人某月某类型的统计数据 -->
|
|
|
+ <insert id="insertBySome" parameterType="com.goafanti.common.model.TOrderNew">
|
|
|
+ INSERT INTO t_order_month_report(`type`,`month`,amount,proof_count,salemans_id)
|
|
|
+ select order_type, date_format( sign_time , '%Y%m' ), sum(total_amount) as amount, sum(proof_count) as proof_count, salesman_id
|
|
|
+ from t_order_new
|
|
|
+ where
|
|
|
+ proof_status = 1
|
|
|
+ and salesman_id = #{salesmanId,jdbcType=VARCHAR}
|
|
|
+ and order_type = #{orderType,jdbcType=INTEGER}
|
|
|
+ and date_format( sign_time , '%Y%m' ) = date_format( #{signTime,jdbcType=DATE}, '%Y%m' )
|
|
|
+ </insert>
|
|
|
+ <!-- 更新指定月份的统计数据 -->
|
|
|
+ <insert id="updateByMonth" parameterType="java.lang.Integer">
|
|
|
+ REPLACE INTO t_order_month_report(`type`,`month`,amount,proof_count,salemans_id)
|
|
|
+ select o.order_type, date_format(#{month,jdbcType=INTEGER},'%Y%m'),sum(o.total_amount), sum(o.proof_count), o.salesman_id
|
|
|
+ from t_order_new o
|
|
|
+ where 1 = 1
|
|
|
+ and o.proof_status = 1
|
|
|
+ and date_format( o.sign_time, '%Y%m' ) = #{month,jdbcType=INTEGER}
|
|
|
+ group by o.salesman_id , o.order_type
|
|
|
+ </insert>
|
|
|
+ <!-- 更新本年的年统计数据 -->
|
|
|
+ <insert id="updateByYear">
|
|
|
+ REPLACE INTO t_order_year_report(`type`,`year`,amount,proof_count,salemans_id)
|
|
|
+ select m.`type`, year(now()), sum(amount), sum(proof_count), salemans_id from t_order_month_report m
|
|
|
+ where CAST(`month` as CHAR) like concat (year(now()),'%')
|
|
|
+ group by m.salemans_id , m.`type`
|
|
|
+ </insert>
|
|
|
</mapper>
|