Trippest结算汇总:多地预订的团款计算

hotfix/远程访问多媒体中心
lyt 6 years ago
parent d8b1a6a738
commit a654b8190a

@ -41,6 +41,7 @@ class Vendor_money extends CI_Controller {
,"default_date2" => $end_date
,"default_vendor" => $vendors
,"trippest_order_vendor_money" => array()
,"trippest_order_multi_city" => array()
,"transfer_sum" => 0
/** 列总计 */
,"col_sum" => array(
@ -68,6 +69,7 @@ class Vendor_money extends CI_Controller {
)
)
);
$result['trippest_order_multi_city'] = array_merge($result['trippest_order_multi_city'], $this->money_model->trippest_order_multi_city($start_date, $end_date, implode(',', $vendors)));
/** 团款 */
foreach ($vendors as $key => $vendor) {
$sourcetype = $vendor_sourcetype[strval($vendor)]["sourcetype"];
@ -78,7 +80,8 @@ class Vendor_money extends CI_Controller {
"trippest_sum" => 0,
"vendor_sum" => 0,
"other_sum_cost" => 0,
"other_sum" => 0
"other_sum" => 0,
"other_vendor_sum" => 0
),
"vendor" =>
array(
@ -86,7 +89,8 @@ class Vendor_money extends CI_Controller {
"vendor_sum" => 0,
"transfer_sum" => 0,
"other_sum_cost" => 0,
"other_sum" => 0
"other_sum" => 0,
"other_vendor_sum" => 0
)
);
// 按照海纳的算法
@ -100,6 +104,7 @@ class Vendor_money extends CI_Controller {
$ret['trippest']['other_sum'] = bcadd($ret['trippest']['other_sum'], $opi_money['other_price_sum']);
$ret['trippest']['other_sum_cost'] = bcadd($ret['trippest']['other_sum_cost'], $opi_money['other_cost_sum']);
$ret["trippest"]['trippest_sum'] = bcsub($ret["trippest"]['trippest_sum'], $opi_money['other_price_sum']);
$ret['trippest']['other_vendor_sum'] = bcadd($ret['trippest']['other_vendor_sum'], $opi_money['other_vendorprice_RMB_sum']);
}
// 按照图兰朵算法: Trippest自营订单的代收算在海纳收款
foreach ($opi_summoney as $kv => $opi_money_v) {
@ -112,6 +117,7 @@ class Vendor_money extends CI_Controller {
$ret['vendor']['other_sum'] = bcadd($ret['vendor']['other_sum'], $opi_money_v['other_price_sum']);
$ret['vendor']['other_sum_cost'] = bcadd($ret['vendor']['other_sum_cost'], $opi_money_v['other_cost_sum']);
$ret["vendor"]['trippest_sum'] = bcsub($ret["vendor"]['trippest_sum'], $opi_money_v['other_price_sum']);
$ret['vendor']['other_vendor_sum'] = bcadd($ret['vendor']['other_vendor_sum'], $opi_money['other_vendorprice_RMB_sum']);
}
$ret["vendor"]["transfer_sum"] = bcsub($ret["vendor"]['vendor_sum'], $ret["trippest"]['vendor_sum']);
if ($ret["vendor"]["transfer_sum"] != 0) {

@ -17,6 +17,7 @@ class Vendor_money_model extends CI_Model {
$sql = "SELECT sum_opi.COLI_OPI_ID,sum(sum_opi.海纳收款) as trippest_sum,sum(sum_opi.地接社收款) as vendor_sum,
sum(sum_opi.other_price_RMB) as other_price_sum
, sum(sum_opi.other_cost_RMB) as other_cost_sum
,sum(sum_opi.other_vendorprice_RMB) as other_vendorprice_RMB_sum
from (
SELECT
(select isnull(SUM(COLD_TotalPrice),0) from BIZ_ConfirmLineDetail cold
@ -31,6 +32,11 @@ class Vendor_money_model extends CI_Model {
and COLD_PlanVEI_SN IN ($all_vendor)
and cold.DeleteFlag=0
) as other_cost_RMB,
(dbo.ConvertToRMB('USD',other_vendor_price)) as other_vendorprice_RMB,
case when other_vendor_price > 0 then
(总收款-dbo.ConvertToRMB('USD',other_vendor_price))
else 海纳收款_origin end
as 海纳收款,
*
from (
select
@ -40,6 +46,13 @@ class Vendor_money_model extends CI_Model {
and COLD_ServiceType='D'
and DeleteFlag=0
) as service_cnt,
(select isnull(SUM(COLD_TotalPrice),0) from BIZ_ConfirmLineDetail
where COLD_COLI_SN=COLI_SN
--and COLD_ServiceType='D'
and DeleteFlag=0
and COLD_PlanVEI_SN<>$vendor
and COLD_PlanVEI_SN not in ($all_vendor)
) as other_vendor_price,
COLI.COLI_sourcetype,
COLI.COLI_Price,
coli.COLI_Currency,
@ -54,9 +67,10 @@ class Vendor_money_model extends CI_Model {
(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
and GAI_Type not in (" . PAY_OTHER . ")
) as 海纳收款,
) as 海纳收款_origin,
(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
and GAI_VEI_SN=$vendor
and GAI_Type in (" . PAY_OTHER . ")
) as 地接社收款
,coli.COLI_OPI_ID
@ -158,6 +172,58 @@ class Vendor_money_model extends CI_Model {
return $query->result_array();
}
public function trippest_order_multi_city($start_date, $end_date, $all_vendor)
{
$sql = "SELECT COLI_SN,COLI_ID,COLI_GroupCode,
(select top 1 ISNULL(GCI_combineNo,'') from GroupCombineInfo where GCI_GRI_SN=COLI_GRI_SN) as gci_no,
convert(date,cgi.CGI_ArriveDate) CGI_ArriveDate,
COLI.COLI_sourcetype, COLI.COLI_Price, coli.COLI_Currency,
(select isnull(SUM(dbo.ConvertToRMB('USD',COLD_TotalPrice)),0) from BIZ_ConfirmLineDetail
where COLD_COLI_SN=COLI_SN
and DeleteFlag=0
and COLD_PlanVEI_SN not in ($all_vendor)
) as other_vendorprice_RMB
,(select isnull(SUM(dbo.ConvertToRMB('USD',COLD_TotalPrice)),0) from BIZ_ConfirmLineDetail
where COLD_COLI_SN=COLI_SN
and DeleteFlag=0
and COLD_PlanVEI_SN in ($all_vendor)
) as this_vendorprice_RMB
,(SELECT isnull(SUM(GAI_SSJE),0)
FROM BIZ_GroupAccountInfo
WHERE DeleteFlag=0
AND GAI_COLI_SN=COLI_SN
) AS money_sum
,(select dbo.[GetVendorName](COLD_PlanVEI_SN,2) from BIZ_ConfirmLineDetail
where COLD_COLI_SN=COLI_SN
and DeleteFlag=0
and COLD_PlanVEI_SN in ($all_vendor)
) as vendor_name
FROM CK_GroupInfo cgi
INNER JOIN GRoupInfo gri ON CGI_GRI_SN=GRI_SN
INNER JOIN BIZ_ConfirmLineInfo coli ON COLI_GRI_SN=GRI_SN
WHERE 1=1
AND CGI_ArriveDate BETWEEN '$start_date' and '$end_date'
AND EXISTS
(SELECT 1
FROM OperatorInfo
WHERE OPI_DEI_SN=30
AND OPI_SN=CGI_OPI_SN)
AND CGI_Checked=1
AND GRI_OrderType=227002
AND COLI_OPI_ID <> 435
AND exists (
select 1 from BIZ_ConfirmLineDetail where COLD_COLI_SN=COLI_SN
and COLD_PlanVEI_SN in ($all_vendor) --in ($all_vendor)
)
AND exists (
select 1 from BIZ_ConfirmLineDetail where COLD_COLI_SN=COLI_SN
and COLD_PlanVEI_SN not in ($all_vendor)
)
ORDER BY COLI_sourcetype ";
$query = $this->HT->query($sql);
return $query->result_array();
}
}

@ -119,6 +119,21 @@
<?php
}
?>
<?php
if ($trippest['trippest']['other_vendor_sum'] > 0) {
?>
<tr class="bg-grey">
<td >已扣减的其他地接的团款 <br></td>
<td ><?php echo $trippest['trippest']['other_vendor_sum'] ?></td>
<td ></td>
<td ></td>
<td ></td>
<td ></td>
<td colspan="4"></td>
</tr>
<?php
}
?>
<?php
}
} ?>
@ -136,8 +151,32 @@
<td><?php echo $col_sum['trippest']['sum_payout'] ?></td>
</tr>
<?php } ?>
<?php if ( ! empty($trippest_order_multi_city)) {
?>
<tr class="text-bold">
<th >多地预订的团号</th>
<th >拼团号</th>
<th >总报价/USD</th>
<th >总收款/RMB</th>
<th >计入上表海纳收团款</th>
<th colspan="4">应扣除的其他地接收款: (实时计算, 存在汇率误差)</th>
</tr>
<?php foreach ($trippest_order_multi_city as $ko => $order) {
?>
<tr>
<td class="text-left"><?php echo $order['COLI_GroupCode'] ?></td>
<td class="text-left"><?php echo $order['gci_no'] ?></td>
<td ><?php echo $order['COLI_Price'] ?></td>
<td ><?php echo $order['money_sum'] ?></td>
<td ><?php echo bcsub($order['money_sum'],$order["other_vendorprice_RMB"]) ?>
<br> <?php echo ($order["vendor_name"]) ?>
</td>
<td colspan="4" class="text-left"><?php echo $order["other_vendorprice_RMB"] ?></td>
</tr>
<?php } } ?>
</tbody>
</table>
<!--
<p>旧的算法, 需扣除Trippest自营订单的地接代收款项:</p>
<table class="table table-bordered table-hover">
<thead>
@ -218,6 +257,7 @@
<?php } } ?>
</tbody>
</table>
-->
</div>
</body>
<script src="/js/jquery.min.js" type="text/javascript"></script>

Loading…
Cancel
Save