diff --git a/application/third_party/trainsystem/controllers/api.php b/application/third_party/trainsystem/controllers/api.php index 2356894e..e6a2e17f 100644 --- a/application/third_party/trainsystem/controllers/api.php +++ b/application/third_party/trainsystem/controllers/api.php @@ -422,11 +422,13 @@ class api extends CI_Controller{ $from_date = $this->input->post("from_date"); $to_date = $this->input->post("to_date"); $examine = $this->input->post("examine"); + $importht = $this->input->post("importht"); $reback=array();//返回的数据 $reback["from_date"] = $from_date; $reback["to_date"] = $to_date; $reback["examine"] = $examine; + $reback["importht"] = $importht; if(!empty($from_date) && !empty($to_date)){ //拼接发送的报文 @@ -457,6 +459,12 @@ class api extends CI_Controller{ $string_r = "";//输出 $arr = array();//整合完成的数组,写进excel表的数据 + + //账单导入到汉特。 先删除同一编码的数据,防止重复 + if (!empty($importht)){ + $BillSn = date('Ymd',strtotime($from_date)).date('Ymd',strtotime($to_date)); //这是获取开始结束日期作为编码,一定要和下面获取代码一样。 + $this->BIZ_train_model->del_lanhai_bill($BillSn); + } foreach ($ResponseData->data->records as $record) { # code... @@ -475,6 +483,22 @@ class api extends CI_Controller{ } $arr[] = $arrRecord; + + //账单导入到汉特。 + if (!empty($importht)){ + $AddHt_data = new stdClass(); //账单保存到汉特 + $AddHt_data->BillSn = date('Ymd',strtotime($from_date)).date('Ymd',strtotime($to_date)); + $AddHt_data->BillDate = $record->saveDay; + $AddHt_data->OrderId = $record->mainOrderId; + $AddHt_data->VEIName = LANHAI_appId; + $AddHt_data->From = "桂林海纳国际旅行社有限公司"; + $AddHt_data->BillType = $record->type; + $AddHt_data->OrderType = null; + $AddHt_data->Cost = -($record->price); + $AddHt_data->Memo = $record->handleTime; + //入库 + $this->BIZ_train_model->add_lanhai_bill($AddHt_data); + } } //print_r($arr); diff --git a/application/third_party/trainsystem/models/BIZ_train_model.php b/application/third_party/trainsystem/models/BIZ_train_model.php index 1113e56f..ae42485e 100644 --- a/application/third_party/trainsystem/models/BIZ_train_model.php +++ b/application/third_party/trainsystem/models/BIZ_train_model.php @@ -350,7 +350,7 @@ class BIZ_train_model extends CI_Model { ) or EXISTS(select Top 1 1 from InfoManager.dbo.trainsystem WHERE ts_cold_sn = COLD_SN and (ts_status = '5' or ts_status='11') and ts_cold_sn not in (select ts_cold_sn from InfoManager.dbo.trainsystem - where (ts_status='4' or ts_status='3' or ts_status='10') and ts_cold_sn = COLD_SN) )) + where (ts_status='4' or ts_status='3' or ts_status='2' or ts_status='10') and ts_cold_sn = COLD_SN) )) AND COLD_SN NOT IN ( select FOI_COLD_SN from BIZ_FlightsOrderInfo where FOI_COLD_SN=COLD_SN and FOI_TrainNetOrderNo>'') and (COLD_StartDate between GETDATE() and CONVERT(varchar(100),GETDATE()+14,23)+' 23:59') and isnull((select top 1 ts_autotimes from InfoManager.dbo.trainsystem where ts_cold_sn= bcld.cold_sn order by ts_id desc),0)<4 @@ -665,4 +665,32 @@ class BIZ_train_model extends CI_Model { $sql = "delete from trainsystem where ts_id = '860'"; $query = $this->INFO->query($sql); } + + //添加澜海账单到汉特 + function add_lanhai_bill($data){ + //2.添加 + $sql2 = "insert into BIZ_Platform_BookingInfo_XC ( + XC_BillSN,XC_BillDate,XC_OrderID,XC_VEIName,XC_From,XC_BillType,XC_Cost,XC_Memo,XC_Creator,XC_CreateDate + ) values ( + '{$data->BillSn}', + '{$data->BillDate}', + '{$data->OrderId}', + '{$data->VEIName}', + '{$data->From}', + '{$data->BillType}', + '{$data->Cost}', + '{$data->Memo}', + '29', + getdate() + )"; + $query = $this->HT->query($sql2); + } + + //删除重复数据 + function del_lanhai_bill($BillSn){ + //1.删除数据 ,防止重复,根据 XC_BillSn + $sql = "delete from BIZ_Platform_BookingInfo_XC where XC_BillSn = '{$BillSn}' and XC_VEIName='9082253783' "; + $query=$this->HT->query($sql); + + } } diff --git a/application/third_party/trainsystem/views/export_lanhai.php b/application/third_party/trainsystem/views/export_lanhai.php index 3ffc50a6..8da92eac 100644 --- a/application/third_party/trainsystem/views/export_lanhai.php +++ b/application/third_party/trainsystem/views/export_lanhai.php @@ -7,8 +7,12 @@