Browse Source

添加服务专员判断

master
Mike 5 years ago
parent
commit
92fe8d81d6
  1. 35
      app/Controller/v3/HomeController.php
  2. 30
      app/Model/v3/ServicePersonnel.php
  3. 39
      app/Service/v3/Implementations/UserCenterBlockService.php
  4. 6
      app/Service/v3/Implementations/UserInfoService.php
  5. 2
      app/Service/v3/Interfaces/UserCenterBlockServiceInterface.php
  6. 2
      app/Service/v3/Interfaces/UserInfoServiceInterface.php

35
app/Controller/v3/HomeController.php

@ -122,19 +122,34 @@ class HomeController extends BaseController
{ {
$params = $request->validated(); $params = $request->validated();
$data['user'] = $this->userInfoService->detail($params['user_id']); $data['user'] = $this->userInfoService->detail($params['user_id']);
$data['user']['store_info'] = $this->userInfoService->getStoreByUID($params['user_id']);
$data['user']['role'] = [
[
$store_info = $this->userInfoService->getStoreByUID($params['user_id']);
$sp_info = $this->userInfoService->getServicePersonnelByUID($params['user_id']);
$data['user']['store_info'] = $store_info;
$data['user']['sp_info'] = $sp_info;
$roles = [];
//角色判断
if($store_info){
$roles[] = [
'key'=>'store',
'title'=>'商家', 'title'=>'商家',
'color'=>'#0091FF' 'color'=>'#0091FF'
],
[
'title'=>'骑手',
'color'=>'#009100'
],
];
];
}
if($sp_info){
$roles[] = [
'key'=>'sp',
'title'=>'服务',
'color'=>'#0091FF'
];
}
$data['user']['collection_count'] = $this->collectStoreService->countByUser($params['user_id']); $data['user']['collection_count'] = $this->collectStoreService->countByUser($params['user_id']);
$data['user']['coupon_count'] = $this->couponService->countAvailableByUser($params['user_id']); $data['user']['coupon_count'] = $this->couponService->countAvailableByUser($params['user_id']);
$data['user']['role'] = $roles;
$ssdb = ApplicationContext::getContainer()->get(SSDBTask::class); $ssdb = ApplicationContext::getContainer()->get(SSDBTask::class);
$data['badge'] = [ $data['badge'] = [
@ -148,7 +163,7 @@ class HomeController extends BaseController
$data['badge'] = array_merge($data['badge'], $badge); $data['badge'] = array_merge($data['badge'], $badge);
} }
$data['block'] = $this->userCenterBlockService->all();
$data['block'] = $this->userCenterBlockService->all($roles);
return $this->success($data); return $this->success($data);
} }

30
app/Model/v3/ServicePersonnel.php

@ -0,0 +1,30 @@
<?php
declare (strict_types=1);
namespace App\Model\v3;
use App\Model\Model;
class ServicePersonnel extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'lanzu_service_personnel';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
// protected $casts = [
// 'set_reward' => 'array'
// ];
}

39
app/Service/v3/Implementations/UserCenterBlockService.php

@ -22,13 +22,14 @@ class UserCenterBlockService implements UserCenterBlockServiceInterface
// TODO: Implement undo() method. // TODO: Implement undo() method.
} }
public function all()
public function all($roles = [])
{ {
// //
$img_host = config('alioss.img_host').'/'; $img_host = config('alioss.img_host').'/';
return [
$blocks = [
[ [
'type' => 'user', 'type' => 'user',
'title' => '常用功能', 'title' => '常用功能',
@ -39,15 +40,35 @@ class UserCenterBlockService implements UserCenterBlockServiceInterface
['name' => '联系服务站', 'icon' => $img_host . 'user_icons/contact_fwz.png', 'type' => 'page', 'path' => '/pages/contactMarket/contactMarket','command'=>'contact_fwz'], ['name' => '联系服务站', 'icon' => $img_host . 'user_icons/contact_fwz.png', 'type' => 'page', 'path' => '/pages/contactMarket/contactMarket','command'=>'contact_fwz'],
['name' => '关于懒族', 'icon' => $img_host . 'user_icons/about_lz.png', 'type' => 'page', 'path' => '/pages/aboutUs/aboutUs','command'=>'about'], ['name' => '关于懒族', 'icon' => $img_host . 'user_icons/about_lz.png', 'type' => 'page', 'path' => '/pages/aboutUs/aboutUs','command'=>'about'],
] ]
],
[
'type' => 'store_user',
'title' => '商户相关',
'items' => [
['name' => '商家入口', 'icon' => $img_host . 'user_icons/shop_enter.png', 'type' => 'page', 'path' => '/pages/shopLogin/shopLogin','command'=>'store_login']
]
] ]
]; ];
foreach ($roles as $key => $item) {
# code...
if($item['key'] == 'store'){
$blocks[] = [
'type' => 'store_user',
'title' => '商户相关',
'items' => [
['name' => '商家入口', 'icon' => $img_host . 'user_icons/shop_enter.png', 'type' => 'page', 'path' => '/pages/shopLogin/shopLogin','command'=>'store_login']
]
];
}
if($item['key'] == 'sp'){
$blocks[] = [
'type' => 'sp_user',
'title' => '服务专员',
'items' => [
['name' => '评价', 'icon' => $img_host . 'user_icons/shop_enter.png', 'type' => 'page', 'path' => '/zh_cjdianc/pages/appraise/index','command'=>'store_login']
]
];
}
}
return $blocks;
} }
} }

6
app/Service/v3/Implementations/UserInfoService.php

@ -6,6 +6,7 @@ use App\Constants\v3\ErrorCode;
use App\Constants\v3\SsdbKeys; use App\Constants\v3\SsdbKeys;
use App\Exception\ErrorCodeException; use App\Exception\ErrorCodeException;
use App\Model\v3\User; use App\Model\v3\User;
use App\Model\v3\ServicePersonnel;
use App\Model\v3\Store; use App\Model\v3\Store;
use App\Service\v3\Interfaces\UserInfoServiceInterface; use App\Service\v3\Interfaces\UserInfoServiceInterface;
use App\TaskWorker\SSDBTask; use App\TaskWorker\SSDBTask;
@ -82,5 +83,10 @@ class UserInfoService implements UserInfoServiceInterface
return $store; return $store;
} }
public function getServicePersonnelByUID($userId)
{
$sp = ServicePersonnel::where('user_id',$userId)->select(['id'])->first();
return $sp;
}
} }

2
app/Service/v3/Interfaces/UserCenterBlockServiceInterface.php

@ -9,5 +9,5 @@ interface UserCenterBlockServiceInterface
public function do(); public function do();
public function check(); public function check();
public function undo(); public function undo();
public function all();
public function all($roles = []);
} }

2
app/Service/v3/Interfaces/UserInfoServiceInterface.php

@ -9,4 +9,6 @@ interface UserInfoServiceInterface
public function undo($userId); public function undo($userId);
public function detail($userId); public function detail($userId);
public function getStoreByUID($userId); public function getStoreByUID($userId);
public function getServicePersonnelByUID($userId);
} }
Loading…
Cancel
Save