Ejemplo n.º 1
0
 public function post()
 {
     try {
         /*$requestBody = $app->request->getBody();
         		$requestJson = json_decode($requestBody, true);*/
         $requestJson = RequestBodyHandler::getJsonBody($this->_app);
         RequestBodyHandler::verifyJsonBody($requestJson, array("ProductId", "Comment", "ConsumerId"));
         $obj = R::dispense('productcomment');
         $obj->productid = $requestJson->ProductId;
         $obj->comment = $requestJson->Comment;
         $obj->consumerid = $requestJson->ConsumerId;
         $obj->lastmodifiedtime = now();
         $id = R::store($obj);
         $response = R::find('productcomment', 'id=?', array($id));
         echo ResponseJsonHandler::normalizeJsonResponse(R::exportAll($response));
         //sendSuccess(json_encode(R::exportAll($obj)), 201);
     } catch (Exception $ex) {
         return ExceptionHandler::Response($ex, $this->_app);
     }
 }
Ejemplo n.º 2
0
Archivo: Product.php Proyecto: WTer/NJB
 public function put_BasicInfo($ProductId)
 {
     try {
         $requestJson = RequestBodyHandler::getJsonBody($this->_app);
         RequestBodyHandler::verifyJsonBody($requestJson, array("Name", "Description", "Type", "Price", "OriginalPrice", "Unit", "Freight"));
         $product = R::findOne('product', 'id=?', array($ProductId));
         if (!isset($product) || empty($product)) {
             throw new RecordNotFoundException("Record not found, id:" . $ProductId);
         }
         $product->name = $requestJson->Name;
         $product->description = $requestJson->Description;
         $product->type = $requestJson->Type;
         $product->price = $requestJson->Price;
         $product->originalprice = $requestJson->OriginalPrice;
         $product->unit = $requestJson->Unit;
         $product->freight = $requestJson->Freight;
         $product->lastmodifiedtime = now();
         R::store($product);
         $response = R::find('product', 'id=?', array($ProductId));
         echo ResponseJsonHandler::normalizeJsonResponse(R::exportAll($response));
     } catch (Exception $ex) {
         return ExceptionHandler::Response($ex, $this->_app);
     }
 }
Ejemplo n.º 3
0
 public function postSmsCode()
 {
     try {
         $requestJson = RequestBodyHandler::getJsonBody($this->_app);
         RequestBodyHandler::verifyJsonBody($requestJson, array("Telephone"));
         $randomCode = rand(1000, 9999);
         $expireInMins = "1";
         $tempId = "46556";
         //发送短信验证码
         $reponseArray = SMS::SendTemplateSMS($requestJson->Telephone, array($randomCode, $expireInMins), $tempId);
         $rdb = R::dispense('producersmscode');
         $rdb->telephone = $requestJson->Telephone;
         $rdb->code = $randomCode;
         $rdb->expirationtime = date('Y-m-d H:i:s', strtotime("+1 minute"));
         $rdb->statuscode = $reponseArray[0];
         $rdb->smsmessagesid = $reponseArray[1];
         $rdb->datecreated = $reponseArray[2];
         $rdb->lastmodifiedtime = now();
         $id = R::store($rdb);
         echo ResponseJsonHandler::normalizeJsonResponse(array("id" => $id, "smsCode" => $randomCode, "telephone" => $requestJson->Telephone));
     } catch (Exception $ex) {
         return ExceptionHandler::Response($ex, $this->_app);
     }
 }
Ejemplo n.º 4
0
Archivo: Order.php Proyecto: WTer/NJB
 public function put_Consignee($ConsigneeId)
 {
     try {
         $requestJson = RequestBodyHandler::getJsonBody($this->_app);
         RequestBodyHandler::verifyJsonBody($requestJson, array("Name", "Telephone", "Address", "IsDefault"));
         $obj = R::findOne('consignee', 'id=?', array($ConsigneeId));
         if (!isset($obj) || empty($obj)) {
             throw new RecordNotFoundException("Record not found, id:" . $ConsigneeId);
         }
         $obj->name = $requestJson->Name;
         $obj->telephone = $requestJson->Telephone;
         $obj->address = $requestJson->Address;
         $obj->isdefault = $requestJson->IsDefault;
         $obj->lastmodifiedtime = now();
         $id = R::store($obj);
         if ($requestJson->IsDefault == "true") {
             R::exec('UPDATE consignee SET isdefault = "false" WHERE id <> ?', array($id));
         }
         $response = R::find('consignee', 'id=?', array($id));
         echo ResponseJsonHandler::normalizeJsonResponse(R::exportAll($response));
         /*
         $order = R::findOne('orders', 'id=?', array($OrderId));
         if (!isset($order) || empty($order))
         {
         	throw new RecordNotFoundException("Record not found, id:" . $OrderId);
         }
         
         $order->count = $requestJson->Count;
         $order->unit = $requestJson->Unit;
         $order->description = $requestJson->Description;
         $order->lastmodifiedtime = now();
         R::store($order);
         
         $response = R::find('orders', 'id=?', array($OrderId));
         //echo json_encode(R::exportAll($response));
         echo ResponseJsonHandler::normalizeJsonResponse(R::exportAll($response));
         */
     } catch (Exception $ex) {
         return ExceptionHandler::Response($ex, $this->_app);
     }
 }