Commit 563221c8 authored by Kulya's avatar Kulya 😊

Add billz clientId to order 1

parent afd25a23
...@@ -2337,7 +2337,26 @@ CFU='; ...@@ -2337,7 +2337,26 @@ CFU=';
// } // }
public function beginCall($data){ public function beginCall($data){
if(!empty($data["BX24_CALLID"])){
$updRes = self::statAPI("update",[
"ID" => $data["BX24_CALLID"],
"KEY" => "4Ad49wD",
'fields' => [
"CALLDATE" => date("Y-m-d"),
"CHANNEL" => (!empty($data["channel"])) ? $data["channel"] : "",
"TIME_BEGINCALL" => time(),
"DIALSTATUS" => 'BEGIN',
"CALL_DATETIME" => date("Y-m-d H:i:s"),
"HOUR" => date("H"),
]
]);
self::eLog($updRes,"--== beginCall STATAPI UPD RES:");
return $data["BX24_CALLID"];
}
$stRes = self::statAPI("insert",[ $stRes = self::statAPI("insert",[
"KEY" => "4Ad49wD", "KEY" => "4Ad49wD",
'fields' => [ 'fields' => [
...@@ -2358,6 +2377,7 @@ CFU='; ...@@ -2358,6 +2377,7 @@ CFU=';
else { else {
return 0; return 0;
} }
} }
public function startCall($queryData,$full=[]){ public function startCall($queryData,$full=[]){
......
...@@ -244,6 +244,10 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener ...@@ -244,6 +244,10 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener
elseif ($eventName == "Newchannel" && $eventKeys["priority"] == "1" && $eventKeys["uniqueid"] == $eventKeys["linkedid"]) { elseif ($eventName == "Newchannel" && $eventKeys["priority"] == "1" && $eventKeys["uniqueid"] == $eventKeys["linkedid"]) {
self::eLog($eventKeys,"--== NEW NewchannelEvent new Call Handle".$eventKeys["linkedid"] ); self::eLog($eventKeys,"--== NEW NewchannelEvent new Call Handle".$eventKeys["linkedid"] );
$calls[$eventKeys["linkedid"]] = $eventKeys; //new AloVoiceHandle($event); $calls[$eventKeys["linkedid"]] = $eventKeys; //new AloVoiceHandle($event);
if(!empty($bxchannels[$eventKeys["linkedid"]]["BX24_CALLID"])){
$eventKeys["BX24_CALLID"] = $bxchannels[$eventKeys["linkedid"]]["BX24_CALLID"];
}
$bxchannels[$eventKeys["linkedid"]] = $eventKeys; $bxchannels[$eventKeys["linkedid"]] = $eventKeys;
$bxchannels[$eventKeys["linkedid"]]["BX24_begincall"] = time(); $bxchannels[$eventKeys["linkedid"]]["BX24_begincall"] = time();
$bxchannels[$eventKeys["linkedid"]]["BX24_CALLTONUM"] = $eventKeys["exten"]; $bxchannels[$eventKeys["linkedid"]]["BX24_CALLTONUM"] = $eventKeys["exten"];
......
...@@ -754,9 +754,12 @@ class AloVoiceRest ...@@ -754,9 +754,12 @@ class AloVoiceRest
]; ];
if($order_client_id = self::process_order_client($order["id"])){
$arOrderParams["client_id"] = $order_client_id;
}
$arResOrders[] = BillzRest::createOrder($arOrderParams); $arResOrders[] = BillzRest::createOrder($arOrderParams);
$arOrder = self::process_order_client($order["id"]);
} }
self::set_orders_last_update(); self::set_orders_last_update();
...@@ -778,7 +781,7 @@ class AloVoiceRest ...@@ -778,7 +781,7 @@ class AloVoiceRest
if(empty($id)){ $id = 56; } if(empty($id)){ $id = 56; }
$res = BxRest::call("sale.order.get",[ "id" => $id ]); $res = BxRest::call("sale.order.get",[ "id" => $id ]);
ALVC::eLog($res["result"],"------ Billz :: Order RES:"); // ALVC::eLog($res["result"],"------ Billz :: Order RES:");
if(empty($res["result"]["order"]['clients'])){ return false; } if(empty($res["result"]["order"]['clients'])){ return false; }
$client = $res["result"]["order"]['clients'][0]; $client = $res["result"]["order"]['clients'][0];
...@@ -786,7 +789,7 @@ class AloVoiceRest ...@@ -786,7 +789,7 @@ class AloVoiceRest
$clientTypeId = $client["entityTypeId"]; $clientTypeId = $client["entityTypeId"];
if($clientTypeId==3){ if($clientTypeId==3){
$resCont = BxRest::call("crm.contact.get",[ "id" => $clientId ]); $resCont = BxRest::call("crm.contact.get",[ "id" => $clientId ]);
ALVC::eLog($resCont["result"],"------ Billz :: Client(contact) RES:"); // ALVC::eLog($resCont["result"],"------ Billz :: Client(contact) RES:");
if(empty($resCont["result"])){ if(empty($resCont["result"])){
return false; return false;
...@@ -806,19 +809,17 @@ class AloVoiceRest ...@@ -806,19 +809,17 @@ class AloVoiceRest
$arClientParams['birthDate'] = $arBdate[0]; $arClientParams['birthDate'] = $arBdate[0];
} }
ALVC::eLog($arClientParams,"------ Billz :: Client Add PARAMS:");
$clientAddRes = BillzRest::createClient($arClientParams); $clientAddRes = BillzRest::createClient($arClientParams);
ALVC::eLog($clientAddRes,"------ Billz :: Client Add RES:"); // ALVC::eLog($clientAddRes,"------ Billz :: Client Add RES:");
if(!empty($clientAddRes["answer"]["result"]["clientId"])){ if(!empty($clientAddRes["answer"]["result"]["clientId"])){
$blzClientID = $clientAddRes["answer"]["result"]["clientId"]; $blzClientID = $clientAddRes["answer"]["result"]["clientId"];
$resContUpd = BxRest::call("crm.contact.update",[ "id" => $clientId, "fields"=> ["UF_CRM_1644411792448"=>$blzClientID] ]); $resContUpd = BxRest::call("crm.contact.update",[ "id" => $clientId, "fields"=> ["UF_CRM_1644411792448"=>$blzClientID] ]);
ALVC::eLog($resContUpd,"------ Billz :: Client(contact) Update RES:"); // ALVC::eLog($resContUpd,"------ Billz :: Client(contact) Update RES:");
return $blzClientID;
} }
} }
} }
return false;
} }
private function get_bx_order_products($id=false) { private function get_bx_order_products($id=false) {
......
...@@ -90,7 +90,9 @@ require_once (__DIR__.'/keys.php'); ...@@ -90,7 +90,9 @@ require_once (__DIR__.'/keys.php');
]; ];
$qPparams['subTotalPrice'] = $qPparams['subTotalPrice']+$price; $qPparams['subTotalPrice'] = $qPparams['subTotalPrice']+$price;
} }
if(){
$qPparams['clientId'] = $params["client_id"];
}
$qPparams['orderID'] = $params["order_id"]; $qPparams['orderID'] = $params["order_id"];
$qPparams['dateCreated'] = date('Y-m-d').'T'.date('H:i:s').'Z'; $qPparams['dateCreated'] = date('Y-m-d').'T'.date('H:i:s').'Z';
$qPparams['datePaid'] = date('Y-m-d').'T'.date('H:i:s').'Z'; $qPparams['datePaid'] = date('Y-m-d').'T'.date('H:i:s').'Z';
...@@ -189,7 +191,7 @@ require_once (__DIR__.'/keys.php'); ...@@ -189,7 +191,7 @@ require_once (__DIR__.'/keys.php');
$result = []; $result = [];
if(!empty($arSettings)) if(!empty($arSettings))
{ {
if($method=="orders.create") { $arSettings["apiversion"]="v2"; } if($method=="orders.create") { $arSettings["apiversion"]="v3"; } //v2
if($method=="client.create") { $arSettings["apiversion"]="v1"; } if($method=="client.create") { $arSettings["apiversion"]="v1"; }
$url = $arSettings["url"].$arSettings["apiversion"]."/"; $url = $arSettings["url"].$arSettings["apiversion"]."/";
...@@ -201,12 +203,7 @@ require_once (__DIR__.'/keys.php'); ...@@ -201,12 +203,7 @@ require_once (__DIR__.'/keys.php');
]; ];
$sendData = json_encode($arData); $sendData = json_encode($arData);
ALVC::eLog($sendData,"------ Billz :: curl req_Orig:"); // ALVC::eLog($sendData,"------ Billz :: curl req_Orig:");
if($method=="client.create"){
$rsendData = '{"jsonrpc":"2.0","method":"client.create","params":{"phone":"998931830000","firstName":"Ivan","lastName":"Petrov","gender":1,"birthDate":"1999-01-17"},"id":"1"}';
ALVC::eLog($rsendData,"------ Billz :: curl req_True:");
}
$result["params"] = $sendData; $result["params"] = $sendData;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment