当前位置: 首页>>代码示例>>PHP>>正文


PHP Tools::getNow方法代码示例

本文整理汇总了PHP中Tools::getNow方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::getNow方法的具体用法?PHP Tools::getNow怎么用?PHP Tools::getNow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tools的用法示例。


在下文中一共展示了Tools::getNow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postFavorite

 public function postFavorite($id)
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $type = Input::get('type', 0);
     try {
         $user = User::chkUserByToken($token, $u_id);
         $booth = Booth::find($id);
         if (empty($booth)) {
             throw new Exception("请求的店铺不存在", 2001);
         }
         $chk = $booth->favorites()->where('favorites.u_id', '=', $u_id)->first();
         if ($type == 1) {
             if (empty($chk)) {
                 $data = ['u_id' => $u_id, 'created_at' => Tools::getNow(), 'u_name' => $user->u_nickname];
                 $favorite = new Favorite($data);
                 $booth->favorites()->save($favorite);
             }
         } else {
             if (!empty($chk)) {
                 $booth->favorites()->detach($chk->id);
                 $chk->delete();
             }
         }
         $re = Tools::reTrue('操作成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '操作失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:30,代码来源:BoothController.php

示例2: addLog

 public static function addLog($command, $message)
 {
     $log = new LogCronjob();
     $log->created_at = Tools::getNow();
     $log->command = $command;
     $log->message = $message;
     $log->save();
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:8,代码来源:LogCronjob.php

示例3: addProduct

 public function addProduct()
 {
     $this->baseValidate();
     $now = Tools::getNow();
     $this->created_at = $now;
     $this->p_status = 1;
     return $this->save();
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:8,代码来源:CrowdFundingProduct.php

示例4: checkBlacklist

 public static function checkBlacklist($u_id)
 {
     $now = Tools::getNow();
     $blacklist = AuctionBlacklist::where('u_id', '=', $u_id)->where('start_at', '<', $now)->where('end_at', '>', $now)->first();
     if (empty($blacklist)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:10,代码来源:AuctionBid.php

示例5: listAuctions

 public function listAuctions()
 {
     $per_page = Input::get('per_page', 30);
     try {
         $now = Tools::getNow();
         $list = Auction::with('eventItem')->join('event_items', function ($q) {
             $q->on('event_items.e_id', '=', 'auctions.e_id');
         })->where('event_items.e_end_at', '<', $now)->orderBy('event_items.e_end_at', 'DESC')->paginate($per_page);
         $data = [];
         foreach ($list as $key => $auction) {
             $data[] = $auction->showDetail();
         }
         $re = Tools::reTrue('获取往届竞拍成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '获取往届竞拍失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:18,代码来源:AuctionController.php

示例6: import

 public function import()
 {
     $this->baseValidate();
     $chk = UserImportWechat::where('u_ext_id', '=', $this->u_ext_id)->first();
     $u_id = 0;
     if (empty($chk)) {
         $re = $this->register($this->u_ext_id, $this->u_ext_token, $this->u_nickname, $this->u_head_img, $this->u_gender);
         $this->u_id = $re['u_id'];
         $this->created_at = Tools::getNow();
         $this->save();
         $u_id = $re['u_id'];
     } else {
         $u_id = $chk->u_id;
     }
     $re = $this->login($u_id);
     $re['import_type'] = 'wechat';
     return $re;
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:18,代码来源:UserImportWechat.php

示例7: register

 public function register($ext_id, $ext_token = '', $nickname = '', $head_img = '', $gender = 3)
 {
     $user = new User();
     $user->u_nickname = $nickname;
     $user->u_name = $nickname;
     $user->u_sex = $gender;
     $user->u_birthday = Tools::getNow('Y-m-d');
     $user->u_token = $user->getUniqueToken();
     $user->u_invite_code = $user->getInviteCode();
     $user->created_at = Tools::getNow();
     $user->updated_at = Tools::getNow();
     $user->u_type = 1;
     $user->u_status = 1;
     $user->save();
     if (!$nickname) {
         $user->u_nickname = $this->u_id;
         $user->u_name = $this - u_id;
         $user->save();
     }
     $data = ['u_id' => $user->u_id, 'ext_id' => $ext_id, 'ext_token' => $ext_token];
     return $data;
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:22,代码来源:UserImport.php

示例8: fakeCrowdFundingPurches

 public function fakeCrowdFundingPurches($id)
 {
     set_time_limit(0);
     $this->login();
     $bottom = Input::get('bottom', '');
     $top = Input::get('top', '');
     $p_id = Input::get('p_id', '');
     try {
         if (!$p_id || !$top || !$bottom) {
             throw new Exception("需要关键数据", 1);
         }
         $funding = CrowdFunding::find($id);
         $funding->load(['eventItem']);
         $product = CrowdFundingProduct::find($p_id);
         $quantity = 1;
         $users = User::where('u_mobile', '>=', $bottom)->where('u_mobile', '<=', $top)->get();
         foreach ($users as $key => $user) {
             $u_id = $user->u_id;
             // sku need to be calulated before cart generated
             $product->loadProduct($quantity);
             // add cart
             $cart = new Cart();
             $cart->p_id = $p_id;
             $cart->p_name = $product->p_title;
             $cart->u_id = $u_id;
             $cart->b_id = $product->b_id;
             $cart->created_at = Tools::getNow();
             $cart->c_quantity = $quantity;
             $cart->c_price = $product->p_price;
             $cart->c_amount = $product->p_price * $quantity;
             $cart->c_discount = 100;
             $cart->c_price_origin = $product->p_price;
             $cart->c_amount_origin = $product->p_price * $quantity;
             $cart->c_status = 2;
             $cart->c_type = 2;
             $re = $cart->save();
             if (!$re) {
                 throw new Exception("提交库存失败", 7006);
             }
             $shipping_address = 'Fake Purches';
             $shipping_name = $user->u_name;
             $shipping_phone = $user->u_mobile;
             $date_obj = new DateTime($funding->eventItem->e_start_at);
             $delivery_time_obj = $date_obj->modify('+' . ($funding->c_time + $funding->c_yield_time) . 'days');
             // add order
             $order_group_no = Order::generateOrderGroupNo($u_id);
             $rnd_str = rand(10, 99);
             $order_no = $order_group_no . $cart->b_id . $rnd_str;
             $order = new Order();
             $order->u_id = $u_id;
             $order->b_id = $cart->b_id;
             $order->o_amount_origin = $cart->c_amount_origin;
             $order->o_amount = $cart->c_amount;
             $order->o_shipping_fee = $funding->c_shipping_fee;
             $order->o_shipping_name = $shipping_name;
             $order->o_shipping_phone = $shipping_phone;
             $order->o_shipping_address = $shipping_address;
             $order->o_delivery_time = $delivery_time_obj->format('Y-m-d H:i:s');
             $order->o_shipping = $funding->c_shipping;
             $order->o_comment = 'Fake Order';
             $order->o_number = $order_no;
             $order->o_group_number = $order_group_no;
             $o_id = $order->addOrder();
             Cart::bindOrder([$order->o_id => [$cart->c_id]]);
             $cart->checkout();
             $order->o_status = 2;
             $order->o_shipping_status = 10;
             $order->paied_at = Tools::getNow();
             $order->save();
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     echo "done";
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:75,代码来源:EmergencyController.php

示例9: postReply

 public function postReply($id)
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $content = Input::get('content', '');
     $to_u_id = Input::get('to', 0);
     $to = Input::get('parent', 0);
     try {
         $product = Product::find($id);
         $product->p_reply_count += 1;
         $user = User::chkUserByToken($token, $u_id);
         $to_user = User::find($to_u_id);
         if (empty($to_user)) {
             $to_u_id = 0;
             $to_u_name = '';
         } else {
             $to_u_name = $to_user->u_nickname;
             if ($product->p_type == 2) {
                 $cate = Notification::$CATE_FLEA;
             } else {
                 $cate = Notification::$CATE_PRODUCT_PROMO;
             }
             $msg = new MessageDispatcher();
             $msg->fireCateToUser('您有新的用户回复', $cate, $id);
         }
         $data = ['to_id' => $to, 'created_at' => Tools::getNow(), 'content' => $content, 'u_id' => $u_id, 'u_name' => $user->u_nickname, 'status' => 1, 'to_u_id' => $to_u_id, 'to_u_name' => $to_u_name];
         $reply = new Reply($data);
         $product->replies()->save($reply);
         $product->save();
         $re = Tools::reTrue('回复成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '回复失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:35,代码来源:ProductController.php

示例10: listSellCrowdFunding

 public function listSellCrowdFunding()
 {
     $per_page = Input::get('per_page', 30);
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $filter_option = Input::get('filter_option', 0);
     try {
         $now = Tools::getNow();
         $user = User::chkUserByToken($token, $u_id);
         $query = CrowdFunding::with(['city', 'school', 'user', 'product', 'eventItem', 'praises' => function ($q) {
             $q->where('praises.u_id', '=', $this->u_id);
         }])->join('event_items', function ($q) {
             $q->on('event_items.e_id', '=', 'crowd_fundings.e_id');
         })->where('crowd_fundings.u_id', '=', $u_id);
         switch ($filter_option) {
             case 1:
                 $query = $query->where('crowd_fundings.c_status', '=', 1);
                 break;
             case 2:
                 $query = $query->where('crowd_fundings.c_status', '=', 2);
                 break;
             case 3:
                 $query = $query->where('event_items.e_start_at', '>', $now);
                 break;
             case 4:
                 $query = $query->where('crowd_fundings.c_status', '=', 4);
                 break;
             case 5:
                 $query = $query->where('crowd_fundings.c_status', '=', 5);
                 break;
             case 6:
                 $query = $query->where('crowd_fundings.c_status', '=', 3);
                 break;
             default:
                 break;
         }
         $list = $query->orderBy('crowd_fundings.created_at', 'DESC')->paginate($per_page);
         $data = [];
         foreach ($list as $key => $funding) {
             $tmp = $funding->showInList();
             $tmp['is_praised'] = 0;
             if (count($funding->praises) > 0) {
                 $tmp['is_praised'] = 1;
             }
             $data[] = $tmp;
         }
         $re = Tools::reTrue('获取众筹成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '获取众筹失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:52,代码来源:MeCrowdFundingController.php

示例11: addLog

 public function addLog()
 {
     $this->baseValidate();
     $this->created_at = Tools::getNow();
     return $this->save();
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:6,代码来源:LogTransaction.php

示例12: addLog

 public function addLog()
 {
     $now = Tools::getNow();
     $this->created_at = $now;
     return $this->save();
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:6,代码来源:LogUserInviteCode.php

示例13: flea

 public function flea()
 {
     $city = Input::get('city', 0);
     $province = Input::get('province', 0);
     $school = Input::get('school', 0);
     $key = Input::get('key', '');
     $range = Input::get('range', 0);
     $u_id = Input::get('u_id');
     $is_follow = Input::get('is_follow', 0);
     $cate = Input::get('cate', 0);
     $filter_option = Input::get('filter_option', 0);
     // 1-within 1 day, 2-within 3 days, 3-within 7 days
     $perPage = Input::get('per_page', 30);
     $page = Input::get('page', 1);
     try {
         if (!$school) {
             $range = 2;
         }
         if (!$u_id) {
             throw new Exception("请传入有效的用户id", 2001);
         }
         $user = User::find($u_id);
         $user->load('school');
         $query = Product::with(['user', 'booth' => function ($q) {
             $q->with(['school']);
         }, 'quantity', 'praises' => function ($q) {
             $q->where('praises.u_id', '=', $this->u_id);
         }]);
         $query = $query->select('products.*')->where('products.p_status', '=', 1)->where('products.p_type', '=', 2);
         $query = $query->leftJoin('booths', function ($q) {
             $q->on('booths.b_id', '=', 'products.b_id');
         });
         if ($is_follow) {
             $query = $query->rightJoin('booth_follows', function ($q) use($u_id) {
                 $q->on('booths.b_id', '=', 'booth_follows.b_id')->where('booth_follows.u_id', '=', $u_id);
             });
             $school = 0;
             $city = 0;
             $range = 1;
         }
         if ($school && $range == 3) {
             $query = $query->where('booths.s_id', '=', $school);
         }
         if ($city && $province && $range == 2) {
             $query = $query->where('booths.c_id', '=', $city)->where('booths.pv_id', '=', $province);
         }
         if ($cate) {
             $query = $query->where('products.p_cate', '=', $cate);
         }
         if ($key) {
             $query = $query->where(function ($q) use($key) {
                 $q->where('booths.b_product_source', 'LIKE', '%' . $key . '%')->orWhere('booths.b_product_category', 'LIKE', '%' . $key . '%')->orWhere('booths.b_desc', 'LIKE', '%' . $key . '%')->orWhere('booths.b_title', 'LIKE', '%' . $key . '%')->orWhere('products.p_title', 'LIKE', '%' . $key . '%')->orWhere('products.p_desc', 'LIKE', '%' . $key . '%');
             });
         }
         if ($filter_option) {
             if ($filter_option == 1) {
                 $days = 1;
             } elseif ($filter_option == 2) {
                 $days = 3;
             } else {
                 $days = 7;
             }
             $now = Tools::getNow(false);
             $now->modify('-' . $days . ' days');
             $date = $now->format('Y-m-d H:i:s');
             $query = $query->where('products.active_at', '>', $date);
         }
         $list = $query->orderBy('products.created_at', 'DESC')->paginate($perPage);
         $data = [];
         $start = 0;
         $end = 0;
         foreach ($list as $k => $product) {
             $tmp = $product->showInList();
             if ($k == 0) {
                 $start = $end = $tmp['created_at_timestamps'];
             } else {
                 $start = min($start, $tmp['created_at_timestamps']);
                 $end = max($end, $tmp['created_at_timestamps']);
             }
             if (empty($tmp['booth']['school'])) {
                 $tmp['school'] = [];
             } else {
                 $tmp['school'] = $tmp['booth']['school'];
             }
             if (empty($tmp['booth']['city'])) {
                 $tmp['city'] = [];
             } else {
                 $tmp['city'] = $tmp['booth']['city'];
             }
             unset($tmp['booth']);
             if (count($product->praises) > 0) {
                 $tmp['is_praised'] = 1;
             } else {
                 $tmp['is_praised'] = 0;
             }
             $tmp['item_type'] = 1;
             $data[] = $tmp;
         }
         if (!$key) {
             $start = $start > 0 ? date('Y-m-d H:i:s', $start) : null;
//.........这里部分代码省略.........
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:101,代码来源:MarketController.php

示例14: fetchAd

 public static function fetchAd($position, $start_at, $end_at, $s_id = 0, $c_id = 0, $p_id = 0, $range = 1)
 {
     $query = Advertisement::select('advertisements.*')->with(['eventItem'])->where('advertisements.ad_status', '>', 0)->join('event_positions', function ($q) use($position) {
         $q->on('event_positions.e_id', '=', 'advertisements.e_id')->where('event_positions.position', '=', $position);
     })->join('event_ranges', function ($q) {
         $q->on('event_ranges.e_id', '=', 'advertisements.e_id');
     });
     if ($range == 1) {
         $query = $query->where('event_ranges.s_id', '=', 0)->where('event_ranges.c_id', '=', 0)->where('event_ranges.p_id', '=', 0);
     }
     if ($range == 2) {
         $query = $query->where(function ($q) use($c_id, $p_id) {
             $q->where(function ($qq) use($c_id, $p_id) {
                 $qq->where('event_ranges.c_id', '=', $c_id)->where('event_ranges.p_id', '=', $p_id);
             })->orWhere(function ($qq) {
                 $qq->where('event_ranges.s_id', '=', 0)->where('event_ranges.c_id', '=', 0)->where('event_ranges.p_id', '=', 0);
             });
         });
     }
     if ($range == 3) {
         $query = $query->where(function ($q) use($s_id) {
             $q->where(function ($qq) use($s_id) {
                 $qq->where('event_ranges.s_id', '=', $s_id);
             })->orWhere(function ($qq) {
                 $qq->where('event_ranges.s_id', '=', 0)->where('event_ranges.c_id', '=', 0)->where('event_ranges.p_id', '=', 0);
             });
         });
     }
     $query = $query->join('event_items', function ($q) {
         $q->on('event_items.e_id', '=', 'advertisements.e_id');
     });
     if ($start_at) {
         $query = $query->where('advertisements.created_at', '>', $start_at);
     }
     if ($end_at) {
         $query = $query->where('advertisements.created_at', '<', $end_at);
     }
     $now = Tools::getNow();
     $query = $query->where('event_items.e_start_at', '<', $now)->where('event_items.e_end_at', '>', $now);
     $query->orderBy('advertisements.created_at', 'DESC');
     $ads = $query->get();
     if (count($ads) > 0) {
         $data = [];
         foreach ($ads as $key => $ad) {
             $tmp = $ad->showInList();
             $tmp['item_type'] = 2;
             $data[] = $tmp;
         }
     } else {
         $data = null;
     }
     return $data;
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:53,代码来源:Advertisement.php

示例15: addCrowdFunding

 public function addCrowdFunding()
 {
     $this->baseValidate();
     $now = Tools::getNow();
     $this->created_at = $now;
     return $this->save();
 }
开发者ID:qnck,项目名称:qingnianchuangke,代码行数:7,代码来源:CrowdFunding.php


注:本文中的Tools::getNow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。