|
|
@@ -1644,8 +1644,7 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getSalesTrackingReportDetail" resultType="java.util.Map">
|
|
|
- SELECT T
|
|
|
- ."id",
|
|
|
+ SELECT T."id",
|
|
|
T."no",
|
|
|
T."itemId",
|
|
|
T."type",
|
|
|
@@ -2933,5 +2932,89 @@
|
|
|
select dkic_b.f_query_mac_pay_current_item(#{cpId},#{objectId} ::uuid,#{orgId} ::uuid,#{macType},#{accDateStart} ::date
|
|
|
,#{accDateEnd} ::date,#{i18n} ,#{currentPage},#{pageSize})
|
|
|
</select>
|
|
|
+ <select id="getCusRecPayReportItemByUser" resultType="java.util.Map">
|
|
|
+ SELECT a.object_id as "objectId"
|
|
|
+ , a.biznis_no as "biznisNo"
|
|
|
+ , COALESCE(SUM(tpo.out_amt), 0) as "outAmt"
|
|
|
+ , COALESCE(SUM(tpo.return_amt), 0) as "returnAmt"
|
|
|
+ , COALESCE(SUM(tmrp.sum_amt_rec), 0) as "sumAmtRec"
|
|
|
+ , a.acc_date as "accDate"
|
|
|
+ FROM
|
|
|
+ dkic_b.t_mac_account_item a
|
|
|
+ LEFT JOIN dkic_b.t_psi_outbound tpo ON tpo.out_id = a.biznis_id
|
|
|
+ LEFT JOIN dkic_b.t_mac_rec_pay tmrp ON tmrp.rp_id = a.biznis_id
|
|
|
+ WHERE a.flg_valid
|
|
|
+ <if test="objectId != null and objectId != ''">
|
|
|
+ AND a.object_id = #{objectId}::uuid
|
|
|
+ </if>
|
|
|
+ <if test="staffId != null and staffId != ''">
|
|
|
+ AND a.staff_id = #{staffId}::uuid
|
|
|
+ </if>
|
|
|
+ <if test="orgId != null and orgId != ''">
|
|
|
+ AND a.org_id = #{orgId}::uuid
|
|
|
+ </if>
|
|
|
+ <if test="makeTimeStart != null and makeTi8meStart != ''">
|
|
|
+ AND a.acc_date >= #{makeTimeStart}::timestamp with time zone
|
|
|
+ </if>
|
|
|
+ <if test="makeTimeEnd != null and makeTimeEnd != ''">
|
|
|
+ AND a.acc_date <= #{makeTimeStart}::timestamp with time zone
|
|
|
+ </if>
|
|
|
+ <if test="staffIds != null and staffIds.size() > 0">
|
|
|
+ AND a.staff_id IN
|
|
|
+ <foreach collection="staffIds" index="index" item="item" separator="," open="(" close=")">
|
|
|
+ #{item}::uuid
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="orgIds != null and orgIds.size() > 0">
|
|
|
+ AND a.org_id IN
|
|
|
+ <foreach collection="orgIds" index="index" item="item" separator="," open="(" close=")">
|
|
|
+ #{item}::uuid
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ <if test="recTypeIds != null and recTypeIds.size() > 0">
|
|
|
+ <foreach collection="recTypeIds" item="item">
|
|
|
+ <if test="item != null and item != '' and item == '收支类型-出库'">
|
|
|
+ AND tpo.out_amt > 0
|
|
|
+ </if>
|
|
|
+ <if test="item != null and item != '' and item == '收支类型-退货'">
|
|
|
+ AND tpo.out_amt < 0
|
|
|
+ </if>
|
|
|
+ <if test="item != null and item != '' and item == '收支类型-收款'">
|
|
|
+ AND tmrp.sum_amt_rec > 0
|
|
|
+ </if>
|
|
|
+ <if test="item != null and item != '' and item == '收支类型-退款'">
|
|
|
+ AND tmrp.sum_amt_rec < 0
|
|
|
+ </if>
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ group by a.object_id, a.biznis_no, a.acc_date, a.staff_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="getUserArrears" resultType="java.util.Map">
|
|
|
+ SELECT a.object_id as "objectId"
|
|
|
+ , tmc.cus_name as "cusName"
|
|
|
+ , tmc.cus_phone as "cusPhone"
|
|
|
+ , SUM(COALESCE(tpo.out_amt, 0) + COALESCE(tpo.return_amt, 0)) - SUM(COALESCE(tmrp.sum_amt_rec, 0)) as arrears
|
|
|
+ FROM
|
|
|
+ dkic_b.t_mac_account_item a
|
|
|
+ LEFT JOIN dkic_b.t_psi_outbound tpo ON tpo.out_id = a.biznis_id
|
|
|
+ LEFT JOIN dkic_b.t_mac_rec_pay tmrp ON tmrp.rp_id = a.biznis_id
|
|
|
+ LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = a.object_id
|
|
|
+ WHERE a.flg_valid
|
|
|
+ AND tmc.cus_name IS NOT NULL AND tmc.cus_name != ''
|
|
|
+ GROUP BY a.object_id, tmc.cus_name, tmc.cus_phone, tmc.address_full
|
|
|
+ HAVING SUM(COALESCE(tpo.out_amt, 0) + COALESCE(tpo.return_amt, 0)) - SUM(COALESCE(tmrp.sum_amt_rec, 0)) > 0
|
|
|
+ <if test="objectId != null">
|
|
|
+ AND a.object_id = #{objectId}::uuid
|
|
|
+ </if>
|
|
|
+ <if test="searchText != null and searchText != ''">
|
|
|
+ AND (tmc.cus_name LIKE concat('%',#{searchText},'%')
|
|
|
+ OR tmc.cus_phone LIKE concat('%',#{searchText},'%')
|
|
|
+ OR tmc.address_full LIKE concat('%',#{searchText},'%'))
|
|
|
+ </if>
|
|
|
+ <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
|
|
|
+ LIMIT #{pageSize} OFFSET #{currentPage}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
|
|
|
</mapper>
|