This commit is contained in:
linfso 2025-06-18 11:17:03 +08:00
parent a40435969d
commit 670af37ed4
5 changed files with 302 additions and 0 deletions

View File

@ -339,6 +339,40 @@ public class EmisSettleBillController extends BaseController
return getDataTable(list);
}
/**
* 销售回款率统计
* @param emisSettleBill
* @return
*/
@GetMapping("/querySalesPayBackRateList")
public TableDataInfo querySalesPayBackRateList(EmisSettleBill emisSettleBill)
{
startPage();
setPrivParams(emisSettleBill);
String billCodeStr = MapUtil.getStr(emisSettleBill.getParams(),"billCode");
if(!StringUtils.isEmpty(billCodeStr)){
emisSettleBill.getParams().put("billCode",WaybillHelper.formatQueryValue(billCodeStr));
String[] billCodeSortList = billCodeStr.split(",");
if(billCodeSortList.length>1){
emisSettleBill.getParams().put("billCodeSortList", Arrays.asList(billCodeSortList));
}
}
if(!StringUtils.isEmpty(emisSettleBill.getSettleBillNo())){
emisSettleBill.setSettleBillNo(WaybillHelper.formatQueryValue(emisSettleBill.getSettleBillNo()));
String[] settleBillNoSortList = emisSettleBill.getSettleBillNo().split(",");
if(settleBillNoSortList.length>1){
emisSettleBill.getParams().put("settleBillNoSortList",Arrays.asList(settleBillNoSortList));
}
}
List<Map> list = emisSettleBillService.querySalesPayBackRateList(emisSettleBill);
return getDataTable(list);
}
/**
* 新增运单总账单

View File

@ -56,6 +56,13 @@ public interface EmisSettleBillMapper extends BaseMapper<EmisSettleBill>
*/
public List<Map> queryPayBackStatList(EmisSettleBill emisSettleBill);
/**
* 销售回款率统计
* @param emisSettleBill
* @return
*/
public List<Map> querySalesPayBackRateList(EmisSettleBill emisSettleBill);
public List<OpenBillStatInfo> selectOpenBillStatInfoList(EmisSettleBill emisSettleBill);

View File

