diff --git a/webht/third_party/trippestOrderSync/controllers/vendor_money.php b/webht/third_party/trippestOrderSync/controllers/vendor_money.php index 9f7bbc41..bbd56867 100644 --- a/webht/third_party/trippestOrderSync/controllers/vendor_money.php +++ b/webht/third_party/trippestOrderSync/controllers/vendor_money.php @@ -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) { diff --git a/webht/third_party/trippestOrderSync/models/vendor_money_model.php b/webht/third_party/trippestOrderSync/models/vendor_money_model.php index 9770e447..f5516703 100644 --- a/webht/third_party/trippestOrderSync/models/vendor_money_model.php +++ b/webht/third_party/trippestOrderSync/models/vendor_money_model.php @@ -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(); + } + } diff --git a/webht/third_party/trippestOrderSync/views/vendor_money_sum.php b/webht/third_party/trippestOrderSync/views/vendor_money_sum.php index 76876eb1..7d3974e7 100644 --- a/webht/third_party/trippestOrderSync/views/vendor_money_sum.php +++ b/webht/third_party/trippestOrderSync/views/vendor_money_sum.php @@ -119,6 +119,21 @@ + 0) { + ?> + + 已扣减的其他地接的团款
+ + + + + + + + @@ -136,8 +151,32 @@ + + + 多地预订的团号 + 拼团号 + 总报价/USD + 总收款/RMB + 计入上表海纳收团款 + 应扣除的其他地接收款: (实时计算, 存在汇率误差) + + $order) { + ?> + + + + + + +
+ + + + +