Commit b0241f75 by mushishixian

添加账号维护缓存

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