|
@@ -2559,71 +2559,66 @@ class common {
|
|
|
|
|
|
|
|
public static function FixedAnswerAndLogData($fixedChat,$question_content){
|
|
public static function FixedAnswerAndLogData($fixedChat,$question_content){
|
|
|
$reference = "";
|
|
$reference = "";
|
|
|
- //单个处理:Shipments arriving in the next 7 days.
|
|
|
|
|
- if($fixedChat["fixed_faq"] == "Shipments arriving in the next 7 days."){
|
|
|
|
|
|
|
+ //返回格式相同的放到一起处理
|
|
|
|
|
+ if($fixedChat["fixed_faq"] == "Shipments arriving in the next 7 days."
|
|
|
|
|
+ || $fixedChat["fixed_faq"] == "What is the current status of my active shipments?"){
|
|
|
|
|
+
|
|
|
$reference = $fixedChat["answer_style"];
|
|
$reference = $fixedChat["answer_style"];
|
|
|
- //执行sql 语句
|
|
|
|
|
$sql = $fixedChat["fixed_sql"];
|
|
$sql = $fixedChat["fixed_sql"];
|
|
|
- // $sql = "select h_bol,place_of_receipt_exp,place_of_delivery_exp,description,eta,cargo_type
|
|
|
|
|
- // from (
|
|
|
|
|
- // SELECT h_bol, place_of_receipt_exp, place_of_delivery_exp,m.description,eta, '' as cargo_type
|
|
|
|
|
- // FROM public.kln_ocean oo
|
|
|
|
|
- // left join LATERAL (select a.code,a.description
|
|
|
|
|
- // from public.ocean_milestone a
|
|
|
|
|
- // inner join public.customer_service_milestone_sno s
|
|
|
|
|
- // on a.code = s.code
|
|
|
|
|
- // and s.type = 'sea'
|
|
|
|
|
- // and a.serial_no = oo.serial_no
|
|
|
|
|
- // and a.act_date is not null
|
|
|
|
|
- // order by s.sno desc limit 1) m on true
|
|
|
|
|
- // WHERE <{ExtendHand_KLN}> and oo.transport_mode = 'sea' and order_from = 'public' and m.code <> '' limit 20
|
|
|
|
|
- // ) t order by eta";
|
|
|
|
|
- //给所有sql 拼接用户权限
|
|
|
|
|
|
|
+ if($_POST['is_demo'] == 't'){
|
|
|
|
|
+ $sql = utils::getDmoeSqlForAi($fixedChat["fixed_faq"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ //拼接用户权限
|
|
|
$sqlWhere = ' ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
$sqlWhere = ' ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
- //根据public.kln_ocean 和 WHERE 的位置关系,带入权限
|
|
|
|
|
$_sql = str_replace('<{ExtendHand_KLN}>', $sqlWhere, $sql);
|
|
$_sql = str_replace('<{ExtendHand_KLN}>', $sqlWhere, $sql);
|
|
|
error_log($_sql);
|
|
error_log($_sql);
|
|
|
$data = common::excuteListSql($_sql);
|
|
$data = common::excuteListSql($_sql);
|
|
|
|
|
|
|
|
- //--[Details](https://example.com/details) [Notify](https://example.com/notify)
|
|
|
|
|
- foreach($data as $key =>$d){
|
|
|
|
|
- $data[$key]['action'] = "[Details](https://example.com/details) [Notify](https://example.com/notify)";
|
|
|
|
|
|
|
+ if($fixedChat["fixed_faq"] == "Shipments arriving in the next 7 days."){
|
|
|
|
|
+ foreach($data as $key =>$d){
|
|
|
|
|
+ $serial_no = common::deCode($d['serial_no'], 'E');
|
|
|
|
|
+ $httpUrl = "tracking/detail?a=".$serial_no."&_schemas=".$d["order_from"];
|
|
|
|
|
+ $data[$key]['action'] = "[Details](".$httpUrl.") [Notify](SystemSettings)";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if($fixedChat["fixed_faq"] == "What is the current status of my active shipments?"){
|
|
|
|
|
+ $refer_data =array();
|
|
|
|
|
+ foreach($data as $key =>$d){
|
|
|
|
|
+ $temp = array();
|
|
|
|
|
+ $temp['h_bol'] = $d['h_bol'];
|
|
|
|
|
+ $temp['place_of_receipt_exp'] = $d['place_of_receipt_exp'];
|
|
|
|
|
+ $temp['place_of_delivery_exp'] = $d['place_of_delivery_exp'];
|
|
|
|
|
+ $temp['description'] = $d['description'];
|
|
|
|
|
+ $temp['time'] = common::dealDateTime($d['act_date'],$d['act_time'],$d['timezone'],"m/d/Y");
|
|
|
|
|
+ $temp['locations'] = $d['locations'];
|
|
|
|
|
+ $temp['cargo_type'] = $d['cargo_type'];
|
|
|
|
|
+
|
|
|
|
|
+ $serial_no = common::deCode($d['serial_no'], 'E');
|
|
|
|
|
+ $httpUrl = "tracking/detail?a=".$serial_no."&_schemas=".$d["order_from"];
|
|
|
|
|
+ $temp['action'] = "[Details](".$httpUrl.") [Notify](SystemSettings)";
|
|
|
|
|
+ $refer_data[] = $temp;
|
|
|
|
|
+ }
|
|
|
|
|
+ $data = $refer_data;
|
|
|
}
|
|
}
|
|
|
$reference = utils::replacementsFixedMultilineForFixed($data,$fixedChat['answer_style'],$fixedChat['table_format_tr']);
|
|
$reference = utils::replacementsFixedMultilineForFixed($data,$fixedChat['answer_style'],$fixedChat['table_format_tr']);
|
|
|
|
|
|
|
|
//替换总数
|
|
//替换总数
|
|
|
$total = array("total" =>count($data));
|
|
$total = array("total" =>count($data));
|
|
|
$reference = utils::replacementsFixed($total,$reference,array("total"));
|
|
$reference = utils::replacementsFixed($total,$reference,array("total"));
|
|
|
- error_log($reference);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if($fixedChat["fixed_faq"] == "List shipments with milestone updates in the last 7 days."){
|
|
if($fixedChat["fixed_faq"] == "List shipments with milestone updates in the last 7 days."){
|
|
|
$reference = $fixedChat["answer_style"];
|
|
$reference = $fixedChat["answer_style"];
|
|
|
- //执行sql 语句
|
|
|
|
|
$sql = $fixedChat["fixed_sql"];
|
|
$sql = $fixedChat["fixed_sql"];
|
|
|
- // $sql = "select h_bol, description,update_date_format,update_date,timezone,locations
|
|
|
|
|
- // from (
|
|
|
|
|
- // select h_bol,description,to_char(update_date,'Mon DD') as update_date_format,update_date,
|
|
|
|
|
- // COALESCE(jsonb_data->>'milestone','')::jsonb->>'timezone' as timezone,
|
|
|
|
|
- // COALESCE(jsonb_data->>'milestone','')::jsonb->>'locations' as locations
|
|
|
|
|
- // from (SELECT oo.h_bol,s.description,a.update_date,public.getTimeAndLocationForKln(oo.serial_no,a.code,''::text)::jsonb as jsonb_data
|
|
|
|
|
- // from public.ocean_milestone a
|
|
|
|
|
- // inner join public.customer_service_milestone_sno s on a.code = s.code
|
|
|
|
|
- // inner join public.kln_ocean oo on oo.serial_no = a.serial_no and (<{ExtendHand_KLN}>)
|
|
|
|
|
- // where s.type = 'sea'
|
|
|
|
|
- // and a.act_date is not null
|
|
|
|
|
- // and a.update_date is not null
|
|
|
|
|
- // and a.update_date > '2025-04-06') po
|
|
|
|
|
- // )t";
|
|
|
|
|
-
|
|
|
|
|
- //给所有sql 拼接用户权限
|
|
|
|
|
|
|
+ if($_POST['is_demo'] == 't'){
|
|
|
|
|
+ $sql = utils::getDmoeSqlForAi($fixedChat["fixed_faq"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ //拼接用户权限
|
|
|
$sqlWhere = ' ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
$sqlWhere = ' ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
- //根据public.kln_ocean 和 WHERE 的位置关系,带入权限
|
|
|
|
|
$_sql = str_replace('<{ExtendHand_KLN}>', $sqlWhere, $sql);
|
|
$_sql = str_replace('<{ExtendHand_KLN}>', $sqlWhere, $sql);
|
|
|
error_log($_sql);
|
|
error_log($_sql);
|
|
|
$data = common::excuteListSql($_sql);
|
|
$data = common::excuteListSql($_sql);
|
|
|
|
|
|
|
|
- //--[Details](https://example.com/details) [Notify](https://example.com/notify)
|
|
|
|
|
$refer_data =array();
|
|
$refer_data =array();
|
|
|
foreach($data as $key =>$d){
|
|
foreach($data as $key =>$d){
|
|
|
$temp = array();
|
|
$temp = array();
|
|
@@ -2631,7 +2626,10 @@ class common {
|
|
|
$temp['description'] = $d['description'];
|
|
$temp['description'] = $d['description'];
|
|
|
$temp['update_date'] = common::dealDateTime($d['update_date'],"",$d['timezone'],"m/d/Y H:i:s");
|
|
$temp['update_date'] = common::dealDateTime($d['update_date'],"",$d['timezone'],"m/d/Y H:i:s");
|
|
|
$temp['locations'] = $d['locations'];
|
|
$temp['locations'] = $d['locations'];
|
|
|
- $temp['action'] = "[Details](https://example.com/details) [Notify](https://example.com/notify)";
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $serial_no = common::deCode($d['serial_no'], 'E');
|
|
|
|
|
+ $httpUrl = "tracking/detail?a=".$serial_no."&_schemas=".$d["order_from"];
|
|
|
|
|
+ $temp['action'] = "[Details](".$httpUrl.") [Notify](SystemSettings)";
|
|
|
$refer_data[] = $temp;
|
|
$refer_data[] = $temp;
|
|
|
}
|
|
}
|
|
|
$reference = utils::replacementsFixedMultilineForFixed($refer_data,$fixedChat['answer_style'],$fixedChat['table_format_tr']);
|
|
$reference = utils::replacementsFixedMultilineForFixed($refer_data,$fixedChat['answer_style'],$fixedChat['table_format_tr']);
|
|
@@ -2657,19 +2655,22 @@ class common {
|
|
|
|
|
|
|
|
if($fixedChat["fixed_faq"] == "Show me the full history of my container."){
|
|
if($fixedChat["fixed_faq"] == "Show me the full history of my container."){
|
|
|
$reference = $fixedChat["answer_style"];
|
|
$reference = $fixedChat["answer_style"];
|
|
|
- //执行sql 语句
|
|
|
|
|
$sql = $fixedChat["fixed_sql"];
|
|
$sql = $fixedChat["fixed_sql"];
|
|
|
-
|
|
|
|
|
|
|
+ if($_POST['is_demo'] == 't'){
|
|
|
|
|
+ $question_content = 'DRYU9375994';
|
|
|
|
|
+ }
|
|
|
$sqlArr = explode(";", $sql);
|
|
$sqlArr = explode(";", $sql);
|
|
|
-
|
|
|
|
|
$sqlOne = $sqlArr[0];
|
|
$sqlOne = $sqlArr[0];
|
|
|
- //给所有sql 拼接用户权限
|
|
|
|
|
|
|
+ //拼接用户权限
|
|
|
$sqlWhere = ' ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
$sqlWhere = ' ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
- //根据public.kln_ocean 和 WHERE 的位置关系,带入权限
|
|
|
|
|
$sqlOne = str_replace('<{ExtendHand_KLN}>', $sqlWhere, $sqlOne);
|
|
$sqlOne = str_replace('<{ExtendHand_KLN}>', $sqlWhere, $sqlOne);
|
|
|
$sqlOne = str_replace('<{ctnr}>', strtolower($question_content), $sqlOne);
|
|
$sqlOne = str_replace('<{ctnr}>', strtolower($question_content), $sqlOne);
|
|
|
|
|
+
|
|
|
error_log($sqlOne);
|
|
error_log($sqlOne);
|
|
|
$data = common::excuteListSql($sqlOne);
|
|
$data = common::excuteListSql($sqlOne);
|
|
|
|
|
+ if(empty($data)){
|
|
|
|
|
+ return "No valid Container number detected. Please try clicking on other FAQ questions or input your own question. Thank you.";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
//如果数据为空,用这个fileds配置的 把模板里值逐个替换为空
|
|
//如果数据为空,用这个fileds配置的 把模板里值逐个替换为空
|
|
|
$fileds = array("ctnr","size","h_bol","carrier","vessel","voyage","grs_kgs","ams_commodity","seal_no",
|
|
$fileds = array("ctnr","size","h_bol","carrier","vessel","voyage","grs_kgs","ams_commodity","seal_no",
|
|
@@ -2699,8 +2700,218 @@ class common {
|
|
|
}
|
|
}
|
|
|
$rsdata = array("complete_container_status" =>$complete_container_status);
|
|
$rsdata = array("complete_container_status" =>$complete_container_status);
|
|
|
$reference = utils::replacementsFixed($rsdata,$reference,[]);
|
|
$reference = utils::replacementsFixed($rsdata,$reference,[]);
|
|
|
- error_log($reference);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if($fixedChat["fixed_faq"] == "Show me the full history of my shipment."){
|
|
|
|
|
+ $reference = $fixedChat["answer_style"];
|
|
|
|
|
+ $sql = $fixedChat["fixed_sql"];
|
|
|
|
|
+ if($_POST['is_demo'] == 't'){
|
|
|
|
|
+ $question_content = 'XSTSNA003195';
|
|
|
|
|
+ }
|
|
|
|
|
+ $sqlArr = explode(";", $sql);
|
|
|
|
|
+ $sqlOne = $sqlArr[0];
|
|
|
|
|
+ //拼接用户权限
|
|
|
|
|
+ $sqlWhere = ' ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
|
|
+ $sqlOne = str_replace('<{ExtendHand_KLN}>', $sqlWhere, $sqlOne);
|
|
|
|
|
+ $sqlOne = str_replace('<h_bol>', strtolower($question_content), $sqlOne);
|
|
|
|
|
+
|
|
|
|
|
+ error_log($sqlOne);
|
|
|
|
|
+ $data = common::excuteListSql($sqlOne);
|
|
|
|
|
+ if(empty($data)){
|
|
|
|
|
+ return "No valid Shipment number detected. Please try clicking on other FAQ questions or input your own question. Thank you.";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //如果数据为空,用这个fileds配置的 把模板里值逐个替换为空
|
|
|
|
|
+ $fileds = array("h_bol","carrier_booking","po_no","service","incoterms","shipper_city","consignee_city","etd","eta",
|
|
|
|
|
+ "shipper","consignee","notify_party","origin_agent","destination_agent","carrier");
|
|
|
|
|
+ //Container Information替换
|
|
|
|
|
+ $reference = utils::replacementsFixed($data[0],$reference,$fileds);
|
|
|
|
|
+
|
|
|
|
|
+ //Complete Container Status
|
|
|
|
|
+ //根据第一个sql 查出来的serial_no,和 container_no.
|
|
|
|
|
+ $complete_container_status = "";
|
|
|
|
|
+ if (!empty($data)) {
|
|
|
|
|
+ $sqltwo = $sqlArr[1];
|
|
|
|
|
+ $sqltwo = str_replace('<{serial_no}>', $data[0]['serial_no'], $sqltwo);
|
|
|
|
|
+ $csdata = common::excuteListSql($sqltwo);
|
|
|
|
|
+ foreach($csdata as $csd){
|
|
|
|
|
+ $complete_container_status .= "- **".$csd['eventdate']." ".$csd['eventtime']."** ".$csd['description']." | ".$csd['uncity']." \n";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $rsdata = array("complete_container_status" =>$complete_container_status);
|
|
|
|
|
+ $reference = utils::replacementsFixed($rsdata,$reference,[]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($fixedChat["fixed_faq"] == "List shipments with container status updates in the last 7 days."){
|
|
|
|
|
+ $reference = $fixedChat["answer_style"];
|
|
|
|
|
+ $sql = $fixedChat["fixed_sql"];
|
|
|
|
|
+ if($_POST['is_demo'] == 't'){
|
|
|
|
|
+ $sql = utils::getDmoeSqlForAi($fixedChat["fixed_faq"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ //拼接用户权限
|
|
|
|
|
+ $sqlWhere = ' ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
|
|
+ $_sql = str_replace('<{ExtendHand_KLN}>', $sqlWhere, $sql);
|
|
|
|
|
+
|
|
|
|
|
+ error_log($_sql);
|
|
|
|
|
+ $data = common::excuteListSql($_sql);
|
|
|
|
|
+
|
|
|
|
|
+ $refer_data =array();
|
|
|
|
|
+ foreach($data as $key =>$d){
|
|
|
|
|
+ $temp = array();
|
|
|
|
|
+ $temp['container_no'] = $d['container_no'];
|
|
|
|
|
+ $temp['description'] = $d['description'];
|
|
|
|
|
+ $temp['time'] = common::dealDateTime($d['eventdate'],$d['eventtime'],$d['timezone'],"m/d/Y H:i:s");
|
|
|
|
|
+ $temp['uncity'] = $d['uncity'];
|
|
|
|
|
+
|
|
|
|
|
+ $serial_no = common::deCode($d['serial_no'], 'E');
|
|
|
|
|
+ $httpUrl = "tracking/detail?a=".$serial_no."&_schemas=".$d["order_from"];
|
|
|
|
|
+ $temp['action'] = "[Details](".$httpUrl.") [Notify](SystemSettings)";
|
|
|
|
|
+ $refer_data[] = $temp;
|
|
|
|
|
+ }
|
|
|
|
|
+ $reference = utils::replacementsFixedMultilineForFixed($refer_data,$fixedChat['answer_style'],$fixedChat['table_format_tr']);
|
|
|
|
|
+
|
|
|
|
|
+ //替换总数
|
|
|
|
|
+ $total = array("total" =>count($data));
|
|
|
|
|
+ $reference = utils::replacementsFixed($total,$reference,array("total"));
|
|
|
|
|
+
|
|
|
|
|
+ //Timeline View
|
|
|
|
|
+ $dateGroups = utils::uniqueGroupbyData("container_no","_eventdate",$data);
|
|
|
|
|
+ $timeline_view = "";
|
|
|
|
|
+ if(!empty($dateGroups)){
|
|
|
|
|
+ $timeline_view = "## Timeline View: \n";
|
|
|
|
|
+ }
|
|
|
|
|
+ foreach($dateGroups as $date => $count){
|
|
|
|
|
+ $timeline_view.="- ".$date.": ".$count." containers have been updated \n";
|
|
|
|
|
+ }
|
|
|
|
|
+ $total = array("Timeline View" =>$timeline_view);
|
|
|
|
|
+ $reference = utils::replacementsFixed($total,$reference,array("Timeline View"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($fixedChat["fixed_faq"] == "Today's shipments summary."){
|
|
|
|
|
+ $reference = $fixedChat["answer_style"];
|
|
|
|
|
+ $sql = $fixedChat["fixed_sql"];
|
|
|
|
|
+ if($_POST['is_demo'] == 't'){
|
|
|
|
|
+ $sql = utils::getDmoeSqlForAi($fixedChat["fixed_faq"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ //拼接用户权限
|
|
|
|
|
+ $sqlWhere = ' ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
|
|
+ $_sql = str_replace('<{ExtendHand_KLN}>', $sqlWhere, $sql);
|
|
|
|
|
+ error_log($_sql);
|
|
|
|
|
+ $data = common::excuteListSql($_sql);
|
|
|
|
|
+
|
|
|
|
|
+ $refer_data =array();
|
|
|
|
|
+ foreach($data as $key =>$d){
|
|
|
|
|
+ $temp = array();
|
|
|
|
|
+ $temp['h_bol'] = $d['h_bol'];
|
|
|
|
|
+ $temp['transport_mode'] = $d['transport_mode'];
|
|
|
|
|
+ $temp['place_of_receipt_exp'] = $d['place_of_receipt_exp'];
|
|
|
|
|
+ $temp['place_of_delivery_exp'] = $d['place_of_delivery_exp'];
|
|
|
|
|
+ $temp['action_type'] = $d['action_type'];
|
|
|
|
|
+ $temp['time'] = common::dealDateTime($d['act_date'],$d['act_time'],$d['timezone'],"m/d/Y H:i:s");
|
|
|
|
|
+ $temp['locations'] = $d['locations'];
|
|
|
|
|
+
|
|
|
|
|
+ $serial_no = common::deCode($d['serial_no'], 'E');
|
|
|
|
|
+ $httpUrl = "tracking/detail?a=".$serial_no."&_schemas=".$d["order_from"];
|
|
|
|
|
+ $temp['action'] = "[Details](".$httpUrl.") [Notify](SystemSettings)";
|
|
|
|
|
+ $refer_data[] = $temp;
|
|
|
|
|
+ }
|
|
|
|
|
+ $reference = utils::replacementsFixedMultilineForFixed($refer_data,$fixedChat['answer_style'],$fixedChat['table_format_tr']);
|
|
|
|
|
+
|
|
|
|
|
+ //替换总数
|
|
|
|
|
+ $d1_day = empty($data) ? "" : $data[0]['_update_date'];
|
|
|
|
|
+ $total = array("total" =>count($data),"date" => $d1_day);
|
|
|
|
|
+ $reference = utils::replacementsFixed($total,$reference,[]);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ $dep_total = 0;
|
|
|
|
|
+ $arr_total = 0;
|
|
|
|
|
+ $del_total = 0;
|
|
|
|
|
+ $dateGroups = utils::uniqueGroupbyData("","action_type",$data);
|
|
|
|
|
+ foreach($dateGroups as $action_type => $count){
|
|
|
|
|
+ if($action_type == "Departure"){
|
|
|
|
|
+ $dep_total = $count;
|
|
|
|
|
+ }
|
|
|
|
|
+ if($action_type == "Arrived"){
|
|
|
|
|
+ $arr_total = $count;
|
|
|
|
|
+ }
|
|
|
|
|
+ if($action_type == "Delivered"){
|
|
|
|
|
+ $del_total = $count;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $total = array("dep" =>$dep_total,"arr" => $arr_total,"del" => $del_total);
|
|
|
|
|
+ $reference = utils::replacementsFixed($total,$reference,[]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($fixedChat["fixed_faq"] == "Show me the current location of my shipment."){
|
|
|
|
|
+ $reference = $fixedChat["answer_style"];
|
|
|
|
|
+ $sql = $fixedChat["fixed_sql"];
|
|
|
|
|
+ if($_POST['is_demo'] == 't'){
|
|
|
|
|
+ $question_content = 'DRYU9375994';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $sqlArr = explode(";", $sql);
|
|
|
|
|
+ $sqlOne = $sqlArr[0];
|
|
|
|
|
+ //拼接用户权限
|
|
|
|
|
+ $sqlWhere = ' ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
|
|
+ $sqlOne = str_replace('<{ExtendHand_KLN}>', $sqlWhere, $sqlOne);
|
|
|
|
|
+ $sqlOne = str_replace('<{ctnr}>', strtolower($question_content), $sqlOne);
|
|
|
|
|
+ error_log($sqlOne);
|
|
|
|
|
+ $data = common::excuteListSql($sqlOne);
|
|
|
|
|
+ if(empty($data)){
|
|
|
|
|
+ return "No valid Container/BOL number detected. Please try clicking on other FAQ questions or input your own question. Thank you.";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //如果数据为空,用这个fileds配置的 把模板里值逐个替换为空
|
|
|
|
|
+ $fileds = array("tracking_no","h_bol","question_content","transport_mode","shipper_city","consignee_city","carrier","vessel","voyage","link");
|
|
|
|
|
+ $ref_data = array();
|
|
|
|
|
+ if(!empty($data)){
|
|
|
|
|
+ $ref_data = $data[0];
|
|
|
|
|
+ $ref_data['question_content'] = $question_content;
|
|
|
|
|
+
|
|
|
|
|
+ $serial_no = common::deCode($data[0]['serial_no'], 'E');
|
|
|
|
|
+ $httpUrl = "tracking/detail?a=".$serial_no."&_schemas=".$data[0]['order_from'];
|
|
|
|
|
+ $ref_data['link'] = $httpUrl;
|
|
|
|
|
+ }
|
|
|
|
|
+ $reference = utils::replacementsFixed($data[0],$reference,$fileds);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($fixedChat["fixed_faq"] == "Sort my active shipments by earliest arrival date."){
|
|
|
|
|
+ $reference = $fixedChat["answer_style"];
|
|
|
|
|
+ $sql = $fixedChat["fixed_sql"];
|
|
|
|
|
+ if($_POST['is_demo'] == 't'){
|
|
|
|
|
+ $sql = utils::getDmoeSqlForAi($fixedChat["fixed_faq"]);
|
|
|
|
|
+ }
|
|
|
|
|
+ //拼接用户权限
|
|
|
|
|
+ $sqlWhere = ' ' . common::searchExtendHand_KLN("ocean", $_SESSION["ONLINE_USER"]);
|
|
|
|
|
+ $_sql = str_replace('<{ExtendHand_KLN}>', $sqlWhere, $sql);
|
|
|
|
|
+ error_log($_sql);
|
|
|
|
|
+ $data = common::excuteListSql($_sql);
|
|
|
|
|
+
|
|
|
|
|
+ $refer_data =array();
|
|
|
|
|
+ foreach($data as $key =>$d){
|
|
|
|
|
+ $temp = array();
|
|
|
|
|
+ $temp['eta'] = $d['eta'];
|
|
|
|
|
+ $temp['h_bol'] = $d['h_bol'];
|
|
|
|
|
+ $temp['transport_mode'] = $d['transport_mode'];
|
|
|
|
|
+ $temp['place_of_receipt_exp'] = $d['place_of_receipt_exp'];
|
|
|
|
|
+ $temp['place_of_delivery_exp'] = $d['place_of_delivery_exp'];
|
|
|
|
|
+ $temp['day_to_arr'] = $d['day_to_arr'];
|
|
|
|
|
+
|
|
|
|
|
+ $serial_no = common::deCode($d['serial_no'], 'E');
|
|
|
|
|
+ $httpUrl = "tracking/detail?a=".$serial_no."&_schemas=".$d["order_from"];
|
|
|
|
|
+ $temp['action'] = "[Details](".$httpUrl.") [Notify](SystemSettings)";
|
|
|
|
|
+ $refer_data[] = $temp;
|
|
|
|
|
+ }
|
|
|
|
|
+ $data = $refer_data;
|
|
|
|
|
+ $reference = utils::replacementsFixedMultilineForFixed($data,$fixedChat['answer_style'],$fixedChat['table_format_tr']);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if($fixedChat["fixed_faq"] == "Set up automatic notifications for shipment updates."
|
|
|
|
|
+ || $fixedChat["fixed_faq"] == "How can I view the detailed shipping route of my package?" ){
|
|
|
|
|
+ $reference = $fixedChat["answer_style"];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ error_log($reference);
|
|
|
return $reference;
|
|
return $reference;
|
|
|
}
|
|
}
|
|
|
|
|
|