|
@@ -18,15 +18,37 @@
|
|
|
from daily_sales_report
|
|
from daily_sales_report
|
|
|
where id = #{id,jdbcType=INTEGER}
|
|
where id = #{id,jdbcType=INTEGER}
|
|
|
</select>
|
|
</select>
|
|
|
- <insert id="insertSalesReports">
|
|
|
|
|
- insert into daily_sales_report
|
|
|
|
|
- (admin_id, dep_id, order_count, order_amount)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectAdmins" resultMap="BaseResultMap">
|
|
|
|
|
+ select a.id as admin_id, dm.id as dep_id
|
|
|
|
|
+ from admin a
|
|
|
|
|
+ left join department_management dm on dm.id = a.department_id
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <select id="selectDailySalesReports" resultMap="BaseResultMap">
|
|
|
SELECT o.salesman_id as admin_id, a.department_id as dep_id,
|
|
SELECT o.salesman_id as admin_id, a.department_id as dep_id,
|
|
|
count(o.order_no) as order_count, sum(o.order_amount) as order_amount
|
|
count(o.order_no) as order_count, sum(o.order_amount) as order_amount
|
|
|
FROM aft.t_order o
|
|
FROM aft.t_order o
|
|
|
left join aft.admin a on o.salesman_id=a.id
|
|
left join aft.admin a on o.salesman_id=a.id
|
|
|
where o.order_status=3 and o.sign_time >= #{startTime,jdbcType=TIMESTAMP} and o.sign_time < #{endTime,jdbcType=TIMESTAMP}
|
|
where o.order_status=3 and o.sign_time >= #{startTime,jdbcType=TIMESTAMP} and o.sign_time < #{endTime,jdbcType=TIMESTAMP}
|
|
|
group by o.salesman_id, a.department_id;
|
|
group by o.salesman_id, a.department_id;
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <delete id="deleteByDate">
|
|
|
|
|
+ delete from daily_sales_report
|
|
|
|
|
+ where create_time = #{createTime,jdbcType=TIMESTAMP}
|
|
|
|
|
+ </delete>
|
|
|
|
|
+
|
|
|
|
|
+ <insert id="insertBatch" parameterType="com.goafanti.common.model.DailySalesReport" >
|
|
|
|
|
+ insert into daily_sales_report (admin_id, dep_id, order_count, order_amount, create_time)
|
|
|
|
|
+ values
|
|
|
|
|
+ <foreach item="item" index="index" collection="list" separator=",">
|
|
|
|
|
+ (#{item.adminId,jdbcType=VARCHAR},
|
|
|
|
|
+ #{item.depId,jdbcType=VARCHAR},
|
|
|
|
|
+ #{item.orderCount,jdbcType=INTEGER},
|
|
|
|
|
+ #{item.orderAmount,jdbcType=DECIMAL},
|
|
|
|
|
+ #{item.createTime,jdbcType=TIMESTAMP})
|
|
|
|
|
+ </foreach>
|
|
|
</insert>
|
|
</insert>
|
|
|
|
|
|
|
|
<select id="selectSalesPersonalReports" resultType="com.goafanti.report.bo.PersonalSalesReportBO">
|
|
<select id="selectSalesPersonalReports" resultType="com.goafanti.report.bo.PersonalSalesReportBO">
|
|
@@ -35,7 +57,7 @@
|
|
|
FROM admin a
|
|
FROM admin a
|
|
|
left join daily_sales_report dsr on dsr.admin_id = a.id
|
|
left join daily_sales_report dsr on dsr.admin_id = a.id
|
|
|
left join department_management dm on dm.id = dsr.dep_id
|
|
left join department_management dm on dm.id = dsr.dep_id
|
|
|
- where (dsr.create_time is null or (dsr.create_time >= #{startTime,jdbcType=TIMESTAMP} and dsr.create_time < #{endTime,jdbcType=TIMESTAMP}))
|
|
|
|
|
|
|
+ where dsr.create_time >= #{startTime,jdbcType=TIMESTAMP} and dsr.create_time < #{endTime,jdbcType=TIMESTAMP}
|
|
|
<if test="depName != null">
|
|
<if test="depName != null">
|
|
|
and dm.name like concat(#{depName,jdbcType=VARCHAR},'%')
|
|
and dm.name like concat(#{depName,jdbcType=VARCHAR},'%')
|
|
|
</if>
|
|
</if>
|
|
@@ -52,6 +74,25 @@
|
|
|
</if>
|
|
</if>
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
|
|
+ <select id="selectSalesPersonalReportsCount" resultType="java.lang.Long">
|
|
|
|
|
+ SELECT count(distinct(a.id))
|
|
|
|
|
+ FROM admin a
|
|
|
|
|
+ left join daily_sales_report dsr on dsr.admin_id = a.id
|
|
|
|
|
+ <if test="depName != null">
|
|
|
|
|
+ left join department_management dm on dm.id = a.department_id
|
|
|
|
|
+ </if>
|
|
|
|
|
+ where dsr.create_time >= #{startTime,jdbcType=TIMESTAMP} and dsr.create_time < #{endTime,jdbcType=TIMESTAMP}
|
|
|
|
|
+ <if test="depName != null">
|
|
|
|
|
+ and dm.name like concat(#{depName,jdbcType=VARCHAR},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="name != null">
|
|
|
|
|
+ and a.name like concat(#{name,jdbcType=VARCHAR},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="position != null">
|
|
|
|
|
+ and a.position like concat(#{position,jdbcType=VARCHAR},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
<select id="selectSalesPersonalExtraReports" resultType="org.springframework.ui.ModelMap">
|
|
<select id="selectSalesPersonalExtraReports" resultType="org.springframework.ui.ModelMap">
|
|
|
SELECT dsr.admin_id as id, sum(dsr.order_count) as order_count, sum(dsr.order_amount) as order_amount
|
|
SELECT dsr.admin_id as id, sum(dsr.order_count) as order_count, sum(dsr.order_amount) as order_amount
|
|
|
FROM daily_sales_report dsr
|
|
FROM daily_sales_report dsr
|
|
@@ -83,7 +124,20 @@
|
|
|
|
|
|
|
|
<select id="selectTotalReports" resultType="org.springframework.ui.ModelMap">
|
|
<select id="selectTotalReports" resultType="org.springframework.ui.ModelMap">
|
|
|
SELECT sum(dsr.order_count) as totalCount, sum(dsr.order_amount) as totalAmount
|
|
SELECT sum(dsr.order_count) as totalCount, sum(dsr.order_amount) as totalAmount
|
|
|
- FROM daily_sales_report dsr
|
|
|
|
|
|
|
+ FROM admin a
|
|
|
|
|
+ left join daily_sales_report dsr on dsr.admin_id = a.id
|
|
|
|
|
+ <if test="depName != null">
|
|
|
|
|
+ left join department_management dm on dm.id = a.department_id
|
|
|
|
|
+ </if>
|
|
|
where dsr.create_time >= #{startTime,jdbcType=TIMESTAMP} and dsr.create_time < #{endTime,jdbcType=TIMESTAMP}
|
|
where dsr.create_time >= #{startTime,jdbcType=TIMESTAMP} and dsr.create_time < #{endTime,jdbcType=TIMESTAMP}
|
|
|
|
|
+ <if test="depName != null">
|
|
|
|
|
+ and dm.name like concat(#{depName,jdbcType=VARCHAR},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="name != null">
|
|
|
|
|
+ and a.name like concat(#{name,jdbcType=VARCHAR},'%')
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="position != null">
|
|
|
|
|
+ and a.position like concat(#{position,jdbcType=VARCHAR},'%')
|
|
|
|
|
+ </if>
|
|
|
</select>
|
|
</select>
|
|
|
</mapper>
|
|
</mapper>
|