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


PHP Book::get_books_info方法代码示例

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


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

示例1: get_operations

 /**
  * @param $personid
  * @return mixed
  */
 public static function get_operations($personid)
 {
     $books = array();
     $books_info = Book::get_books_info(Auth::user()->id);
     $books_left = array();
     $books_distr = array();
     $used = 0;
     $laxmi = 0;
     $os = DB::table('operations AS o')->leftJoin('books AS b', 'o.book_id', '=', 'b.id')->where('o.person_id', $personid)->orderBy('o.custom_date', 'asc')->orderBy('o.operation_type', 'asc')->orderBy('o.datetime', 'asc')->select('o.datetime', 'o.custom_date', 'o.person_id', 'o.book_id', 'o.price', 'o.quantity', 'o.operation_type', 'o.created_at', 'o.updated_at', 'o.laxmi', 'o.description', 'b.name')->get();
     $prevcase = 0;
     $prevop = 0;
     $lxm = 0;
     $gain = 0;
     $debt = 0;
     $oss = [];
     $os[] = 1;
     foreach ($os as $o) {
         if ($prevcase == 10 && (gettype($o) != 'object' || ($o->operation_type != 10 || $o->operation_type == 10 && $prevop != $o->datetime))) {
             foreach ($books as $k => $v) {
                 if (!isset($books_distr[$k])) {
                     $books_distr[$k] = 0;
                 }
                 foreach (array_slice($v, 1) as $b) {
                     $lxm += $b[0] * $b[1];
                     $gain += $b[0] * ($b[1] > $books_info[$k]->price_buy ? $b[1] - $books_info[$k]->price_buy : 0);
                     $books_distr[$k] += $b[0];
                 }
                 unset($books[$k]);
             }
             $books = $books_left;
             $books_left = [];
             $oss[] = array('type' => 'info', 'text' => 'Распространенные книги:', 'o' => '');
             $total_books = 0;
             $points = 0;
             $book_types = ['Махабиги' => 0, 'Биги' => 0, 'Средние' => 0, 'Маленькие' => 0];
             foreach ($books_distr as $k => $v) {
                 $oss[] = array('type' => 'info', 'text' => $books_info[$k]->name, 'o' => $v);
                 switch ($books_info[$k]->book_type) {
                     case 1:
                         $points += 2 * $v;
                         $book_types['Махабиги'] += $v;
                         $total_books += $v;
                         break;
                     case 2:
                         $points += 1 * $v;
                         $book_types['Биги'] += $v;
                         $total_books += $v;
                         break;
                     case 3:
                         $points += 0.5 * $v;
                         $book_types['Средние'] += $v;
                         $total_books += $v;
                         break;
                     case 4:
                         $points += 0.25 * $v;
                         $book_types['Маленькие'] += $v;
                         $total_books += $v;
                         break;
                 }
             }
             $books_distr = [];
             $oss[] = array('type' => 'info', 'text' => 'Всего распространено книг', 'o' => $total_books);
             foreach ($book_types as $k => $v) {
                 $oss[] = array('type' => 'info', 'text' => $k, 'o' => $v);
             }
             $oss[] = array('type' => 'info', 'text' => 'Всего очков', 'o' => $points);
             $oss[] = array('type' => 'info', 'text' => 'Распространено на', 'o' => $lxm);
             $oss[] = array('type' => 'info', 'text' => 'Прибыль', 'o' => $gain);
             $oss[] = array('type' => 'info', 'text' => 'Получено', 'o' => $laxmi);
             if ($laxmi - $debt > $lxm) {
                 $oss[] = array('type' => 'info', 'text' => 'Сверхпожертвование', 'o' => $laxmi - $debt - $lxm);
                 $debt = 0;
             } elseif ($laxmi - $debt < $lxm) {
                 $debt -= $laxmi - $lxm;
                 $oss[] = array('type' => 'info', 'text' => 'Долг', 'o' => $debt);
             } else {
                 $debt = 0;
             }
             $lxm = 0;
             $laxmi = 0;
             $gain = 0;
         }
         if (gettype($o) != 'object') {
             break;
         }
         if ($prevop != $o->datetime || !$prevop) {
             $oss[] = array('type' => 'operation', 'o' => $o);
         }
         $prevcase = $o->operation_type;
         $prevop = $o->datetime;
         switch ($o->operation_type) {
             case 10:
                 if (!$o->book_id) {
                 } elseif (isset($books[$o->book_id])) {
                     $used = $books[$o->book_id][0] - $o->quantity;
                     if ($used < 0) {
//.........这里部分代码省略.........
开发者ID:vladimirgolovanov,项目名称:brihad-mridanga,代码行数:101,代码来源:Operation.php


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