Exemple #1
0
 /**
  * Create a new comment
  *
  * @param  array           $input
  * @param  \Project        $project
  * @param  \Project\Issue  $issue
  * @return Comment
  */
 public static function create_comment($input, $project, $issue)
 {
     $fill = array('created_by' => \Auth::user()->id, 'project_id' => $project->id, 'issue_id' => $issue->id, 'comment' => $input['comment']);
     $comment = new static();
     $comment->fill($fill);
     $comment->save();
     /* Add to user's activity log */
     \User\Activity::add(2, $project->id, $issue->id, $comment->id);
     /* Add attachments to issue */
     \DB::table('projects_issues_attachments')->where('upload_token', '=', $input['token'])->where('uploaded_by', '=', \Auth::user()->id)->update(array('issue_id' => $issue->id, 'comment_id' => $comment->id));
     /* Update the project */
     $issue->updated_at = date('Y-m-d H:i:s');
     $issue->updated_by = \Auth::user()->id;
     $issue->save();
     /* Notify the person to whom the issue is currently assigned, unless that person is the one making the comment */
     if ($issue->assigned_to && $issue->assigned_to != \Auth::user()->id) {
         $project = \Project::current();
         //$subject = 'Issue "' . $issue->title . '" in "' . $project->name . '" project has a new comment';
         $subject = sprintf(__('email.new_comment'), $issue->title, $project->name);
         $text = \View::make('email.commented_issue', array('actor' => \Auth::user()->firstname . ' ' . \Auth::user()->lastname, 'project' => $project, 'issue' => $issue, 'comment' => $comment->comment));
         \Mail::send_email($text, $issue->assigned->email, $subject);
     }
     return $comment;
 }
Exemple #2
0
 /**
  * Add a new user
  *
  * @param  array  $info
  * @return array
  */
 public static function add_user($info)
 {
     $rules = array('firstname' => array('required', 'max:50'), 'lastname' => array('required', 'max:50'), 'email' => array('required', 'email', 'unique:users'));
     $validator = Validator::make($info, $rules);
     if ($validator->fails()) {
         return array('success' => false, 'errors' => $validator->errors);
     }
     $insert = array('email' => $info['email'], 'firstname' => $info['firstname'], 'lastname' => $info['lastname'], 'role_id' => $info['role_id'], 'password' => Hash::make($password = Str::random(6)));
     $user = new User();
     $user->fill($insert)->save();
     /* Send Activation email */
     $view = View::make('email.new_user', array('email' => $info['email'], 'password' => $password));
     //Mail::send_email($view, $info['email'], 'Your Tiny Issue Account');
     Mail::send_email($view, $info['email'], __('email.subject_newuser'));
     return array('success' => true, 'password' => $password);
 }
