hongxudong 1 год назад
Родитель
Сommit
b026d7b3ac

+ 18 - 6
src/main/java/com/dk/mdm/mapper/report/ReportMapper.xml

@@ -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 &gt;= #{makeTimeStart}::timestamp with time zone
-            AND tpr.op_create_time &lt; #{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

+ 2 - 2
src/main/java/com/dk/mdm/service/report/ReportService.java

@@ -988,7 +988,7 @@ public class ReportService {
     public ResponseResultVO<Map<String, Object>> getSaleProfitGroupByStaff(Map<String, Object> param) {
         Map<String, Object> res = new HashMap<>();
         res.put("profit", reportMapper.getSaleProfit(param));
-        res.put("orgProfit", reportMapper.getSaleProfitGroupByStaff(param));
+        res.put("staffProfit", reportMapper.getSaleProfitGroupByStaff(param));
         return ResponseResultUtil.success(res);
     }
 
@@ -1000,7 +1000,7 @@ public class ReportService {
     public ResponseResultVO<Map<String, Object>> getSaleProfitGroupBySku(Map<String, Object> param) {
         Map<String, Object> res = new HashMap<>();
         res.put("profit", reportMapper.getSaleProfit(param));
-        res.put("orgProfit", reportMapper.getSaleProfitGroupBySku(param));
+        res.put("skuProfit", reportMapper.getSaleProfitGroupBySku(param));
         return ResponseResultUtil.success(res);
     }
 }