审查视图

application/api/controller/Common.php 21.4 KB
jinglong authored
1
<?php
2 3 4 5 6 7 8 9 10
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------
jinglong authored
11 12
namespace app\api\controller;
13
use app\admin\model\Car;
jinglong authored
14 15
use app\admin\model\Ogoods;
use app\admin\model\Order;
jinglong authored
16
use app\admin\model\Rcoupon;
17
use think\Db;
jinglong authored
18
use think\db\Query;
jinglong authored
19
/**
jinglong authored
20
 * 公共方法
jinglong authored
21
 */
22
class Common
jinglong authored
23
{
jinglong authored
24 25 26 27
    /**
     * 查找单条数据(软删除)
     * @ApiInternal
     */
28
    public static function findSoftWhereData($table,$where,$field,$except=false,$order='id desc'){
29 30
        $res = Db::name($table)
            ->where($where)
jinglong authored
31
            ->field($field,$except)
32
            ->order($order)
jinglong authored
33
            ->useSoftDelete('deletetime')
34 35 36
            ->find();
        return $res;
    }
jinglong authored
37
jinglong authored
38 39 40 41 42
    /**
     * 查找单条数据(有排序)
     * @ApiInternal
     */
    public static function findWhereData($table,$where,$field,$order='id desc'){
43 44 45 46 47 48
        $res = Db::name($table)
            ->where($where)
            ->field($field)
            ->order($order)
            ->find();
        return $res;
jinglong authored
49 50
    }
jinglong authored
51 52 53 54 55
    /**
     * 查找多条数据(无条件)
     * @ApiInternal
     */
    public static function selectData($table,$field,$order='id desc'){
56 57
        $res = Db::name($table)
            ->field($field)
jinglong authored
58
            ->order($order)
59 60 61
            ->select();
        return $res;
    }
jinglong authored
62
jinglong authored
63
    /**
jinglong authored
64 65 66 67 68 69 70 71 72 73 74 75 76
     * 查找多条数据
     * @ApiInternal
     */
    public static function selectWhereData($table,$where,$field,$order='id desc'){
        $res = Db::name($table)
            ->where($where)
            ->field($field)
            ->order($order)
            ->select();
        return $res;
    }

    /**
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
     * 查找多条数据
     * @ApiInternal
     */
    public static function selectWherePageData($table,$where,$field,$page,$limit='',$order='id desc'){
        if($limit == ''){
            $limit = config('verify.limit');
        }
        $res = Db::name($table)
            ->where($where)
            ->field($field)
            ->page($page,$limit)
            ->order($order)
            ->select();
        return $res;
    }

    /**
jinglong authored
94 95 96 97
     * 查找多条数据(软删除)
     * @ApiInternal
     */
    public static function selectSoftData($table,$field,$order='id desc'){
98 99 100 101 102 103 104
        $res = Db::name($table)
            ->field($field)
            ->order($order)
            ->useSoftDelete('deletetime')
            ->select();
        return $res;
    }
jinglong authored
105
jinglong authored
106
    /**
107 108 109 110 111 112 113 114 115 116 117 118 119 120
     * 查找多条数据
     * @ApiInternal
     */
    public static function selectSoftWhereData($table,$where,$field,$order='id desc'){
        $res = Db::name($table)
            ->where($where)
            ->field($field)
            ->order($order)
            ->useSoftDelete('deletetime')
            ->select();
        return $res;
    }

    /**
jinglong authored
121 122 123
     * 查找多条数据(软删除,分页)
     * @ApiInternal
     */
jinglong authored
124 125 126 127
    public static function selectSoftWherePageData($table,$where,$field,$page,$limit='',$order='id desc'){
        if($limit == ''){
            $limit = config('verify.limit');
        }
128
        $res = Db::name($table)
jinglong authored
129
            ->where($where)
130
            ->field($field)
jinglong authored
131 132 133
            ->page($page,$limit)
            ->order($order)
            ->useSoftDelete('deletetime')
134 135 136
            ->select();
        return $res;
    }
jinglong authored
137
jinglong authored
138
    /**
jinglong authored
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
     * 查找多条数据(软删除,分页)
     * @ApiInternal
     */
    public static function selectSoftPageData($table,$field,$page,$limit='',$order='id desc'){
        if($limit == ''){
            $limit = config('verify.limit');
        }
        $res = Db::name($table)
            ->field($field)
            ->page($page,$limit)
            ->order($order)
            ->useSoftDelete('deletetime')
            ->select();
        return $res;
    }

    /**
jinglong authored
156 157 158 159 160
     * 查找多条数据(软删除,限制条数)
     * @ApiInternal
     */
    public static function selectSoftWhereLimitData($table,$where,$field,$order='id desc'){
        $limit = config('verify.limit');
161
        $res = Db::name($table)
jinglong authored
162
            ->where($where)
163 164
            ->field($field)
            ->limit($limit)
jinglong authored
165
            ->order($order)
166 167 168 169
            ->useSoftDelete('deletetime')
            ->select();
        return $res;
    }
jinglong authored
170
jinglong authored
171 172 173 174
    /**
     * 查找多条数据(软删除,无条件,限制条数)
     * @ApiInternal
     */
jinglong authored
175
    public static function selectSoftLimitData($table,$field,$limit,$order='id desc'){
176 177
        $res = Db::name($table)
            ->field($field)
jinglong authored
178 179 180
            ->limit($limit)
            ->order($order)
            ->useSoftDelete('deletetime')
181 182 183
            ->select();
        return $res;
    }
jinglong authored
184
jinglong authored
185
    /**
186
     * 查询总页数
jinglong authored
187 188
     * @ApiInternal
     */
189 190 191 192
    public static function count($table,$where,$limit=''){
        if($limit == ''){
            $limit = config('verify.limit');
        }
193 194 195 196 197 198
        $count = Db::name($table)
            ->where($where)
            ->count();
        return ceil($count/$limit);
    }
jinglong authored
199
    /**
200 201 202 203 204 205 206 207 208 209 210 211
     * 查询总条数
     * @ApiInternal
     */
    public static function count_count($table,$where){
        $count = Db::name($table)
            ->where($where)
            ->count();
        return $count;
    }

    /**
     * 查询总页数(软删除)
jinglong authored
212 213
     * @ApiInternal
     */
214 215 216 217 218 219 220 221 222 223
    public static function countSoft($table,$where='',$limit=''){
        if(empty($limit)){
            $limit = config('verify.limit');
        }

        if(empty($where)){
            $count = Db::name($table)->useSoftDelete('deletetime')->count();
        }else{
            $count = Db::name($table)->where($where)->useSoftDelete('deletetime')->count();
        }
jinglong authored
224 225 226 227
        return ceil($count/$limit);
    }

    /**
jinglong authored
228 229 230 231 232 233 234 235 236 237 238 239
     * 查询总数(软删除)
     * @ApiInternal
     */
    public static function countSoftTotal($table,$where){
        $count = Db::name($table)
            ->where($where)
            ->useSoftDelete('deletetime')
            ->count();
        return $count;
    }

    /**
jinglong authored
240 241 242
     * 商品列表
     * @ApiInternal
     */
jinglong authored
243
    public static function goodsList($where='',$page,$uid='',$limit='',$order='id desc',$flag = '',$flag1=''){
jinglong authored
244
        $arr = [];
245
        //默认未登录
jinglong authored
246
        $is_news = self::is_new($uid);
jinglong authored
247
        if(empty($where)){
248 249
            if($is_news == 1){
                //去除含有新人标签的数据
jinglong authored
250
                $res = Common::selectSoftWherePageData('goods',['is_new'=>0],'id,image,name,tag,style,sale_price1 sale_price,expense_price,is_new',$page,$limit,$order);
251
            }else{
jinglong authored
252
                $res = Common::selectSoftPageData('goods','id,image,name,tag,style,sale_price1 sale_price,expense_price,is_new',$page,$limit,$order);
253
            }
jinglong authored
254
        }else{
255
            if($is_news == 1){
256
                //旧人
257 258
                $where['is_new'] = 0;
            }
jinglong authored
259
            $res = Common::selectSoftWherePageData('goods',$where,'id,image,name,tag,style,sale_price1 sale_price,expense_price,is_new',$page,$limit,$order);
jinglong authored
260 261
        }
jinglong authored
262
        foreach ($res as &$value){
263 264 265 266 267 268 269 270 271 272 273
            if($is_news == 2 || $is_news == 0){//未登录或者新人
                if($value['is_new'] == 0){
                    //非新人优惠标签
                    $value['is_new_tag'] = 0;//不用显示新人价标签
                }else{
                    //新人优惠标签
                    $value['is_new_tag'] = 1;//显示新人价标签
                }
            }else{
                $value['is_new_tag'] = 0;//不用显示新人价标签(新人价标签商品不会出来)
            }
jinglong authored
274
            $value['image'] = self::absolutionUrlOne($value['image']);
jinglong authored
275
            $value['style'] = explode('|',$value['style']);
jinglong authored
276
            $value['tag'] = explode('|',$value['tag']);
jinglong authored
277 278 279 280 281 282
            $sale_price = self::salePrice($value['sale_price']);
            if($sale_price){
                $value['sale_price'] = $sale_price[0];
            }else{
                $value['sale_price'] = '';
            }
283
            unset($value['is_new']);
jinglong authored
284
        }
jinglong authored
285 286 287 288 289 290 291 292 293 294 295 296 297
        if(!empty($flag1)){
            //销售价格排序
            if($flag1 == 1){
                //倒序
                $sale_price = array_column($res,'sale_price');
                array_multisort($sale_price,SORT_DESC,$res);
            }else{
                //正序
                $sale_price = array_column($res,'sale_price');
                array_multisort($sale_price,SORT_ASC,$res);
            }
        }
jinglong authored
298 299
        $arr['data'] = $res;
        //总页数
300 301 302 303 304 305 306 307 308
        if(empty($where)){
            if($is_news == 1){
                $arr['total_page'] = self::countSoft('goods',['is_new'=>0],$limit);
            }else{
                $arr['total_page'] = self::countSoft('goods','',$limit);
            }
        }else{
            $arr['total_page'] = self::countSoft('goods',$where,$limit);
        }
309 310 311 312 313
        if(empty($flag)){
            return $arr;
        }else{
            return $res;
        }
jinglong authored
314 315 316
    }

    /**
jinglong authored
317
     * 是否是新人
jinglong authored
318 319
     * @ApiInternal
     */
jinglong authored
320
    public static function is_new($uid){
321 322 323
        $is_news = 2;
        if(!empty($uid)){
            //已登录
324
            $res1 = self::findSoftWhereData('order',['uid'=>$uid,'status'=>config('verify.status')[8]],'id');
325 326 327 328 329 330
            if($res1){
                $is_news = 1;//旧人
            }else{
                $is_news = 0;//新人
            }
        }
jinglong authored
331 332 333 334 335 336 337 338 339 340 341
        return $is_news;
    }

    /**
     * 检索商品列表
     * @ApiInternal
     */
    public static function searchGoodsList($keyword,$where,$page,$uid){
        $arr = [];
        //默认未登录
        $is_news = self::is_new($uid);
342 343 344
        if($is_news == 1){
            $where['is_new'] = 0;
        }
jinglong authored
345 346
        $limit = config('verify.limit');
        $res = Db::name('goods')
jinglong authored
347
            ->field('LOCATE("'.$keyword.'",name) as nameIndex,id,image,name,tag,is_new,style,sale_price1 sale_price,expense_price')//获取关键字的位置:LOCATE(关键字,字段) 返回索引位置
jinglong authored
348 349
            ->where($where)//多字段条件查询
            ->page($page,$limit)
350
            ->order('nameIndex')//按tIndex 值排序
jinglong authored
351
            ->select();
jinglong authored
352
        foreach ($res as &$value){
353 354 355 356 357 358 359 360 361 362 363
            if($is_news == 2 || $is_news == 0){//未登录或者新人
                if($value['is_new'] == 0){
                    //非新人优惠标签
                    $value['is_new_tag'] = 0;//不用显示新人价标签
                }else{
                    //新人优惠标签
                    $value['is_new_tag'] = 1;//显示新人价标签
                }
            }else{
                $value['is_new_tag'] = 0;//不用显示新人价标签(新人价标签商品不会出来)
            }
jinglong authored
364
365 366 367
            $value['image'] = self::absolutionUrlOne($value['image']);
            $value['tag'] = explode('|',$value['tag']);
            $value['style'] = explode('|',$value['style']);
jinglong authored
368 369 370 371 372 373
            $sale_price = self::salePrice($value['sale_price']);
            if($sale_price){
                $value['sale_price'] = $sale_price[0];
            }else{
                $value['sale_price'] = '';
            }
374 375

            $value['str_count'] = 0;
jinglong authored
376 377 378
            if(strpos($value['name'],$keyword) !== false){
                //包含
                $value['name'] = str_replace($keyword,'<a href="javascript:void(0);" style="color:red;">'.$keyword.'</a>',$value['name']);
379
                $value['str_count'] = substr_count($value['name'],$keyword);
jinglong authored
380
            }
381
            unset($value['is_new']);
jinglong authored
382
        }
383 384
        $str_count = array_column($res,'str_count');
        array_multisort($str_count,SORT_DESC,$res);
jinglong authored
385 386 387 388 389 390 391
        $arr['data'] = $res;
        //总页数
        $arr['total_page'] = Common::countSoft('goods',$where);
        return $arr;
    }

    /**
jinglong authored
392 393 394 395 396 397 398 399 400 401 402 403
     * 价格字符串转数组
     * @ApiInternal
     */
    public static function salePrice($string=''){
        $arr = [];
        if(!empty($string)){
            $arr = explode('|',$string);
        }
        return $arr;
    }

    /**
jinglong authored
404 405 406 407 408 409 410 411 412 413 414 415
     * 单张相对路径转绝对路径
     * @ApiInternal
     */
    public static function absolutionUrlOne($image){
        $url = '';
        if(!empty($image)){
            $host = config('verify.host');
            $url = $host.$image;
        }
        return $url;
    }
416
    /**
jinglong authored
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
     * @param $style 传递规格
     * @param $goods_number 传递数量
     * @param $g_style 数据库商品规格
     * @param $g_stock 数据库商品库存
     * @ApiInternal
     * @return bool
     */
    public static function checkStock($style,$goods_number,$g_style,$g_stock){
        $s_index = array_search($style,self::salePrice($g_style));
        $stock = self::salePrice($g_stock)[$s_index];
        if(($stock <=> $goods_number) == -1){
            //库存不足
            return false;
        }
        return true;
    }

    /**
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
     * 合并数组
     * @ApiInternal
     */
    public static function array_merge_more($keys, ...$arrs){
        // 检查参数是否正确
        if(!$keys || !is_array($keys) || !$arrs || !is_array($arrs) || count($keys)!=count($arrs)){
            return array();
        }
        // 一维数组中最大长度
        $max_len = 0;
        // 整理数据,把所有一维数组转重新索引
        for($i=0,$len=count($arrs); $i<$len; $i++){
            $arrs[$i] = array_values($arrs[$i]);

            if(count($arrs[$i])>$max_len){
                $max_len = count($arrs[$i]);
            }
        }
        // 合拼数据
        $result = array();
        for($i=0; $i<$max_len; $i++){
            $tmp = array();
            foreach($keys as $k=>$v){
                if(isset($arrs[$k][$i])){
                    $tmp[$v] = $arrs[$k][$i];
                }
            }
            $result[] = $tmp;
        }
        return $result;
    }
jinglong authored
467 468 469 470 471
    /**
     * 订单号
     * @ApiInternal
     */
    public static function genOrderSn() {
jinglong authored
472
        $res = Db::name('order')->field('id,order_sn')->order('id desc')->find();
jinglong authored
473 474 475 476 477 478 479 480 481 482 483 484 485
        if($res){
            $order_sn = $res['order_sn'];
            $order_sn++;
        }else{
            $order_sn = '1000001';
        }
        return $order_sn;
    }

    /**
     * 支付订单号
     * @ApiInternal
     */
jinglong authored
486 487 488 489 490 491 492 493
    public static function genPayOrderSn($letter = '') {
        $time = explode (" ", microtime ());
        $timeArr = explode('.',$time [0]);
        $mtime = array_pop($timeArr);
        $fulltime = $letter.$time[1].$mtime.mt_rand(1000,9999);
        return $fulltime;
    }
jinglong authored
494 495 496 497
    /**
     * 写入订单数据
     * @ApiInternal
     */
498
    public static function createOrder($data,$pay_order_sn,$uid,$status=''){
jinglong authored
499
        Db::startTrans();
jinglong authored
500 501 502 503 504 505 506 507 508 509 510 511 512
        //写入订单主表
        $data1['order_sn'] = self::genOrderSn();
        $data1['pay_order_sn'] = $pay_order_sn;
        $data1['uid'] = $uid;
        $data1['receive_name'] = $data['receive_name'];
        $data1['receive_mobile'] = $data['receive_mobile'];
        $data1['receive_address'] = $data['receive_address'];
        if(isset($data['leave_message']) && !empty($data['leave_message'])){
            $data1['leave_message'] = $data['leave_message'];//留言
        }
        if(isset($data['coupon_id']) && !empty($data['coupon_id'])){
            $data1['coupon_id'] = $data['coupon_id'];//优惠券id
        }
513
        if(!empty($status)){
jinglong authored
514
            $data1['status'] = $status;//更新支付成功
515
        }
jinglong authored
516 517 518
        $data1['total_goods_price'] = $data['total_goods_price'];//商品金额
        $data1['discount_price'] = $data['discount_price'];//优惠金额
        $data1['total_expense_price'] = $data['total_expense_price'];//运费总金额
jinglong authored
519
        $data1['total_price'] = $data['total_price'];//商+运-优惠
jinglong authored
520 521 522
        $orderModel = new Order();
        $res1 = $orderModel->create($data1);
        //写入订单附加表
jinglong authored
523 524 525
        $goods_id_s = explode(',',$data['goods_id']);
        $price_s = explode(',',$data['price']);
        $goods_number_s = explode(',',$data['goods_number']);
jinglong authored
526
        $style_s = explode(',',$data['style']);
jinglong authored
527
        //合并数组
jinglong authored
528 529
        $key = ['g_id','price','goods_number','style'];
        $res_goods = self::array_merge_more($key,$goods_id_s,$price_s,$goods_number_s,$style_s);
jinglong authored
530 531 532 533 534 535 536 537 538 539 540 541 542 543
        $o_id = $res1->id;
        foreach($res_goods as &$value){
            $value['o_id'] = $o_id;
        }
        $oGoodsModel = new Ogoods();
        $res2 = $oGoodsModel->saveAll($res_goods);
        if($res1 && $res2){
            Db::commit();
            $arr['order_id'] = $o_id;
            return $arr;
        }else{
            Db::rollback();
            return false;
        }
jinglong authored
544 545
    }
546
    /**
jinglong authored
547 548 549 550 551 552 553 554 555 556 557 558
     * 减库存
     * @ApiInternal
     */
    public static function decStock($where){
        $goodsModel = new \app\admin\model\Goods();
        $goodsModel->where($where)->setDec('stock',1);
    }

    /**
     * 增销量
     * @ApiInternal
     */
jinglong authored
559
    public static function incSales($where,$sale_number){
jinglong authored
560
        $goodsModel = new \app\admin\model\Goods();
jinglong authored
561
        $goodsModel->where($where)->setInc('sales',$sale_number);
jinglong authored
562 563 564
    }

    /**
jinglong authored
565 566 567 568 569 570 571 572 573
     * 减少销量
     * @ApiInternal
     */
    public static function decSales($where,$sale_number){
        $goodsModel = new \app\admin\model\Goods();
        $goodsModel->where($where)->setDec('sales',$sale_number);
    }

    /**
574 575 576 577 578 579 580 581 582
     * 删购物车
     * @ApiInternal
     */
    public static function deleteCar($where){
        $carModel = new Car();
        $carModel->where($where)->delete();
    }

    /**
583 584 585 586 587 588 589
     * 更新优惠券
     * @ApiInternal
     */
    public static function updateRCoupon($uid,$coupon_id,$is_use){
        $rCouponModel = new Rcoupon();
        $rCouponModel->where(['uid'=>$uid,'c_id'=>$coupon_id])->update(['is_use'=>$is_use]);
    }
jinglong authored
590 591

    /**
592
     * 购买成功,更新订单号为待发货,销量增加1,减库存,删除购物车
jinglong authored
593 594
     * @ApiInternal
     */
jinglong authored
595
    public static function paySuccess($out_trade_no){
jinglong authored
596 597 598
        $status = config('verify.status');
        //更新订单号成功
        $orderModel = new Order();
jinglong authored
599
        $orderModel->where(['pay_order_sn'=>$out_trade_no,'status'=>$status[0]])->update(['status'=>$status[2],'paytime'=>time()]);//待发货
jinglong authored
600
        //销量增加1
601
        $res = self::findSoftWhereData('order',['pay_order_sn'=>$out_trade_no,'status'=>$status[2]],'id,uid,coupon_id');
jinglong authored
602
        if($res){
jinglong authored
603
            $res1 = self::selectSoftWhereData('ogoods',['o_id'=>$res['id']],'id,g_id,style,goods_number');
jinglong authored
604
            $g_ids = array_column($res1,'g_id');
605
            //减库存
606 607 608
            $goodsModel = new \app\admin\model\Goods();
            //查询商品的库存
            $res_stock = self::selectSoftWhereData('goods',['id'=>['in',$g_ids]],'id,style g_style,stock');
jinglong authored
609 610
            foreach($res_stock as $g_value){
                $arr_stock = explode('|',$g_value['stock']);
jinglong authored
611
                $sale_number = 1;
jinglong authored
612 613
                foreach($res1 as $value){
                    if($g_value['id'] == $value['g_id']){
614
                        $s_index = array_search($value['style'],self::salePrice($g_value['g_style']));
jinglong authored
615
                        $stock = self::salePrice($g_value['stock'])[$s_index] - $value['goods_number'];
616
                        $arr_stock[$s_index] = $stock;
jinglong authored
617
                        $sale_number = $value['goods_number'];
618 619
                    }
                }
jinglong authored
620 621
                //更新库存
                $stock1 = implode('|',$arr_stock);
jinglong authored
622
                $goodsModel->where(['id'=>$g_value['id']])->update(['stock'=>$stock1]);
jinglong authored
623 624
                //增加销售
                self::incSales(['id'=>['in',$g_ids]],$sale_number);
625
            }
626 627
            //删除购物车
            self::deleteCar(['uid'=>$res['uid'],'g_id'=>['in',$g_ids]]);
628 629 630 631

            //更新优惠券已使用
            $flag = config('verify.flag');
            self::updateRCoupon($res['uid'],$res['coupon_id'],$flag[1]);
jinglong authored
632
        }
jinglong authored
633
    }
jinglong authored
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662

    /**
     * 支付检测库存
     * @ApiInternal
     */
    public static function checkPayStock($order_goods,$goods_id = ''){
        //检查库存
        if(empty($goods_id)){
            $goods_id_s = array_column($order_goods,'goods_id');
            //查询商品
            $res = self::selectSoftWhereData('goods',['id'=>['in',$goods_id_s]],'id,name,stock,style g_style');
        }else{
            //查询商品
            $res = self::selectSoftWhereData('goods',['id'=>['in',$goods_id]],'id,name,stock,style g_style');
        }

        foreach($order_goods as $g_value){
            foreach ($res as $value){
                if($value['id'] == $g_value['goods_id']){
                    //检测库存
                    $check_stock = self::checkStock($g_value['style'],$g_value['goods_number'],$value['g_style'],$value['stock']);
                    if(!$check_stock){
                        return '商品名称:'.$value['name'].',规格:'.$g_value['style'].'库存不足';
                    }
                }
            }
        }
        return true;
    }
jinglong authored
663 664 665 666 667 668 669 670 671 672 673 674 675 676

    /**
     * @param $type (0:首页,1:商品浏览,2:商品收藏 )
     * @param int $uid
     * @param int $g_id
     * @ApiInternal
     */
    public static function statistics($type=0,$uid=0,$g_id=0){
        $arr['type'] = $type;
        $arr['uid'] = $uid;
        $arr['g_id'] = $g_id;
        $arr['createtime'] = time();
        Db::name('statistics')->insert($arr);
    }
jinglong authored
677
}