Exemple #3
0
          }
          else
          {
              $uploadData = array('upload_data' => $Upload->data('resume_file')); // [new] input name (type file)
          }*/
        if (!empty($firstName) && !empty($lastName)) {
            $user = get_user_by('login', 'admin');
            $blog_title = get_bloginfo();
            $htmlBody = "\n            <html>\n            <head>\n            <title>Резюме</title>\n            </head>\n            <body>\n            <table>\n                <tr><td><strong>Имя:</strong></td><td>" . $firstName . "</td></tr>\n                <tr><td><strong>Фамилия:</strong></td><td>" . $lastName . "</td></tr>\n                <tr><td><strong>Коментарий:</strong></td><td>" . $comment . "</td></tr>\n            </table>\n            </body>\n            </html>";
            $config = array();
            $Mail = new Mail($config);
            $Mail->set_mailtype('html');
            if (!empty($uploadData) && (isset($uploadData['upload_data']) && !empty($uploadData['upload_data']))) {
                $Mail->attach($uploadData['upload_data']['full_path']);
            }
            $result = $Mail->send_email($user->user_email, $blog_title, $user->user_email, "Заказ банкета", $htmlBody);
            $sent = true;
            $message = "Ваши данные были успешно отправлены!";
        }
    }
}
global $pageType, $uriPieces, $uriPiecesSlug, $_page, $currentCategoryName;
global $post;
global $translations;
$pageType = "contacts";
get_header();
query_posts('category_name=' . $uriPiecesSlug . '&showposts=2&paged=' . $_page);
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>
Exemple #4
0
 public function forget_act()
 {
     $email = Filter::sql(Req::args('email'));
     $model = $this->model->table('user');
     $obj = $model->where("email = '" . $email . "'")->find();
     if (!empty($obj)) {
         $model = $this->model->table('reset_password');
         $obj = $model->where("email = '" . $email . "'")->find();
         $safecode = md5(md5($email) . md5(CHash::random(32)));
         if (!empty($obj)) {
             $obj['safecode'] = $safecode;
             $model->data($obj)->update();
         } else {
             $model->data(array('email' => $email, 'safecode' => $safecode))->add();
         }
         $reset_url = Url::fullUrlFormat("/simple/reset_password/safecode/{$safecode}");
         $msg_content = '';
         $site_url = Url::fullUrlFormat('/');
         $msg_title = '找回密码--' . $this->site_name;
         $msg_template_model = new Model("msg_template");
         $msg_template = $msg_template_model->where('id=3')->find();
         if ($msg_template) {
             $msg_content = str_replace(array('{$site_name}', '{$reset_url}', '{$site_url}', '{$current_time}'), array($this->site_name, $reset_url, $site_url, date('Y-m-d H:i:s')), $msg_template['content']);
             $msg_title = $msg_template['title'];
         } else {
             $msg_content .= '<p>亲爱的用户:</p>';
             $msg_content .= '<p>感谢您注册' . $this->site_name . ',请点击以下链接重置您的密码。<br/><br/>';
             $msg_content .= "<a href='{$reset_url}' target='_blank'>{$reset_url}</a><br/><br/>";
             $msg_content .= '愿您在' . $this->site_name . '度过愉快的时光。<br/><br/>';
             $msg_content .= "<a href='" . $site_url . "'>" . $this->site_name . "</a></p>";
         }
         $mail = new Mail();
         $flag = $mail->send_email($email, $msg_title, $msg_content);
         if ($flag) {
             $this->assign('status', 'success');
         } else {
             $this->assign('status', 'error');
         }
     } else {
         $this->assign('status', 'fail');
     }
     $this->redirect('forget_result', false);
 }
Exemple #5
0
 public function order_status()
 {
     $parse_status = array('3' => '审核订单', '4' => '完成订单成功', '6' => '作废订单');
     $id = Filter::int(Req::args("id"));
     $status = Req::args("status");
     $admin_remark = Req::args("remark");
     $model = new Model("order");
     $order = $model->where("id={$id}")->find();
     $flag = false;
     $info = array();
     if ($order) {
         if ($status) {
             if ($order['status'] == 1 || $order['status'] == 2) {
                 if ($status == 3 || $status == 6) {
                     $flag = true;
                 }
                 /* S 二次开发 */
                 if ($status == 3) {
                     //发送邮件
                     $user_id = $order['user_id'];
                     $user_model = new Model('user');
                     $user = $user_model->where('id=' . $user_id)->find();
                     $order_url = Url::fullUrlFormat("/ucenter/order_detail/id/{$order['id']}");
                     $email_message_model = new Model('email_message');
                     $email_message = $email_message_model->where('`trigger`=2 and status=1')->find();
                     if ($email_message) {
                         $body = str_replace(array('{$order_no}', '{$user_name}', '{$current_time}', '{$order_url}'), array($order['order_no'], $user['name'], date('Y-m-d H:i:s'), $order_url), $email_message['content']);
                         $mail = new Mail();
                         $mail->send_email($user['email'], $email_message['title'], $body);
                     }
                 }
                 /* E 二次开发*/
             }
             if ($order['status'] == 3) {
                 if ($status == 4 || $status == 6) {
                     $flag = true;
                 }
                 if ($status == 4) {
                     //货到付款的订单处理
                     $payment_plugin = Common::getPaymentInfo($order['payment']);
                     if ($payment_plugin != null && $payment_plugin['class_name'] == 'received') {
                         Order::updateStatus($order['order_no']);
                     }
                     //订单完成
                     $model_tem = new Model('order');
                     $model_tem->where("id={$id}")->data(array('delivery_status' => 2, 'status' => 4, 'completion_time' => date('Y-m-d H:i:s')))->update();
                     //允许评价
                     $model_tem = new Model('order as od');
                     $products = $model_tem->join('left join order_goods as og on od.id=og.order_id')->where('od.id=' . $id)->findAll();
                     foreach ($products as $product) {
                         $data = array('goods_id' => $product['goods_id'], 'user_id' => $order['user_id'], 'order_no' => $product['order_no'], 'buy_time' => $product['create_time']);
                         $model_tem->table('review')->data($data)->insert();
                     }
                 }
             }
             if ($order['status'] == 4 && $status == 6) {
                 $flag = true;
             }
             if ($flag) {
                 $model->where("id={$id}")->data(array('status' => $status, 'admin_remark' => $admin_remark))->update();
                 $info = array('status' => 'success', 'msg' => $parse_status[$status]);
             } else {
                 $info = array('status' => 'fail', 'msg' => $parse_status[$status]);
             }
         } else {
             $op = Req::args("op");
             if ($op == 'note') {
                 $model->where("id={$id}")->data(array('admin_remark' => $admin_remark))->update();
                 $info = array('status' => 'success', 'msg' => '备注');
             } else {
                 if ($op == 'del') {
                     $model->where("id={$id}")->delete();
                     $info = array('status' => 'success', 'msg' => '删除');
                 }
             }
         }
     } else {
         $info = array('status' => 'fail', 'msg' => '不存在此订单');
     }
     echo JSON::encode($info);
 }
