Commit fe1bc370 authored by Kulya's avatar Kulya 😊

Upd alvbx get sect

parent b5947730
......@@ -98,13 +98,27 @@
</div>
<div class="form-group row">
<div class="form-group ml-4">
<div class="form-check">
<label class="form-check-label" for="autocreateentity">Авто создание лида при вызове</label>
<select id="autocreateentity">
<option value="0" selected>Не создовать</option>
<option value="1">Авто создание ЛИДа при вызове</option>
<option value="2">Авто создание СДЕЛКи при вызове</option>
<option value="3">Авто создание КОНТАКТа при вызове</option>
</select>
</div>
</div>
</div>
<!--div class="form-group row">
<div class="form-group ml-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="autocreatelead">
<label class="form-check-label" for="autocreatelead">Авто создание лида при вызове</label>
</div>
</div>
</div>
</div-->
<div class="form-group row">
<div class="form-group ml-4">
......
......@@ -311,10 +311,16 @@ class AloVoiceHandle implements \PAMI\Listener\IEventListener
$callRegisterParams = array(
// 'CALL_START_DATE' => date("Y-m-d H:i",$bxchannels[$eventKeys["linkedid"]]["BX24_begincall"] ), //'2016-16-11 10:10',
'CALL_START_DATE' => date("c",$bxchannels[$eventKeys["linkedid"]]["BX24_begincall"] ), //'2016-16-11 10:10',
'CRM_CREATE' => (!empty($this->config["autocreatelead"]) && !empty($this->config["autocreatelead"]=="false")) ? 0 : 1,
'CRM_CREATE' => 0, //(!empty($this->config["autocreatelead"]) && !empty($this->config["autocreatelead"]=="false")) ? 0 : 1,
'SHOW' => (!empty($this->config["showcallcard"]) && !empty($this->config["showcallcard"]=="false")) ? 0 : 1,
'DESC' => "AloVoiceCall"
);
if(!empty($this->config["autocreateentity"])){
}
if(!empty($bxchannels[$eventKeys["linkedid"]]["BX24_CRM_TYPE"])){
$callRegisterParams["CRM_ENTITY_TYPE"] = $bxchannels[$eventKeys["linkedid"]]["BX24_CRM_TYPE"];
}
......
......@@ -10,6 +10,7 @@ class AloVoiceRest
private $options;
private $config;
private $smsparts;
private $billzconf;
public function __construct($config) {
$this->config = $config;
......@@ -339,7 +340,7 @@ class AloVoiceRest
private function billz_products_all_synch($r=false) {
$tms["0_begin"] = time();
$return = ["result"=>false];
$date = "2018-01-01T00:00:00Z";
$date = "2017-01-01T00:00:00Z";
echo "\nBegin loading billz products [date_from:".$date."]...";
$allProds = BillzRest::getProducts($date);
......@@ -372,8 +373,14 @@ class AloVoiceRest
$loadedCnt = 0;
$bxlang = 'Ru';
$tms["0_begin"] = time();
$arSections = [];
$arSubSections = [];
$arTrdSections = [];
$arOffices = [];
$arAllProperties = [
"ID" => 'ID', //123123123,
"name" => 'Наименование', //"*Tahorat va namoz",
"sku" => 'Артикуль', //"Q001",
"barCode" => 'Баркод', //"9789943542556",
......@@ -381,8 +388,8 @@ class AloVoiceRest
"priceUSD" => 'ЦенаUSD', //23000,
"discountAmount" => 'Скидка', //0,
"qty" => 'Количество', //15,
"_imageUrls.url" => 'Изображение', //15,
"_offices" => 'В складах', //15,
".imageUrls" => 'Изображение', //15, [url]
".offices" => 'В складах', //15, [officeID,officeName,qty]
/*{
"officeID": 1347,
"officeName" => "Qamar Kitoblar A.Navoiy",
......@@ -394,8 +401,8 @@ class AloVoiceRest
];
$sdata = date("Y-m-d")."T".date("H").":00:00Z";
// $sdata = date("Y-m-d")."T".date("H").":00:00Z";
$sdata = "2017-01-01T00:00:00Z";
$first = BillzRest::getProducts($sdata);
......@@ -405,18 +412,87 @@ class AloVoiceRest
$arAllProperties["properties_".$prk] = $prk;
}
}
foreach($first["answer"]["result"] as $prd){
if(!empty($prd["properties"]["CATEGORY"])){
if(!in_array($prd["properties"]["CATEGORY"],$arSections)){
$arSections[] = $prd["properties"]["CATEGORY"];
}
}
if(!empty($prd["properties"]["SUB_CATEGORY"])){
if(!in_array($prd["properties"]["SUB_CATEGORY"],$arSubSections)){
$arSubSections[] = $prd["properties"]["SUB_CATEGORY"];
}
}
if(!empty($prd["properties"]["ПОДКАТЕГОРИЯ2"])){
if(!in_array($prd["properties"]["ПОДКАТЕГОРИЯ2"],$arTrdSections)){
$arTrdSections[] = $prd["properties"]["ПОДКАТЕГОРИЯ2"];
}
}
// process offices
if(!empty($prd["offices"])){
foreach($prd["offices"] as $ofc){
if(!empty($ofc["officeID"]) && !empty($ofc["officeName"]) && empty($arOffices[$ofc["officeID"]])){
$arOffices[$ofc["officeID"]] = $ofc["officeName"];
}
}
}
}
}
$arConf = self::get_billzconf();
$arConf["billz_productfields"] = $arAllProperties;
self::save_billzconf(["conf"=>$arConf]);
$return = ["billzprops"=>count($arAllProperties)];
$tms["2_end"] = time();
$tms["9_ALL"] = $tms["3_end"]-$tms["0_begin"];
$return = ["billzprops"=>count($arAllProperties), "categories"=>$arSections, "subcats"=>$arSubSections, "trdcats"=>$arTrdSections, "offices"=>$arOffices, "times"=>$tms];
ALVC::eLog($return,"------ AloVoiceRest :: billz_catalog_infos_synch CRON Done!");
return $return;
}
private function bx_get_product_section($name='') {
$name='BOOKS';
$conf = self::get_billzconf();
$result = false;
return $conf;
if(!empty($conf["bx_catalog_id"])){
$result = BxRest::call("catalog.section.list",[
// "select"=>[],
"filter"=>[
"name" => $name
]
]);
}
return $result;
}
private function bx_add_product_section($name,$parent_id=false) {
$conf = self::get_billzconf();
$result = false;
if(!empty($conf["bx_catalog_id"])){
$addParams = [
"iblockId" => $conf["bx_catalog_id"],
"name" => $name,
// "code": 'news'
];
if(!empty($parent_id) && is_numeric($parent_id)){
$addParams["iblockSectionId"] = $parent_id;
}
$result = BxRest::call("catalog.section.add",["fields"=>$addParams]);
}
return $result;
}
private function billz_catalog_infos_synch_OLD($r=false) {
$p=1;
$ps=10;
......@@ -481,26 +557,26 @@ class AloVoiceRest
}
$p++;
}
// {
// "count": 3122,
// "billzprops": {
// "barCode": "Баркод",
// "counts.active": "Количество",
// "id": "ID",
// "name": "Наименование",
// "officeId": "Номер магазина",
// "officeName": "Магазин",
// "prices.retailPriceUzs": "Цена",
// "vendorCode": "Код производителя",
// "properties.subCategory": "Подкатегория",
// "properties.category": "Категория",
// "properties.brand": "Бренд",
// "properties.description": "Описание",
// "properties.size": "Размер",
// "properties.collection": "Коллекция",
// "properties.season": "Сезон"
// },
// "alltime": 336
// {
// "count": 3122,
// "billzprops": {
// "barCode": "Баркод",
// "counts.active": "Количество",
// "id": "ID",
// "name": "Наименование",
// "officeId": "Номер магазина",
// "officeName": "Магазин",
// "prices.retailPriceUzs": "Цена",
// "vendorCode": "Код производителя",
// "properties.subCategory": "Подкатегория",
// "properties.category": "Категория",
// "properties.brand": "Бренд",
// "properties.description": "Описание",
// "properties.size": "Размер",
// "properties.collection": "Коллекция",
// "properties.season": "Сезон"
// },
// "alltime": 336
// }
// $prCount = count($first["answer"]["result"]["data"]["results"]);
// var_dump($first["answer"]["result"]["data"]["results"]);
......@@ -608,8 +684,18 @@ class AloVoiceRest
}
private function get_billzconf() {
$jsConf = file_get_contents(__DIR__."/billz.conf");
return json_decode($jsConf,1);
$arConf = [];
if(!empty($this->billzconf)){
$arConf = $this->billzconf;
}
elseif(file_exists(__DIR__."/billz.conf")){
$jsConf = file_get_contents(__DIR__."/billz.conf");
$arConf = $this->billzconf = json_decode($jsConf,1);
}
return $arConf;
}
private function get_synchstatus($all,$cnt) {
......
......@@ -23,7 +23,7 @@ require_once (__DIR__.'/keys.php');
$getParams = [
"LastUpdatedDate" => $sdata,
"WithProductPhotoOnly" => 0,
"IncludeEmptyStocks" => 0
"IncludeEmptyStocks" => 1 //0
];
$result = static::callCurl("products.get",$getParams);
......
{"billz_productfields":{"ID":"ID","name":"\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435","sku":"\u0410\u0440\u0442\u0438\u043a\u0443\u043b\u044c","barCode":"\u0411\u0430\u0440\u043a\u043e\u0434","price":"\u0426\u0435\u043d\u0430","priceUSD":"\u0426\u0435\u043d\u0430USD","discountAmount":"\u0421\u043a\u0438\u0434\u043a\u0430","qty":"\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e",".imageUrls":"\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435",".offices":"\u0412 \u0441\u043a\u043b\u0430\u0434\u0430\u0445","properties_BRAND":"BRAND","properties_CATEGORY":"CATEGORY","properties_COLLECTION":"COLLECTION","properties_COLOR":"COLOR","properties_DESCRIPTION":"DESCRIPTION","properties_GENDER":"GENDER","properties_SEASON":"SEASON","properties_SIZE":"SIZE","properties_SUB_CATEGORY":"SUB_CATEGORY","properties_\u0410\u0412\u0422\u041e\u0420":"\u0410\u0412\u0422\u041e\u0420","properties_\u0412\u0415\u0421":"\u0412\u0415\u0421","properties_\u0416\u0410\u041d\u0420":"\u0416\u0410\u041d\u0420","properties_\u0418\u0417\u0414\u0410\u0422\u0415\u041b\u042c\u0421\u0422\u0412\u041e":"\u0418\u0417\u0414\u0410\u0422\u0415\u041b\u042c\u0421\u0422\u0412\u041e","properties_\u041a\u041e\u041b\u0418\u0427\u0415\u0421\u0422\u0412\u041e_\u0421\u0422\u0420\u0410\u041d\u0418\u0426":"\u041a\u041e\u041b\u0418\u0427\u0415\u0421\u0422\u0412\u041e_\u0421\u0422\u0420\u0410\u041d\u0418\u0426","properties_\u041d\u0410\u041f\u0420\u0410\u0412\u041b\u0415\u041d\u0418\u0415":"\u041d\u0410\u041f\u0420\u0410\u0412\u041b\u0415\u041d\u0418\u0415","properties_\u041f\u041e\u0414\u041a\u0410\u0422\u0415\u0413\u041e\u0420\u0418\u042f2":"\u041f\u041e\u0414\u041a\u0410\u0422\u0415\u0413\u041e\u0420\u0418\u042f2","properties_\u041f\u041e\u0421\u0422\u0410\u0412\u0429\u0418\u041a":"\u041f\u041e\u0421\u0422\u0410\u0412\u0429\u0418\u041a","properties_\u0422\u0418\u041f_\u041e\u0411\u041b\u041e\u0416\u041a\u0418":"\u0422\u0418\u041f_\u041e\u0411\u041b\u041e\u0416\u041a\u0418"}}
\ No newline at end of file
This diff is collapsed.
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