作者 lms

合并分支 'lms' 到 'develop'

Lms



查看合并请求 !281
@@ -392,6 +392,7 @@ class SyncProject extends Command @@ -392,6 +392,7 @@ class SyncProject extends Command
392 'level_id' => 6, 392 'level_id' => 6,
393 'level_day' => $data['exclusive_aicc_day'] ?: 1, 393 'level_day' => $data['exclusive_aicc_day'] ?: 1,
394 'from_order_id' => $data['from_order_id'], 394 'from_order_id' => $data['from_order_id'],
  395 + 'nickname' => $data['username_sales'] ?? $data['principal_mobile'],
395 ]; 396 ];
396 397
397 //sign 398 //sign
@@ -423,6 +424,7 @@ class SyncProject extends Command @@ -423,6 +424,7 @@ class SyncProject extends Command
423 'planday' => $data['exclusive_hagro_day'] ?: 1, 424 'planday' => $data['exclusive_hagro_day'] ?: 1,
424 'from_order_id' => $data['from_order_id'], 425 'from_order_id' => $data['from_order_id'],
425 'agent_phone' => Channel::where('source_id', $data['company_id'])->value('contact_mobile') ?: '', 426 'agent_phone' => Channel::where('source_id', $data['company_id'])->value('contact_mobile') ?: '',
  427 + 'nickname' => $data['username_sales'] ?? $data['principal_mobile'],
426 ]; 428 ];
427 $common = new Common(); 429 $common = new Common();
428 $token = $common->encrypt($param); 430 $token = $common->encrypt($param);
@@ -13,6 +13,8 @@ use App\Models\Com\UpdateOldInfo; @@ -13,6 +13,8 @@ use App\Models\Com\UpdateOldInfo;
13 use App\Models\News\News; 13 use App\Models\News\News;
14 use App\Models\News\NewsCategory; 14 use App\Models\News\NewsCategory;
15 use App\Models\Product\Category; 15 use App\Models\Product\Category;
  16 +use App\Models\Product\Extend;
  17 +use App\Models\Product\ExtendInfo;
16 use App\Models\Product\Keyword; 18 use App\Models\Product\Keyword;
17 use App\Models\Product\Product; 19 use App\Models\Product\Product;
18 use App\Models\RouteMap\RouteMap; 20 use App\Models\RouteMap\RouteMap;
@@ -241,6 +243,8 @@ class ProjectUpdate extends Command @@ -241,6 +243,8 @@ class ProjectUpdate extends Command
241 243
242 $model = new Product(); 244 $model = new Product();
243 $category_model = new Category(); 245 $category_model = new Category();
  246 + $extend_model = new Extend();
  247 + $extend_info_model = new ExtendInfo();
244 $logic = new CategoryLogic(); 248 $logic = new CategoryLogic();
245 249
246 foreach ($items as $item) { 250 foreach ($items as $item) {
@@ -252,7 +256,7 @@ class ProjectUpdate extends Command @@ -252,7 +256,7 @@ class ProjectUpdate extends Command
252 $gallery = []; 256 $gallery = [];
253 if ($item['images'] ?? []) { 257 if ($item['images'] ?? []) {
254 foreach ($item['images'] as $k_img => $img) { 258 foreach ($item['images'] as $k_img => $img) {
255 - $gallery[] = ['alt' => 'This is a product picture', 'url' => $this->source_download($img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)]; 259 + $gallery[] = ['alt' => '', 'url' => $this->source_download($img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)];
256 } 260 }
257 } 261 }
258 //分类 262 //分类
@@ -286,25 +290,71 @@ class ProjectUpdate extends Command @@ -286,25 +290,71 @@ class ProjectUpdate extends Command
286 ]); 290 ]);
287 $this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id); 291 $this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id);
288 292
  293 + //扩展字段
  294 + if ($item['extend'] ?? []) {
  295 + foreach (array_reverse($item['extend']) as $ke => $ve) {
  296 + $extend = $extend_model->read(['title' => $ke]);
  297 + if (!$extend) {
  298 + $extend_key = $this->get_extend_key($extend_model);
  299 + $extend_model->add([
  300 + 'project_id' => $project_id,
  301 + 'title' => $ke,
  302 + 'type' => 1,
  303 + 'key' => $extend_key
  304 + ]);
  305 + } else {
  306 + $extend_key = $extend['key'];
  307 + }
  308 +
  309 + $extend_info = $extend_info_model->read(['key' => $extend_key, 'product_id' => $id]);
  310 + if (!$extend_info) {
  311 + $extend_info_model->add([
  312 + 'key' => $extend_key,
  313 + 'project_id' => $project_id,
  314 + 'product_id' => $id,
  315 + 'values' => $ve,
  316 + 'type' => 1
  317 + ]);
  318 + }
  319 + }
  320 + }
  321 +