Exemple #6
0
 /**
  * Create a new issue
  *
  * @param  array    $input
  * @param  \Project  $project
  * @return Issue
  */
 public static function create_issue($input, $project)
 {
     $rules = array('title' => 'required|max:200', 'body' => 'required');
     $validator = \Validator::make($input, $rules);
     if ($validator->fails()) {
         return array('success' => false, 'errors' => $validator->errors);
     }
     $fill = array('created_by' => \Auth::user()->id, 'project_id' => $project->id, 'title' => $input['title'], 'body' => $input['body'], 'status' => 1);
     if (\Auth::user()->permission('issue-modify')) {
         $fill['assigned_to'] = $input['assigned_to'];
     }
     $issue = new static();
     $issue->fill($fill);
     $issue->save();
     /* Create tags */
     $issue->set_tags('create');
     /* Add to user's activity log */
     \User\Activity::add(1, $project->id, $issue->id);
     /* Add attachments to issue */
     \DB::table('projects_issues_attachments')->where('upload_token', '=', $input['token'])->where('uploaded_by', '=', \Auth::user()->id)->update(array('issue_id' => $issue->id));
     /* Notify the person being assigned to. */
     /* If no one is assigned, notify all users who are assigned to this project and who have permission to modify the issue. */
     /* Do not notify the person creating the issue. */
     if ($issue->assigned_to) {
         if ($issue->assigned_to != \Auth::user()->id) {
             $project = \Project::current();
             //$subject = 'New issue "' . $issue->title . '" was submitted to "' . $project->name . '" project and assigned to you';
             $subject = sprintf(__('email.assignment'), $issue->title, $project->name);
             $text = \View::make('email.new_assigned_issue', array('project' => $project, 'issue' => $issue));
             \Mail::send_email($text, $issue->assigned->email, $subject);
         }
     } else {
         $project = \Project::current();
         foreach ($project->users()->get() as $row) {
             if ($row->id != \Auth::user()->id && $row->permission('project-modify')) {
                 //$subject = 'New issue "' . $issue->title . '" was submitted to "' . $project->name . '" project';
                 $subject = sprintf(__('email.new_issue'), $issue->title, $project->name);
                 $text = \View::make('email.new_issue', array('project' => $project, 'issue' => $issue));
                 \Mail::send_email($text, $row->email, $subject);
             }
         }
     }
     /* Return success and issue object */
     return array('success' => true, 'issue' => $issue);
 }
Exemple #7
0
 public function send_notify()
 {
     $condition = Req::args("condition");
     $notify_model = new Model("notify as n");
     $condition = Common::str2where($condition);
     if ($condition != null) {
         $items = $notify_model->fields("n.*,go.name as goods_name,u.name as user_name")->join("left join user as u on n.user_id = u.id left join goods as go on n.goods_id = go.id")->where($condition)->findAll();
         $mail = new Mail();
         $msg_model = new Model("msg_template");
         $template = $msg_model->where("id=1")->find();
         $success = 0;
         $fail = 0;
         foreach ($items as $item) {
             $subject = str_replace(array('{$user_name}', '{$goods_name}'), array($item['user_name'], $item['goods_name']), $template['title']);
             $body = str_replace(array('{$user_name}', '{$goods_name}'), array($item['user_name'], $item['goods_name']), $template["content"]);
             $status = $mail->send_email($item['email'], $subject, $body);
             if ($status) {
                 $data = array('notify_time' => date('Y-m-d H:i:s'), 'notify_status' => '1');
                 $notify_model->data($data)->where('id=' . $item['id'])->update();
                 $success++;
             } else {
                 $fail++;
             }
         }
         $return = array('isError' => false, 'count' => count($items), 'success' => $success, 'fail' => $fail);
     } else {
         $return = array('isError' => true, 'msg' => '没有选择筛选条件!');
     }
     echo JSON::encode($return);
 }
