|
|
|
<?php
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
class Order_finance extends CI_Controller {
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* 基本流程
|
|
|
|
* * 获取拼团类别: PVT?
|
|
|
|
* * 获取拼团总人数, 价格人等
|
|
|
|
* * 分别计算每次拼团成本
|
|
|
|
* * * 写入report_tour
|
|
|
|
* * 所有产品总成本
|
|
|
|
* * * 写入report_order
|
|
|
|
* END
|
|
|
|
*/
|
|
|
|
/*!
|
|
|
|
* GCI_groupType
|
|
|
|
* 1 - PVT
|
|
|
|
* 2 - combine
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function __construct(){
|
|
|
|
parent::__construct();
|
|
|
|
$this->load->helper('array');
|
|
|
|
$this->load->model('OrderFinance_model');
|
|
|
|
mb_regex_encoding("UTF-8");
|
|
|
|
}
|
|
|
|
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* 单团财务表计算
|
|
|
|
* @date 2018-07-18
|
|
|
|
* @param integer $coli_sn 订单主表key
|
|
|
|
* @return [type] [description]
|
|
|
|
*/
|
|
|
|
public function single_order_report($coli_sn=0)
|
|
|
|
{
|
|
|
|
$combineNo_arr = $this->OrderFinance_model->get_order_combineNo($coli_sn);
|
|
|
|
$group_type_arr = array_unique(array_map(function($ele){return $ele->GCI_groupType;}, $combineNo_arr));
|
|
|
|
// $this->output->set_content_type('application/json')->set_output(json_encode($combineNo_arr));
|
|
|
|
// $this->output->set_content_type('application/json')->set_output(json_encode($group_type_arr));
|
|
|
|
foreach ($combineNo_arr as $kc => $vc) {
|
|
|
|
if ($vc->GCI_groupType == 1) {
|
|
|
|
$pvt_cost = $this->pvt_basic($vc->GCI_combineNo);
|
|
|
|
} else if ($vc->GCI_groupType == 2) {
|
|
|
|
$combine_cost = $this->combine_basic($vc->GCI_combineNo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* 基本拼团
|
|
|
|
* * 仅含有一个产品
|
|
|
|
* @example 180712534
|
|
|
|
* @date 2018-07-18
|
|
|
|
* @param string $combineNo
|
|
|
|
* @return [type] [description]
|
|
|
|
*/
|
|
|
|
public function combine_basic($combineNo="")
|
|
|
|
{
|
|
|
|
# code...
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* pvt计算
|
|
|
|
* @example 180515061M
|
|
|
|
* @date 2018-07-18
|
|
|
|
*/
|
|
|
|
public function pvt_basic($combineNo="", $coli_sn=0)
|
|
|
|
{
|
|
|
|
$ret = new stdClass();
|
|
|
|
$ret->tour = array();
|
|
|
|
$all_orders = $this->OrderFinance_model->get_all_combine_order($combineNo);
|
|
|
|
if (empty($all_orders)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
// 预定的产品数
|
|
|
|
$ret->tour_count = count(array_unique(array_map(function($ele) {return $ele->PAG_Code;}, $all_orders)));
|
|
|
|
$ret->person_num = $this->OrderFinance_model->get_order_person_num($coli_sn);
|
|
|
|
bcscale(2);
|
|
|
|
$tour_s = new stdClass();
|
|
|
|
$combine_cost = $this->OrderFinance_model->get_combine_sumMoney($combineNo);
|
|
|
|
$tour_s->startdate = $all_orders[0]->COLD_StartDate;
|
|
|
|
// $tour_s->person_grade = ($all_orders[0]->COLD_PersonNum + $all_orders[0]->COLD_ChildNum );
|
|
|
|
$tour_s->cost_category = $combine_cost->cost_category;
|
|
|
|
$tour_s->cost_sum = $combine_cost->cost_sum;
|
|
|
|
$tour_s->person_cost = bcdiv($tour_s->cost_sum, $ret->person_num);
|
|
|
|
$tour_s->comment = "按PVT,共" . $ret->person_num . "人";// 150
|
|
|
|
$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));
|
|
|
|
$tour_s->PAG_Code = substr(implode(",", array_values(array_unique(array_map(function($ele) {return $ele->PAG_Code;}, $pags_info)))), 0, 50) ; // TODO 限制50
|
|
|
|
$tour_s->vendor_name = implode(",", array_values(array_unique(array_map(function($ele) {return $ele->VEI2_CompanyBN;}, $pags_info)))) ; // 50
|
|
|
|
$tour_s->pag_name = substr(implode(";\r\n", array_map(function($ele) {return $ele->PAG_Title;}, $pags_info)), 0, 200) ; // TODO 限制200
|
|
|
|
$ret->tour[0] = $tour_s;
|
|
|
|
if ( $ret->tour_count > 1 ) {
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
$ret->order_cost = array_sum(array_map(function($ele) {return $ele->cost_sum;}, $ret->tour));
|
|
|
|
$this->output->set_content_type('application/json')->set_output(json_encode($ret));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* 获取允许拼团的数组
|
|
|
|
* @date 2018-07-18
|
|
|
|
* @param string $tour_code 产品编号
|
|
|
|
* @return array 含允许拼团产品编号的数组
|
|
|
|
*/
|
|
|
|
public function get_allowed_combine($tour_code="")
|
|
|
|
{
|
|
|
|
$allowed = null;
|
|
|
|
$all_allowed = $this->allowed_combine();
|
|
|
|
foreach ($all_allowed as $key => $va) {
|
|
|
|
if (in_array($tour_code, $va)) {
|
|
|
|
$allowed = $va;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $allowed;
|
|
|
|
}
|
|
|
|
/** 允许拼团的不同编号产品 */
|
|
|
|
public function allowed_combine()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
// * 不同产品但部分行程相同所以允许拼团 *
|
|
|
|
array("XASIC-15", "XASIC-41"),
|
|
|
|
array("BJSIC-47", "BJSIC-41"),
|
|
|
|
// * 产品编号不同实际是同一产品 *
|
|
|
|
array("SHSIC-31", "SHSIC-41"),
|
|
|
|
array("SHSIC-32", "SHSIC-42"),
|
|
|
|
array("SHSIC-33", "SHSIC-43"),
|
|
|
|
array("SHSIC-34", "SHSIC-44")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* End of file order_finance.php */
|
|
|
|
/* Location: ./webht/third_party/trippestOrderSync/controllers/order_finance.php */
|