|
|
|
@ -113,7 +113,8 @@ class Order_finance extends CI_Controller {
|
|
|
|
|
if ($vc->GCI_groupType == 1) {
|
|
|
|
|
// 除去只能PVT的. 避免预定接送*1+tour*1, tour拼团只有一个订单, 被视为整团pvt,漏算接送成本
|
|
|
|
|
$processed_code = array_diff($processed_code, $this->forbidden_combine());
|
|
|
|
|
$ret->pvt = $pvt_cost = $this->pvt_basic($vc->GCI_combineNo, $coli_sn, $processed_code);
|
|
|
|
|
$ret->pvt[] = $pvt_cost = $this->pvt_basic($vc->GCI_combineNo, $coli_sn, $processed_code);
|
|
|
|
|
$processed_code = array_merge($processed_code, $pvt_cost->processed_code); // 多地pvt时需要区分
|
|
|
|
|
} else if ($vc->GCI_groupType == 2) {
|
|
|
|
|
// 这里不排除产品编号是否已处理, 因为重复的情况比较多
|
|
|
|
|
$tmp_cost = $this->combine_basic($vc->GCI_combineNo, $coli_sn);
|
|
|
|
@ -127,35 +128,38 @@ class Order_finance extends CI_Controller {
|
|
|
|
|
// pvt
|
|
|
|
|
$report_tour_pvt = array();
|
|
|
|
|
if ( ! empty($ret->pvt)) {
|
|
|
|
|
$processed_cold_sn = array_merge($processed_cold_sn,$ret->pvt->cold_sn);
|
|
|
|
|
$report_tour_pvt['ordernumber'] = $ret->pvt->coli_id;
|
|
|
|
|
$report_tour_pvt['tourCode'] = mb_substr($ret->pvt->PAG_Code, 0, 50);
|
|
|
|
|
$report_tour_pvt['tourname'] = substr($ret->pvt->pag_name, 0, 200);
|
|
|
|
|
$report_tour_pvt['tourtime'] = $ret->pvt->startdate;
|
|
|
|
|
$report_tour_pvt['tourRSd'] = $ret->pvt->adult_num;
|
|
|
|
|
$report_tour_pvt['tourRSx'] = $ret->pvt->child_num;
|
|
|
|
|
$report_tour_pvt['tourCostRsd'] = $ret->pvt->person_cost;
|
|
|
|
|
$report_tour_pvt['tourCostRSx'] = $ret->pvt->person_cost;
|
|
|
|
|
$report_tour_pvt['tourcost'] = $ret->pvt->cost_sum;
|
|
|
|
|
$report_tour_pvt['tourPrice'] = $this->OrderFinance_model->convert_to_RMB($ret->pvt->totalPrice);
|
|
|
|
|
foreach ($ret->pvt as $kpvt => $cpvt) {
|
|
|
|
|
$processed_cold_sn = array_merge($processed_cold_sn,$cpvt->cold_sn);
|
|
|
|
|
$report_tour_pvt = array();
|
|
|
|
|
$report_tour_pvt['ordernumber'] = $cpvt->coli_id;
|
|
|
|
|
$report_tour_pvt['tourCode'] = mb_substr($cpvt->PAG_Code, 0, 50);
|
|
|
|
|
$report_tour_pvt['tourname'] = substr($cpvt->pag_name, 0, 200);
|
|
|
|
|
$report_tour_pvt['tourtime'] = $cpvt->startdate;
|
|
|
|
|
$report_tour_pvt['tourRSd'] = $cpvt->adult_num;
|
|
|
|
|
$report_tour_pvt['tourRSx'] = $cpvt->child_num;
|
|
|
|
|
$report_tour_pvt['tourCostRsd'] = $cpvt->person_cost;
|
|
|
|
|
$report_tour_pvt['tourCostRSx'] = $cpvt->person_cost;
|
|
|
|
|
$report_tour_pvt['tourcost'] = $cpvt->cost_sum;
|
|
|
|
|
$report_tour_pvt['tourPrice'] = $this->OrderFinance_model->convert_to_RMB($cpvt->totalPrice);
|
|
|
|
|
$report_tour_pvt['tourProfit'] = ($report_tour_pvt['tourPrice']>0) ? bcsub($report_tour_pvt['tourPrice'], $report_tour_pvt['tourcost']) : 0;
|
|
|
|
|
$report_tour_pvt['tourProvide'] = mb_substr($ret->pvt->vendor_name, 0, 50);
|
|
|
|
|
$report_tour_pvt['tourBZ'] = mb_substr($ret->pvt->comment, 0, 150);
|
|
|
|
|
$report_tour_pvt['tourProvide'] = mb_substr($cpvt->vendor_name, 0, 50);
|
|
|
|
|
$report_tour_pvt['tourBZ'] = mb_substr($cpvt->comment, 0, 150);
|
|
|
|
|
$report_tour_pvt['orderstats'] = 0;
|
|
|
|
|
// 成本详情
|
|
|
|
|
$report_tour_pvt['RPT_Car'] = $ret->pvt->cost_category['touristCarOperations'];
|
|
|
|
|
$report_tour_pvt['RPT_Meal'] = $ret->pvt->cost_category['restraurantOperations'];
|
|
|
|
|
$report_tour_pvt['RPT_Ticket'] = $ret->pvt->cost_category['sceneryOperations'];
|
|
|
|
|
$report_tour_pvt['RPT_Service'] = $ret->pvt->cost_category['guiderOperations'];
|
|
|
|
|
$report_tour_pvt['RPT_MealGrants'] = $ret->pvt->cost_category['guide_meal'];
|
|
|
|
|
$report_tour_pvt['RPT_Water'] = $ret->pvt->cost_category['water'];
|
|
|
|
|
$report_tour_pvt['RPT_Other'] = $ret->pvt->cost_category['otherCosts'];
|
|
|
|
|
$report_tour_pvt['RPT_Total'] = $ret->pvt->cost_sum;
|
|
|
|
|
$report_tour_pvt['RPT_PersonGrade'] = $ret->pvt->person_grade;
|
|
|
|
|
$report_tour_pvt['RPT_Car'] = $cpvt->cost_category['touristCarOperations'];
|
|
|
|
|
$report_tour_pvt['RPT_Meal'] = $cpvt->cost_category['restraurantOperations'];
|
|
|
|
|
$report_tour_pvt['RPT_Ticket'] = $cpvt->cost_category['sceneryOperations'];
|
|
|
|
|
$report_tour_pvt['RPT_Service'] = $cpvt->cost_category['guiderOperations'];
|
|
|
|
|
$report_tour_pvt['RPT_MealGrants'] = $cpvt->cost_category['guide_meal'];
|
|
|
|
|
$report_tour_pvt['RPT_Water'] = $cpvt->cost_category['water'];
|
|
|
|
|
$report_tour_pvt['RPT_Other'] = $cpvt->cost_category['otherCosts'];
|
|
|
|
|
$report_tour_pvt['RPT_Total'] = $cpvt->cost_sum;
|
|
|
|
|
$report_tour_pvt['RPT_PersonGrade'] = $cpvt->person_grade;
|
|
|
|
|
$ret->report_tour[] = $report_tour_pvt;
|
|
|
|
|
// 计算订单总成本
|
|
|
|
|
$report_order['basemoney'] = bcadd($report_order['basemoney'], $report_tour_pvt['tourcost']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 拼团
|
|
|
|
|
if ( ! empty($ret->combine_cost)) {
|
|
|
|
|
foreach ($ret->combine_cost as $kcc => $cost) {
|
|
|
|
@ -378,10 +382,25 @@ class Order_finance extends CI_Controller {
|
|
|
|
|
public function pvt_basic($combineNo="", $coli_sn=0, $processed_code=array())
|
|
|
|
|
{
|
|
|
|
|
$ret = new stdClass();
|
|
|
|
|
$all_orders = $this->OrderFinance_model->get_all_combine_order($combineNo, $processed_code);
|
|
|
|
|
if (empty($all_orders)) {
|
|
|
|
|
$all_orders_raw = $this->OrderFinance_model->get_all_combine_order($combineNo, $processed_code);
|
|
|
|
|
if (empty($all_orders_raw)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
$all_orders = $all_orders_raw;
|
|
|
|
|
// 取出供应商id, 有多个供应商时, 说明拆分为多个pvt
|
|
|
|
|
// 多地PVT
|
|
|
|
|
$all_vei_cnt = count(array_unique(array_map(function($ele) {return mb_strtoupper($ele->COLD_PlanVEI_SN);}, $all_orders_raw)));
|
|
|
|
|
$ret->processed_code = array();
|
|
|
|
|
if ($all_vei_cnt > 1) {
|
|
|
|
|
$all_vei = array_unique(array_map(function($ele) {return mb_strtoupper($ele->COLD_PlanVEI_SN);}, $all_orders_raw));
|
|
|
|
|
$all_orders = array();
|
|
|
|
|
foreach ($all_orders_raw as $kor => $vor) {
|
|
|
|
|
if ($vor->COLD_PlanVEI_SN === $all_orders_raw[0]->COLD_PlanVEI_SN) {
|
|
|
|
|
$all_orders[] = $vor;
|
|
|
|
|
$ret->processed_code[] = $vor->PAG_Code;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$ret->coli_sn = $coli_sn;
|
|
|
|
|
$ret->coli_id = $all_orders[0]->coli_ID;
|
|
|
|
|
$ret->cold_sn = array_unique(array_map(function($ele) {return $ele->COLD_SN;}, $all_orders));
|
|
|
|
@ -402,7 +421,7 @@ class Order_finance extends CI_Controller {
|
|
|
|
|
$ret->cost_category = $combine_cost->cost_category;
|
|
|
|
|
$ret->cost_sum = $combine_cost->cost_sum;
|
|
|
|
|
$ret->person_cost = bcdiv($ret->cost_sum, $ret->person_num);
|
|
|
|
|
$ret->comment = "PVT,共" . $ret->person_num . "人";
|
|
|
|
|
$ret->comment = "PVT[" . $combineNo . "],共" . $ret->person_num . "人";
|
|
|
|
|
$pag_sns = array_values(array_unique(array_map(function($ele) {return $ele->COLD_ServiceSN;}, $all_orders)));
|
|
|
|
|
$pags_info = $this->OrderFinance_model->get_pag_info(implode(',', $pag_sns));
|
|
|
|
|
$ret->PAG_Code = implode(",", array_values(array_unique(array_map(function($ele) {return mb_strtoupper($ele->PAG_Code);}, $pags_info))));
|
|
|
|
|