public function Create()
 {
     $this->LogInfo("APP create order...");
     //验证APP是否登录
     $this->DoAuth();
     $req = $this->GetReqObj();
     //创建订单
     $order = $req->order;
     $orderData = $this->objectToArray($order);
     $orderDao = $this->GetModel();
     do {
         $orderData['order_code'] = date('ymdHis', time()) . rand(1000, 9999);
     } while ($orderDao->where('order_code=' . $orderData['order_code'])->count());
     if (OrderEnum::OnlinePay == $orderData['pay_option']) {
         $orderData['order_status'] = OrderEnum::WaitBuyerPay;
     } else {
         $orderData['order_status'] = OrderEnum::OrderSubmit;
     }
     $orderData['create_time'] = date('Y-m-d H:i:s', time());
     $orderData['company_id'] = $req->app_id;
     $this->LogInfo("order info is " . json_encode($orderData));
     try {
         $result = MispCommonService::Create($orderDao, $orderData);
     } catch (FuegoException $e) {
         $this->errorCode = $e->getCode();
         $this->ReturnJson();
         return;
     }
     //正常下单创建订单详情
     if ($orderData['order_type'] == OrderEnum::NormalOrder) {
         //创建订单详情
         $orderDetailDao = LaundryDaoContext::OrderDetail();
         $orderDetailList = $req->orderDetailList;
         for ($i = 0; $i < count($orderDetailList); $i++) {
             $orderDetailList[$i] = $this->objectToArray($orderDetailList[$i]);
             $orderDetailList[$i]['order_id'] = $result;
         }
         $this->LogInfo("order type is " . OrderEnum::NormalOrder);
         $this->LogInfo("order detail is " . json_encode($orderDetailList));
         try {
             $detailResult = MispCommonService::CreateList($orderDetailDao, $orderDetailList);
         } catch (FuegoException $e) {
             $this->errorCode = $e->getCode();
             $this->ReturnJson();
             return;
         }
     }
     //直接下单
     if (OrderEnum::DirectOrder == $orderData['order_type']) {
         $this->LogInfo("order type is " . OrderEnum::DirectOrder);
     }
     //发出订单邮件通知
     $adminDao = LaundryDaoContext::administrators();
     $CompanyCondition['company_id'] = $req->app_id;
     $Email = $adminDao->where($CompanyCondition)->getField('email');
     $this->LogInfo("admin email is " . $Email);
     if (false == SendMail($Email, OrderEnum::EMAIL_TITLE, "会员:" . $orderData['user_name'] . " 已成功提交订单,订单号为:" . $orderData['order_code'] . "。请及时处理!")) {
         $this->LogErr("Order has create,But send mail failed.");
     }
     //获取订单信息返回
     $orderCondition['order_code'] = $orderData['order_code'];
     try {
         $object = MispCommonService::GetUniRecord($orderDao, $orderCondition);
     } catch (FuegoException $e) {
         $this->errorCode = $e->getCode();
         $this->ReturnJson();
         return;
     }
     $data['obj'] = $object;
     $this->ReturnJson($data);
 }
 public function CreateAdmin($admin)
 {
     $errorCode = MispErrorCode::SUCCESS;
     FuegoLog::getLog()->LogInfo("Create admin");
     $adminDao = LaundryDaoContext::administrators();
     try {
         $result = MispCommonService::Create($adminDao, $admin);
     } catch (FuegoException $e) {
         $errorCode = $e->getCode();
     }
     return $errorCode;
 }
 protected function GetModel()
 {
     return LaundryDaoContext::administrators();
 }