Commit b0241f75 by mushishixian

添加账号维护缓存

parent 7084aa32
...@@ -8,6 +8,7 @@ use App\Http\Services\SupplierAccountService; ...@@ -8,6 +8,7 @@ use App\Http\Services\SupplierAccountService;
use App\Http\Transformers\SupplierLogTransformer; use App\Http\Transformers\SupplierLogTransformer;
use App\Http\Validators\SupplierAccountValidator; use App\Http\Validators\SupplierAccountValidator;
use App\Model\LogModel; use App\Model\LogModel;
use App\Model\RedisModel;
use App\Model\SupplierAccountModel; use App\Model\SupplierAccountModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use App\Model\SupplierLogModel; use App\Model\SupplierLogModel;
...@@ -52,11 +53,14 @@ class SupplierAccountApiController extends Controller ...@@ -52,11 +53,14 @@ class SupplierAccountApiController extends Controller
$data['create_uid'] = $request->user->userId; $data['create_uid'] = $request->user->userId;
$data['password'] = Hash::make($data['password_raw']); $data['password'] = Hash::make($data['password_raw']);
$model = new SupplierAccountModel(); $model = new SupplierAccountModel();
$result = $model->insert($data); $id = $model->insertGetId($data);
if ($result) { if ($id) {
//还要插入一个redis
$redis = new RedisModel();
$redis->hset('yunxin_api_user_mobile', $data['mobile'], $id);
$this->response(0, '添加成功'); $this->response(0, '添加成功');
} }
$this->response(-1, '添加失败', $result); $this->response(-1, '添加失败');
} }
//修改 //修改
......
...@@ -31,7 +31,7 @@ class SupplierAccountValidator ...@@ -31,7 +31,7 @@ class SupplierAccountValidator
if (empty($receipt['id'])) { if (empty($receipt['id'])) {
$model = new SupplierAccountModel(); $model = new SupplierAccountModel();
$count = $model->where('supplier_code',$receipt['supplier_code']) $count = $model->where('supplier_code',$receipt['supplier_code'])
->where('mobile',$receipt['mobile'])->count(); ->orWhere('mobile',$receipt['mobile'])->count();
if ($count > 0) { if ($count > 0) {
return '该供应商以及对应的账号已经存在,请更换手机号'; return '该供应商以及对应的账号已经存在,请更换手机号';
} }
......
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 sign in to comment