public function test()
 {
     Sys::D('Order');
     $goodsData = array(array(1, 3), array(2, 1));
     $receiveData = array('username' => 'bee', 'tel' => '18224087281', 'email' => '*****@*****.**', 'address' => '四川省成都市青羊区');
     OrderModel::add(1, 1, $goodsData, $receiveData, 'this is a remark');
 }
Esempio n. 2
0
 static function add($data)
 {
     if (!$data) {
         return false;
     }
     $model = new OrderModel();
     $result = $model->add($data);
     return $result;
 }
Esempio n. 3
0
 /**
  * 保存订单
  *
  * @param xml string $request
  * @return xml string
  */
 private function orderSave($request)
 {
     try {
         $item = $request["body"];
         if ($item) {
             $model = new OrderModel();
             $item["client"] = $item["clientName"];
             $item["qty"] = intval($item["qty"]);
             $item["weight"] = doubleval($item["weight"]);
             $item["cubage"] = floatval($item["cubage"]);
             $item["insuranceValue"] = doubleval($item["insuranceValue"]);
             $item["getMoney"] = doubleval($item["getMoney"]);
             $item["receipt"] = intval($item["receipt"]);
             //有id的更新,否则新增
             if ($item["id"]) {
                 $item["id"] = intval($item["id"]);
                 $result = $model->save($item);
             } else {
                 unset($item["id"]);
                 $result = $model->add($item);
             }
             if ($result === false) {
                 return $this->createResult($request["head"]["type"], -1, 'save/add bill error');
             }
             if ($item["id"]) {
                 $id = $item["id"];
             } else {
                 $id = $result;
             }
             return $this->createResult($request["head"]["type"], 1, 'succeed', 1, "<item>{$id}</item>");
         } else {
             return $this->createResult($request["head"]["type"], -3, 'not a valid action in order save');
         }
     } catch (Exception $e) {
         return $this->createResult($request["head"]["type"], -1, 'error in order save');
     }
 }