/** * * 创建二手交易 */ public function create() { if ($this->get_method() != 'POST') { $this->send_response(405, NULL, '请求的方法不存在'); } $data = $this->get_data(); $title = $data['title'] ? trim($data['title']) : ''; $description = $data['description'] ? trim($data['description']) : ''; $price = $data['price'] ? trim($data['price']) : ''; $sync = $data['sync'] ? $data['sync'] : array(); $private = $data['private'] ? (int) $data['private'] : 0; $image = $data['image'] ? $data['image'] : array(); $location = $data['location'] ? $data['location'] : array(); $str_len = str::strLen($description); if (empty($title)) { $this->send_response(400, NULL, '401301:标题为空'); } if (empty($description)) { $this->send_response(400, NULL, '401302:描述为空'); } if (!empty($image) && !is_array($image)) { $this->send_response(400, NULL, '401303:图片参数不正确'); } if (!empty($location) && (!$location['longitude'] || !$location['latitude'])) { $this->send_response(400, NULL, '401304:地理位置参数不正确'); } if ($str_len > 500) { $this->send_response(400, NULL, '401305:字数超出500字'); } $synced = $this->_sync_weibo($sync, $this->user_id, $site, $title, $description, $image, $location); if ($this->model->create($title, $description, $price, $private, $image, $location, $this->user_id, $synced)) { $this->send_response(200, array('sync' => $synced)); } $this->send_response(400, NULL, '401306:创建二手交易失败'); }