$code ])->find(); if($commonInfo) { $commonInfo = $commonInfo->toArray(); } cache('common_info:'.$code, $commonInfo, 60 * 60 * 24); } if (!$commonInfo) { $this->success(); } $this->successWithData([ 'imageUrl' => $commonInfo['value'], 'tips' => $commonInfo['max'] ]); } public function friendConfigSave() { $params = $this->request->post(); if (empty($params['imageUrl'])) { $this->error('顶部图片地址不能为空'); } if (empty($params['tips'])) { $this->error('邀请文案不能为空'); } if (strlen($params['tips']) > 20) { $this->error('邀请文案不能大于20个字符'); } $commonInfo = (new CommonInfo())->getByCode(999); if ($commonInfo) { Db::name('common_info')->where([ 'id' => $commonInfo['id'] ])->update([ 'max' => $params['tips'], 'value' => $params['imageUrl'] ]); }else{ Db::name('common_info')->insert([ 'code' => 999, 'max' => $params['tips'], 'value' => $params['imageUrl'], 'min' => '邀请好友配置', 'is_app_use' => 1, 'create_at' => getNormalDate() ]); } cache('common_info:999', Db::name('common_info')->where([ 'type' => 999 ])->find()); $this->success(); } }