Exemple #8
0
 public function send_email_test()
 {
     $test_email = Req::args('email');
     if (Validator::email($test_email)) {
         $mail = new Mail();
         try {
             $flag = $mail->send_email($test_email, 'TinyShop电子商务系统,邮箱验证测试', "<div><h3>亲爱的TinyShop用户您好:</h3><p style='text-indent:2em;'>当您收到这封邮件时,说明您的信息配制正确,邮件系统可以正常工作。</p></div>");
             $info = array('status' => 'success', 'msg' => '测试成功,邮件已发送');
             if (!$flag) {
                 $info = array('status' => 'fail', 'msg' => '测试失败,请检测配制信息');
             }
             echo JSON::encode($info);
         } catch (Exception $e) {
             $msg = $e->errorMessage();
             $info = array('status' => 'fail', 'msg' => $msg);
             echo JSON::encode($info);
         }
     } else {
         $info = array('status' => 'fail', 'msg' => '测试邮箱地址格式不正确,核实后再测试');
         echo JSON::encode($info);
     }
 }
Exemple #9
0
 if ($user->password == md5('pass') || $user->password == md5('password')) {
     sleep(2);
     echo '<h4 class="alert alert-info">Information</h4>';
     echo '<hr>';
     echo 'The password you entered is too predictable. ';
     echo 'Please use the close button to close the window and change your password before you can continue. ';
     echo '<hr>';
 } else {
     //create a random key
     $key = $user->email . $user->phone_number . $date_now;
     $key = sha1(md5($key));
     //put info into an array to send to the function
     $info = array('email' => $user->email, 'phone_number' => $user->phone_number, 'key' => $key);
     $user->save();
     if ($database->affected_rows() == 1) {
         $send_mail = Mail::send_email($info);
         if ($send_mail) {
             sleep(2);
             echo '<h4 class="alert alert-success">Success</h4>';
             echo '<hr>';
             echo "The information for user with email address <font color=#0000FF>" . $user->email . "</font> has been successfully saved.<br>";
             echo "Check your email for a verification link, if you do not find it in inbox, check your spam.<br>";
             echo "Use the close botton to go back and continue.";
             echo '<br>';
             echo '<hr>';
             echo '<a href="select_form.php" class="btn btn-primary">Proceed</a>';
         } else {
             sleep(2);
             echo '<h4 class="alert alert-info">Information</h4>';
             echo '<hr>';
             echo 'Your information has been successfully saved but activation mail was not sent.<br>';
Exemple #10
0
global $pageType;
$pageType = "photos";
get_header();
$segmentsUrl = explode('/', $_SERVER['REQUEST_URI']);
if (in_array('page', $segmentsUrl)) {
    $pageSegment = array_search('page', $segmentsUrl) + 1;
    $this->page = $segmentsUrl[$pageSegment];
}
if (!empty($_POST)) {
    $name = isset($_POST["email_name"]) ? $_POST["email_name"] : "";
    $name = isset($_POST["email_order"]) ? $_POST["email_order"] : "";
    $email = isset($_POST["email_email"]) ? $_POST["email_email"] : "";
    $config = array();
    $Mail = new Mail($config);
    $result = $Mail->send_email($email, "Subject", "message");
    echo "<pre>";
    var_dump($result);
    echo "</pre>";
    exit;
}
?>
<script type="text/javascript" src="<?php 
bloginfo('stylesheet_directory');
?>
/js/jquery.js"></script>
<script type="text/javascript" src="<?php 
bloginfo('stylesheet_directory');
?>
/js/highslide-with-gallery.js"></script>
<script type="text/javascript" src="<?php 
Exemple #11
0
 public static function updateStatus($orderNo, $payment_id = 0, $callback_info = null)
 {
     //SKM-ORDER-STATUS 这个方法得大改
     $model = new Model("order");
     $order = $model->where("order_no='" . $orderNo . "'")->find();
     if (isset($callback_info['trade_no'])) {
         $trading_info = $callback_info['trade_no'];
     } else {
         $trading_info = '';
     }
     if (empty($order)) {
         return false;
     }
     if ($order['pay_status'] == 1) {
         return $order['id'];
     } else {
         if ($order['pay_status'] == 0) {
             //更新订单信息
             $data = array('status' => 3, 'pay_time' => date('Y-m-d H:i:s'), 'trading_info' => $trading_info, 'pay_status' => 1);
             //修改用户最后选择的支付方式
             if ($payment_id != 0) {
                 $data['payment'] = $payment_id;
             } else {
                 $payment_id = $order['payment'];
             }
             //更新订单支付状态
             $model->table("order")->data($data)->where("id=" . $order['id'])->update();
             //SKM-SMS 支付成功  发送支付完成信息
             $sms_inst = new Sms();
             $orderNo = $order['order_no'];
             $text = "【全品电台】感谢您使用全品电台。您的订单 {$orderNo} 已经支付成功,我们将会在24小时内给您发货。";
             $mobile = $order['mobile'];
             if ($mobile != "") {
                 // 测试时 不发送SMS
                 $sms_inst->sendSms($text, $mobile);
             }
             /* S 二次开发 */
             //发送邮件
             $order_url = Url::fullUrlFormat("/ucenter/order_detail/id/{$order['id']}");
             $safebox = Safebox::getInstance();
             $user = $safebox->get('user');
             $email_message_model = new Model('email_message');
             $email_message = $email_message_model->where('`trigger`=2 and status=1')->find();
             if ($email_message) {
                 $body = str_replace(array('{$order_no}', '{$user_name}', '{$current_time}', '{$order_url}'), array($orderNo, $user['name'], date('Y-m-d H:i:s'), $order_url), $email_message['content']);
                 $mail = new Mail();
                 $mail->send_email($user['email'], $email_message['title'], $body);
             }
             /* E 二次开发 */
             //商品中优惠券的处理
             $products = $model->table("order_goods")->where("order_id=" . $order['id'])->findAll();
             $goods_ids = array();
             foreach ($products as $pro) {
                 //SKM-ORDER-STATUS 添加捆绑促销的处理
                 if ($pro['prom_type'] == 'bundling') {
                     // 添加
                 } else {
                     $prom = unserialize($pro['prom_goods']);
                     if (isset($prom['prom'])) {
                         $prom_series = isset($prom['series']['prom']) ? $prom['series']['prom'] : null;
                         $prom = $prom['prom'];
                         //商品中优惠券的处理
                         if (isset($prom['type']) && $prom['type'] == 3 && $order['type'] == 0) {
                             $voucher_template_id = $prom['expression'];
                             $voucher_template = $model->table("voucher_template")->where("id=" . $voucher_template_id)->find();
                             Common::paymentVoucher($voucher_template, $order['user_id']);
                             //优惠券发放日志
                         }
                         //二次开发部分
                         //系列中的优惠券
                         if (isset($prom_series['type']) && $prom_series['type'] == 3 && $order['type'] == 0) {
                             $voucher_template_id = $prom_series['expression'];
                             $voucher_template = $model->table("voucher_template")->where("id=" . $voucher_template_id)->find();
                             Common::paymentVoucher($voucher_template, $order['user_id']);
                             //优惠券发放日志
                         }
                     }
                     //更新货品中的库存信息
                     $goods_nums = $pro['goods_nums'];
                     $product_id = $pro['product_id'];
                     $model->table("products")->where("id=" . $product_id)->data(array('store_nums' => "`store_nums`-" . $goods_nums))->update();
                     $goods_ids[$pro['goods_id']] = $pro['goods_id'];
                 }
             }
             //更新商品表里的库存信息
             foreach ($goods_ids as $id) {
                 $objs = $model->table('products')->fields('sum(store_nums) as store_nums')->where('goods_id=' . $id)->query();
                 if ($objs) {
                     $num = $objs[0]['store_nums'];
                     $model->table('goods')->data(array('store_nums' => $num))->where('id=' . $id)->update();
                 }
             }
             //普通订单的处理
             foreach ($products as $pro) {
                 //SKM-ORDER-STATUS 添加捆绑促销的处理
                 if ($pro['prom_type'] == 'bundling') {
                 } else {
                     if ($order['type'] == 0) {
                         //订单优惠券活动事后处理
                         $prom = unserialize($order['prom']);
                         if (!empty($prom) && $prom['type'] == 3) {
                             $voucher_template_id = $prom['expression'];
                             $voucher_template = $model->table("voucher_template")->where("id=" . $voucher_template_id)->find();
                             Common::paymentVoucher($voucher_template, $order['user_id']);
                         }
                     } else {
                         if ($order['type'] == 1) {
                             //更新团购信息
                             $prom = unserialize($order['prom']);
                             if (isset($prom['id'])) {
                                 $groupbuy = $model->table("groupbuy")->where("id=" . $prom['id'])->find();
                                 if ($groupbuy) {
                                     $goods_num = $groupbuy['goods_num'];
                                     $order_num = $groupbuy['order_num'];
                                     $max_num = $groupbuy['max_num'];
                                     $end_time = $groupbuy['end_time'];
                                     $time_diff = time() - strtotime($end_time);
                                     foreach ($products as $pro) {
                                         $data = array('goods_num' => $goods_num + $pro['goods_nums'], 'order_num' => $order_num + 1);
                                     }
                                     if ($time_diff >= 0 || $max_num <= $data['goods_num']) {
                                         $data['is_end'] = 1;
                                     }
                                     $model->table("groupbuy")->where("id=" . $prom['id'])->data($data)->update();
                                 }
                             }
                         } else {
                             if ($order['type'] == 2) {
                                 //更新抢购信息
                                 $prom = unserialize($order['prom']);
                                 if (isset($prom['id'])) {
                                     $flashbuy = $model->table("flash_sale")->where("id=" . $prom['id'])->find();
                                     if ($flashbuy) {
                                         $goods_num = $flashbuy['goods_num'];
                                         $order_num = $flashbuy['order_num'];
                                         $max_num = $flashbuy['max_num'];
                                         $end_time = $flashbuy['end_time'];
                                         $time_diff = time() - strtotime($end_time);
                                         foreach ($products as $pro) {
                                             $data = array('goods_num' => $goods_num + $pro['goods_nums'], 'order_num' => $order_num + 1);
                                         }
                                         if ($time_diff >= 0 || $max_num <= $data['goods_num']) {
                                             $data['is_end'] = 1;
                                         }
                                         $model->table("flash_sale")->where("id=" . $prom['id'])->data($data)->update();
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             //送积分
             Pointlog::write($order['user_id'], $order['point'], '购买商品,订单:' . $order['order_no'] . ' 赠送' . $order['point'] . '积分');
             //对使用代金券的订单,修改代金券的状态
             if ($order['voucher_id']) {
                 $model->table("voucher")->where("id=" . $order['voucher_id'])->data(array('status' => 1))->update();
             }
             //生成收款单
             $receivingData = array('order_id' => $order['id'], 'user_id' => $order['user_id'], 'amount' => $order['order_amount'], 'create_time' => date('Y-m-d H:i:s'), 'payment_time' => date('Y-m-d H:i:s'), 'doc_type' => 0, 'payment_id' => $payment_id, 'pay_status' => 1);
             $model->table("doc_receiving")->data($receivingData)->insert();
             //统计会员规定时间内的消费金额,进行会员升级。
             $config = Config::getInstance();
             $config_other = $config->get('other');
             $grade_days = isset($config_other['other_grade_days']) ? intval($config_other['other_grade_days']) : 365;
             $time = date("Y-m-d H:i:s", strtotime("-" . $grade_days . " day"));
             $obj = $model->table("doc_receiving")->fields("sum(amount) as amount")->where("user_id=" . $order['user_id'] . " and doc_type=0 and payment_time > '{$time}'")->query();
             if (isset($obj[0])) {
                 $amount = $obj[0]['amount'];
                 $grade = $model->table('grade')->where('money < ' . $amount)->order('money desc')->find();
                 if ($grade) {
                     $model->table('customer')->data(array('group_id' => $grade['id']))->where("user_id=" . $order['user_id'])->update();
                 }
             }
             return $order['id'];
         } else {
             return false;
         }
     }
 }