|
|
@@ -2993,82 +2993,16 @@
|
|
|
<!-- 根据用户信息和筛选信息查询账款明细 -->
|
|
|
<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(a.amt_rec), 0) as "sumAmtRec"
|
|
|
- , COALESCE(SUM(tmrp.sum_amt_pay), 0) as "sumAmtPay"
|
|
|
- , COALESCE(SUM(a.amt_handle), 0) as "amtHandle"
|
|
|
- , a.acc_date as "accDate"
|
|
|
+ , COALESCE(SUM(a.amt_rec), 0) as "sumAmtRec"
|
|
|
FROM
|
|
|
- dkic_b.t_psi_order tpio
|
|
|
- LEFT JOIN dkic_b.t_mac_account_item a ON a.object_id = tpio.cus_id
|
|
|
- LEFT JOIN dkic_b.t_psi_outbound tpo ON tpo.out_id = a.biznis_id and tpo.out_type = '出库类型-销退回库'
|
|
|
- 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
|
|
|
- LEFT JOIN dkic_b.t_mac_rec_pay_item tmrpi ON tmrpi.rp_id = tmrp.rp_id
|
|
|
- <if test="moneyAccountList != null and moneyAccountList.size() > 0">
|
|
|
- LEFT JOIN dkic_b.t_mst_money_account tmma ON tmma.mac_id = tmrpi.mac_id
|
|
|
- </if>
|
|
|
+ dkic_b.t_mac_account_item a
|
|
|
WHERE a.flg_valid
|
|
|
- AND a.cp_id = #{cpId}
|
|
|
- <if test="objectId != null">
|
|
|
- AND a.object_id = #{objectId}::uuid
|
|
|
- </if>
|
|
|
- <if test="staffId != null">
|
|
|
- AND a.staff_id = #{staffId}::uuid
|
|
|
- </if>
|
|
|
- <if test="orgId != null">
|
|
|
- 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="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="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="recTypeList != null and recTypeList.size() > 0">
|
|
|
- <foreach collection="recTypeList" 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 a.amt_rec > 0
|
|
|
- </if>
|
|
|
- <if test="item != null and item != '' and item == '收支类型-退款'">
|
|
|
- AND a.amt_rec < 0
|
|
|
- </if>
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- <if test="moneyAccountList != null and moneyAccountList.size() > 0">
|
|
|
- AND
|
|
|
- <foreach collection="moneyAccountList" item="item" separator="OR" open="(" close=")">
|
|
|
- <if test="item != null and item != ''">
|
|
|
- tmma.mac_code = #{item}
|
|
|
- </if>
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
+ AND a.cp_id = #{cpId}
|
|
|
+ AND a.object_id = #{objectId}::uuid
|
|
|
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"
|
|
|
@@ -3102,8 +3036,6 @@
|
|
|
<select id="getPsiOrderCount" resultType="java.util.Map">
|
|
|
SELECT
|
|
|
tpo.cus_id as "objectId"
|
|
|
- , tpo.order_no as "biznisNo"
|
|
|
- , tpo.make_time as "accDate"
|
|
|
, COALESCE(SUM(tpo.fact_amt), 0) as "facAmt"
|
|
|
FROM dkic_b.t_psi_order tpo
|
|
|
WHERE tpo.flg_valid
|
|
|
@@ -3126,6 +3058,20 @@
|
|
|
group by tpo.cus_id, tpo.make_time, tpo.fact_amt, tpo.order_no
|
|
|
</select>
|
|
|
|
|
|
+ <select id="getOutboundAmtByUser" resultType="java.util.Map">
|
|
|
+ select
|
|
|
+ tpo.cus_id as "objectId"
|
|
|
+ ,COALESCE(SUM(tpo.out_amt), 0) as "outAmt"
|
|
|
+ from dkic_b.t_psi_outbound tpo
|
|
|
+ where tpo.flg_valid
|
|
|
+ and tpo.out_type = '出库类型-销退回库'
|
|
|
+ AND tpo.cp_id = #{cpId}
|
|
|
+ <if test="objectId != null">
|
|
|
+ AND tpo.cus_id = #{objectId}::uuid
|
|
|
+ </if>
|
|
|
+ group by tpo.cus_id, tpo.out_amt
|
|
|
+ </select>
|
|
|
+
|
|
|
<select id="getPsiOrderByUser" resultType="java.util.Map">
|
|
|
SELECT
|
|
|
tpo.cus_id as "objectId"
|
|
|
@@ -3150,12 +3096,6 @@
|
|
|
#{item}::uuid
|
|
|
</foreach>
|
|
|
</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="orgIds != null and orgIds.size() > 0">
|
|
|
AND tpo.org_id IN
|
|
|
<foreach collection="orgIds" index="index" item="item" separator="," open="(" close=")">
|
|
|
@@ -3169,12 +3109,18 @@
|
|
|
<select id="getOrderAmt" resultType="java.util.Map">
|
|
|
select COALESCE(SUM(tpio.fact_amt), 0) as "orderAmt" from dkic_b.t_psi_order tpio where tpio.flg_valid
|
|
|
AND tpio.cp_id = #{cpId}
|
|
|
+ <if test="objectId != null">
|
|
|
+ AND tpio.cus_id = #{objectId}::uuid
|
|
|
+ </if>
|
|
|
AND tpio.make_time::date <= CURRENT_DATE
|
|
|
</select>
|
|
|
<!--获取退货额-->
|
|
|
<select id="getOutboundAmt" resultType="java.util.Map">
|
|
|
select COALESCE(SUM(tpo.out_amt), 0) as "outboundAmt" from dkic_b.t_psi_outbound tpo where tpo.flg_valid and tpo.out_type = '出库类型-销退回库'
|
|
|
AND tpo.cp_id = #{cpId}
|
|
|
+ <if test="objectId != null">
|
|
|
+ AND tpo.cus_id = #{objectId}::uuid
|
|
|
+ </if>
|
|
|
AND tpo.make_time::date <= CURRENT_DATE
|
|
|
</select>
|
|
|
<!--获取收支额-->
|
|
|
@@ -3186,6 +3132,9 @@
|
|
|
WHERE a.flg_valid
|
|
|
AND a.cp_id = #{cpId}
|
|
|
AND tmc.cus_name IS NOT NULL AND tmc.cus_name != ''
|
|
|
+ <if test="objectId != null">
|
|
|
+ AND tmc.cus_id = #{objectId}::uuid
|
|
|
+ </if>
|
|
|
AND a.make_time::date <= CURRENT_DATE
|
|
|
</select>
|
|
|
<!--获取欠款额-->
|