|
|
|
|
@ -9,39 +9,37 @@ class BIZ_train_model extends CI_Model {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//新增或更新价格
|
|
|
|
|
public function addOrUpdate($TPL_Train_No,$TPL_Train_Code,$TPL_From_Station_Code,$TPL_To_Station_Code,$TPL_Price){
|
|
|
|
|
public function addOrUpdate($tpc_from_station,$tpc_to_station,$tpc_content){
|
|
|
|
|
$sql = "IF NOT EXISTS(
|
|
|
|
|
SELECT 1
|
|
|
|
|
FROM TrainPriceList
|
|
|
|
|
WHERE TPL_Train_Code = '$TPL_Train_Code'
|
|
|
|
|
AND TPL_From_Station_Code = '$TPL_From_Station_Code'
|
|
|
|
|
AND TPL_To_Station_Code = '$TPL_To_Station_Code'
|
|
|
|
|
FROM TrainPriceCache
|
|
|
|
|
WHERE
|
|
|
|
|
tpc_from_station = '$tpc_from_station'
|
|
|
|
|
AND tpc_to_station = '$tpc_to_station'
|
|
|
|
|
) BEGIN
|
|
|
|
|
INSERT INTO TrainPriceList
|
|
|
|
|
INSERT INTO TrainPriceCache
|
|
|
|
|
(
|
|
|
|
|
TPL_Train_No,
|
|
|
|
|
TPL_Train_Code,
|
|
|
|
|
TPL_From_Station_Code,
|
|
|
|
|
TPL_To_Station_Code,
|
|
|
|
|
TPL_Price,
|
|
|
|
|
TPL_Datetime,
|
|
|
|
|
TPL_Source
|
|
|
|
|
tpc_from_station,
|
|
|
|
|
tpc_to_station,
|
|
|
|
|
tpc_content,
|
|
|
|
|
tpc_datetime,
|
|
|
|
|
tpc_source
|
|
|
|
|
)
|
|
|
|
|
VALUES
|
|
|
|
|
(
|
|
|
|
|
'$TPL_Train_No','$TPL_Train_Code','$TPL_From_Station_Code','$TPL_To_Station_Code','$TPL_Price',GETDATE(),'juhe'
|
|
|
|
|
'$tpc_from_station','$tpc_to_station','$tpc_content',GETDATE(),'juhe'
|
|
|
|
|
)
|
|
|
|
|
END
|
|
|
|
|
ELSE
|
|
|
|
|
BEGIN
|
|
|
|
|
UPDATE TrainPriceList
|
|
|
|
|
SET TPL_Train_No = '$TPL_Train_No',
|
|
|
|
|
TPL_Price = '$TPL_Price',
|
|
|
|
|
TPL_Datetime = GETDATE(),
|
|
|
|
|
UPDATE TrainPriceCache
|
|
|
|
|
SET tpc_from_station = '$tpc_from_station',
|
|
|
|
|
tpc_to_station = '$tpc_to_station',
|
|
|
|
|
tpc_datetime = GETDATE(),
|
|
|
|
|
TPL_Source = 'juhe'
|
|
|
|
|
WHERE TPL_Train_Code = '$TPL_Train_Code'
|
|
|
|
|
AND TPL_From_Station_Code = '$TPL_From_Station_Code'
|
|
|
|
|
AND TPL_To_Station_Code = '$TPL_To_Station_Code'
|
|
|
|
|
WHERE
|
|
|
|
|
tpc_from_station = '$tpc_from_station'
|
|
|
|
|
AND tpc_to_station = '$tpc_to_station'
|
|
|
|
|
END
|
|
|
|
|
";
|
|
|
|
|
$query = $this->INFO->query($sql);
|
|
|
|
|
|