@ -54,6 +54,14 @@ public interface IEmisSettleBillService extends IDataAuditService
*/
public List<Map> queryPayBackStatList(EmisSettleBill emisSettleBill);
/**
* 销售回款率统计
* @param emisSettleBill
* @return
*/
public List<Map> querySalesPayBackRateList(EmisSettleBill emisSettleBill);
/**
* 获取开票统计数据
* @param emisSettleBill

View File

@ -128,6 +128,12 @@ public class EmisSettleBillServiceImpl extends EmisBaseService implements IEmisS
return emisSettleBillMapper.queryPayBackStatList(emisSettleBill);
}
@Override
public List<Map> querySalesPayBackRateList(EmisSettleBill emisSettleBill)
{
return emisSettleBillMapper.querySalesPayBackRateList(emisSettleBill);
}
/**
* 获取开票统计数据
* @param emisSettleBill

View File

@ -634,7 +634,254 @@
</select>
<!-- 销售回款率统计-PMS需求:1610
销售回款率统计界面:
(1)数据来源于 财务收款统计界面 以 销售联系人 为主键,
(2)统计销售联系人的现金账单数、现金账单总金额、现金账期内收款金额(100%)总金额;
现金回款系数=现金账单账期内收款总金额(100%) / 现金账单 总金额 * 100%
(3)月结回款系数=月结100%回款系数+月结70%回款系数
月结100%回款系数 = 月结账期内收款总金额100% / 月结账单总金额 * 100%
月结70%回款系数 = 月结账期内收款总金额70% / 月结账单总金额 * 70%
-->
<select id="querySalesPayBackRateList" parameterType="EmisSettleBill" resultType="map">
SELECT
tbMA.salesmen,
tbMA.billMonth,
sum(if( tbMA.settleType=1,1, 0 ) ) AS totalMoneyBillCount,
sum(if( tbMA.settleType=1,tbMA.recMoney, 0 ) ) AS totalMoneyRecAmount,
sum(if( tbMA.settleType=1,tbMA.recdMoneyIn, 0 ) ) AS totalMoneyRecdIn,
sum(if( tbMA.settleType=2,1, 0 ) ) AS totalMonthBillCount,
sum(if( tbMA.settleType=2,tbMA.recMoney, 0 ) ) AS totalMonthRecAmount,
sum(if( tbMA.settleType=2,tbMA.recdMoneyIn, 0 ) ) AS totalMonthRecdIn,
sum(if( tbMA.settleType=2,tbMA.recdPayMoney60D, 0 ) ) AS totalMonthRecd70
from (
SELECT
tba.settle_bill_no AS settleBillNo,
tba.settle_bill_name as settleBillName,
tba.cust_no as custNo,
tba.cust_name as custName,
tba.customer_name as customerName,
tba.bill_month as billMonth,
tba.settle_type as settleType,
tba.open_bill_status as openBillStatus,
tba.payment_status as paymentStatus,
tba.settle_day as settleDay,
tba.send_piece_sum as sendPieceSum,
tba.credit_period as creditPeriod,
DATE(tba.payment_due_date) as paymentDueDate,
tba.rec_money as recMoney,
tba.reced_money as recedMoney,
tba.salesmen as salesmen,
tba.payee as payee,
tba.create_time as createTime,
tbc.satisfyMoney as satisfyMoney,
tbc.allowanceMoney as allowanceMoney,
tbc.deductionMoney as deductionMoney,
tbc.otherMoney as otherMoney,
tbc.totalOtherMoney as totalOtherMoney,
if( tbb.totalPayMoney > 0,tbb.totalPayMoney-tbc.totalOtherMoney, 0 ) AS totalPayMoney,
if( tbb.recdMoneyIn > 0,tbb.recdMoneyIn-tbc.totalOtherMoney,0) AS recdMoneyIn,
if( tbb.recdPayMoney60D > 0,tbb.recdPayMoney60D-tbc.totalOtherMoney,0) recdPayMoney60D,
if( tbb.recdPayMoneyGreat60D >0,tbb.recdPayMoneyGreat60D-tbc.totalOtherMoney,0) recdPayMoneyGreat60D,
( tba.rec_money - tba.reced_money - tbc.totalOtherMoney ) AS noRecMoney
FROM
(
SELECT
settle_bill_no,
settle_bill_name,
cust_no,
cust_name,
customer_name,
bill_month,
settle_type,
open_bill_status,
payment_status,
settle_day,
credit_period,
payment_due_date,
send_piece_sum,
rec_money,
reced_money,
satisfy_money,
allowance_money,
deduction_money,
other_money,
salesmen,
payee,
create_time
FROM
emis_settle_bill a
<where>
a.del_flag='0'
<if test="settleBillNo != null and settleBillNo != ''"> and FIND_IN_SET(a.`settle_bill_no`,#{settleBillNo})</if>
<if test="custNo != null and custNo != ''"> and a.cust_no = #{custNo}</if>
<if test="salesmen != null and salesmen!='' "> and a.salesmen = #{salesmen}</if>
<if test="payee != null and payee!='' "> and a.payee = #{payee}</if>
<if test="settleType != null and settleType != ''"> and a.settle_type= #{settleType}</if>
<if test="billMonth != null and billMonth!='' "> and FIND_IN_SET(a.`bill_month`,#{billMonth})</if>
<if test="openBillStatus != null and openBillStatus != ''"> and a.open_bill_status = #{openBillStatus}</if>
<if test="paymentStatus != null and paymentStatus != ''"> and a.payment_status = #{paymentStatus}</if>
<if test="params.billCode != null and params.billCode != ''">
and exists (
select 1 from emis_settle_sub_bill b
where a.settle_bill_no=b.settle_bill_no
and ( FIND_IN_SET(b.`bill_code`,#{params.billCode}) or b.bill_code like concat('%', #{params.billCode}, '%') )
)
</if>
<if test="params.beginTradeDate != null and params.beginTradeDate != ''">
and exists (
select 1 from emis_settle_pay_record espr,emis_settle_pay_bill_rel espbr
where espr.del_flag='0' and espbr.del_flag='0' and a.settle_bill_no=espr.settle_bill_no and espr.pay_id = espbr.pay_id
and espr.trade_date <![CDATA[ >= ]]> #{params.beginTradeDate}
)
</if>
<if test="params.endTradeDate != null and params.endTradeDate != ''">
and exists (
select 1 from emis_settle_pay_record espr,emis_settle_pay_bill_rel espbr
where espr.del_flag='0' and espbr.del_flag='0' and a.settle_bill_no=espr.settle_bill_no and espr.pay_id = espbr.pay_id
and espr.trade_date <![CDATA[ <= ]]> #{params.endTradeDate}
)
</if>
<if test="params.payCreateBy != null and params.payCreateBy != ''">
and exists (
select 1 from emis_settle_pay_record espr,emis_settle_pay_bill_rel espbr
where espr.del_flag='0' and espbr.del_flag='0' and a.settle_bill_no=espr.settle_bill_no and espr.pay_id = espbr.pay_id
and espr.create_by = #{params.payCreateBy}
)
</if>
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and (
a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.salesmen in(
select salesmen from emis_salesmen_rel esr where esr.del_flag='0' and esr.bl_open='1' and now() <![CDATA[ >= ]]> esr.start_date and now() <![CDATA[ <= ]]> esr.end_date and esr.sales_ass=#{params.privEmpName}
)
)
</if>
</where>
) tba
LEFT JOIN (
SELECT
a.settle_bill_no,
sum( ifnull(d.pay_money,0) ) AS totalPayMoney,
sum( if(b.trade_date <![CDATA[ <= ]]> a.payment_due_date,ifnull(d.pay_money,0) ,0) ) AS recdMoneyIn,
sum( if(a.settle_type='2' and a.credit_period <![CDATA[ >= ]]> 30 and b.trade_date <![CDATA[ > ]]> a.payment_due_date and b.trade_date <![CDATA[ > ]]> a.payment_due_date and b.trade_date <![CDATA[ < ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ),ifnull(d.pay_money,0) ,0) ) AS recdPayMoney60D,
sum( if( (a.settle_type='2' and a.credit_period <![CDATA[ >= ]]> 30 and b.trade_date <![CDATA[ > ]]> a.payment_due_date and b.trade_date <![CDATA[ >= ]]> DATE_SUB( a.payment_due_date, INTERVAL (a.credit_period-60) DAY ) ) or ( ( (a.settle_type='2' and a.credit_period <![CDATA[ < ]]> 30) or a.settle_type='1' ) and b.trade_date <![CDATA[ > ]]> a.payment_due_date ),ifnull(d.pay_money,0) ,0) ) AS recdPayMoneyGreat60D
FROM
emis_settle_bill a,
emis_settle_pay_record b,
emis_settle_pay_bill_rel c,
emis_settle_pay_rel d,
emis_settle_sub_bill e
<where>
a.del_flag = '0'
AND b.del_flag = '0'
AND c.del_flag = '0'
and d.del_flag ='0'
AND a.settle_bill_no = c.settle_bill_no
and d.pay_id=b.pay_id
and d.bill_no=e.bill_code
and e.settle_bill_no=a.settle_bill_no
AND b.pay_id = c.pay_id
<if test="settleBillNo != null and settleBillNo != ''"> and FIND_IN_SET(a.`settle_bill_no`,#{settleBillNo})</if>
<if test="custNo != null and custNo != ''"> and a.cust_no = #{custNo}</if>
<if test="salesmen != null and salesmen!='' "> and a.salesmen = #{salesmen}</if>
<if test="payee != null and payee!='' "> and a.payee = #{payee}</if>
<if test="settleType != null and settleType != ''"> and a.settle_type= #{settleType}</if>
<if test="billMonth != null and billMonth!='' "> and FIND_IN_SET(a.`bill_month`,#{billMonth})</if>
<if test="openBillStatus != null and openBillStatus != ''"> and a.open_bill_status = #{openBillStatus}</if>
<if test="paymentStatus != null and paymentStatus != ''"> and a.payment_status = #{paymentStatus}</if>
<if test="params.billCode != null and params.billCode != ''">
and ( FIND_IN_SET(e.`bill_code`,#{params.billCode}) or e.bill_code like concat('%', #{params.billCode}, '%') )
</if>
<if test="params.payCreateBy != null and params.payCreateBy != ''">
and b.create_by = #{params.payCreateBy}
</if>
<if test="params.beginTradeDate != null and params.beginTradeDate != ''">
and b.trade_date <![CDATA[ >= ]]> #{params.beginTradeDate}
</if>
<if test="params.endTradeDate != null and params.endTradeDate != ''">
and b.trade_date <![CDATA[ <= ]]> #{params.endTradeDate}
</if>
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and (
a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.salesmen in(
select salesmen from emis_salesmen_rel esr where esr.del_flag='0' and esr.bl_open='1' and now() <![CDATA[ >= ]]> esr.start_date and now() <![CDATA[ <= ]]> esr.end_date and esr.sales_ass=#{params.privEmpName}
)
)
</if>
</where>
GROUP BY a.settle_bill_no
) tbb ON tba.settle_bill_no = tbb.settle_bill_no
LEFT JOIN (
SELECT
a.settle_bill_no,
sum( ifnull(b.satisfy_money,0) ) AS satisfyMoney,
sum( ifnull(b.allowance_money,0) ) AS allowanceMoney,
sum( ifnull(b.deduction_money,0) ) AS deductionMoney,
sum( ifnull(b.other_money,0) ) AS otherMoney,
sum(ifnull(b.satisfy_money,0)+ifnull(b.allowance_money,0)+ifnull(b.deduction_money,0)+ifnull(b.other_money,0) ) as totalOtherMoney
FROM
emis_settle_bill a,
emis_settle_pay_record b,
emis_settle_pay_bill_rel c
<where>
a.del_flag = '0'
AND b.del_flag = '0'
AND c.del_flag = '0'
AND a.settle_bill_no = c.settle_bill_no
AND b.pay_id = c.pay_id
<if test="settleBillNo != null and settleBillNo != ''"> and FIND_IN_SET(a.`settle_bill_no`,#{settleBillNo})</if>
<if test="custNo != null and custNo != ''"> and a.cust_no = #{custNo}</if>
<if test="salesmen != null and salesmen!='' "> and a.salesmen = #{salesmen}</if>
<if test="payee != null and payee!='' "> and a.payee = #{payee}</if>
<if test="settleType != null and settleType != ''"> and a.settle_type= #{settleType}</if>
<if test="billMonth != null and billMonth!='' "> and FIND_IN_SET(a.`bill_month`,#{billMonth})</if>
<if test="openBillStatus != null and openBillStatus != ''"> and a.open_bill_status = #{openBillStatus}</if>
<if test="paymentStatus != null and paymentStatus != ''"> and a.payment_status = #{paymentStatus}</if>
<if test="params.payCreateBy != null and params.payCreateBy != ''">
and b.create_by = #{params.payCreateBy}
</if>
<if test="params.beginTradeDate != null and params.beginTradeDate != ''">
and b.trade_date <![CDATA[ >= ]]> #{params.beginTradeDate}
</if>
<if test="params.endTradeDate != null and params.endTradeDate != ''">
and b.trade_date <![CDATA[ <= ]]> #{params.endTradeDate}
</if>
<if test="params.billCode != null and params.billCode != ''">
and b.pay_id in(
select pay_id from emis_settle_pay_rel espr
where espr.del_flag='0'
and FIND_IN_SET(espr.`bill_no`,#{params.billCode})
)
</if>
<if test="params.privSiteCode != null and params.privSiteCode != '88888'">
and (
a.salesmen=#{params.privEmpName}
or a.payee=#{params.privEmpName}
or a.salesmen in(
select salesmen from emis_salesmen_rel esr where esr.del_flag='0' and esr.bl_open='1' and now() <![CDATA[ >= ]]> esr.start_date and now() <![CDATA[ <= ]]> esr.end_date and esr.sales_ass=#{params.privEmpName}
)
)
</if>
</where>
GROUP BY a.settle_bill_no
) tbc ON tba.settle_bill_no = tbc.settle_bill_no
) tbMA
group by tbMA.salesmen,tbMA.billMonth
</select>
<sql id="selectEmisSettleBillVo">
select id, settle_bill_no, settle_bill_name, settle_type, settle_start_date, settle_end_date, bill_month, rec_money, reced_money, invoiced_money, cust_no, cust_name, customer_code, customer_name, site_code, site_name, satisfy_money, allowance_money, deduction_money, other_money, satisfy_reason, allowance_reason, deduction_reason, other_reason, open_bill_status, payment_status, charge_status, send_piece_sum, piece_number, fee_weight, uncollected_amount, send_money_sum, refund_amount, refund_money, payee, salesmen, credit_period, credit_period_type, settle_day, payment_due_date, bl_send_oms, bl_confirm_center, confirm_center_date, confirm_center_note, confirm_center_man_code, confirm_center_code, bl_confirm_site, confirm_site_date, confirm_site_man_code, confirm_site_note, confirm_site_code, remark, del_flag, create_by, create_time, update_by, update_time, create_site, update_site from emis_settle_bill a