作者 lms

合并分支 'lms' 到 'develop'

Lms



查看合并请求 !281
... ... @@ -392,6 +392,7 @@ class SyncProject extends Command
'level_id' => 6,
'level_day' => $data['exclusive_aicc_day'] ?: 1,
'from_order_id' => $data['from_order_id'],
'nickname' => $data['username_sales'] ?? $data['principal_mobile'],
];
//sign
... ... @@ -423,6 +424,7 @@ class SyncProject extends Command
'planday' => $data['exclusive_hagro_day'] ?: 1,
'from_order_id' => $data['from_order_id'],
'agent_phone' => Channel::where('source_id', $data['company_id'])->value('contact_mobile') ?: '',
'nickname' => $data['username_sales'] ?? $data['principal_mobile'],
];
$common = new Common();
$token = $common->encrypt($param);
... ...
... ... @@ -13,6 +13,8 @@ use App\Models\Com\UpdateOldInfo;
use App\Models\News\News;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Product\Extend;
use App\Models\Product\ExtendInfo;
use App\Models\Product\Keyword;
use App\Models\Product\Product;
use App\Models\RouteMap\RouteMap;
... ... @@ -241,6 +243,8 @@ class ProjectUpdate extends Command
$model = new Product();
$category_model = new Category();
$extend_model = new Extend();
$extend_info_model = new ExtendInfo();
$logic = new CategoryLogic();
foreach ($items as $item) {
... ... @@ -252,7 +256,7 @@ class ProjectUpdate extends Command
$gallery = [];
if ($item['images'] ?? []) {
foreach ($item['images'] as $k_img => $img) {
$gallery[] = ['alt' => 'This is a product picture', 'url' => $this->source_download($img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)];
$gallery[] = ['alt' => '', 'url' => $this->source_download($img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)];
}
}
//分类
... ... @@ -286,25 +290,71 @@ class ProjectUpdate extends Command
]);
$this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id);
//扩展字段
if ($item['extend'] ?? []) {
foreach (array_reverse($item['extend']) as $ke => $ve) {
$extend = $extend_model->read(['title' => $ke]);
if (!$extend) {
$extend_key = $this->get_extend_key($extend_model);
$extend_model->add([
'project_id' => $project_id,
'title' => $ke,
'type' => 1,
'key' => $extend_key
]);
} else {
$extend_key = $extend['key'];
}
$extend_info = $extend_info_model->read(['key' => $extend_key, 'product_id' => $id]);
if (!$extend_info) {
$extend_info_model->add([
'key' => $extend_key,
'project_id' => $project_id,
'product_id' => $id,
'values' => $ve,
'type' => 1
]);
}
}
}
CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $link_type, $language_list, $page_list);
$is_flush = 1;
} catch (\Exception $e) {
echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
continue;
}
} else {
$gallery = [];
if ($item['images'] ?? []) {
foreach ($item['images'] as $k_img => $img) {
$gallery[] = ['alt' => 'This is a product picture', 'url' => $this->source_download($img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)];
}else{
$id = $product['id'];
//扩展字段
if ($item['extend'] ?? []) {
foreach (array_reverse($item['extend']) as $ke => $ve) {
$extend = $extend_model->read(['title' => $ke]);
if (!$extend) {
$extend_key = $this->get_extend_key($extend_model);
$extend_model->add([
'project_id' => $project_id,
'title' => $ke,
'type' => 1,
'key' => $extend_key
]);
} else {
$extend_key = $extend['key'];
}
$extend_info = $extend_info_model->read(['key' => $extend_key, 'product_id' => $id]);
if (!$extend_info) {
$extend_info_model->add([
'key' => $extend_key,
'project_id' => $project_id,
'product_id' => $id,
'values' => $ve,
'type' => 1
]);
}
}
}
$edit = [
'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',
'gallery' => Arr::a2s($gallery)
];
$model->edit($edit, ['id' => $product['id']]);
}
}
}
... ... @@ -659,4 +709,16 @@ class ProjectUpdate extends Command
return $url_complete;
}
}
//获取自定义字段key
protected function get_extend_key($model, $i = 1)
{
$key = 'pd_extended_field_';
$info = $model->read(['key' => $key . $i]);
if ($info !== false) {
return $this->get_extend_key($model, $i + 1);
} else {
return $key . $i;
}
}
}
... ...
... ... @@ -268,6 +268,7 @@ class ComController extends BaseController
'phone' => $this->user['mobile'],
'from_order_id' => $this->user['from_order_id'] ?? '5a179274si3j8z', // 提单系统 同步到个项目的唯一凭证(数字或者字符串)
'timestamp' => time(), // 接收到字符串解密出来以后需要 验证时间不超过30秒 超过时间视为无效授权
'nickname' => $this->user['name'], // 名称
];
$common = new Common();
$str = $common->encrypt($data);
... ...
... ... @@ -33,7 +33,7 @@ class ProjectAssociationController extends BaseController
}
$status = (bool)request()->post('status', 1); # 1 - 正常, 0 - 禁用
$user_id = (int)request()->post('user_id', 0);
$user_id = (int)env('AICC_WECHAT_USER_ID') ?? 0;
if (empty($user_id) && $status) {
$this->fail('请选择要绑定的AICC用户!', Code::USER_PARAMS_ERROE);
}
... ...
... ... @@ -719,7 +719,8 @@ class ProjectLogic extends BaseLogic
'principal_mobile'=>$projectInfo['mobile'],
'remark'=>'',
'exclusive_aicc_day'=>$this->param['exclusive_aicc_day'] ?: 1,
'from_order_id'=>$projectInfo['from_order_id']
'from_order_id'=>$projectInfo['from_order_id'],
'nickname' => $projectInfo['lead_name'] ?? $projectInfo['mobile'],
];
$this->toAicc($data);
}
... ... @@ -730,7 +731,8 @@ class ProjectLogic extends BaseLogic
'principal_mobile'=>$projectInfo['mobile'],
'exclusive_hagro_day'=>$this->param['exclusive_hagro_day'] ?: 1,
'from_order_id'=>$projectInfo['from_order_id'],
'company_id'=>$projectInfo['channel']['channel_id']
'company_id'=>$projectInfo['channel']['channel_id'],
'nickname' => $projectInfo['lead_name'] ?? $projectInfo['mobile'],
];
$this->toHagro($data);
}
... ... @@ -756,8 +758,7 @@ class ProjectLogic extends BaseLogic
/**
* 同步到AICC
* @param $data
* @author zbj
* @date 2023/9/1
* @return bool
*/
protected function toAicc($data){
$url = 'https://biz.ai.cc/api/sync_company_for_order';
... ... @@ -770,6 +771,7 @@ class ProjectLogic extends BaseLogic
'level_id' => 6,
'level_day' => $data['exclusive_aicc_day'] ?: 1,
'from_order_id' => $data['from_order_id'],
'nickname' => $data['nickname'],
];
//sign
ksort($param);
... ... @@ -790,8 +792,9 @@ class ProjectLogic extends BaseLogic
/**
* 同步到Hagro
* @param $data
* @author zbj
* @date 2023/9/1
* @return bool
* @throws AsideGlobalException
* @throws \App\Exceptions\BsideGlobalException
*/
protected function toHagro($data){
$url = 'https://admin.hagro.cn/globalso/create_project';
... ... @@ -801,6 +804,7 @@ class ProjectLogic extends BaseLogic
'planday' => $data['exclusive_hagro_day'] ?: 1,
'from_order_id' => $data['from_order_id'],
'agent_phone' => Channel::where('source_id', $data['company_id'])->value('contact_mobile') ?: '',
'nickname' => $data['nickname'],
];
$common = new Common();
$token = $common->encrypt($param);
... ...