|
|
@@ -3074,10 +3074,16 @@
|
|
|
select
|
|
|
<include refid="getSaleProfitInOutBound"/>
|
|
|
from dkic_b.t_psi_in_out_record tpr
|
|
|
- where tpr.cp_id = #{cpId}
|
|
|
- <if test="makeTimeStart != null and makeTimeEnd != null">
|
|
|
- AND tpr.op_create_time >= #{makeTimeStart}::timestamp with time zone
|
|
|
- AND tpr.op_create_time < #{makeTimeEnd}::timestamp with time zone + interval '1 day'
|
|
|
+ <if test="orgIds!=null and orgIds.size()>0">
|
|
|
+ left join dkic_b.t_psi_inbound tpi on tpi.into_id = biznis_id
|
|
|
+ left join dkic_b.t_psi_outbound tpo on tpo.out_id = biznis_id
|
|
|
+ </if>
|
|
|
+ <include refid="getSaleProfitCond"/>
|
|
|
+ <if test="orgIds!=null and orgIds.size()>0">
|
|
|
+ and (
|
|
|
+ (tpo.org_id = any(#{orgIds, typeHandler=UuidListTypeHanlder}) and tpi.org_id is null)
|
|
|
+ or (tpi.org_id = any(#{orgIds, typeHandler=UuidListTypeHanlder}) and tpo.org_id is null)
|
|
|
+ )
|
|
|
</if>
|
|
|
) t
|
|
|
</select>
|
|
|
@@ -3137,6 +3143,12 @@
|
|
|
left join dkic_b.t_psi_inbound tpi on tpi.into_id = biznis_id
|
|
|
left join dkic_b.t_psi_outbound tpo on tpo.out_id = biznis_id
|
|
|
<include refid="getSaleProfitCond"/>
|
|
|
+ <if test="orgIds!=null and orgIds.size()>0">
|
|
|
+ and (
|
|
|
+ (tpo.org_id = any(#{orgIds, typeHandler=UuidListTypeHanlder}) and tpi.org_id is null)
|
|
|
+ or (tpi.org_id = any(#{orgIds, typeHandler=UuidListTypeHanlder}) and tpo.org_id is null)
|
|
|
+ )
|
|
|
+ </if>
|
|
|
group by coalesce(tpi.staff_id, tpo.staff_id)) t
|
|
|
) tt
|
|
|
left join dkic_b.t_mst_staff tms on tms.staff_id = tt.staff_id
|
|
|
@@ -3180,10 +3192,10 @@
|
|
|
order by tt.profit desc
|
|
|
</if>
|
|
|
<if test="orderBy != null and orderBy=='rateAsc'">
|
|
|
- order by tt.profitRate
|
|
|
+ order by tt."profitRate"
|
|
|
</if>
|
|
|
<if test="orderBy != null and orderBy=='rateDsc'">
|
|
|
- order by tt.profitRate desc
|
|
|
+ order by tt."profitRate" desc
|
|
|
</if>
|
|
|
<if test="limit!=null and limit">
|
|
|
limit 5
|