289 CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $link_type, $language_list, $page_list); 322 CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $link_type, $language_list, $page_list);
290 $is_flush = 1; 323 $is_flush = 1;
291 } catch (\Exception $e) { 324 } catch (\Exception $e) {
292 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 325 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
293 continue; 326 continue;
294 } 327 }
295 - } else {  
296 - $gallery = [];  
297 - if ($item['images'] ?? []) {  
298 - foreach ($item['images'] as $k_img => $img) {  
299 - $gallery[] = ['alt' => 'This is a product picture', 'url' => $this->source_download($img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)]; 328 + }else{
  329 + $id = $product['id'];
  330 + //扩展字段
  331 + if ($item['extend'] ?? []) {
  332 + foreach (array_reverse($item['extend']) as $ke => $ve) {
  333 + $extend = $extend_model->read(['title' => $ke]);
  334 + if (!$extend) {
  335 + $extend_key = $this->get_extend_key($extend_model);
  336 + $extend_model->add([
  337 + 'project_id' => $project_id,
  338 + 'title' => $ke,
  339 + 'type' => 1,
  340 + 'key' => $extend_key
  341 + ]);
  342 + } else {
  343 + $extend_key = $extend['key'];
  344 + }
  345 +
  346 + $extend_info = $extend_info_model->read(['key' => $extend_key, 'product_id' => $id]);
  347 + if (!$extend_info) {
  348 + $extend_info_model->add([
  349 + 'key' => $extend_key,
  350 + 'project_id' => $project_id,
  351 + 'product_id' => $id,
  352 + 'values' => $ve,
  353 + 'type' => 1
  354 + ]);
  355 + }
300 } 356 }
301 } 357 }
302 -  
303 - $edit = [  
304 - 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',  
305 - 'gallery' => Arr::a2s($gallery)  
306 - ];  
307 - $model->edit($edit, ['id' => $product['id']]);  
308 } 358 }
309 } 359 }
310 } 360 }
@@ -659,4 +709,16 @@ class ProjectUpdate extends Command @@ -659,4 +709,16 @@ class ProjectUpdate extends Command
659 return $url_complete; 709 return $url_complete;
660 } 710 }
661 } 711 }
  712 +
  713 + //获取自定义字段key
  714 + protected function get_extend_key($model, $i = 1)
  715 + {
  716 + $key = 'pd_extended_field_';
  717 + $info = $model->read(['key' => $key . $i]);
  718 + if ($info !== false) {
  719 + return $this->get_extend_key($model, $i + 1);
  720 + } else {
  721 + return $key . $i;
  722 + }
  723 + }
662 } 724 }
@@ -268,6 +268,7 @@ class ComController extends BaseController @@ -268,6 +268,7 @@ class ComController extends BaseController
268 'phone' => $this->user['mobile'], 268 'phone' => $this->user['mobile'],
269 'from_order_id' => $this->user['from_order_id'] ?? '5a179274si3j8z', // 提单系统 同步到个项目的唯一凭证(数字或者字符串) 269 'from_order_id' => $this->user['from_order_id'] ?? '5a179274si3j8z', // 提单系统 同步到个项目的唯一凭证(数字或者字符串)
270 'timestamp' => time(), // 接收到字符串解密出来以后需要 验证时间不超过30秒 超过时间视为无效授权 270 'timestamp' => time(), // 接收到字符串解密出来以后需要 验证时间不超过30秒 超过时间视为无效授权
  271 + 'nickname' => $this->user['name'], // 名称
271 ]; 272 ];
272 $common = new Common(); 273 $common = new Common();
273 $str = $common->encrypt($data); 274 $str = $common->encrypt($data);
@@ -33,7 +33,7 @@ class ProjectAssociationController extends BaseController @@ -33,7 +33,7 @@ class ProjectAssociationController extends BaseController
33 } 33 }
34 $status = (bool)request()->post('status', 1); # 1 - 正常, 0 - 禁用 34 $status = (bool)request()->post('status', 1); # 1 - 正常, 0 - 禁用
35 35
36 - $user_id = (int)request()->post('user_id', 0); 36 + $user_id = (int)env('AICC_WECHAT_USER_ID') ?? 0;
37 if (empty($user_id) && $status) { 37 if (empty($user_id) && $status) {
38 $this->fail('请选择要绑定的AICC用户!', Code::USER_PARAMS_ERROE); 38 $this->fail('请选择要绑定的AICC用户!', Code::USER_PARAMS_ERROE);
39 } 39 }
@@ -719,7 +719,8 @@ class ProjectLogic extends BaseLogic @@ -719,7 +719,8 @@ class ProjectLogic extends BaseLogic
719 'principal_mobile'=>$projectInfo['mobile'], 719 'principal_mobile'=>$projectInfo['mobile'],
720 'remark'=>'', 720 'remark'=>'',
721 'exclusive_aicc_day'=>$this->param['exclusive_aicc_day'] ?: 1, 721 'exclusive_aicc_day'=>$this->param['exclusive_aicc_day'] ?: 1,
722 - 'from_order_id'=>$projectInfo['from_order_id'] 722 + 'from_order_id'=>$projectInfo['from_order_id'],
  723 + 'nickname' => $projectInfo['lead_name'] ?? $projectInfo['mobile'],
