feat: Trippest账单解决不同地接社拼团号相同等问题

feature/trippest
lyt 6 years ago
parent 16bdae5534
commit 98ef4396de

@ -91,6 +91,9 @@ class Vendor_money extends CI_Controller {
)
)
);
// 不同地接社但是拼团号相同
$actual_vendor_duplicate_combineno = $this->money_model->get_duplicate_vei_combineno($start_date, $end_date, implode(",", $vendors));
$duplicate_coli_sn = array_column($actual_vendor_duplicate_combineno, 'COLI_SN');
$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)));
$result['trippest_order_cost_debug'] = $this->money_model->cost_debug_detail($start_date, $end_date, implode(',', $vendors));
/**
@ -102,7 +105,7 @@ class Vendor_money extends CI_Controller {
/** 团款 */
foreach ($vendors as $key => $vendor) {
$sourcetype = $vendor_sourcetype[strval($vendor)]["sourcetype"];
$opi_summoney = $this->money_model->checked_group_list($vendor, $sourcetype, $start_date, $end_date, implode(',', $vendors));
$opi_summoney = $this->money_model->checked_group_list($vendor, $sourcetype, $start_date, $end_date, implode(',', $vendors), implode(",", $duplicate_coli_sn));
$ret = array(
"trippest" =>
array(
@ -133,6 +136,11 @@ class Vendor_money extends CI_Controller {
"other_vendor_sum" => 0
)
);
foreach ($actual_vendor_duplicate_combineno as $kad => $vad) {
if ($vad['vendor1'] == $vendor) {
$opi_summoney[] = $vad;
}
}
// 按照海纳的算法
foreach ($opi_summoney as $key => $opi_money) {
if (floatval($opi_money['vendor_sum']) > 0) {
@ -147,7 +155,10 @@ class Vendor_money extends CI_Controller {
$ret['trippest']['other_vendor_sum'] = bcadd($ret['trippest']['other_vendor_sum'], $opi_money['other_vendorprice_RMB_sum']);
}
foreach ($all_price_cost as $ks => $sync) {
if ($sync['vendor_code'] != $vendor || in_array($sync['GCI_combineNo'],$unique_sync_groupno)) {
if ($sync['vendor_code'] != $vendor ) {
continue;
}
if (in_array($sync['GCI_combineNo'],$unique_sync_groupno)) {
$dumplicate_groupno[] = $sync;
continue;
}
@ -198,6 +209,7 @@ class Vendor_money extends CI_Controller {
// $result['col_sum']['vendor']['sum_other'] = bcadd($result['col_sum']['vendor']['sum_other'], $ret['vendor']['other_sum']);
}
/** 成本 */
// 排除上述的重复拼团号, 后面再加到第一个地接的数据中
$vendors_cost = $this->money_model->vendor_cost(implode(',', $vendors), $start_date, $end_date);
foreach ($result['money'] as $km => &$vm) {
$vm['vendor_cost'] = $vm['trippest_cost'] = 0;
@ -206,6 +218,11 @@ class Vendor_money extends CI_Controller {
$vm['vendor_cost'] = $vvc['vendor_cost'];
}
}
foreach ($actual_vendor_duplicate_combineno as $kdc => $vdc) {
if (strval($vm['vendor_code']) === strval($vdc['vendor1'])) {
$vm['vendor_cost'] += $vdc['pure_cost'];
}
}
// 成本总计
$result['col_sum']['trippest']['sum_trippest_cost'] = $result['col_sum']['vendor']['sum_trippest_cost'] = bcadd($result['col_sum']['trippest']['sum_trippest_cost'], $vm['trippest_cost']);
$result['col_sum']['trippest']['sum_vendor_cost'] = $result['col_sum']['vendor']['sum_vendor_cost'] = bcadd(

@ -1,7 +1,7 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
define('PAY_OTHER','15017,15008,15006,15020');
define('PAY_OTHER','15006, 15017,15008,15006,15020');
class Vendor_money_model extends CI_Model {
@ -12,7 +12,7 @@ class Vendor_money_model extends CI_Model {
bcscale(4);
}
public function checked_group_list($vendor, $sourcetype, $start_date, $end_date, $all_vendor)
public function checked_group_list($vendor, $sourcetype, $start_date, $end_date, $all_vendor, $duplicate_gri)
{
$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
@ -70,7 +70,7 @@ class Vendor_money_model extends CI_Model {
) 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_VEI_SN in ($vendor, 1343)
and GAI_Type in (" . PAY_OTHER . ")
) as 地接社收款
,coli.COLI_OPI_ID
@ -85,6 +85,7 @@ class Vendor_money_model extends CI_Model {
)
and CGI_Checked=1
and GRI_OrderType=227002
and COLI_SN not in ($duplicate_gri)
and exists (
select 1 from BIZ_ConfirmLineDetail where COLD_COLI_SN=coli.COLI_SN
and DeleteFlag=0
@ -165,6 +166,10 @@ class Vendor_money_model extends CI_Model {
WHERE CGI_Checked=1
AND CGI_GRI_SN=GCI_GRI_SN
AND CGI_ArriveDate BETWEEN '$start_date' AND '$end_date')
and not exists (
select 1 from GroupCombineInfo g2 where g2.GCI_combineNo=gci.GCI_combineNo
and g2.GCI_VEI_SN<>gci.GCI_VEI_SN
)
) AS group_cost
) as tmp
GROUP BY tmp.vendor_code ";
@ -479,7 +484,10 @@ class Vendor_money_model extends CI_Model {
,(select SUM(CONVERT(float, GCI_agencyReceipt)) from GroupCombineInfo where GCI_combineNo=group_cost.GCI_combineNo
) as agency_receive_price
FROM
(SELECT isnull(gci.GCI_combineNo,'1') GCI_combineNo
(SELECT case when gci.GCI_combineNo is null then '1'
when gci.GCI_combineNo='cancel' then convert(varchar(10),gci.GCI_SN)
else gci.GCI_combineNo end
as GCI_combineNo
,GCI_VEI_SN
FROM GroupCombineInfo gci
WHERE 1=1
@ -490,7 +498,9 @@ class Vendor_money_model extends CI_Model {
WHERE CGI_Checked=1
AND CGI_GRI_SN=GCI_GRI_SN
AND CGI_ArriveDate BETWEEN '$start_date' AND '$end_date')
group by isnull(gci.GCI_combineNo,'1')
group by case when gci.GCI_combineNo is null then '1'
when gci.GCI_combineNo='cancel' then convert(varchar(10),gci.GCI_SN)
else gci.GCI_combineNo end
,GCI_VEI_SN
) AS group_cost
order by GCI_combineNo desc";
@ -498,6 +508,52 @@ class Vendor_money_model extends CI_Model {
return $query->result_array();
}
public function get_duplicate_vei_combineno($start_date, $end_date, $all_vendor)
{
$sql = "SELECT pure_group.*
,(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
where DeleteFlag=0 and GAI_GRI_SN=COLI_SN
and GAI_VEI_SN in ($all_vendor)
and GAI_Type in (" . PAY_OTHER . ")
) as vendor_sum
,(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
) as total_receipt
,(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 trippest_sum
,0 as other_price_sum,0 as other_cost_sum,0 as other_vendorprice_RMB_sum
from (SELECT GCI_combineNo
,(select top 1 GCI_VEI_SN from groupcombineinfo g1 where g1.gci_combineno=vendor_group.GCI_combineNo) as vendor1
,(select top 1 c.COLI_SN from groupcombineinfo g1
inner join BIZ_ConfirmLineInfo c on COLI_GRI_SN=GCI_GRI_SN
where g1.gci_combineno=vendor_group.GCI_combineNo
) as COLI_SN
,(SELECT isnull(SUM(CONVERT(float, isnull(gcod.GCOD_sumMoney,0))),0)
FROM GroupCombineOperationDetail gcod
WHERE gcod.GCOD_GCI_combineNo=GCI_combineNo
AND gcod.GCOD_operationType<> 'otherReceives'
) as pure_cost
from (
select GCI_combineNo ,GCI_VEI_SN
from GroupCombineInfo where 1=1
and GCI_VEI_SN in ($all_vendor)
AND EXISTS
( SELECT 1
FROM CK_GroupInfo
WHERE CGI_Checked=1
AND CGI_GRI_SN=GCI_GRI_SN
AND CGI_ArriveDate BETWEEN '$start_date' AND '$end_date')
group by GCI_combineNo, GCI_VEI_SN
) as vendor_group
group by vendor_group.GCI_combineNo
having COUNT(1)>1
) as pure_group";
$query = $this->HT->query($sql);
return $query->result_array();
}
}
/* End of file vendor_money.php */

@ -30,6 +30,7 @@
.text-bold {font-weight: bold;}
.text-red {color: red;}
.cell-right {float: right;}
.bgred{ background-color: lightcoral;}
td a {cursor: pointer;}
</style>
</head>
@ -125,13 +126,13 @@
<tr>
<td class="text-left"><?php echo $ep['GRI_Name']; ?></td>
<td class="text-left"><?php echo $ep['combineNo']; ?></td>
<td><?php echo $ep['total_income_err']; ?></td>
<td>
<td <?php echo abs($ep['total_income_err'])<=1 ? "" : 'class=bgred';?> ><?php echo $ep['total_income_err']; ?></td>
<td <?php echo abs($ep['total_price_err'])<=1 ? "" : 'class=bgred';?> >
<?php echo $ep['total_price_err']; ?>
<!-- <p><?php // echo "=" . $ep['TLD_total_price'] . "-(" . $ep['HT_haina_receipt'] . "+" . $ep['HT_agency_receipt'] . ")"; ?></p> -->
</td>
<td><?php echo $ep['agency_receipt_err']; ?></td>
<td><?php echo $ep['HT_receipt_err']; ?></td>
<td <?php echo abs($ep['agency_receipt_err'])<=1 ? "" : 'class=bgred';?> ><?php echo $ep['agency_receipt_err']; ?></td>
<td <?php echo abs($ep['HT_receipt_err'])<=1 ? "" : 'class=bgred';?> ><?php echo $ep['HT_receipt_err']; ?></td>
<td><?php echo $ep['TLD_total_price']; ?></td>
<td><?php echo $ep['TLD_agency_receipt']; ?></td>
<td><?php echo $ep['HT_haina_receipt']; ?></td>

Loading…
Cancel
Save