添加绑定用户功能
This commit is contained in:
parent
8373590803
commit
48e51a87b7
@ -398,12 +398,24 @@ class LocalStore extends Api
|
||||
// 绑定用户
|
||||
public function bindUser()
|
||||
{
|
||||
|
||||
try {
|
||||
$post = $this->request->post();
|
||||
LocalStoreLogic::bindUser($post);
|
||||
return JsonServer::success('添加成功');
|
||||
} catch (\Exception $e) {
|
||||
return JsonServer::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//解绑用户
|
||||
public function unbindUser()
|
||||
{
|
||||
|
||||
try {
|
||||
$post = $this->request->post();
|
||||
LocalStoreLogic::unbindUser($post);
|
||||
return JsonServer::success('解绑成功');
|
||||
} catch (\Exception $e) {
|
||||
return JsonServer::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@ namespace app\api\logic;
|
||||
use app\common\basics\Logic;
|
||||
use app\common\model\LocalStore;
|
||||
use app\common\model\localstore\LocalGoodsStore;
|
||||
use app\common\model\localstore\LocalStoreBind;
|
||||
use app\common\model\LocalStoreOrder;
|
||||
use app\common\model\LocalStorePostStation;
|
||||
use app\common\model\user\User;
|
||||
@ -491,4 +492,35 @@ class LocalStoreLogic extends Logic
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function bindUser($post)
|
||||
{
|
||||
if ($post['user']['id'] <=0 ) {
|
||||
throw new \Exception('缺少用户ID');
|
||||
}
|
||||
|
||||
if (empty($post['user']['rule'])) {
|
||||
throw new \Exception('请为用户分配权限');
|
||||
}
|
||||
|
||||
$data = array();
|
||||
foreach ($post['user']['rule'] as $k => &$v) {
|
||||
$data[$k]['lstore_id'] = $post['lstore_id'];
|
||||
$data[$k]['bind_user_id'] = $post['user']['id'];
|
||||
$data[$k]['rule_id'] = $v;
|
||||
$data[$k]['bind_time'] = time();
|
||||
}
|
||||
|
||||
$model = new LocalStoreBind();
|
||||
$result = $model->insertAll($data);
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new \Exception('添加失败');
|
||||
}
|
||||
|
||||
public static function unbindUser($post)
|
||||
{
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user