$user_id]); return $detail ? ((int)$detail['apply_status']['value'] === 10) : false; } /** * 获取最新的一条申请数据 */ public function getDatail($user_id) { $detail = $this->where(['user_id' => $user_id])->order("create_time desc")->find(); return $detail; } /** * 提交申请 */ public function submit($user, $data) { // 数据整理 $data = [ 'user_id' => $user['user_id'], 'real_name' => trim($data['name']), 'mobile' => trim($data['mobile']), // 'province_id' => trim($data['province_id']), // 'city_id' => trim($data['city_id']), // 'region_id' => trim($data['region_id']), // 'location_address' => $data['location_address'], // 'longitude' => $data['longitude'], // 'latitude' => $data['latitude'], // 'detail' => $data['detail'], 'apply_type' => 10, 'apply_status' => 10, 'apply_time' => time(), 'app_id' => self::$app_id, ]; return $this->add($user, $data); } /** * 更新申请信息 */ private function add($user, $data) { // 实例化模型 $model = self::detail(['user_id' => $user['user_id']]) ?: $this; // 更新记录 $this->startTrans(); try { // 保存申请信息 $model->save($data); $this->commit(); return true; } catch (\Exception $e) { $this->error = $e->getMessage(); $this->rollback(); return false; } } }