723 ]; 724 ];
724 $this->toAicc($data); 725 $this->toAicc($data);
725 } 726 }
@@ -730,7 +731,8 @@ class ProjectLogic extends BaseLogic @@ -730,7 +731,8 @@ class ProjectLogic extends BaseLogic
730 'principal_mobile'=>$projectInfo['mobile'], 731 'principal_mobile'=>$projectInfo['mobile'],
731 'exclusive_hagro_day'=>$this->param['exclusive_hagro_day'] ?: 1, 732 'exclusive_hagro_day'=>$this->param['exclusive_hagro_day'] ?: 1,
732 'from_order_id'=>$projectInfo['from_order_id'], 733 'from_order_id'=>$projectInfo['from_order_id'],
733 - 'company_id'=>$projectInfo['channel']['channel_id'] 734 + 'company_id'=>$projectInfo['channel']['channel_id'],
  735 + 'nickname' => $projectInfo['lead_name'] ?? $projectInfo['mobile'],
734 ]; 736 ];
735 $this->toHagro($data); 737 $this->toHagro($data);
736 } 738 }
@@ -756,8 +758,7 @@ class ProjectLogic extends BaseLogic @@ -756,8 +758,7 @@ class ProjectLogic extends BaseLogic
756 /** 758 /**
757 * 同步到AICC 759 * 同步到AICC
758 * @param $data 760 * @param $data
759 - * @author zbj  
760 - * @date 2023/9/1 761 + * @return bool
761 */ 762 */
762 protected function toAicc($data){ 763 protected function toAicc($data){
763 $url = 'https://biz.ai.cc/api/sync_company_for_order'; 764 $url = 'https://biz.ai.cc/api/sync_company_for_order';
@@ -770,6 +771,7 @@ class ProjectLogic extends BaseLogic @@ -770,6 +771,7 @@ class ProjectLogic extends BaseLogic
770 'level_id' => 6, 771 'level_id' => 6,
771 'level_day' => $data['exclusive_aicc_day'] ?: 1, 772 'level_day' => $data['exclusive_aicc_day'] ?: 1,
772 'from_order_id' => $data['from_order_id'], 773 'from_order_id' => $data['from_order_id'],
  774 + 'nickname' => $data['nickname'],
773 ]; 775 ];
774 //sign 776 //sign
775 ksort($param); 777 ksort($param);
@@ -790,8 +792,9 @@ class ProjectLogic extends BaseLogic @@ -790,8 +792,9 @@ class ProjectLogic extends BaseLogic
790 /** 792 /**
791 * 同步到Hagro 793 * 同步到Hagro
792 * @param $data 794 * @param $data
793 - * @author zbj  
794 - * @date 2023/9/1 795 + * @return bool
  796 + * @throws AsideGlobalException
  797 + * @throws \App\Exceptions\BsideGlobalException
795 */ 798 */
796 protected function toHagro($data){ 799 protected function toHagro($data){
797 $url = 'https://admin.hagro.cn/globalso/create_project'; 800 $url = 'https://admin.hagro.cn/globalso/create_project';
@@ -801,6 +804,7 @@ class ProjectLogic extends BaseLogic @@ -801,6 +804,7 @@ class ProjectLogic extends BaseLogic
801 'planday' => $data['exclusive_hagro_day'] ?: 1, 804 'planday' => $data['exclusive_hagro_day'] ?: 1,
802 'from_order_id' => $data['from_order_id'], 805 'from_order_id' => $data['from_order_id'],
803 'agent_phone' => Channel::where('source_id', $data['company_id'])->value('contact_mobile') ?: '', 806 'agent_phone' => Channel::where('source_id', $data['company_id'])->value('contact_mobile') ?: '',
  807 + 'nickname' => $data['nickname'],
804 ]; 808 ];
805 $common = new Common(); 809 $common = new Common();
806 $token = $common->encrypt($param); 810 $token = $common->encrypt($param);