18315626215 5 年 前
コミット
29b0100550
47 ファイル変更2320 行追加695 行削除
  1. 31 0
      addons/qrcode/Qrcode.php
  2. 22 0
      addons/qrcode/config.php
  3. 77 0
      addons/qrcode/controller/Index.php
  4. 8 0
      addons/qrcode/info.ini
  5. 177 0
      addons/qrcode/view/index/index.html
  6. 63 11
      application/admin/controller/Dashboard.php
  7. 76 0
      application/admin/controller/Edition.php
  8. 3 3
      application/admin/controller/Index.php
  9. 76 0
      application/admin/controller/agreemen/Setbean.php
  10. 77 0
      application/admin/controller/cash/Cashlog.php
  11. 9 5
      application/admin/controller/order/Torder.php
  12. 8 0
      application/admin/controller/users/Users.php
  13. 6 0
      application/admin/lang/zh-cn/agreemen/setbean.php
  14. 13 0
      application/admin/lang/zh-cn/cash/cashlog.php
  15. 7 0
      application/admin/lang/zh-cn/edition.php
  16. 56 0
      application/admin/model/cash/Cashlog.php
  17. 16 0
      application/admin/view/agreemen/setbean/add.html
  18. 16 0
      application/admin/view/agreemen/setbean/edit.html
  19. 35 0
      application/admin/view/agreemen/setbean/index.html
  20. 52 0
      application/admin/view/cash/cashlog/add.html
  21. 52 0
      application/admin/view/cash/cashlog/edit.html
  22. 35 0
      application/admin/view/cash/cashlog/index.html
  23. 110 259
      application/admin/view/dashboard/index.html
  24. 36 0
      application/admin/view/edition/add.html
  25. 36 0
      application/admin/view/edition/edit.html
  26. 35 0
      application/admin/view/edition/index.html
  27. 108 66
      application/api/controller/Login.php
  28. 6 5
      application/api/controller/Member.php
  29. 178 42
      application/api/controller/Order.php
  30. 34 6
      application/api/controller/Plan.php
  31. 72 10
      application/api/controller/Queue.php
  32. 1 1
      application/api/controller/Recharge.php
  33. 4 3
      application/api/controller/Register.php
  34. 169 38
      application/api/controller/User.php
  35. 138 138
      application/api/controller/Validate.php
  36. 60 25
      application/api/controller/Wechatwebopenid.php
  37. 49 43
      application/api/model/Cashwechat.php
  38. 1 1
      application/api/model/Logistics.php
  39. 4 0
      application/api/model/OrderCommodityModel.php
  40. 157 26
      application/api/model/OrderModel.php
  41. 4 4
      application/common/lib/Promote.php
  42. 50 0
      public/assets/js/backend/agreemen/setbean.js
  43. 58 0
      public/assets/js/backend/cash/cashlog.js
  44. 52 0
      public/assets/js/backend/edition.js
  45. 43 9
      public/assets/js/backend/users/users.js
  46. BIN
      public/uploads/logo.jpg
  47. BIN
      public/uploads/logo.png

+ 31 - 0
addons/qrcode/Qrcode.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace addons\qrcode;
+
+use think\Addons;
+
+/**
+ * 二维码生成
+ */
+class Qrcode extends Addons
+{
+
+    /**
+     * 插件安装方法
+     * @return bool
+     */
+    public function install()
+    {
+        return true;
+    }
+
+    /**
+     * 插件卸载方法
+     * @return bool
+     */
+    public function uninstall()
+    {
+        return true;
+    }
+
+}

+ 22 - 0
addons/qrcode/config.php

@@ -0,0 +1,22 @@
+<?php
+
+return [
+    array(
+        'name'    => 'rewrite',
+        'title'   => '伪静态',
+        'type'    => 'array',
+        'content' =>
+        array(
+        ),
+        'value'   =>
+        array(
+            'index/index' => '/qrcode$',
+            'index/build' => '/qrcode/build$',
+        ),
+        'rule'    => 'required',
+        'msg'     => '',
+        'tip'     => '',
+        'ok'      => '',
+        'extend'  => '',
+    ),
+];

+ 77 - 0
addons/qrcode/controller/Index.php

@@ -0,0 +1,77 @@
+<?php
+
+namespace addons\qrcode\controller;
+
+use Endroid\QrCode\QrCode;
+use think\addons\Controller;
+use think\Response;
+
+/**
+ * 二维码生成
+ *
+ */
+class Index extends Controller
+{
+
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+    }
+
+    public function index()
+    {
+        return $this->view->fetch();
+    }
+
+    // 生成二维码
+    public function build()
+    {
+        $text = $this->request->get('text', 'hello world');
+        $size = $this->request->get('size', 250);
+        $padding = $this->request->get('padding', 15);
+        $errorcorrection = $this->request->get('errorcorrection', 'medium');
+        $foreground = $this->request->get('foreground', "#ffffff");
+        $background = $this->request->get('background', "#000000");
+        $logo = $this->request->get('logo');
+        $logosize = $this->request->get('logosize');
+        $label = $this->request->get('label');
+        $labelfontsize = $this->request->get('labelfontsize');
+        $labelhalign = $this->request->get('labelhalign');
+        $labelvalign = $this->request->get('labelvalign');
+        // 前景色
+        list($r, $g, $b) = sscanf($foreground, "#%02x%02x%02x");
+        $foregroundcolor = ['r' => $r, 'g' => $g, 'b' => $b];
+
+        // 背景色
+        list($r, $g, $b) = sscanf($background, "#%02x%02x%02x");
+        $backgroundcolor = ['r' => $r, 'g' => $g, 'b' => $b];
+
+        $qrCode = new QrCode();
+        $qrCode
+            ->setText($text)
+            ->setSize($size)
+            ->setPadding($padding)
+            ->setErrorCorrection($errorcorrection)
+            ->setForegroundColor($foregroundcolor)
+            ->setBackgroundColor($backgroundcolor)
+            ->setLogoSize($logosize)
+            ->setLabel($label)
+            ->setLabelFontSize($labelfontsize)
+            ->setLabelHalign($labelhalign)
+            ->setLabelValign($labelvalign)
+            ->setImageType(QrCode::IMAGE_TYPE_PNG);
+        $fontPath = ROOT_PATH . 'public/assets/fonts/SourceHanSansK-Regular.ttf';
+        if (file_exists($fontPath)) {
+            $qrCode->setLabelFontPath($fontPath);
+        }
+        if ($logo) {
+            $qrCode->setLogo(ROOT_PATH . 'public/assets/img/qrcode.png');
+        }
+        //也可以直接使用render方法输出结果
+        //$qrCode->render();
+        return new Response($qrCode->get(), 200, ['Content-Type' => $qrCode->getContentType()]);
+    }
+
+}

+ 8 - 0
addons/qrcode/info.ini

@@ -0,0 +1,8 @@
+name = qrcode
+title = 二维码生成
+intro = 生成二维码插件
+author = Karson
+website = http://www.fastadmin.net
+version = 1.0.3
+state = 1
+url = /addons/qrcode.html

+ 177 - 0
addons/qrcode/view/index/index.html

@@ -0,0 +1,177 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
+        <title>二维码生成 - {$site.name}</title>
+        <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
+
+        <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
+        <!--[if lt IE 9]>
+          <script src="http://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
+          <script src="http://apps.bdimg.com/libs/respond.js/1.4.2/respond.js"></script>
+        <![endif]-->
+    </head>
+    <body>
+        <div class="container">
+            <h2>二维码生成</h2>
+            <hr>
+            <div class="well">
+                <form action="" method="post">
+                    <div class="row">
+                        <div class="col-md-4">
+                            <div class="form-group">
+                                <label class="control-label">文本内容</label>
+                                <input type="text" name="text" class="form-control" placeholder="" value="http://www.fastadmin.net">
+                            </div>
+                            <div class="form-group">
+                                <label class="control-label">标签</label>
+                                <input type="text" name="label" placeholder="" class="form-control" value="FastAdmin">
+                            </div>
+                            <div class="form-group">
+                                <label class="control-label">Logo</label>
+                                <div class="form-inline">
+                                    <div class="radio">
+                                        <label>
+                                            <input type="radio" name="logo" id="logoyes" value="1" checked="">
+                                            显示(Logo地址在代码中修改)
+                                        </label>
+                                    </div>
+                                    <div class="radio">
+                                        <label>
+                                            <input type="radio" name="logo" id="logono" value="0">
+                                            不显示
+                                        </label>
+                                    </div>
+                                </div>
+                            </div>
+                            <div class="form-group">
+                                <input type="submit" class="btn btn-info" />
+                                <input type="reset" class="btn btn-default" />
+                            </div>
+                        </div>
+
+                        <div class="col-md-2">
+                            <div id="toastTypeGroup">
+                                <label>标签水平位置</label>
+                                <div class="form-group radio">
+                                    <label><input type="radio" name="labelhalign" value="0" checked="">居中</label>
+                                </div>
+                                <div class="form-group radio">
+                                    <label><input type="radio" name="labelhalign" value="1">左</label>
+                                </div>
+                                <div class="form-group radio">
+                                    <label><input type="radio" name="labelhalign" value="2">左边框</label>
+                                </div>
+                                <div class="form-group radio">
+                                    <label><input type="radio" name="labelhalign" value="3">左图片</label>
+                                </div>
+                                <div class="form-group radio">
+                                    <label><input type="radio" name="labelhalign" value="4">右</label>
+                                </div>
+                                <div class="form-group radio">
+                                    <label><input type="radio" name="labelhalign" value="5">右边框</label>
+                                </div>
+                                <div class="form-group radio">
+                                    <label><input type="radio" name="labelhalign" value="6">右图片</label>
+                                </div>
+                            </div>
+                            <div id="positionGroup">
+                                <label>标签垂直位置</label>
+                                <div class="form-group radio">
+                                    <label>
+                                        <input type="radio" name="labelvalign" value="1">上
+                                    </label>
+                                </div>
+                                <div class="form-group radio">
+                                    <label>
+                                        <input type="radio" name="labelvalign" value="2">上边框
+                                    </label>
+                                </div>
+                                <div class="form-group radio">
+                                    <label>
+                                        <input type="radio" name="labelvalign" value="3" checked="">中
+                                    </label>
+                                </div>
+                                <div class="form-group radio">
+                                    <label>
+                                        <input type="radio" name="labelvalign" value="4">下
+                                    </label>
+                                </div>
+                            </div>
+                        </div>
+
+                        <div class="col-md-2">
+                            <div class="form-group">
+                                <div class="form-group">
+                                    <label class="control-label">前景色</label>
+                                    <input type="text" name="foreground" placeholder="" class="form-control" value="#ffffff">
+                                </div>
+                                <div class="form-group">
+                                    <label class="control-label">背景色</label>
+                                    <input type="text" name="background" placeholder="" class="form-control" value="#000000">
+                                </div>
+                                <div class="form-group">
+                                    <label class="control-label">大小</label>
+                                    <input type="number" name="size" placeholder="" class="form-control" value="300">
+                                </div>
+                                <div class="form-group">
+                                    <label class="control-label">内边距</label>
+                                    <input type="number" name="padding" placeholder="" class="form-control" value="10">
+                                </div>
+                            </div>
+                        </div>
+
+                        <div class="col-md-3">
+                            <div class="form-group">
+                                <label class="control-label">Logo大小</label>
+                                <input type="number" name="logosize" placeholder="" class="form-control" value="50">
+                            </div>
+                            <div class="form-group">
+                                <label class="control-label">标签大小</label>
+                                <input type="number" name="labelfontsize" placeholder="" class="form-control" value="14">
+                            </div>
+                            <div class="form-group">
+                                <div id="positionGroup">
+                                    <label>容错级别</label>
+                                    <div class="form-group radio">
+                                        <label>
+                                            <input type="radio" name="errorcorrection" value="low">低
+                                        </label>
+                                    </div>
+                                    <div class="form-group radio">
+                                        <label>
+                                            <input type="radio" name="errorcorrection" value="medium" checked="">中等
+                                        </label>
+                                    </div>
+                                    <div class="form-group radio">
+                                        <label>
+                                            <input type="radio" name="errorcorrection" value="quartile">高
+                                        </label>
+                                    </div>
+                                    <div class="form-group radio">
+                                        <label>
+                                            <input type="radio" name="errorcorrection" value="high">超高
+                                        </label>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </form>
+            </div>
+            <input type="text" class="form-control" id='qrcodeurl' />
+            <img src="" alt="" id='qrcodeimg' />
+        </div>
+        <script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
+        <script type="text/javascript">
+            $(function () {
+                $("form").submit(function () {
+                    $("#qrcodeimg").prop("src", "{:addon_url('qrcode/index/build',[],false)}?" + $(this).serialize());
+                    $("#qrcodeurl").val("{:addon_url('qrcode/index/build',[],false,true)}?" + $(this).serialize());
+                    return false;
+                });
+                $("form").trigger('submit');
+            });
+        </script>
+    </body>
+</html>

+ 63 - 11
application/admin/controller/Dashboard.php

@@ -2,8 +2,15 @@
 
 namespace app\admin\controller;
 
+use app\admin\model\RechargeModel;
+use app\api\controller\Order;
+use app\api\controller\User;
+use app\api\model\OrderModel;
+use app\api\model\QueueModel;
+use app\api\model\UsersModel;
 use app\common\controller\Backend;
 use think\Config;
+use think\Db;
 
 /**
  * 控制台
@@ -21,8 +28,7 @@ class Dashboard extends Backend
     {
         $seventtime = \fast\Date::unixtime('day', -7);
         $paylist = $createlist = [];
-        for ($i = 0; $i < 7; $i++)
-        {
+        for ($i = 0; $i < 7; $i++) {
             $day = date("Y-m-d", $seventtime + ($i * 86400));
             $createlist[$day] = mt_rand(20, 200);
             $paylist[$day] = mt_rand(1, mt_rand(1, $createlist[$day]));
@@ -33,21 +39,67 @@ class Dashboard extends Backend
         Config::parse($addonComposerCfg, "json", "composer");
         $config = Config::get("composer");
         $addonVersion = isset($config['version']) ? $config['version'] : __('Unknown');
+        // VIP开通次数
+        $vipBuyNum = \app\admin\model\Viplog::where('pay_status', 1)->count();
+        // 排队次数
+        $queueNum = QueueModel::where('pay_status', 1)->count();
+        // 排队总收入
+        $queueIncome = QueueModel::where('pay_status', 1)->sum('amount');
+        // 排队总支出
+        $queueOut = QueueModel::where('pay_status', 1)->sum('income');
+        // 话费充值次数
+        $rechargeNum = RechargeModel::where('pay_status', 1)->count();
+        // 话费充值收入
+        $rechargeIncome = RechargeModel::where('pay_status', 1)->sum('final_fee');
+        // 话费充值支出
+        $rechargeOut = RechargeModel::where('pay_status', 1)->sum('price');
+        // 待发货订单
+        $dafaihuo = OrderModel::where('state', 2)->count();
+        // 退款订单
+        $tuikuan = OrderModel::where('state', 4)->count();
+        // 商城总收入
+        $zongmongey = OrderModel::where('state', 6)->sum('money');
+        // 提现总支出
+        $tixian = Db::name('cash_log')->where('state', 2)->sum('money');
+        // 会员总数
+        $totaluser = Db::name('users')->count();
+        // 普通会员总数
+        $pt = UsersModel::where('user_level',1)->count();
+        // 店长总数
+        $dianzhang = UsersModel::where('user_level',2)->count();
+        // 经理总数
+        $jingli = UsersModel::where('user_level',3)->count();
+        // 总监总数
+        $zongjian = UsersModel::where('user_level',4)->count();
+        // 董事总数
+        $dongshi = UsersModel::where('user_level',5)->count();
+        // vip会员总数
+        $vip = UsersModel::where('user_level',6)->count();
         $this->view->assign([
-            'totaluser'        => 35200,
-            'totalviews'       => 219390,
-            'totalorder'       => 32143,
-            'totalorderamount' => 174800,
-            'todayuserlogin'   => 321,
-            'todayusersignup'  => 430,
+            'totaluser'        => $totaluser,
+            'totalviews'       => $pt,
+            'totalorder'       => $dianzhang,
+            'totalorderamount' => $jingli,
+            'todayuserlogin'   => $zongjian,
+            'todayusersignup'  => $dongshi,
             'todayorder'       => 2324,
             'unsettleorder'    => 132,
             'sevendnu'         => '80%',
-            'sevendau'         => '32%',
+            'vip'         => $vip,
             'paylist'          => $paylist,
             'createlist'       => $createlist,
-            'addonversion'       => $addonVersion,
-            'uploadmode'       => $uploadmode
+            'addonversion'     => $addonVersion,
+            'uploadmode'       => $uploadmode,
+            'vipBuyNum'        => $vipBuyNum,
+            'queueIncome'      => $queueIncome,
+            'queueOut'         => $queueOut,
+            'rechargeIncome'   => $rechargeIncome,
+            'rechargeNum'      => $rechargeNum,
+            'rechargeOut'      => $rechargeOut,
+            'daifahuo'         => $dafaihuo,
+            'tuikuan'          => $tuikuan,
+            'zongmoney'        => $zongmongey,
+            'tixian'           => $tixian,
         ]);
 
         return $this->view->fetch();

+ 76 - 0
application/admin/controller/Edition.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\common\controller\Backend;
+
+/**
+ * 
+ *
+ * @icon fa fa-circle-o
+ */
+class Edition extends Backend
+{
+    
+    /**
+     * Edition模型对象
+     * @var \app\admin\model\Edition
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\Edition;
+
+    }
+    
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+    
+
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        //当前是否为关联查询
+        $this->relationSearch = false;
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax())
+        {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField'))
+            {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+            $total = $this->model
+                    
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->count();
+
+            $list = $this->model
+                    
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->limit($offset, $limit)
+                    ->select();
+
+            foreach ($list as $row) {
+                $row->visible(['e_id','edition','url','erweima_image']);
+                
+            }
+            $list = collection($list)->toArray();
+            $result = array("total" => $total, "rows" => $list);
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+}

+ 3 - 3
application/admin/controller/Index.php

@@ -33,10 +33,10 @@ class Index extends Backend
     {
         //左侧菜单
         list($menulist, $navlist, $fixedmenu, $referermenu) = $this->auth->getSidebar([
-            'dashboard' => 'hot',
-            'addon'     => ['new', 'red', 'badge'],
+            'dashboard' => '',//'hot',
+            'addon'     => '',//['new', 'red', 'badge'],
             'auth/rule' => __('Menu'),
-            'general'   => ['new', 'purple'],
+            'general'   => '',//['new', 'purple'],
         ], $this->view->site['fixedpage']);
         $action = $this->request->request('action');
         if ($this->request->isPost()) {

+ 76 - 0
application/admin/controller/agreemen/Setbean.php

@@ -0,0 +1,76 @@
+<?php
+
+namespace app\admin\controller\agreemen;
+
+use app\common\controller\Backend;
+
+/**
+ * 白豆递减设置管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Setbean extends Backend
+{
+    
+    /**
+     * Setbean模型对象
+     * @var \app\admin\model\agreemen\Setbean
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\agreemen\Setbean;
+
+    }
+    
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+    
+
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        //当前是否为关联查询
+        $this->relationSearch = false;
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax())
+        {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField'))
+            {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+            $total = $this->model
+                    
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->count();
+
+            $list = $this->model
+                    
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->limit($offset, $limit)
+                    ->select();
+
+            foreach ($list as $row) {
+                $row->visible(['b_id','num']);
+                
+            }
+            $list = collection($list)->toArray();
+            $result = array("total" => $total, "rows" => $list);
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+}

+ 77 - 0
application/admin/controller/cash/Cashlog.php

@@ -0,0 +1,77 @@
+<?php
+
+namespace app\admin\controller\cash;
+
+use app\common\controller\Backend;
+
+/**
+ * 提现记录管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Cashlog extends Backend
+{
+    
+    /**
+     * Cashlog模型对象
+     * @var \app\admin\model\cash\Cashlog
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\cash\Cashlog;
+
+    }
+    
+    /**
+     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
+     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
+     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     */
+    
+
+    /**
+     * 查看
+     */
+    public function index()
+    {
+        //当前是否为关联查询
+        $this->relationSearch = true;
+        //设置过滤方法
+        $this->request->filter(['strip_tags', 'trim']);
+        if ($this->request->isAjax())
+        {
+            //如果发送的来源是Selectpage,则转发到Selectpage
+            if ($this->request->request('keyField'))
+            {
+                return $this->selectpage();
+            }
+            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+            $total = $this->model
+                    ->with(['users'])
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->count();
+
+            $list = $this->model
+                    ->with(['users'])
+                    ->where($where)
+                    ->order($sort, $order)
+                    ->limit($offset, $limit)
+                    ->select();
+
+            foreach ($list as $row) {
+                $row->visible(['t_id','user_id','money','state','create_time','number','reason','admin_look']);
+                $row->visible(['users']);
+				$row->getRelation('users')->visible(['user_nickname','user_tel','user_avatar']);
+            }
+            $list = collection($list)->toArray();
+            $result = array("total" => $total, "rows" => $list);
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+}

+ 9 - 5
application/admin/controller/order/Torder.php

@@ -68,7 +68,6 @@ class Torder extends Backend
                     ->order($sort, $order)
                     ->limit($offset, $limit)
                     ->select();
-
             foreach ($list as $row) {
                 $row->visible(['o_id','money','freight','number','create_time','pay_time','f_time','whitebeon','state','type','tuikuan_state']);
                 $row->visible(['orderaddress']);
@@ -104,18 +103,23 @@ class Torder extends Backend
                 $params = $this->preExcludeFields($params);
                 if ($params['tuikuan_state'] == 1) {
                     $order = Db::name('order')->where('o_id',$ids)->find();
+                    $t_order = Db::name('t_order')->where('o_id',$ids)->find();
                     if ($order['type'] == 1) {
                         // 申请微信退款
                         $out_trade_no = $order['number'];
                         $out_refund_no = $order['number'];
-                        $total_fee = $order['money'];
-                        $refund_fee = $order['money'];
+                        //$total_fee = $t_order['money'];
+                        $total_fee = 1;
+                        $refund_fee = 1;
+                        //$refund_fee = $t_order['money'];
                         $notify_url = config('site.httpurl')."/api/order/notify_refund";
                         $wxpay = new WxPay();
                         $res = $wxpay->refund($out_trade_no,$out_refund_no,$total_fee,$refund_fee,$notify_url);
+                        //halt($res);
                         if ($res['return_code'] == "SUCCESS" ) {
-                            if ($res['result_code'] != 'SUCCESS')
-                            return json(['code' => 100, 'msg' => $res['err_code_des']]);
+                            if ($res['result_code'] != 'SUCCESS'){
+                                return json(['code' => 100, 'msg' => $res['err_code_des']]);
+                            }
                         } else {
                             return json(['code' => 100, 'msg' => '请求微信退失败']);
                         }

+ 8 - 0
application/admin/controller/users/Users.php

@@ -41,6 +41,8 @@ class Users extends Backend
      */
     public function index()
     {
+
+
         //当前是否为关联查询
         $this->relationSearch = false;
         //设置过滤方法
@@ -53,6 +55,12 @@ class Users extends Backend
                 return $this->selectpage();
             }
             list($where, $sort, $order, $offset, $limit) = $this->buildparams();
+            $user_level = input('user_level');
+            if (isset($user_level)) {
+                $where = [
+                    'user_level' => $user_level
+                ];
+            }
             $total = $this->model
                     
                     ->where($where)

+ 6 - 0
application/admin/lang/zh-cn/agreemen/setbean.php

@@ -0,0 +1,6 @@
+<?php
+
+return [
+    'B_id' => '白豆递减设置表',
+    'Num'  => '规则'
+];

+ 13 - 0
application/admin/lang/zh-cn/cash/cashlog.php

@@ -0,0 +1,13 @@
+<?php
+
+return [
+    'T_id'                => '提现id',
+    'State'               => '0提现失败1提现中2提现成功',
+    'Create_time'         => '提现时间',
+    'Number'              => '编号',
+    'Reason'              => '失败原因',
+    'Admin_look'          => '开发者看的失败原因',
+    'Users.user_nickname' => '姓名',
+    'Users.user_tel'      => '手机号',
+    'Users.user_avatar'   => '头像'
+];

+ 7 - 0
application/admin/lang/zh-cn/edition.php

@@ -0,0 +1,7 @@
+<?php
+
+return [
+    'Edition'       => '版本号',
+    'Url'           => '地址',
+    'Erweima_image' => '二维码'
+];

+ 56 - 0
application/admin/model/cash/Cashlog.php

@@ -0,0 +1,56 @@
+<?php
+
+namespace app\admin\model\cash;
+
+use think\Model;
+
+
+class Cashlog extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'cash_log';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'create_time_text'
+    ];
+    
+
+    
+
+
+
+    public function getCreateTimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+        public function getStateAttr($value)
+    {
+        $state = ['0' => '失败',1 => '提现中', '2' => '成功', ];
+        return  $state[$value];
+    }
+    protected function setCreateTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+
+    public function users()
+    {
+        return $this->belongsTo('app\admin\model\users\Users', 'user_id', 'user_id', [], 'LEFT')->setEagerlyType(0);
+    }
+}

+ 16 - 0
application/admin/view/agreemen/setbean/add.html

@@ -0,0 +1,16 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Num')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-num" data-rule="required" class="form-control" name="row[num]" type="text">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 16 - 0
application/admin/view/agreemen/setbean/edit.html

@@ -0,0 +1,16 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Num')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-num" data-rule="required" class="form-control" name="row[num]" type="text" value="{$row.num|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 35 - 0
application/admin/view/agreemen/setbean/index.html

@@ -0,0 +1,35 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+<!--                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('agreemen/setbean/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
+                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('agreemen/setbean/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('agreemen/setbean/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('agreemen/setbean/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
+
+                        <div class="dropdown btn-group {:$auth->check('agreemen/setbean/multi')?'':'hide'}">
+                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
+                            <ul class="dropdown-menu text-left" role="menu">
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
+                            </ul>
+                        </div>
+
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-edit="{:$auth->check('agreemen/setbean/edit')}" 
+                           data-operate-del="{:$auth->check('agreemen/setbean/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 52 - 0
application/admin/view/cash/cashlog/add.html

@@ -0,0 +1,52 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-money" data-rule="required" class="form-control" step="0.01" name="row[money]" type="number">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('State')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-state" data-rule="required" class="form-control" name="row[state]" type="number" value="1">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-create_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:date('Y-m-d H:i:s')}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Number')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-number" data-rule="required" class="form-control" name="row[number]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Reason')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-reason" class="form-control" name="row[reason]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Admin_look')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-admin_look" class="form-control" name="row[admin_look]" type="text">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 52 - 0
application/admin/view/cash/cashlog/edit.html

@@ -0,0 +1,52 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="{$row.user_id|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Money')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-money" data-rule="required" class="form-control" step="0.01" name="row[money]" type="number" value="{$row.money|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('State')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-state" data-rule="required" class="form-control" name="row[state]" type="number" value="{$row.state|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-create_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:$row.create_time?datetime($row.create_time):''}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Number')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-number" data-rule="required" class="form-control" name="row[number]" type="text" value="{$row.number|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Reason')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-reason" class="form-control" name="row[reason]" type="text" value="{$row.reason|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Admin_look')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-admin_look" class="form-control" name="row[admin_look]" type="text" value="{$row.admin_look|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 35 - 0
application/admin/view/cash/cashlog/index.html

@@ -0,0 +1,35 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+<!--                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('cash/cashlog/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>-->
+<!--                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('cash/cashlog/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>-->
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('cash/cashlog/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+<!--                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('cash/cashlog/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>-->
+
+                        <div class="dropdown btn-group {:$auth->check('cash/cashlog/multi')?'':'hide'}">
+                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
+                            <ul class="dropdown-menu text-left" role="menu">
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
+                            </ul>
+                        </div>
+
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-edit="{:$auth->check('cash/cashlog/edit')}" 
+                           data-operate-del="{:$auth->check('cash/cashlog/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 110 - 259
application/admin/view/dashboard/index.html

@@ -97,6 +97,15 @@
         background-color: #23b7e5;
     }
 
+    .st-yellow {
+        background-color: #B2F707;
+    }
+    .st-pink {
+        background-color: #FFC0CB;
+    }
+     .st-zise {
+         background-color: #a000ff;
+     }
     .stats .stat-icon {
         color: #28bb9c;
         display: inline-block;
@@ -166,323 +175,165 @@
     <div class="panel-body">
         <div id="myTabContent" class="tab-content">
             <div class="tab-pane fade active in" id="one">
-
                 <div class="row">
                     <div class="col-sm-3 col-xs-6">
                         <div class="sm-st clearfix">
                             <span class="sm-st-icon st-red"><i class="fa fa-users"></i></span>
                             <div class="sm-st-info">
                                 <span>{$totaluser}</span>
-                                {:__('Total user')}
+                                会员总数
                             </div>
                         </div>
                     </div>
+
                     <div class="col-sm-3 col-xs-6">
                         <div class="sm-st clearfix">
-                            <span class="sm-st-icon st-violet"><i class="fa fa-book"></i></span>
+                            <a href="{:url('users/users/index')}?user_level=1"><span class="sm-st-icon st-violet"><i class="fa fa-users"></i></span></a>
                             <div class="sm-st-info">
                                 <span>{$totalviews}</span>
-                                {:__('Total view')}
+                                普通会员总数
+                            </div>
+                        </div>
+                    </div>
+                    <div class="col-sm-3 col-xs-6">
+                        <div class="sm-st clearfix">
+                            <a href="{:url('users/users/index')}?user_level=6"><span class="sm-st-icon st-violet"><i class="fa fa-users"></i></span></a>
+                            <div class="sm-st-info">
+                                <span>{$vip}</span>
+                                vip会员总数
                             </div>
                         </div>
                     </div>
                     <div class="col-sm-3 col-xs-6">
                         <div class="sm-st clearfix">
-                            <span class="sm-st-icon st-blue"><i class="fa fa-shopping-bag"></i></span>
+                            <a href="{:url('users/users/index')}?user_level=2"><span class="sm-st-icon st-blue"><i class="fa fa-users"></i></span></a>
                             <div class="sm-st-info">
                                 <span>{$totalorder}</span>
-                                {:__('Total order')}
+                                店长总数
                             </div>
                         </div>
                     </div>
                     <div class="col-sm-3 col-xs-6">
                         <div class="sm-st clearfix">
-                            <span class="sm-st-icon st-green"><i class="fa fa-cny"></i></span>
+                            <a href="{:url('users/users/index')}?user_level=3"><span class="sm-st-icon st-green"><i class="fa fa-users"></i></span></a>
                             <div class="sm-st-info">
                                 <span>{$totalorderamount}</span>
-                                {:__('Total order amount')}
+                                经理总数
                             </div>
                         </div>
                     </div>
-                </div>
-
-                <div class="row">
-                    <div class="col-lg-8">
-                        <div id="echart" style="height:200px;width:100%;"></div>
+                    <div class="col-sm-3 col-xs-6">
+                        <div class="sm-st clearfix">
+                            <a href="{:url('users/users/index')}?user_level=4"><span class="sm-st-icon st-zise"><i class="fa fa-users"></i></span></a>
+                            <div class="sm-st-info">
+                                <span>{$todayuserlogin}</span>
+                                总监总数
+                            </div>
+                        </div>
                     </div>
-                    <div class="col-lg-4">
-                        <div class="card sameheight-item stats">
-                            <div class="card-block">
-                                <div class="row row-sm stats-container">
-                                    <div class="col-xs-6 stat-col">
-                                        <div class="stat-icon"><i class="fa fa-rocket"></i></div>
-                                        <div class="stat">
-                                            <div class="value"> {$todayusersignup}</div>
-                                            <div class="name"> {:__('Today user signup')}</div>
-                                        </div>
-                                        <div class="progress">
-                                            <div class="progress-bar progress-bar-success" style="width: 30%"></div>
-                                        </div>
-                                    </div>
-                                    <div class="col-xs-6 stat-col">
-                                        <div class="stat-icon"><i class="fa fa-shopping-cart"></i></div>
-                                        <div class="stat">
-                                            <div class="value"> {$todayuserlogin}</div>
-                                            <div class="name"> {:__('Today user login')}</div>
-                                        </div>
-                                        <div class="progress">
-                                            <div class="progress-bar progress-bar-success" style="width: 25%"></div>
-                                        </div>
-                                    </div>
-                                    <div class="col-xs-6  stat-col">
-                                        <div class="stat-icon"><i class="fa fa-line-chart"></i></div>
-                                        <div class="stat">
-                                            <div class="value"> {$todayorder}</div>
-                                            <div class="name"> {:__('Today order')}</div>
-                                        </div>
-                                        <div class="progress">
-                                            <div class="progress-bar progress-bar-success" style="width: 25%"></div>
-                                        </div>
-                                    </div>
-                                    <div class="col-xs-6  stat-col">
-                                        <div class="stat-icon"><i class="fa fa-users"></i></div>
-                                        <div class="stat">
-                                            <div class="value"> {$unsettleorder}</div>
-                                            <div class="name"> {:__('Unsettle order')}</div>
-                                        </div>
-                                        <div class="progress">
-                                            <div class="progress-bar progress-bar-success" style="width: 25%"></div>
-                                        </div>
-                                    </div>
-                                    <div class="col-xs-6  stat-col">
-                                        <div class="stat-icon"><i class="fa fa-list-alt"></i></div>
-                                        <div class="stat">
-                                            <div class="value"> {$sevendnu}</div>
-                                            <div class="name"> {:__('Seven dnu')}</div>
-                                        </div>
-                                        <div class="progress">
-                                            <div class="progress-bar progress-bar-success" style="width: 25%"></div>
-                                        </div>
-                                    </div>
-                                    <div class="col-xs-6 stat-col">
-                                        <div class="stat-icon"><i class="fa fa-dollar"></i></div>
-                                        <div class="stat">
-                                            <div class="value"> {$sevendau}</div>
-                                            <div class="name"> {:__('Seven dau')}</div>
-                                        </div>
-                                        <div class="progress">
-                                            <div class="progress-bar progress-bar-success" style="width: 25%"></div>
-                                        </div>
-                                    </div>
-                                </div>
+                    <div class="col-sm-3 col-xs-6">
+                        <div class="sm-st clearfix">
+                            <a href="{:url('users/users/index')}?user_level=5"> <span class="sm-st-icon st-pink"><i class="fa fa-users"></i></span></a>
+                            <div class="sm-st-info">
+                                <span>{$todayusersignup}</span>
+                                董事总数
                             </div>
                         </div>
                     </div>
-                </div>
 
-                <div class="row" style="margin-top:15px;">
-
-                    <div class="col-lg-12">
-                    </div>
-                    <div class="col-xs-6 col-md-3">
-                        <div class="panel bg-blue">
-                            <div class="panel-body">
-                                <div class="panel-title">
-                                    <span class="label label-success pull-right">{:__('Real time')}</span>
-                                    <h5>{:__('Category count')}</h5>
-                                </div>
-                                <div class="panel-content">
-                                    <h1 class="no-margins">1234</h1>
-                                    <div class="stat-percent font-bold text-gray"><i class="fa fa-commenting"></i> 1234</div>
-                                    <small>{:__('Category count tips')}</small>
-                                </div>
+                    <div class="col-sm-3 col-xs-6">
+                        <div class="sm-st clearfix">
+                            <span class="sm-st-icon st-blue"><i class="fa fa-star"></i></span>
+                            <div class="sm-st-info">
+                                <span>{$vipBuyNum}</span>
+                                {:__('VIP开通次数')}
                             </div>
                         </div>
                     </div>
-                    <div class="col-xs-6 col-md-3">
-                        <div class="panel bg-aqua-gradient">
-                            <div class="panel-body">
-                                <div class="ibox-title">
-                                    <span class="label label-info pull-right">{:__('Real time')}</span>
-                                    <h5>{:__('Attachment count')}</h5>
-                                </div>
-                                <div class="ibox-content">
-                                    <h1 class="no-margins">1043</h1>
-                                    <div class="stat-percent font-bold text-gray"><i class="fa fa-modx"></i> 2592</div>
-                                    <small>{:__('Attachment count tips')}</small>
-                                </div>
+
+                    <div class="col-sm-3 col-xs-6">
+                        <div class="sm-st clearfix">
+                            <span class="sm-st-icon st-green"><i class="fa fa-plus-circle"></i></span>
+                            <div class="sm-st-info">
+                                <span>{$queueIncome}</span>
+                                {:__('排队总收入')}
                             </div>
                         </div>
                     </div>
 
-                    <div class="col-xs-6 col-md-3">
-                        <div class="panel bg-purple-gradient">
-                            <div class="panel-body">
-                                <div class="ibox-title">
-                                    <span class="label label-primary pull-right">{:__('Real time')}</span>
-                                    <h5>{:__('Article count')}</h5>
-                                </div>
-                                <div class="ibox-content">
-
-                                    <div class="row">
-                                        <div class="col-md-6">
-                                            <h1 class="no-margins">1234</h1>
-                                            <div class="font-bold"><i class="fa fa-commenting"></i>
-                                                <small>{:__('Comment count')}</small>
-                                            </div>
-                                        </div>
-                                        <div class="col-md-6">
-                                            <h1 class="no-margins">6754</h1>
-                                            <div class="font-bold"><i class="fa fa-heart"></i>
-                                                <small>{:__('Like count')}</small>
-                                            </div>
-                                        </div>
-                                    </div>
-                                </div>
+                    <div class="col-sm-3 col-xs-6">
+                        <div class="sm-st clearfix">
+                            <span class="sm-st-icon st-red"><i class="fa fa-minus-circle"></i></span>
+                            <div class="sm-st-info">
+                                <span>{$queueOut}</span>
+                                {:__('排队总支出')}
                             </div>
                         </div>
                     </div>
-                    <div class="col-xs-6 col-md-3">
-                        <div class="panel bg-green-gradient">
-                            <div class="panel-body">
-                                <div class="ibox-title">
-                                    <span class="label label-primary pull-right">{:__('Real time')}</span>
-                                    <h5>{:__('News count')}</h5>
-                                </div>
-                                <div class="ibox-content">
-
-                                    <div class="row">
-                                        <div class="col-md-6">
-                                            <h1 class="no-margins">5302</h1>
-                                            <div class="font-bold"><i class="fa fa-commenting"></i>
-                                                <small>{:__('Comment count')}</small>
-                                            </div>
-                                        </div>
-                                        <div class="col-md-6">
-                                            <h1 class="no-margins">8205</h1>
-                                            <div class="font-bold"><i class="fa fa-user"></i>
-                                                <small>{:__('Like count')}</small>
-                                            </div>
-                                        </div>
-                                    </div>
-                                </div>
+
+                    <div class="col-sm-3 col-xs-6">
+                        <div class="sm-st clearfix">
+                            <span class="sm-st-icon st-blue"><i class="fa fa-star"></i></span>
+                            <div class="sm-st-info">
+                                <span>{$rechargeNum}</span>
+                                {:__('话费充值次数')}
                             </div>
                         </div>
                     </div>
-                </div>
 
-                <div class="row">
-                    <div class="col-lg-4">
-                        <div class="box box-danger">
-                            <div class="box-header with-border">
-                                <h3 class="box-title">{:__('Recent news')}</h3>
-
-                                <div class="box-tools pull-right">
-                                </div>
+                    <div class="col-sm-3 col-xs-6">
+                        <div class="sm-st clearfix">
+                            <span class="sm-st-icon st-green"><i class="fa fa-plus-circle"></i></span>
+                            <div class="sm-st-info">
+                                <span>{$rechargeIncome}</span>
+                                {:__('话费充值收入')}
                             </div>
-                            <div class="box-body">
-                                <ul class="products-list product-list-in-box">
-                                    {for start="1" end="8"}
-                                    <li class="item">
-                                        <div class="product-img">
-                                            <img src="__CDN__/assets/img/avatar.png" style="height:40px;width:40px;">
-                                        </div>
-                                        <div class="product-info">
-                                            <a href="https://www.fastadmin.net" target="_blank" class="product-title">
-                                                FastAdmin
-                                                <span class="label label-{:$i%3===0?'warning':($i%2===0?'success':'info')} pull-right">开源免费</span>
-                                            </a>
-                                            <span class="product-description">
-                                              一款基于ThinkPHP5+Bootstrap的极速后台开发框架
-                                            </span>
-                                        </div>
-                                    </li>
-                                    {/for}
-                                </ul>
+                        </div>
+                    </div>
+
+                    <div class="col-sm-3 col-xs-6">
+                        <div class="sm-st clearfix">
+                            <span class="sm-st-icon st-red"><i class="fa fa-minus-circle"></i></span>
+                            <div class="sm-st-info">
+                                <span>{$rechargeOut}</span>
+                                {:__('话费充值支出')}
                             </div>
                         </div>
                     </div>
-                    <div class="col-lg-4">
-                        <div class="box box-success">
-                            <div class="box-header with-border">
-                                <h3 class="box-title">{:__('Recent discussion')}</h3>
 
-                                <div class="box-tools pull-right">
-                                </div>
+                    <div class="col-sm-3 col-xs-6">
+                        <div class="sm-st clearfix">
+                            <span class="sm-st-icon st-blue"><i class="fa fa-calendar"></i></span>
+                            <div class="sm-st-info">
+                                <span>{$daifahuo}</span>
+                                {:__('待发货订单')}
                             </div>
-                            <div class="box-body">
-                                <ul class="nav nav-pills nav-stacked">
-                                    <li><a href="https://www.fastadmin.net" target="_blank">一款基于ThinkPHP5+Bootstrap的极速后台开发框架<span class="pull-right text-red"><i class="fa fa-angle-down"></i> 12%</span></a></li>
-                                    <li><a href="https://www.fastadmin.net" target="_blank">一键生成CRUD控制器模型和视图 <span class="pull-right text-green"><i class="fa fa-angle-up"></i> 4%</span></a></li>
-                                    <li><a href="https://www.fastadmin.net" target="_blank">一键压缩打包JS和CSS文件 <span class="pull-right text-red"><i class="fa fa-angle-down"></i> 3%</span></a></li>
-                                    <li><a href="https://www.fastadmin.net" target="_blank">一键生成控制器菜单和规则 <span class="pull-right text-green"><i class="fa fa-angle-up"></i> 8%</span></a></li>
-                                    <li><a href="https://www.fastadmin.net" target="_blank">一键生成API接口文档 <span class="pull-right text-yellow"><i class="fa fa-angle-left"></i> 0%</span></a></li>
-                                    <li><a href="https://www.fastadmin.net" target="_blank">强大的插件扩展功能,在线安装卸载升级插件 <span class="pull-right text-red"><i class="fa fa-angle-down"></i> 10%</span></a></li>
-                                    <li><a href="https://www.fastadmin.net" target="_blank">通用的会员模块和API模块 <span class="pull-right text-green"><i class="fa fa-angle-up"></i> 2%</span></a></li>
-                                    <li><a href="https://www.fastadmin.net" target="_blank">共用同一账号体系的Web端会员中心权限验证和API接口会员权限验证 <span class="pull-right text-red"><i class="fa fa-angle-down"></i> 6%</span></a></li>
-                                    <li><a href="https://www.fastadmin.net" target="_blank">二级域名部署支持,同时域名支持绑定到插件 <span class="pull-right text-yellow"><i class="fa fa-angle-left"></i> 0%</span></a></li>
-                                    <li><a href="https://www.fastadmin.net" target="_blank">多语言支持,服务端及客户端支持 <span class="pull-right text-yellow"><i class="fa fa-angle-left"></i> 0%</span></a></li>
-                                    <li><a href="https://www.fastadmin.net" target="_blank">基于Bootstrap开发,自适应手机、平板、PC <span class="pull-right text-green"><i class="fa fa-angle-up"></i> 4%</span></a></li>
-                                </ul>
+                        </div>
+                    </div>
+                    <div class="col-sm-3 col-xs-6">
+                        <div class="sm-st clearfix">
+                            <a href="{:url('order/torder/index')}"><span class="sm-st-icon st-yellow"><i class="fa fa-reply-all"></i></span></a>
+                            <div class="sm-st-info">
+                                <span>{$tuikuan}</span>
+                                {:__('退款订单')}
                             </div>
                         </div>
                     </div>
-                    <div class="col-lg-4">
-                        <div class="box box-info">
-                            <div class="box-header"><h3 class="box-title">{:__('Server info')}</h3></div>
-                            <div class="box-body" style="padding-top:0;">
-                                <table class="table table-striped">
-                                    <tbody>
-                                    <tr>
-                                        <td width="140">{:__('FastAdmin version')}</td>
-                                        <td>{$Think.config.fastadmin.version} <a href="javascript:;" class="btn btn-xs btn-checkversion">检查最新版</a></td>
-                                    </tr>
-                                    <tr>
-                                        <td>{:__('FastAdmin addon version')}</td>
-                                        <td>{$addonversion}</td>
-                                    </tr>
-                                    <tr>
-                                        <td>{:__('Thinkphp version')}</td>
-                                        <td>{:THINK_VERSION}</td>
-                                    </tr>
-                                    <tr>
-                                        <td>{:__('Sapi name')}</td>
-                                        <td>{:php_sapi_name()}</td>
-                                    </tr>
-                                    <tr>
-                                        <td>{:__('Debug mode')}</td>
-                                        <td>{$Think.config.app_debug?__('Yes'):__('No')}</td>
-                                    </tr>
-                                    <tr>
-                                        <td>{:__('Software')}</td>
-                                        <td>{$Think.server.SERVER_SOFTWARE}</td>
-                                    </tr>
-                                    <tr>
-                                        <td>{:__('Upload mode')}</td>
-                                        <td>{$uploadmode}</td>
-                                    </tr>
-                                    <tr>
-                                        <td>{:__('Upload url')}</td>
-                                        <td>{$config.upload.uploadurl}</td>
-                                    </tr>
-                                    <tr>
-                                        <td>{:__('Upload Cdn url')}</td>
-                                        <td>{$config.upload.cdnurl}</td>
-                                    </tr>
-                                    <tr>
-                                        <td>{:__('Timezone')}</td>
-                                        <td>{:date_default_timezone_get()}</td>
-                                    </tr>
-                                    <tr>
-                                        <td>{:__('Cdn url')}</td>
-                                        <td>__CDN__</td>
-                                    </tr>
-                                    <tr>
-                                        <td>{:__('Language')}</td>
-                                        <td>{$config.language}</td>
-                                    </tr>
-                                    </tbody>
-                                </table>
+                    <div class="col-sm-3 col-xs-6">
+                        <div class="sm-st clearfix">
+                            <span class="sm-st-icon st-green"><i class="fa fa-cny"></i></span>
+                            <div class="sm-st-info">
+                                <span>{$tuikuan}</span>
+                                {:__('商城总收入')}(已完成订单)
+                            </div>
+                        </div>
+                    </div>
+                    <div class="col-sm-3 col-xs-6">
+                        <div class="sm-st clearfix">
+                            <span class="sm-st-icon st-red"><i class="fa fa-minus-square"></i></span>
+                            <div class="sm-st-info">
+                                <span>{$tixian}</span>
+                                {:__('提现总支出')}
                             </div>
                         </div>
                     </div>

+ 36 - 0
application/admin/view/edition/add.html

@@ -0,0 +1,36 @@
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Edition')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-edition" data-rule="required" class="form-control" name="row[edition]" type="text" value="1">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Url')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-url" data-rule="required" class="form-control" name="row[url]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Erweima_image')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class="input-group">
+                <input id="c-erweima_image" data-rule="required" class="form-control" size="50" name="row[erweima_image]" type="text">
+                <div class="input-group-addon no-border no-padding">
+                    <span><button type="button" id="plupload-erweima_image" class="btn btn-danger plupload" data-input-id="c-erweima_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-erweima_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
+                    <span><button type="button" id="fachoose-erweima_image" class="btn btn-primary fachoose" data-input-id="c-erweima_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
+                </div>
+                <span class="msg-box n-right" for="c-erweima_image"></span>
+            </div>
+            <ul class="row list-inline plupload-preview" id="p-erweima_image"></ul>
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 36 - 0
application/admin/view/edition/edit.html

@@ -0,0 +1,36 @@
+<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Edition')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-edition" data-rule="required" class="form-control" name="row[edition]" type="text" value="{$row.edition|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Url')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-url" data-rule="required" class="form-control" name="row[url]" type="text" value="{$row.url|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Erweima_image')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <div class="input-group">
+                <input id="c-erweima_image" data-rule="required" class="form-control" size="50" name="row[erweima_image]" type="text" value="{$row.erweima_image|htmlentities}">
+                <div class="input-group-addon no-border no-padding">
+                    <span><button type="button" id="plupload-erweima_image" class="btn btn-danger plupload" data-input-id="c-erweima_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-erweima_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
+                    <span><button type="button" id="fachoose-erweima_image" class="btn btn-primary fachoose" data-input-id="c-erweima_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
+                </div>
+                <span class="msg-box n-right" for="c-erweima_image"></span>
+            </div>
+            <ul class="row list-inline plupload-preview" id="p-erweima_image"></ul>
+        </div>
+    </div>
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>

+ 35 - 0
application/admin/view/edition/index.html

@@ -0,0 +1,35 @@
+<div class="panel panel-default panel-intro">
+    {:build_heading()}
+
+    <div class="panel-body">
+        <div id="myTabContent" class="tab-content">
+            <div class="tab-pane fade active in" id="one">
+                <div class="widget-body no-padding">
+                    <div id="toolbar" class="toolbar">
+                        <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
+                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('edition/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('edition/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('edition/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('edition/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a>
+
+                        <div class="dropdown btn-group {:$auth->check('edition/multi')?'':'hide'}">
+                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
+                            <ul class="dropdown-menu text-left" role="menu">
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
+                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
+                            </ul>
+                        </div>
+
+                        
+                    </div>
+                    <table id="table" class="table table-striped table-bordered table-hover table-nowrap"
+                           data-operate-edit="{:$auth->check('edition/edit')}" 
+                           data-operate-del="{:$auth->check('edition/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 108 - 66
application/api/controller/Login.php

@@ -46,28 +46,29 @@ class Login extends Controller
         if (isset($data['user_tel']) && isset($data['user_pwd'])) {
             $validata = $this->validate($data, $rules, $msg); //验证数据规则
             if (is_string($validata)) {
-                return json(['code' => 100, 'msg' => '','data' => $validata]);
+                return json(['code' => 100, 'msg' => '', 'data' => $validata]);
             }
             $valdatatel = UsersModel::where('user_tel', $data['user_tel'])->find();  //判断手机号是否存在
             if ($valdatatel) {
                 $data['user_pwd'] = sha1(md5($data['user_pwd']));                                                                                //加密验证密码
                 $where = array(
-                  'user_tel' => $data['user_tel'],
-                  'user_pwd' => $data['user_pwd'],
+                    'user_tel' => $data['user_tel'],
+                    'user_pwd' => $data['user_pwd'],
                 );
                 $validatapwd = Db::name('users')->where($data)->field('user_id')->find(); //判断密码是否正确
+                if ($valdatatel['status_switch'] == 0) {
+                    return json(['code' => 100, 'msg' => '此账号已被禁用', 'data' => []]);
+                }
                 if ($validatapwd) {
                     $validatapwd['token'] = self::settoken($validatapwd['user_id']);
-                    return json(['code' => 200, 'msg' => '登陆成功,欢迎回来哦','data' => $validatapwd]);
+                    return json(['code' => 200, 'msg' => '登陆成功,欢迎回来哦', 'data' => $validatapwd]);
                 } else {
-                    return json(['code' => 100, 'msg' => '密码错误','data' => []]);
+                    return json(['code' => 100, 'msg' => '密码错误', 'data' => []]);
                 }
             } else {
-                return json(['code' => 100, 'msg' => '手机号不存在','data' => []]);
+                return json(['code' => 100, 'msg' => '手机号不存在', 'data' => []]);
             }
         }
-
-
     }
 
     /**
@@ -92,28 +93,33 @@ class Login extends Controller
         ];
         $validata = $this->validate($params, $rules, $msg);
         if (is_string($validata)) {
-            return json(['code' => 100, 'msg' => '','data' => $validata]);
+            return json(['code' => 100, 'msg' => '', 'data' => $validata]);
         }
-        $validataopenid = UsersModel::where('user_unionid', $params['user_unionid'])->field('user_id')->find();  //判断QQ或者微信登录的openid是否正确
+        $validataopenid = UsersModel::where('user_unionid', $params['user_unionid'])->field('user_id,user_tel')->find();  //判断QQ或者微信登录的openid是否正确
         if ($validataopenid) {
+            if ($validataopenid['user_tel'] == "") {
+                return json(['code' => 10, 'msg' => '请先绑定手机号', 'data' => $validataopenid]);
+            }
             $validataopenid['token'] = self::settoken($validataopenid['user_id']);
-            return json(['code' => 200, 'msg' => '登陆成功,欢迎回来哦','data' => $validataopenid]);
+            return json(['code' => 200, 'msg' => '登陆成功,欢迎回来哦', 'data' => $validataopenid]);
         } else {
-            $data = array(
-                'user_nickname' => $params['user_nickname'],
-                'user_avatar'   => $params['user_avatar'],
-                'create_time'   => date('Y-m-d H:i:s', time()),
-                'user_unionid'  => $params['user_unionid'],
-                'type'          => 1,
-            );
-            $userId['user_id'] = Db::name('users')->insertGetId($data);
-            if ($userId) {
-                return json(['code' => 100, 'msg' => '请先绑定手机号','data' => []]);
-            } else {
-                return json(['code' => 100, 'msg' => '登录失败','data' => []]);
-            }
+            return json(['code' => 10, 'msg' => '请先绑定手机号', 'data' => $params]);
+//            $data = array(
+//                'user_nickname' => $params['user_nickname'],
+//                'user_avatar'   => $params['user_avatar'],
+//                'create_time'   => date('Y-m-d H:i:s', time()),
+//                'user_unionid'  => $params['user_unionid'],
+//                'type'          => 1,
+//            );
+//            $userId['user_id'] = Db::name('users')->insertGetId($data);
+//            if ($userId) {
+//                return json(['code' => 10, 'msg' => '请去绑定手机号', 'data' => []]);
+//            } else {
+//                return json(['code' => 100, 'msg' => '登录失败', 'data' => []]);
+//            }
         }
     }
+
     /**
      * QQ登录
      * @ApiMethod   (POST)
@@ -136,92 +142,128 @@ class Login extends Controller
         ];
         $validata = $this->validate($params, $rules, $msg);
         if (is_string($validata)) {
-            return json(['code' => 100, 'msg' => '','data' => $validata]);
+            return json(['code' => 100, 'msg' => '', 'data' => $validata]);
         }
-        $validataopenid = UsersModel::where('user_unionid', $params['user_unionid'])->field('user_id')->find();  //判断QQ或者微信登录的openid是否正确
+        $validataopenid = UsersModel::where('user_unionid', $params['user_unionid'])->field('user_id,user_tel')->find();  //判断QQ或者微信登录的openid是否正确
         $validataopenid['token'] = self::settoken($validataopenid['user_id']);
         if ($validataopenid) {
-            return json(['code' => 200, 'msg' => '登陆成功,欢迎回来哦','data' => $validataopenid]);
-        } else {
-            $data = array(
-                'user_nickname' => $params['user_nickname'],
-                'user_avatar'   => $params['user_avatar'],
-                'create_time'   => $params('Y-m-d H:i:s', time()),
-                'user_tjtel'    => $params['user_tjtel'],
-                'user_unionid'  => $params['user_openid'],
-                'type'          => $params['type'],
-            );
-            $userId['user_id'] = Db::name('users')->insertGetId($params);
-            if ($userId) {
-                return json(['code' => 100, 'msg' => '请先绑定手机号','data' => []]);
-            } else {
-                return json(['code' => 100, 'msg' => '登录失败','data' => []]);
+            if ($validataopenid['user_tel'] == "") {
+                return json(['code' => 10, 'msg' => '请先绑定手机号', 'data' => $validataopenid]);
             }
+            return json(['code' => 200, 'msg' => '登陆成功,欢迎回来哦', 'data' => $validataopenid]);
+        } else {
+            return json(['code' => 10, 'msg' => '请先绑定手机号', 'data' => $params]);
+//            $data = array(
+//                'user_nickname' => $params['user_nickname'],
+//                'user_avatar'   => $params['user_avatar'],
+//                'create_time'   => $params('Y-m-d H:i:s', time()),
+//                'user_tjtel'    => $params['user_tjtel'],
+//                'user_unionid'  => $params['user_openid'],
+//                'type'          => 2,
+//            );
+//            $userId['user_id'] = Db::name('users')->insertGetId($params);
+//            if ($userId) {
+//
+//                return json(['code' => 10, 'msg' => '请先绑定手机号','data' => []]);
+//            } else {
+//                return json(['code' => 100, 'msg' => '登录失败','data' => []]);
+//            }
         }
     }
+
     /**
      * 添加登录手机号登录
      * @ApiMethod   (POST)
-     * @param string $user_id 用户ID
      * @param string $user_tel 用户手机号
      * @param string $code 验证码
      * @param string $user_tjtel 用户手机号
+     * @param string $user_nickname 昵称
+     * @param string $user_avatar 头像
+     * @param string $user_unionid unionID
+     * @param string $type 0手机号1微信2QQ
      */
     public function addUserTel()
     {
         $params = $this->request->post();
         $rules = [
-            'user_id'    => 'require|number',
+           // 'user_id'    => 'require|number',
             'code'       => 'require|number',
             'user_tel'   => 'require|number',
             'user_tjtel' => 'require|number',
-            'token'      => 'require',
+            //'token'      => 'require',
         ];
         $msg = [
-            'user_id.require'    => '网络错误1',
+            //'user_id.require'    => '网络错误1',
             'code .require'      => '网络错误2',
             'user_tel.require'   => '手机号不能为空',
             'user_tjtel.require' => '推荐人手机号不能为空',
-            'token.require'      => '网络错误3',
-            'user_id.number'     => '网络错误4',
+            //'token.require'      => '网络错误3',
+           // 'user_id.number'     => '网络错误4',
             'code.number'        => '网络错误5',
             'user_tel.number'    => '网络错误6',
             'user_tjtel.number'  => '网络错误7',
         ];
         $validate = $this->validate($params, $rules, $msg);
         if (is_string($validate)) {
-            return json(['code' => 100, 'msg' => $validate,'data' => []]);
+            return json(['code' => 100, 'msg' => $validate, 'data' => []]);
         }
         $check = '/^(1(([35789][0-9])|(47)))\d{8}$/';
         if (!preg_match($check, $params['user_tel'])) {
-            return json(['code' => 100, 'msg' => '手机号不合法','data' => []]);
+            return json(['code' => 100, 'msg' => '手机号不合法', 'data' => []]);
         }
         //检查数据库是否有此推荐人手机号
         $user_tjtel = UsersModel::where('user_tel', $params['user_tjtel'])->find();
         if (!$user_tjtel) {
-            return json(['code' => 100, 'msg' => '无此推荐人','data' => []]);
+            return json(['code' => 100, 'msg' => '无此推荐人', 'data' => []]);
         }
         //判断验证码是否正确
         if (!Cache::get($params['code'])) {
-            return json(['code' => 100, 'msg' => '验证码不正确','data' => []]);
+            return json(['code' => 100, 'msg' => '验证码不正确', 'data' => []]);
+        }
+        //Cache::rm($params['code']);
+        // 判断是否有此手机号
+        $user_tel = UsersModel::where('user_tel', $params['user_tel'])->find();
+        if ($user_tel) {
+            $upddata = array(
+                'user_tjtel'   => $params['user_tjtel'],
+                'type'         => $params['type'],
+                'create_time'  => date('Y-m-d H:i:s', time()),
+                'user_unionid' => $params['user_unionid'],
+                'user_nickname' => $params['user_nickname'],
+                'user_avatar'   => $params['user_avatar'],
+            );
+            $addUserMember = Db::name('Users')->where('user_tel', $params['user_tjtel'])->setInc('user_member_count', 1); // 给上机的下级成员总数加1
+            $updUsertelAndwechat = Db::name('users')->where('user_id', $user_tel['user_id'])->update($upddata);
+            if ($updUsertelAndwechat) {
+                $token = self::settoken($user_tel['user_id']);
+                $res = array(
+                    "user_id" => $user_tel['user_id'],
+                    "token"   => $token,
+                );
+                return json(['code' => 200, 'msg' => '绑定成功', 'data' => $res]);
+            } else {
+                return json(['code' => 100, 'msg' => '绑定失败', 'data' => []]);
+            }
         }
-        Cache::rm($params['code']);
-        $upddata = array(
-            'user_tel'   => $params['user_tel'],
-            'user_tjtel' => $params['user_tjtel'],
-            'type'       => 1,
+        $data = array(
+            'user_tel'     => $params['user_tel'],
+            'user_tjtel'   => $params['user_tjtel'],
+            'type'         => $params['type'],
+            'create_time'  => date('Y-m-d H:i:s', time()),
+            'user_unionid' => $params['user_unionid'],
+            'user_nickname' => $params['user_nickname'],
+            'user_avatar'   => $params['user_avatar'],
         );
-        $updUser_tel = Db::name('users')->where('user_id', $params['user_id'])->update($upddata);
-        if ($updUser_tel) {
-            $token = self::settoken($params['user_id']);
+        $adduser = Db::name('users')->insertGetId($data);
+        if ($adduser) {
+            $token = self::settoken($adduser);
             $res = array(
-                "user_id" => $params['user_id'],
+                "user_id" => $adduser,
                 "token"   => $token,
             );
-            return json(['code' => 200, 'msg' => '绑定成功','data' => []]);
+            return json(['code' => 200, 'msg' => '绑定成功', 'data' => $res]);
         } else {
-            Db::name('users')->where('user_id',$params['user_id'])->delete(); // 绑定失败删除此用户
-            return json(['code' => 100, 'msg' => '绑定失败','data' => []]);
+            return json(['code' => 100, 'msg' => '绑定失败', 'data' => []]);
         }
     }
 
@@ -236,7 +278,7 @@ class Login extends Controller
         $tel = UsersModel::where('user_tel', $tel)->find();
         $num = count($tel);
         if ($num > 0) {
-            return json(['code' => 100, 'msg' => '手机号已存在','data' => []]);
+            return json(['code' => 100, 'msg' => '手机号已存在', 'data' => []]);
         }
     }
 
@@ -248,9 +290,9 @@ class Login extends Controller
     {
         $data = Db::name('agreement')->where('type', 0)->find();
         if ($data) {
-            return json(['code' => 200, 'msg' => '绑定成功','data' => $data]);
+            return json(['code' => 200, 'msg' => '绑定成功', 'data' => $data]);
         } else {
-            return json(['code' => 100, 'msg' => '网络错误','data' => []]);
+            return json(['code' => 100, 'msg' => '网络错误', 'data' => []]);
         }
     }
 

+ 6 - 5
application/api/controller/Member.php

@@ -82,7 +82,7 @@ class Member extends Api
         // 查询剩余开通次数
         $canUseOpenNum = UsersModel::where('user_id', $userId)->value('vip_use_num');
         if ($canUseOpenNum == 5) {
-            $this->result('您本月可开通VIP的次数已用完', [], 200);
+            $this->result('您本月可开通VIP的次数已用完', [], 100);
         }
 
         $out_trade_no = createOutTradeNo();
@@ -105,7 +105,7 @@ class Member extends Api
                 if ($getPrePayInfo) {
                     $payInfo = $payObj->getOrder($getPrePayInfo['prepay_id']);
                     if ($payInfo) {
-                        $this->result('支付订单发起成功', $payInfo, 200);
+                        $this->result('支付订单发起成功', ['payInfoArray' => $payInfo], 200);
                     } else {
                         $this->result('支付订单发起失败,请稍后再试', [], 100);
                     }
@@ -196,7 +196,7 @@ class Member extends Api
                                 ->setField('pay_status', 1);
                             // 修改会员等级
                             if ($user->user_level == 1) {
-                                $updateVipLevel = UsersModel::where('user_id', $order->uid)->update(['user_level' => 2]);
+                                $updateVipLevel = UsersModel::where('user_id', $order->uid)->update(['user_level' => 6]);
                                 $p = new Promote();
                                 $p->uid = $order->uid;
                                 $p->getMyBoss();
@@ -275,10 +275,11 @@ class Member extends Api
                     $user = UsersModel::get($order->uid);
                     if (!empty($order)) {
                         // 更新支付状态
-                        $updatePayStatus = BuyVipLogModel::where('out_trade_no', $params['out_trade_no'])->setField('pay_status', 1);
+                        $updatePayStatus = BuyVipLogModel::where('out_trade_no', $params['out_trade_no'])
+                            ->setField('pay_status', 1);
                         // 修改会员等级
                         if ($user->user_level == 1) {
-                            $updateVipLevel = UsersModel::where('user_id', $order->uid)->update(['user_level' => 2]);
+                            $updateVipLevel = UsersModel::where('user_id', $order->uid)->update(['user_level' => 6]);
                             $p = new Promote();
                             $p->uid = $order->uid;
                             $p->getMyBoss();

+ 178 - 42
application/api/controller/Order.php

@@ -2,7 +2,9 @@
 
 namespace app\api\controller;
 
+use app\api\model\Address;
 use app\api\model\Commoditycolor;
+use app\api\model\CommodityModel;
 use app\api\model\Logistics;
 use app\api\model\OrderModel;
 use app\api\model\Torder;
@@ -11,6 +13,7 @@ use app\common\controller\Api;
 use app\common\lib\WxPay;
 use think\Cache;
 use think\Db;
+use think\File;
 
 /**
  * 订单接口
@@ -107,7 +110,7 @@ class Order extends Api
     {
         $pre_id = $this->request->post('pre_id');
         if (!$pre_id) {
-            return $this->result('网络错误', [], 100);
+            return $this->result('网络错误1', [], 100);
         }
         $order_pre = Db::name('order_pre')->where('pre_id', $pre_id)->find(); //查出预存订单
         $order_pre['colorid'] = explode(',', $order_pre['colorid']);          // 批量拆分id
@@ -115,32 +118,86 @@ class Order extends Api
         $count = count($order_pre['buy_number']);
         $commoditycolor = new Commoditycolor();
         for ($i = 0; $i < $count; $i++) {
-            $data[] = $commoditycolor->alias('co')
+            $data1[] = $commoditycolor->alias('co')
                 ->join('parameter p', 'co.p_id = p.p_id', 'left')
                 ->join('commodity c', 'p.c_id = c.c_id', 'left')
                 ->where('co.colorid', $order_pre['colorid'][$i])
                 ->find();  // 循环查出购买的商品
+            foreach ($data1 as &$v) {
+                $v['zongmoney'] = $v['money'];
+            }
         }
-        $data['money'] = 0;                                  // 总价
-        $data['freight'] = 0;                                // 运费
-        $data['number'] = "yxj" . rand(1000, 9999) . time(); // 订单编号
-        $data['create_time'] = $order_pre['create_time'];    // 创建时间
-        $data['whitebean'] = 0;                              // 白豆个数
+        $data = $data1;
+        $data['params']['money'] = 0;                                  // 总价
+        $data['params']['freight'] = 0;                                // 运费
+        $data['params']['number'] = "yxj" . rand(1000, 9999) . time(); // 订单编号
+        $data['params']['create_time'] = $order_pre['create_time'];    // 创建时间
+        $data['params']['whitebean'] = 0;                              // 白豆个数
         for ($i = 0; $i < $count; $i++) {
-            $data[$i]['buy_number'] = $order_pre['buy_number'][$i];                        // 循环写入购买数量
-            $data['money'] = $data['money'] + $data[$i]['c_freight'] + $data[$i]['money']; // 总费用
-            $data['freight'] = $data['freight'] + $data[$i]['c_freight'];                  // 总运费
-            $data['whitebean'] = $data['whitebean'] + $data[$i]['c_whitebean'];            // 总白豆数
-        }
-        $preAddMoney = Db::name('order_pre')->where('pre_id', $pre_id)->setInc('money', $data['money']);
+        $data[$i]['buy_number'] = $order_pre['buy_number'][$i];                                                                          // 循环写入购买数量
+        $data[$i]['zongmoney'] = $order_pre['buy_number'][$i] * $data[$i]['zongmoney']+ $data[$i]['c_freight'];                                                  // 循环写入单个商品总价
+        $data['params']['freight'] = $data['params']['freight'] + $data[$i]['c_freight'];                                                // 总运费
+        $data['params']['money'] = $data['params']['money'] + $data[$i]['zongmoney'];                                       // 总费用
+        $data['params']['whitebean'] = $data['params']['whitebean'] + $data[$i]['c_whitebean'] * $order_pre['buy_number'][$i];            // 总白豆数
+        }
+        // 把统计出来的总价,写入数据库
+        $preAddMoney = Db::name('order_pre')->where('pre_id', $pre_id)->setInc('money', $data['params']['money']);
+        $order['params'] = $data['params'];
+        unset($data['params']);
+        $order['order'] = $data;
+        // 查出用户地址
+        $order['address'] = Address::where('user_id', $order_pre['user_id'])->order('is_default desc')->select();
         if ($data && $preAddMoney) {
-            return $this->result('', $data, 200);
+            return $this->result('', $order, 200);
         } else {
             return $this->result('网络错误', [], 100);
         }
     }
 
     /**
+     * 支付订单数量修改
+     * @ApiMethod   (POST)
+     * @param string $pre_id 订单提交返回的值
+     * @param string $buy_number 修改后数量
+     * @param string $position 修改的第几个
+     */
+    public function updBuyNumber()
+    {
+        $params = $this->request->post();
+        $rules = [
+            'pre_id'     => 'require',
+            'buy_number' => 'require',
+            'position'   => 'require',
+        ];
+        $msg = [
+            'pre_id.require'     => '网络错误',
+            'buy_number.require' => '网络错误',
+            'position.require'   => '网络错误',
+        ];
+        $validate = $this->validate($params, $rules, $msg);
+        if (is_string($validate)) {
+            return $this->result($validate, [], 100);
+        }
+        $order_pre = Db::name('order_pre')->where('pre_id', $params['pre_id'])->find();
+        if (!$order_pre) {
+            return $this->result('未找到该订单', [], 100);
+        }
+        $buynumber = explode(',', $order_pre['buy_number']);
+        foreach ($buynumber as $k => $v) {
+            if ($k == $params['position']) {
+                $buynumber[$k] = $params['buy_number'];
+            }
+        }
+        $str = implode(',', $buynumber);
+        $upd = Db::name('order_pre')->where('pre_id', $params['pre_id'])->update(['buy_number' => $str]);
+        if ($upd) {
+            return $this->result('成功', $params['pre_id'], 200);
+        } else {
+            return $this->result('点击频率过高', [], 100);
+        }
+    }
+
+    /**
      * 支付订单
      * @ApiMethod   (POST)
      * @param string $pre_id 预存id
@@ -196,6 +253,29 @@ class Order extends Api
     }
 
     /**
+     * 是否设置了余额支付密码
+     * @ApiMethod   (POST)
+     * @param string $user_id 用户id
+     */
+    public function issetpaypwd()
+    {
+        $user_id = $this->request->post('user_id');
+        if (!$user_id) {
+            return $this->result('网络错误', [], 100);
+        }
+        $userinfo = UsersModel::where('user_id', $user_id)->find();
+        if ($userinfo) {
+            if ($userinfo['is_setpaypwd'] == 0) {
+                return $this->result('还未设置支付密码', [], 90);
+            } else {
+                return $this->result('正确', [], 200);
+            }
+        } else {
+            return $this->result('网络错误', [], 100);
+        }
+    }
+
+    /**
      * 全部订单
      * @ApiMethod   (POST)
      * @param string $user_id 用户id
@@ -281,11 +361,32 @@ class Order extends Api
         if (!$o_id) {
             return $this->result('网络错误', [], 100);
         }
-        $orderInfo = OrderModel::with(['OrderCommodityModel', 'OrderAddress'])->where('o_id', $o_id)->find();
+        $orderInfo = OrderModel::with(['OrderCommodityModel', 'OrderAddress'])
+            ->where('o_id', $o_id)
+            ->find()
+            ->toArray();
+        $orderInfo['wecharpay'] = Db::name('order_wechatpay')->where('o_id',$orderInfo['o_id'])->find();
+        unset($orderInfo['wecharpay']['o_id']);
+        unset($orderInfo['wecharpay']['w_id']);
+        if (!$orderInfo) {
+            $orderInfo = [];
+        } else {
+            foreach ($orderInfo['order_commodity_model'] as &$n) {
+                $commodity = CommodityModel::where('c_id', $n['c_id'])->field('c_name')->find();
+                if (!$commodity) {
+                    $n['c_name'] = '已下架商品';
+                } else {
+                    $n['c_name'] = $commodity['c_name'];
+                }
+                $n['c_money'] = $n['c_vipprice'] * $n['buy_number'];  // c_vipprice存的是颜色商品的价格,而不是商品的初始价格
+                $n['money'] = $n['c_money'] + $n['c_freight'];
+                //$n['freight'] = $n['c_freight'] * $n['buy_number'];
+            }
+        }
         if ($orderInfo) {
             return $this->result('', $orderInfo, 200);
         } else {
-            return $this->result('网络错误', [], 100);
+            return $this->result('暂无数据', [], 100);
         }
     }
 
@@ -300,7 +401,17 @@ class Order extends Api
         if (!$o_id) {
             return $this->result('网络错误', [], 100);
         }
-        $order = OrderModel::with(['OrderCommodityModel', 'OrderAddress'])->where('o_id', $o_id)->find();
+        $order = OrderModel::with(['OrderCommodityModel', 'OrderAddress'])->where('o_id', $o_id)->find()->toArray();
+        foreach ($order['order_commodity_model'] as &$n) {
+            $commodity = CommodityModel::where('c_id', $n['c_id'])->field('c_name,c_images')->find();
+            if (!$commodity) {
+                $n['c_name'] = '已下架商品';
+            } else {
+                $n['c_name'] = $commodity['c_name'];
+                $order['c_images'][] = $commodity['c_images'];
+
+            }
+        }
         $model = new Logistics();
         $res = $model->logistics($order);
         return $res;
@@ -318,6 +429,14 @@ class Order extends Api
             return $this->result('网络错误', '', 100);
         }
         $orderInfo = OrderModel::with(['OrderCommodityModel', 'OrderAddress'])->where('o_id', $o_id)->find();
+        foreach ($orderInfo['order_commodity_model'] as $n) {
+            $commodity = CommodityModel::where('c_id', $n['c_id'])->field('c_name')->find();
+            if (!$commodity) {
+                $n['c_name'] = '已下架商品';
+            } else {
+                $n['c_name'] = $commodity['c_name'];
+            }
+        }
         if ($orderInfo) {
             return $this->result('', $orderInfo, 200);
         } else {
@@ -343,27 +462,6 @@ class Order extends Api
         if (!isset($params['money'])) {
             return $this->result('网络错误', [], 100);
         }
-        $files = $_FILES;
-        if ($files) {
-            $imageArr = Array();
-            foreach ($files as $file) {
-                $imageName = $file['name'];
-                //后缀名
-                $ext = strtolower(substr(strrchr($imageName, '.'), 1));
-                //保存文件名
-                $fileName = uniqid();
-                $tmp = $file['tmp_name'];
-                //保存 = 路径 + 文件名 + 后缀名
-                $imageSavePath = ROOT_PATH . 'public' . DS . 'uploads/images/' . $fileName . '.' . $ext;
-                $info = move_uploaded_file($tmp, $imageSavePath);
-                if ($info) {
-                    $path = "/uploads/images/" . $fileName . '.' . $ext;
-                    array_push($imageArr, $path);
-                }
-            }
-            //最终生成的字符串路径
-            $params['images'] = implode(',', $imageArr);
-        }
         //修改订单状态
         $order = OrderModel::where('o_id', $params['o_id'])->find();
         $data = array(
@@ -371,6 +469,9 @@ class Order extends Api
             'tuikuan_state' => 3,
             'state_save'    => $order['state']
         );
+        if(isset($params['files'])) {
+            $params['images'] = implode(',',$params['files']);
+        }
         $params['money'] = $order['money'];
         $params['create_time'] = date('Y-m-d H:i:s', time());
         $updOrder = OrderModel::where('o_id', $params['o_id'])->Update($data);
@@ -382,7 +483,34 @@ class Order extends Api
             return $this->result('申请失败', [], 100);
         }
     }
-
+    /**
+     * 退款图片上传
+     * @ApiMethod   (POST)
+     * @param File $files 图片
+     */
+    public function upload()
+    {
+        $files = $_FILES;
+        $imageArr = Array();
+        foreach ($files as $file) {
+            $imageName = $file['name'];
+            //后缀名
+            $ext = strtolower(substr(strrchr($imageName, '.'), 1));
+            //保存文件名
+            $fileName = uniqid();
+            $tmp = $file['tmp_name'];
+            //保存 = 路径 + 文件名 + 后缀名
+            $imageSavePath = ROOT_PATH . 'public' . DS . 'uploads/images/' . $fileName . '.' . $ext;
+            $info = move_uploaded_file($tmp, $imageSavePath);
+            if ($info) {
+                $path = config('site.httpurl')."/uploads/images/" . $fileName . '.' . $ext;
+                array_push($imageArr, $path);
+            }
+        }
+        //最终生成的字符串路径
+        $imagePathStr = implode(',', $imageArr);
+        return $imagePathStr;
+    }
     /**
      * 取消退款
      * @ApiMethod   (POST)
@@ -419,6 +547,14 @@ class Order extends Api
             return $this->result('网络错误', [], 100);
         }
         $orderInfo = OrderModel::with(['OrderCommodityModel', 'OrderAddress', 'Torder'])->where('o_id', $o_id)->find();
+        foreach ($orderInfo['order_commodity_model'] as $n) {
+            $commodity = CommodityModel::where('c_id', $n['c_id'])->field('c_name')->find();
+            if (!$commodity) {
+                $n['c_name'] = '已下架商品';
+            } else {
+                $n['c_name'] = $commodity['c_name'];
+            }
+        }
         if ($orderInfo) {
             return $this->result('', $orderInfo, 200);
         } else {
@@ -439,21 +575,21 @@ class Order extends Api
         $jsonXml = json_encode(simplexml_load_string($payXml, 'SimpleXMLElement', LIBXML_NOCDATA));
         //将json格式转成数组格式 $result['out_trade_no']
         $result = json_decode($jsonXml, true);
+        Cache::set('result',$result);
         if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') {
             $order = OrderModel::where('number', $result['out_trade_no'])->find();
             //修改订单状态
             $updOederstate = Db::name('order')->where('o_id', $order['o_id'])->update(['state' => 2]);
-            if ($updOederstate) {
+            $updwhitebean = Db::name('users')->where('user_id', $order['user_id'])->setInc('user_whitebean', $order['whitebeon']);
+            if ($updOederstate && $updwhitebean) {
                 $arr = array(
                     'return_code' => 'SUCCESS',
                     'return_msg'  => 'OK',
                 );
                 return $this->arrayToXml($arr);
             }
-
         }
     }
-
     /**
      * 微信退款订单回调
      * 可以通过@ApiInternal忽略请求的方法

+ 34 - 6
application/api/controller/Plan.php

@@ -1,7 +1,9 @@
 <?php
+
 namespace app\api\controller;
 
 use app\api\model\UsersModel;
+use app\common\lib\WxPay;
 use think\Controller;
 use think\Db;
 
@@ -24,14 +26,15 @@ class Plan extends Controller
         }
 
         $info = array(
-            'desc' => '每月清空VIP开通限制',
+            'desc'   => '每月清空VIP开通限制',
             'status' => '成功',
-            'ip' => $ip,
-            'time' => date('Y-m-d H:i:s' ,time())
+            'ip'     => $ip,
+            'time'   => date('Y-m-d H:i:s', time())
         );
 
         Db::name('plan_log')->insert($info);
     }
+
     // 清空今日已用的基础排队次数 /api/plan/clearTodayQueueUseNum
     public function clearTodayQueueUseNum()
     {
@@ -43,12 +46,37 @@ class Plan extends Controller
         }
 
         $info = array(
-            'desc' => '每天清空已用基础排队次数',
+            'desc'   => '每天清空已用基础排队次数',
             'status' => '成功',
-            'ip' => $ip,
-            'time' => date('Y-m-d H:i:s' ,time())
+            'ip'     => $ip,
+            'time'   => date('Y-m-d H:i:s', time())
         );
 
         Db::name('plan_log')->insert($info);
     }
+
+    // 用户白豆每日千分之一递减至红豆
+    public function whiteToRed()
+    {
+        $users = UsersModel::where('user_whitebean', '>', '1')->select();
+        $bean = Db::name('setbean')->find();
+        foreach ($users as &$v) {
+            // 求出每个用户要递减白豆和递加红豆的数量
+            $bean = $v['user_whitebean'] * $bean['num'];
+            // 红豆递加
+            Db::name('users')->where('user_id', $v['user_id'])->setInc('user_redbean', $bean);
+            // 白豆递减
+            Db::name('users')->where('user_id', $v['user_id'])->setDec('user_whitebean', $bean);
+        }
+        // 获取当前访问IP
+        $ip = $this->request->ip();
+        $info = array(
+            'desc'   => '白豆红豆递减递加',
+            'status' => '成功',
+            'ip'     => $ip,
+            'time'   => date('Y-m-d H:i:s', time())
+        );
+        // 生成记录
+        Db::name('plan_log')->insert($info);
+    }
 }

+ 72 - 10
application/api/controller/Queue.php

@@ -4,6 +4,7 @@ namespace app\api\controller;
 use alipay\aop\AopClient;
 use alipay\aop\request\AlipayTradeAppPayRequest;
 use app\admin\model\BuyVipLogModel;
+use app\admin\model\QueueConfig;
 use app\api\model\QueueModel;
 use app\api\model\UsersModel;
 use app\common\controller\Api;
@@ -44,11 +45,65 @@ class Queue extends Api
         $canUseBaseNum = $baseNum - $user->queue_num_today;
         // 总可用次数
         $total = $getNum + $canUseBaseNum;
+        $msg = '2020年3月1日前晋升VIP董事增加奖励华为P305G手机1台。';
         $this->result('ok', [
-            'tip' => '尊敬的VIP会员,你还可排队'.$total.'次,排队时间(09:00-22:00),其中推荐用户获得'.$getNum.'次,VIP会员奖励'.$canUseBaseNum.'次'
+            'tip' => '尊敬的VIP会员,你还可排队'.$total.'次,排队时间(09:00-22:00),其中推荐用户获得'.$getNum.'次,VIP会员奖励'.$canUseBaseNum.'次'.$msg
         ], 200);
     }
     /**
+     * 检查是否满足排队条件
+     *
+     * @ApiTitle    (检查是否满足排队条件)
+     * @ApiSummary  (检查是否满足排队条件)
+     * @ApiMethod   (POST)
+     * @ApiRoute    (/api/queue/checkQueue)
+     * @ApiParams   (name="user_id", type="int", required=true, description="用户id")
+     */
+    public function checkQueue()
+    {
+        $userId = $this->request->post('user_id');
+
+        if (!$userId) {
+            $this->result('参数错误', [], 100);
+        }
+
+        $user = UsersModel::get($userId);
+
+        if (!$user) {
+            $this->result('用户不存在', [], 100);
+        }
+
+        if ($user->user_level == 1) {
+            $this->result('您还不是VIP用户,不能进行排队哦', [], 100);
+        }
+
+        $canQueueNum = Db::name('queue_set')->where('level', $user->user_level)->value('num');
+        if ($user->queue_num_today == $canQueueNum && $canQueueNum != 0) {
+            $this->result('您的可用排队次数不足', [], 100);
+        }
+
+        $nowTime = time();
+        $startTime = strtotime(date('Y-m-d').' 09:00:00');
+        $endTime = strtotime(date('Y-m-d').' 22:00:00');
+
+        if ($startTime < $nowTime && $nowTime < $endTime) {
+
+            $nowHour = date("Y-m-d H:00:00", time());
+            $nextHour = date("Y-m-d H:00:00", strtotime("+1 hour"));
+
+            // 是否在本时间段内排过队
+            $hasOnLine = QueueModel::where(['uid' => $userId, 'pay_status' => 1])
+                ->whereTime('time', 'between', [$nowHour, $nextHour])
+                ->find();
+
+            if (!empty($hasOnLine)) {
+                $this->result('您当前已排过队', [], 100);
+            }
+        }
+
+        $this->result('ok', [], 200);
+    }
+    /**
      * 排队
      *
      * @ApiTitle    (排队)
@@ -62,8 +117,11 @@ class Queue extends Api
     {
         $userId = $this->request->post('user_id');
         $payType = $this->request->post('pay_type'); // 1-余额 2-微信 3-支付宝
-        $amount = 0.01;
-        $income = 2;
+
+        // 读取排队配置
+        $queueConfig = QueueConfig::get(1);
+        $amount = $queueConfig->pay;
+        $income = $queueConfig->income;
 
         if (!$userId || !$payType) {
             $this->result('参数错误', [], 100);
@@ -85,7 +143,7 @@ class Queue extends Api
         // 情况三:获得次数无、基础次数有,可排队
         // 情况四:都无,不可排队
         $canQueueNum = Db::name('queue_set')->where('level', $user->user_level)->value('num');
-        if ($user->queue_num_today == $canQueueNum) {
+        if ($user->queue_num_today == $canQueueNum && $canQueueNum != 0) {
             $this->result('您的可用排队次数不足', [], 100);
         }
 
@@ -137,7 +195,7 @@ class Queue extends Api
                     if ($getPrePayInfo) {
                         $getPayInfo = $payObj->getOrder($getPrePayInfo['prepay_id']);
                         if ($getPayInfo) {
-                            $this->result('订单创建成功', $getPayInfo, 200);
+                            $this->result('订单创建成功', ['payInfoArray' => $getPayInfo], 200);
                         } else {
                             $this->result('支付错误,请稍后再试', [], 100);
                         }
@@ -455,13 +513,17 @@ class Queue extends Api
             $this->result('参数错误', [], 100);
         }
         $queueOrder = QueueModel::field('trade,line_num')->find($id);
-        //$nowTime = date('Y-m-d H:i:s', time());
-        //$nextTime = date("Y-m-d H:00:00", strtotime("+1 hour"));
+        $nowTime = date('Y-m-d H:i:s', time());
+        $nextTime = date("Y-m-d H:00:00", strtotime("+1 hour"));
         //$mistake = strtotime($nextTime) - strtotime($nowTime);
-        //$hour=floor((strtotime($nextTime)-strtotime($nowTime))%86400/3600);
-        //$minute=floor((strtotime($nextTime)-strtotime($nowTime))%86400/60);
-        //$second=floor((strtotime($nextTime)-strtotime($nowTime))%86400%60);
+        $hour=floor((strtotime($nextTime)-strtotime($nowTime))%86400/3600);
+        $minute=floor((strtotime($nextTime)-strtotime($nowTime))%86400/60);
+        $second=floor((strtotime($nextTime)-strtotime($nowTime))%86400%60);
         //halt($second);
+        //$queueOrder['time'] = date('Y-m-d H:i:s', time());
+        $queueOrder['hour'] = $hour;
+        $queueOrder['minute'] = $minute;
+        $queueOrder['second'] = $second;
         if (!empty($queueOrder)) {
             $this->result('ok', $queueOrder, 200);
         } else {

+ 1 - 1
application/api/controller/Recharge.php

@@ -90,7 +90,7 @@ class Recharge extends Api
             }
         }
 
-        if ($tel == 18315626215 || $tel == 15615490741 || $tel == 18853911065) {
+        if ($tel == 13287120502 || $tel == 15615490741 || $tel == 15588511702) {
             $final_fee = 0.01;
             $isDiscount = 0;
         }

+ 4 - 3
application/api/controller/Register.php

@@ -69,14 +69,15 @@ class Register extends Controller
                     if (is_string($validata)) {
                         return json(['code' => 100, 'msg' => $validata,'data' => []]);
                     }
+                    $user_avatar = config('site.httpurl') . '/uploads/logo.png';
                     $data = array(
                         'user_nickname' => '优-' . rand(10000, 99999),
                         'user_tel'      => $params['user_tel'],
                         'user_pwd'      => sha1(md5($params['user_pwd'])),
-                        'user_avatar'   => config('site.httpurl') . '/uploads/logo.jpg',
+                        'user_avatar'   => $user_avatar,
                         'create_time'   => date('Y-m-d H:i:s', time()),
                         'user_tjtel'    => $params['user_tjtel'],
-                        'type'          => $params['type'],
+                        'type'          => 0,
                     );
                     $addUser = $userModel->allowField(true)->save($data);
                     if ($addUser) {
@@ -136,7 +137,7 @@ class Register extends Controller
             'token'   => $token,
         );
         if ($addUser) {
-            return json(['code' => 20, 'msg' => '请绑定手机号','data' => []]);
+            return json(['code' => 10, 'msg' => '请绑定手机号','data' => []]);
         } else {
             return json(['code' => 100, 'msg' => '注册失败','data' => []]);
         }

+ 169 - 38
application/api/controller/User.php

@@ -5,6 +5,7 @@ namespace app\api\controller;
 use app\api\model\Address;
 use app\api\model\Cashwechat;
 use app\api\model\Foot;
+use app\api\model\OrderModel;
 use app\api\model\Realname;
 use app\api\model\Record;
 use app\api\model\UsersModel;
@@ -42,10 +43,13 @@ class User extends Api
             return $this->result('网络错误', [], 100);
         }
         $data = UsersModel::where('user_id', $user_id)->find();
-        $data['daifahuo'] = 1;
-        $data['daishouhuo'] = 1;
-        $data['tuikuan'] = 1;
-        $data['daifukuan'] = 1;
+        if ($data['status_switch'] == 0) {
+            return $this->result('账号已被禁用', 30, 30);
+        }
+        $data['daifahuo'] = OrderModel::where('user_id', $user_id)->where('state', 2)->count();
+        $data['daishouhuo'] = OrderModel::where('user_id', $user_id)->where('state', 3)->count();
+        $data['tuikuan'] = OrderModel::where('user_id', $user_id)->where('state', 4)->count();
+        $data['daifukuan'] = OrderModel::where('user_id', $user_id)->where('state', 1)->count();
         if ($data) {
             return $this->result('', $data, 200);
         } else {
@@ -81,6 +85,48 @@ class User extends Api
     }
 
     /**
+     * 修改头像
+     * @ApiMethod   (POST)
+     * @param string $user_id 用户id
+     * @param string $file 图片
+     */
+    public function updUpload()
+    {
+        $params = $this->request->post();
+        if (!isset($params['user_id'])) {
+            return $this->result('网络错误', [], 100);
+        }
+        $files = $_FILES;
+        if ($files) {
+            $imageArr = Array();
+            foreach ($files as $file) {
+                $imageName = $file['name'];
+                //后缀名
+                $ext = strtolower(substr(strrchr($imageName, '.'), 1));
+                //保存文件名
+                $fileName = uniqid();
+                $tmp = $file['tmp_name'];
+                //保存 = 路径 + 文件名 + 后缀名
+                $imageSavePath = ROOT_PATH . 'public' . DS . 'uploads/images/' . $fileName . '.' . $ext;
+                $info = move_uploaded_file($tmp, $imageSavePath);
+                if ($info) {
+                    $path = config('site.httpurl') . "/uploads/images/" . $fileName . '.' . $ext;
+                    array_push($imageArr, $path);
+                }
+            }
+            //最终生成的字符串路径
+            $params['user_avatar'] = implode(',', $imageArr);
+        }
+        $user = new UsersModel();
+        $upd = $user->allowField(true)->save($params, ['user_id' => $params['user_id']]);
+        if ($upd) {
+            return $this->result('修改成功', $params, 200);
+        } else {
+            return $this->result('修改失败', [], 100);
+        }
+    }
+
+    /**
      * 修改密码
      * @ApiMethod   (POST)
      * @param string $user_id 用户id
@@ -116,6 +162,7 @@ class User extends Api
         );
         $model = new UsersModel();
         $updPwd = $model->allowField(true)->save($data, ['user_id' => $data['user_id']]);
+        $upd = Db::name('users')->where('user_id', $params['user_id'])->update(['is_setpaypwd' => 1]);
         if ($updPwd) {
             return $this->result('修改成功', [], 200);
         } else {
@@ -124,65 +171,92 @@ class User extends Api
     }
 
     /**
-     * 修改支付密码
+     * 设置支付密码
      * @ApiMethod   (POST)
      * @param string $user_id 用户id
-     * @param string $user_tel 手机号
-     * @param string $code 验证码
      * @param string $user_paypwd 支付密码
      * @param string $user_qrpaypwd 确认支付密码
      */
-    public function updPayPwd()
+    public function setPaypwd()
     {
         $params = $this->request->post();
         $rules = [
-            'user_tel'      => "require|number",
             'user_id'       => "require|number",
-            'code'          => "require",
-            'user_paypwd'   => "require|number",
+            'user_paypwd'   => "require|max:6",
             'user_qrpaypwd' => "require",
         ];
         $msg = [
-            'user_tel.require'      => '手机号不能为空',
             'user_id.require'       => '网络错误',
-            'user_code.require'     => '验证码不能为空',
             'user_paypwd.require'   => '支付密码不能为空',
             'user_qrpaypwd.require' => '支付密码不能为空',
-            'user_paypwd.number'    => '支付密码只支持数字',
-            'user_code.number'      => '验证码只支持数字',
+            'user_paypwd.max'       => '支付密码最多六位',
             'user_id.number'        => '网络错误',
-            'user_tel.number'       => '手机号不合法',
         ];
         $validata = $this->validate($params, $rules, $msg);
         if (is_string($validata)) {
             return $this->result($validata, [], 100);
         }
         if ($params['user_paypwd'] != $params['user_qrpaypwd']) {
-            return $this->result('两次密码输入不一致', [], 100);
+            return $this->result('两次密码输入不正确', '', 100);
         }
-        $code = Cache::get($params['code']);
-        if (!$code) {
-            return $this->result('验证码错误', [], 100); // 验证验证码
+
+        //$user = new UsersModel();
+        $users = UsersModel::where('user_id', $params['user_id'])->find();
+        if ($users['is_setpaypwd'] == 1) {
+            return $this->result('您已经设置过支付密码了', '', 90);
+        }
+        $data['user_paypwd'] = $params['user_paypwd'];
+        $data['is_setpaypwd'] = 1;
+        $upd = Db::name('users')->where('user_id', $params['user_id'])->update($data);
+        if ($upd) {
+            return $this->result('设置成功', [], 200);
+        } else {
+            return $this->result('设置失败或与原密码一致', [], 100);
         }
-        $data = array(
-            'user_id'     => $params['user_id'],
-            'user_paypwd' => $params['user_paypwd'],
-        );
+    }
+
+    /**
+     * 修改支付密码
+     * @ApiMethod   (POST)
+     * @param string $user_id 用户id
+     * @param string $user_tel 手机号
+     * @param string $code 验证码
+     */
+    public function updPayPwd()
+    {
+        $params = $this->request->post();
+        $rules = [
+            'user_tel' => "require|number",
+            'user_id'  => "require|number",
+            'code'     => "require",
+        ];
+        $msg = [
+            'user_tel.require'  => '手机号不能为空',
+            'user_id.require'   => '网络错误',
+            'user_code.require' => '验证码不能为空',
+            'user_code.number'  => '验证码只支持数字',
+            'user_id.number'    => '网络错误',
+            'user_tel.number'   => '手机号不合法',
+        ];
+        $validata = $this->validate($params, $rules, $msg);
+        if (is_string($validata)) {
+            return $this->result($validata, [], 100);
+        }
+//        $code = Cache::get($params['code']);
+//        if (!$code) {
+//            return $this->result('验证码错误', [], 100); // 验证验证码
+//        }
         $user = new UsersModel();
-        $validataTel = $user->where('user_id', $data['user_id'])->where('user_tel', $params['user_tel'])->find();
+        $validataTel = $user->where('user_id', $params['user_id'])->where('user_tel', $params['user_tel'])->find();
         if (!$validataTel) {
             return $this->result('请使用此账号手机号修改密码', [], 100);
         }
-        $validataPayPwd = $user->where($data)->find();
-        if ($validataPayPwd) {
-            return $this->result('请输入新密码', [], 100);
-        }
-        $updPayPwd = $user->allowField(true)->save($data, ['user_id' => $data['user_id']]);
-        if ($updPayPwd) {
+        $upd = Db::name('users')->where('user_id', $params['user_id'])->update(['user_paypwd' => 0, 'is_setpaypwd' => 0]);
+        if ($upd) {
             Cache::rm($params['code']); // 删除缓存验证码
-            return $this->result('修改成功', [], 200);
+            return $this->result('重置成功', [], 200);
         } else {
-            return $this->result('修改失败', [], 100);
+            return $this->result('重置失败', [], 100);
         }
     }
 
@@ -530,6 +604,7 @@ class User extends Api
             return $this->result('网络错误', '', 100);
         }
     }
+
     /**
      * 我的余额提现记录
      * @ApiMethod   (POST)
@@ -541,13 +616,14 @@ class User extends Api
         if (!isset($params['user_id'])) {
             return $this->result('网络错误', [], 100);
         }
-        $data =Db::name('cash_log')->where('user_id', $params['user_id'])->order('t_id desc')->select();
+        $data = Db::name('cash_log')->where('user_id', $params['user_id'])->order('t_id desc')->select();
         if ($data) {
             return $this->result('', $data, 200);
         } else {
             return $this->result('暂无数据', [], 100);
         }
     }
+
     /**
      * 我的红豆兑换记录
      * @ApiMethod   (POST)
@@ -559,7 +635,7 @@ class User extends Api
         if (!isset($params['user_id'])) {
             return $this->result('网络错误', [], 100);
         }
-        $data = Record::where('user_id', $params['user_id'])->where('t_type',1)->order('r_id desc')->select();
+        $data = Record::where('user_id', $params['user_id'])->where('t_type', 1)->order('r_id desc')->select();
         if ($data) {
             return $this->result('', $data, 200);
         } else {
@@ -682,9 +758,13 @@ class User extends Api
             return $this->result('余额不足', [], 100);
         }
         // 判断是否微信网页受过权
-        if ($user_cash_level['user_openid'] == '') {
+        if ($user_cash_level['user_openid'] == "") {
             return $this->result('请先微信网页授权在提现', [], 10);
         }
+        // 是否实名认证过了
+        if ($user_cash_level['is_realname'] != 1) {
+            return $this->result('还未实名认证哦', [], 20);
+        }
         // 开启事务
         Db::startTrans();
         try {
@@ -717,11 +797,62 @@ class User extends Api
         // 实例化企业付款到零钱类
         $cashWeChat = new Cashwechat();
         // 调用企业付款接口接口
+        $params['money'] = 0.5;
         $res = $cashWeChat->sendMoney($params['money'], $user_cash_level['user_openid'], '余额提现', $user_cash_level['user_nickname'], $number);
         return $res;
     }
 
     /**
+     * 添加用户openid
+     * @ApiMethod   (POST)
+     * @param string $user_id 用户id
+     * @param string $user_openid openid
+     * @param string $user_unionid unionID
+     */
+    public function addOpenid()
+    {
+        $params = $this->request->post();
+        $rules = [
+            'user_id'      => 'require',
+            'user_openid'  => 'require',
+            'user_unionid' => 'require',
+        ];
+        $msg = [
+            'user_id.require' => '网络错误',
+            'user_openid.require' => '未获取用户信息1',
+            'user_unionid.require' => '未获取用户信息2',
+        ];
+        $validate = $this->validate($params,$rules,$msg);
+        if (is_string($validate)) {
+            return $this->result($validate,[],100);
+        }
+        $user = new UsersModel();
+        $upd = $user->allowField(true)->save($params,['user_id' =>$params['user_id']]);
+        if ($upd) {
+            return $this->result('绑定成功',[], 200);
+        } else {
+            return $this->result('绑定失败', [], 100);
+        }
+    }
+    /**
+     * 版本管理
+     * @ApiMethod   (POST)
+     * @param string $edition 版本号
+     */
+    public function edition()
+    {
+        $edition = $this->request->post('edition');
+        if (!isset($edition)) {
+            return $this->result('系统出错', [], 100);
+        }
+        $data = Db::name('edition')->order('e_id desc')->find();
+        if ($edition != $data['edition']) {
+            return $this->result('已有新版本', $data, 200);
+        } else {
+            return $this->result('当前版本已经是最新版本',[],100);
+        }
+    }
+    /**
      * 隐私协议
      * @ApiMethod   (POST)
      */
@@ -737,7 +868,7 @@ class User extends Api
      */
     public function weweima()
     {
-        $url = "http://file02.16sucai.com/d/file/2015/0128/8b0f093a8edea9f7e7458406f19098af.jpg";
-        return json(['code' => 200, 'msg' => '', 'data' => $url]);
+        $data = Db::name('edition')->order('e_id desc')->find();
+        return json(['code' => 200, 'msg' => '', 'data' => $data['erweima_image']]);
     }
 }

+ 138 - 138
application/api/controller/Validate.php

@@ -1,139 +1,139 @@
 <?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-use app\common\model\User;
-
-/**
- * 验证接口
- */
-class Validate extends Api
-{
-    protected $noNeedLogin = '*';
-    protected $layout = '';
-    protected $error = null;
-    protected $rules = '';
-    protected $msg   = '';
-    public function _initialize()
-    {
-        parent::_initialize();
-    }
-
-    /**
-     * 检测邮箱
-     *
-     * @param string $email 邮箱
-     * @param string $id    排除会员ID
-     */
-    public function check_email_available()
-    {
-        $email = $this->request->request('email');
-        $id = (int)$this->request->request('id');
-        $count = User::where('email', '=', $email)->where('id', '<>', $id)->count();
-        if ($count > 0) {
-            $this->error(__('邮箱已经被占用'));
-        }
-        $this->success();
-    }
-
-    /**
-     * 检测用户名
-     *
-     * @param string $username 用户名
-     * @param string $id       排除会员ID
-     */
-    public function check_username_available()
-    {
-        $email = $this->request->request('username');
-        $id = (int)$this->request->request('id');
-        $count = User::where('username', '=', $email)->where('id', '<>', $id)->count();
-        if ($count > 0) {
-            $this->error(__('用户名已经被占用'));
-        }
-        $this->success();
-    }
-
-    /**
-     * 检测手机
-     *
-     * @param string $mobile 手机号
-     * @param string $id     排除会员ID
-     */
-    public function check_mobile_available()
-    {
-        $mobile = $this->request->request('mobile');
-        $id = (int)$this->request->request('id');
-        $count = User::where('mobile', '=', $mobile)->where('id', '<>', $id)->count();
-        if ($count > 0) {
-            $this->error(__('该手机号已经占用'));
-        }
-        $this->success();
-    }
-
-    /**
-     * 检测手机
-     *
-     * @param string $mobile 手机号
-     */
-    public function check_mobile_exist()
-    {
-        $mobile = $this->request->request('mobile');
-        $count = User::where('mobile', '=', $mobile)->count();
-        if (!$count) {
-            $this->error(__('手机号不存在'));
-        }
-        $this->success();
-    }
-
-    /**
-     * 检测邮箱
-     *
-     * @param string $mobile 邮箱
-     */
-    public function check_email_exist()
-    {
-        $email = $this->request->request('email');
-        $count = User::where('email', '=', $email)->count();
-        if (!$count) {
-            $this->error(__('邮箱不存在'));
-        }
-        $this->success();
-    }
-
-    /**
-     * 检测手机验证码
-     *
-     * @param string $mobile  手机号
-     * @param string $captcha 验证码
-     * @param string $event   事件
-     */
-    public function check_sms_correct()
-    {
-        $mobile = $this->request->request('mobile');
-        $captcha = $this->request->request('captcha');
-        $event = $this->request->request('event');
-        if (!\app\common\library\Sms::check($mobile, $captcha, $event)) {
-            $this->error(__('验证码不正确'));
-        }
-        $this->success();
-    }
-
-    /**
-     * 检测邮箱验证码
-     *
-     * @param string $email   邮箱
-     * @param string $captcha 验证码
-     * @param string $event   事件
-     */
-    public function check_ems_correct()
-    {
-        $email = $this->request->request('email');
-        $captcha = $this->request->request('captcha');
-        $event = $this->request->request('event');
-        if (!\app\common\library\Ems::check($email, $captcha, $event)) {
-            $this->error(__('验证码不正确'));
-        }
-        $this->success();
-    }
-}
+//
+//namespace app\api\controller;
+//
+//use app\common\controller\Api;
+//use app\common\model\User;
+//
+///**
+// * 验证接口
+// */
+//class Validate extends Api
+//{
+//    protected $noNeedLogin = '*';
+//    protected $layout = '';
+//    protected $error = null;
+//    protected $rules = '';
+//    protected $msg   = '';
+//    public function _initialize()
+//    {
+//        parent::_initialize();
+//    }
+//
+//    /**
+//     * 检测邮箱
+//     *
+//     * @param string $email 邮箱
+//     * @param string $id    排除会员ID
+//     */
+//    public function check_email_available()
+//    {
+//        $email = $this->request->request('email');
+//        $id = (int)$this->request->request('id');
+//        $count = User::where('email', '=', $email)->where('id', '<>', $id)->count();
+//        if ($count > 0) {
+//            $this->error(__('邮箱已经被占用'));
+//        }
+//        $this->success();
+//    }
+//
+//    /**
+//     * 检测用户名
+//     *
+//     * @param string $username 用户名
+//     * @param string $id       排除会员ID
+//     */
+//    public function check_username_available()
+//    {
+//        $email = $this->request->request('username');
+//        $id = (int)$this->request->request('id');
+//        $count = User::where('username', '=', $email)->where('id', '<>', $id)->count();
+//        if ($count > 0) {
+//            $this->error(__('用户名已经被占用'));
+//        }
+//        $this->success();
+//    }
+//
+//    /**
+//     * 检测手机
+//     *
+//     * @param string $mobile 手机号
+//     * @param string $id     排除会员ID
+//     */
+//    public function check_mobile_available()
+//    {
+//        $mobile = $this->request->request('mobile');
+//        $id = (int)$this->request->request('id');
+//        $count = User::where('mobile', '=', $mobile)->where('id', '<>', $id)->count();
+//        if ($count > 0) {
+//            $this->error(__('该手机号已经占用'));
+//        }
+//        $this->success();
+//    }
+//
+//    /**
+//     * 检测手机
+//     *
+//     * @param string $mobile 手机号
+//     */
+//    public function check_mobile_exist()
+//    {
+//        $mobile = $this->request->request('mobile');
+//        $count = User::where('mobile', '=', $mobile)->count();
+//        if (!$count) {
+//            $this->error(__('手机号不存在'));
+//        }
+//        $this->success();
+//    }
+//
+//    /**
+//     * 检测邮箱
+//     *
+//     * @param string $mobile 邮箱
+//     */
+//    public function check_email_exist()
+//    {
+//        $email = $this->request->request('email');
+//        $count = User::where('email', '=', $email)->count();
+//        if (!$count) {
+//            $this->error(__('邮箱不存在'));
+//        }
+//        $this->success();
+//    }
+//
+//    /**
+//     * 检测手机验证码
+//     *
+//     * @param string $mobile  手机号
+//     * @param string $captcha 验证码
+//     * @param string $event   事件
+//     */
+//    public function check_sms_correct()
+//    {
+//        $mobile = $this->request->request('mobile');
+//        $captcha = $this->request->request('captcha');
+//        $event = $this->request->request('event');
+//        if (!\app\common\library\Sms::check($mobile, $captcha, $event)) {
+//            $this->error(__('验证码不正确'));
+//        }
+//        $this->success();
+//    }
+//
+//    /**
+//     * 检测邮箱验证码
+//     *
+//     * @param string $email   邮箱
+//     * @param string $captcha 验证码
+//     * @param string $event   事件
+//     */
+//    public function check_ems_correct()
+//    {
+//        $email = $this->request->request('email');
+//        $captcha = $this->request->request('captcha');
+//        $event = $this->request->request('event');
+//        if (!\app\common\library\Ems::check($email, $captcha, $event)) {
+//            $this->error(__('验证码不正确'));
+//        }
+//        $this->success();
+//    }
+//}

+ 60 - 25
application/api/controller/Wechatwebopenid.php

@@ -15,7 +15,8 @@ class Wechatwebopenid extends Controller
      */
     public function unity_url()
     {
-        $data = config('site.httpurl') . '/api/Wechatwebopenid/insertcode';
+        $data['url'] = config('site.httpurl') . '/api/Wechatwebopenid/insertcode';
+        $data['appid'] = "wxa372e8ef8a6f0e1d";
         return json(['data' => $data, 'code' => 200]);
     }
 
@@ -26,40 +27,74 @@ class Wechatwebopenid extends Controller
     public function insertcode()
     {
         $code = input('code');
+        $user_id = input('state');
         $appid = "wxa372e8ef8a6f0e1d";
         $secret = "6b8033de3f71eef386a3abdfc5ba5fd4";
         $access_token = $this->getAccess_token($code, $appid, $secret);
         if (isset($access_token['errcode'])) {
             if ($access_token['errcode'] == 40029) {
-                return json(['code' => 100, 'msg' => '网络错误']);
+                return json(['code' => 100, 'msg' => '网络错误101']);
             }
         }
-        //防止过期。刷新token
-        $refresh_token = $this->refresh_token($appid, $access_token['refresh_token']);
-        if (isset($refresh_token['errcode'])) {
-            if ($refresh_token['errcode'] == 40029) {
-                return json(['code' => 100, 'msg' => '网络错误']);
+        halt($access_token);
+        if (isset($access_token['openid'])) {
+            $data = array(
+                'user_openid' => $access_token['openid'],
+            );
+            $upd = UsersModel::where('user_id', $user_id)->update($data);
+            if ($upd) {
+                return json(['code' => 200, 'msg' => '授权成功']);
+            } else {
+                return json(['code' => 100, 'msg' => '网络错误104']);
             }
-        }
-        //拉取用户信息
-        $userInfo = $this->userInfo($refresh_token['access_token'], $appid);
-        if (isset($userInfo['errcode'])) {
-            if ($userInfo['errcode'] == 40003) {
-                return json(['code' => 100, 'msg' => '网络错误']);
-            }
-        }
-        $data = array(
-            'user_openid'  => $userInfo['openid'],
-            'user_unionid' => $userInfo['unionid'],
-        );
-        //$upd = UsersModel::where('user_unionid', $userInfo['unionid'])->update($data);
-        $upd = UsersModel::where('user_unionid', $userInfo['unionid'])->update($data);
-
-        if ($upd) {
-            return json(['code' => 200, 'msg' => '授权成功']);
         } else {
-            return json(['code' => 100, 'msg' => '网络错误']);
+            return json(['code' => 100, 'msg' => '网络错误104']);
         }
+        // 一下为获取用户详细信息的接口
+//        return json();
+//        //防止过期。刷新token
+//        $refresh_token = $this->refresh_token($appid, $access_token['refresh_token']);
+//        if (isset($refresh_token['errcode'])) {
+//            if ($refresh_token['errcode'] == 40029) {
+//                return json(['code' => 100, 'msg' => '网络错误102']);
+//            }
+//        }
+//        //拉取用户信息
+//        $userInfo = $this->userInfo($refresh_token['access_token'], $appid);
+//        if (isset($userInfo['errcode'])) {
+//            if ($userInfo['errcode'] == 40003) {
+//                return json(['code' => 100, 'msg' => '网络错误103']);
+//            }
+//        }
+//        $data = array(
+//            'user_openid'  => $userInfo['openid'],
+//            'user_unionid' => $userInfo['unionid'],
+//        );
+//        //$upd = UsersModel::where('user_unionid', $userInfo['unionid'])->update($data);
+
+    }
+
+    /**
+     * 调取微信授权
+     */
+    public function toWeChat()
+    {
+
+        $data['url'] = config('site.httpurl') . '/api/Wechatwebopenid/insertcode';
+        $data['appid'] = "wxa372e8ef8a6f0e1d";
+        $user_id = 16;
+        //设置请求之地
+        $toWeChat = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $data['appid'] . '&redirect_uri=' . $data['url'] . '&response_type=code&scope=snsapi_base&state=' . $user_id . '#wechat_redirect';
+        $this->redirect($toWeChat, 302);
+        $ch = curl_init();                                //初始化CURL句柄
+        curl_setopt($ch, CURLOPT_URL, $toWeChat);         //设置请求的URL
+        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    //设为TRUE把curl_exec()结果转化为字串,而不是直接输出
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); //设置请求方式
+        curl_setopt($ch, CURLOPT_POSTFIELDS, false);    //设置提交的字符串
+        $output = curl_exec($ch);
+        curl_close($ch);
+        return json_decode($output, true);
     }
 
     /**

+ 49 - 43
application/api/model/Cashwechat.php

@@ -1,107 +1,112 @@
 <?php
+
 namespace app\api\model;
+
 use think\Db;
 use think\Model;
 
 class Cashwechat extends Model
 {
 
-    public function sendMoney($amount,$re_openid,$desc='推荐奖励',$check_name='',$number){
+    public function sendMoney($amount, $re_openid, $desc = '推荐奖励', $check_name = '', $number)
+    {
         $total_amount = (100) * $amount;
 //        $total_amount = $amount;
         $ip = self::get_client_ip();
-        $data=array(
-            'mch_appid'=> 'wxa372e8ef8a6f0e1d',//商户账号appid
-            'mchid'=> '1550903451',//商户号
-            'nonce_str'=> $this->createNoncestr(),//随机字符串
-            'partner_trade_no'=> $number,//商户订单号
-            'openid'=> $re_openid,//用户openid
-            'check_name'=>'NO_CHECK',//校验用户姓名选项,
-            're_user_name'=> $check_name,//收款用户姓名
-            'amount'=>$total_amount,//金额
-            'desc'=> $desc,//企业付款描述信息
-            'spbill_create_ip'=> $ip,//Ip地址
+        $data = array(
+            'mch_appid'        => 'wx032e75bf42061b96',   //商户账号appid
+            'mchid'            => '1550903451',           //商户号
+            'nonce_str'        => $this->createNoncestr(),//随机字符串
+            'partner_trade_no' => $number,                //商户订单号
+            'openid'           => $re_openid,             //用户openid
+            'check_name'       => 'NO_CHECK',             //校验用户姓名选项,
+            're_user_name'     => $check_name,            //收款用户姓名
+            'amount'           => $total_amount,          //金额
+            'desc'             => $desc,                  //企业付款描述信息
+            'spbill_create_ip' => $ip,                    //Ip地址
         );
         $secrect_key = 'b3ae6bbf3cc4fa017eb169ae219e2c27';//API密码
         $data = array_filter($data);
         ksort($data);
-        $str ='';
-        foreach($data as $k=>$v) {
-            $str.=$k.'='.$v.'&';
+        $str = '';
+        foreach ($data as $k => $v) {
+            $str .= $k . '=' . $v . '&';
         }
-        $str.='key='.$secrect_key;
+        $str .= 'key=' . $secrect_key;
         $data['sign'] = md5($str);
         $xml = $this->arraytoxml($data);
-        $url='https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers'; //调用接口
-        $res = $this->wx_curl($xml,$url);
+        $url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers'; //调用接口
+        $res = $this->wx_curl($xml, $url);
         $return = $this->xmltoarray($res);
         $responseObj = simplexml_load_string($res, 'SimpleXMLElement', LIBXML_NOCDATA);
         $data = json_encode($responseObj);
-        $data = json_decode($data,true);
+        $data = json_decode($data, true);
 //        $res= $responseObj->return_code;  //SUCCESS  如果返回来SUCCESS,则发生成功,处理自己的逻辑 $data['partner_trade_no']
 //        if ($res )
-        $cash_log = Db::name('cash_log')->where('number',$number)->find(); //查出提现记录
+        $cash_log = Db::name('cash_log')->where('number', $number)->find();           //查出提现记录
         if ($data['return_code'] == "SUCCESS" && $data['result_code'] == 'SUCCESS') {
             if ($cash_log) {
                 // 查出用户信息
-                $user = UsersModel::where('user_id',$cash_log['user_id'])->find();
+                $user = UsersModel::where('user_id', $cash_log['user_id'])->find();
                 //修改状态为成功
-                $updCashstate = Db::name('cash_log')->where('number',$number)->update(['state' => 2]);
+                $updCashstate = Db::name('cash_log')->where('number', $number)->update(['state' => 2]);
                 if ($user['cash_level'] < 9) {
                     // 修改用户提现到底几次了
-                    $updUserLevel = UsersModel::where('user_id',$cash_log['user_id'])->setInc('cash_level',1);
+                    $updUserLevel = UsersModel::where('user_id', $cash_log['user_id'])->setInc('cash_level', 1);
                 }
                 if ($updCashstate) {
                     return json(['code' => 200, 'msg' => '提现成功']);
                 }
             }
-        }
-        else {
+        } else {
             //修改状态为失败
             //修改用户金额
-            $updUserMOney = Db::name('users')->where('user_id',$cash_log['user_id'])->setInc('user_money',$cash_log['money']);
-            $updCashstate = Db::name('cash_log')->where('number',$number)->update(['state' => 0]);
+            $updUserMOney = Db::name('users')->where('user_id', $cash_log['user_id'])->setInc('user_money', $cash_log['money']);
+            $updCashstate = Db::name('cash_log')->where('number', $number)->update(['state' => 0]);
             $msg = array(
-                'reason' => '提现失败,请联系客服',
+                'reason'     => '提现失败,请联系客服',
                 'admin_look' => $data['err_code_des']
             );
             // 写入提现失败原因
-            $reason = Db::name('cash_log')->where('number',$number)->update($msg);
-            if ($updCashstate&&$updUserMOney&&$reason) {
+            $reason = Db::name('cash_log')->where('number', $number)->update($msg);
+            if ($updCashstate && $updUserMOney && $reason) {
                 return json(['code' => 200, 'msg' => '提现失败']);
             }
         }
     }
 
-    public function createNoncestr($length =32){
+    public function createNoncestr($length = 32)
+    {
         $chars = "abcdefghijklmnopqrstuvwxyz0123456789";
-        $str ="";
-        for ( $i = 0; $i < $length; $i++ )  {
-            $str.= substr($chars, mt_rand(0, strlen($chars)-1), 1);
+        $str = "";
+        for ($i = 0; $i < $length; $i++) {
+            $str .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
         }
         return $str;
     }
 
-    public function arraytoxml($data){
-        $str='<xml>';
-        foreach($data as $k=>$v) {
-            $str.='<'.$k.'>'.$v.'</'.$k.'>';
+    public function arraytoxml($data)
+    {
+        $str = '<xml>';
+        foreach ($data as $k => $v) {
+            $str .= '<' . $k . '>' . $v . '</' . $k . '>';
         }
-        $str.='</xml>';
+        $str .= '</xml>';
         return $str;
     }
 
-    public function xmltoarray($xml) {
+    public function xmltoarray($xml)
+    {
         //禁止引用外部xml实体
         libxml_disable_entity_loader(true);
         $xmlstring = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
-        $val = json_decode(json_encode($xmlstring),true);
+        $val = json_decode(json_encode($xmlstring), true);
         return $val;
     }
 
-    public function wx_curl($vars,$url,$second = 30, $aHeader = array())
+    public function wx_curl($vars, $url, $second = 30, $aHeader = array())
     {
-        $isdir = ROOT_PATH . "public/cert/";                  //证书位置
+        $isdir = ROOT_PATH . "public/cert/";                             //证书位置
         $ch = curl_init();                                               //初始化curl
         curl_setopt($ch, CURLOPT_TIMEOUT, $second);                      //设置执行最长秒数
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);                     //要求结果为字符串且输出到屏幕上
@@ -130,6 +135,7 @@ class Cashwechat extends Model
         }
 
     }
+
     function get_client_ip()
     {
         if ($_SERVER['REMOTE_ADDR']) {

+ 1 - 1
application/api/model/Logistics.php

@@ -19,7 +19,7 @@ class Logistics extends Model
 
         if($result['error_code'] == 0){//查询成功
             $list = $result['result']['list'];
-            return json(['data' => $result['result'],'order' => $order,'msg' => '', 'code' => 200]);
+            return json(['data' => $list,'order' => $order,'msg' => '', 'code' => 200]);
         }else{
             echo "获取失败,原因:".$result['reason'];
             return json(['msg' => $result['reason'], 'data' => '', 'code' => 100]);

+ 4 - 0
application/api/model/OrderCommodityModel.php

@@ -10,4 +10,8 @@ class OrderCommodityModel extends Model
     {
         return $this->belongsTo('order','o_id','o_id');
     }
+    public function Commodity()
+    {
+        return $this->belongsTo('CommodityModel','c_id','c_id');
+    }
 }

+ 157 - 26
application/api/model/OrderModel.php

@@ -3,12 +3,14 @@
 namespace app\api\model;
 
 use app\common\lib\WxPay;
+use think\Cache;
 use think\Db;
 use think\Model;
 
 class OrderModel extends Model
 {
     protected $name = 'order';
+    protected $resultSetType = 'collection';
 
     /*
      * 用户余额支付
@@ -16,17 +18,20 @@ class OrderModel extends Model
     public function userMoneyPay($params)
     {
         $userInfo = UsersModel::where('user_id', $params['user_id'])->find();
-        if ($userInfo['user_user_paypwd'] != $params['user_paypwd']) {
+        if ($userInfo['is_setpaypwd'] == 0) {
+            return json(['code' => 90, 'msg' => '还未设置支付密码', 'data' => []]);
+        }
+        if ($userInfo['user_paypwd'] != $params['user_paypwd']) {
             return json(['code' => 100, 'msg' => '支付密码不正确', 'data' => '']);
         }
         if (!$userInfo) {
             return json(['code' => 100, 'msg' => '网络错误', 'data' => '']);
         }
         //对照金额书否正确的
-        $isMoney = Db::name('order_pre')->where('pre_id', $params['pre_id'])->where('money', $params['money'])->find();
-        if (!$isMoney) {
-            return json(['code' => 100, 'msg' => '金额不对', 'data' => '']);
-        }
+//        $isMoney = Db::name('order_pre')->where('pre_id', $params['pre_id'])->where('money', $params['money'])->find();
+//        if (!$isMoney) {
+//            return json(['code' => 100, 'msg' => '金额不对', 'data' => '']);
+//        }
         if ($userInfo['user_money'] < $params['money']) {
             return json(['code' => 100, 'msg' => '您的余额不足', 'data' => '']);
         }
@@ -89,7 +94,7 @@ class OrderModel extends Model
                 'p_name'     => $v['p_name'],
                 'color'      => $v['color'],
                 'buy_number' => $v['buy_number'],
-                'c_vipprice' => $v['c_vipprice'],
+                'c_vipprice' => $v['money'],
                 'c_freight'  => $v['c_freight'],
                 'o_id'       => $addOrderId,
             );
@@ -112,8 +117,11 @@ class OrderModel extends Model
         //订单地址添加
         $add_order_address = Db::name('order_address')->insert($order_address);
         if ($add_order_address) {
+            //用户白豆增加
+            Db::name('users')->where('user_id', $params['user_id'])->setInc('user_whitebean', $whitebean);
             return json(['code' => 200, 'msg' => '下单成功', 'data' => $addOrderId]);
         } else {
+            Db::name('order')->where('o_id', $addOrderId)->delete();
             return json(['code' => 200, 'msg' => '下单失败', 'data' => $addOrderId]);
         }
     }
@@ -125,13 +133,13 @@ class OrderModel extends Model
     {
         $userInfo = UsersModel::where('user_id', $params['user_id'])->find();
         if (!$userInfo) {
-            return json(['code' => 100, 'msg' => '网络错误', 'data' => '']);
+            return json(['code' => 100, 'msg' => '网络错误11', 'data' => '']);
         }
         //对照金额书否正确的
-        $isMoney = Db::name('order_pre')->where('pre_id', $params['pre_id'])->where('money', $params['money'])->find();
-        if (!$isMoney) {
-            return json(['code' => 100, 'msg' => '金额不对', 'data' => '']);
-        }
+//        $isMoney = Db::name('order_pre')->where('pre_id', $params['pre_id'])->where('money', $params['money'])->find();
+//        if (!$isMoney) {
+//            return json(['code' => 100, 'msg' => '金额不对', 'data' => '']);
+//        }
         //创建订单信息
         $orderdata = array(
             'user_id'     => $params['user_id'],
@@ -164,16 +172,16 @@ class OrderModel extends Model
                 'p_name'     => $v['p_name'],
                 'color'      => $v['color'],
                 'buy_number' => $v['buy_number'],
-                'c_vipprice' => $v['c_vipprice'],
+                'c_vipprice' => $v['money'],  // 颜色商品的价格
                 'c_freight'  => $v['c_freight'],
                 'o_id'       => $addOrderId,
             );
             //循环插入订单商品信息
             $add_order_commodity = Db::name('order_commodity')->insert($order_commodity_data);
         }
-        if (!$add_order_commodity) {
-            return json(['code' => 100, 'msg' => '网络错误', 'data' => '']);
-        }
+//        if (!$add_order_commodity) {
+//            return json(['code' => 100, 'msg' => '网络错误22', 'data' => '']);
+//        }
         //创建地址信息
         $address = Address::where('a_id', $params['a_id'])->find();
         $order_address = array(
@@ -192,14 +200,28 @@ class OrderModel extends Model
         //获取微信pre_id
         $wxpay = new WxPay();
         $body = "商品支付";
-        $total_fee = $params['money'];
+        //$total_fee = $params['money'] * 100;
+        $total_fee = 1;
         $out_trade_no = $params['number'];
-        $notify_url = config('site.httpurl') . 'api/order/order_notify';
+        $notify_url = config('site.httpurl') . '/api/order/order_notify';
         $res = $wxpay->getPrePayOrder($body, $out_trade_no, $total_fee, $notify_url);
         if ($res['return_code'] == "SUCCESS") {
             if ($res['return_msg'] == 'OK') {
-                $result['prepay_id'] = $res['prepay_id'];
+                $result['params'] = $wxpay->getOrder($res['prepay_id']);
                 $result['o_id'] = $addOrderId;
+                $wechatinfo = array(
+                    "appid"     => $result['params']['appid'],
+                    "noncestr"  => $result['params']['noncestr'],
+                    "package"   => $result['params']['package'],
+                    "partnerid" => $result['params']['partnerid'],
+                    "prepayid"  => $result['params']['prepayid'],
+                    "timestamp" => $result['params']['timestamp'],
+                    "sign"      => $result['params']['sign'],
+                    "o_id"      => $result['o_id'],
+                );
+                Cache::set('wechat', $result);
+                // 插入拉取微信的支付的信息表
+                $add = Db::name('order_wechatpay')->insert($wechatinfo);
                 return json(['data' => $result, 'msg' => '', 'code' => 200]);
             } else {
                 return json(['data' => [], 'msg' => '拉取失败', 'code' => 100]);
@@ -218,57 +240,165 @@ class OrderModel extends Model
         //全部订单
         $data = $this->with(['OrderCommodityModel', 'OrderAddress'])
             ->where('user_id', $user_id)
-            ->select();
+            ->order('o_id desc')
+            ->select()->toArray();
+
         if (!$data) {
             $data = [];
+        } else {
+            foreach ($data as &$v) {
+                foreach ($v['order_commodity_model'] as &$n) {
+                    $commodity = CommodityModel::where('c_id', $n['c_id'])->field('c_name')->find();
+                    if (!$commodity) {
+                        $n['c_name'] = '已下架商品';
+                    } else {
+                        $n['c_name'] = $commodity['c_name'];
+                    }
+                    $n['c_money'] = $n['c_vipprice'] * $n['buy_number'];  // c_vipprice存的是颜色商品的价格,而不是商品的初始价格
+                    $n['money'] = $n['c_vipprice'] * $n['buy_number'] + $n['c_freight'];
+                    $n['freight'] = $n['c_freight'] * $n['buy_number'];
+                }
+            }
         }
         //待支付订单
-        $data1 = $this->with(['OrderCommodityModel', 'OrderAddress'])
+        $data1 = $this->with(['OrderCommodityModel' => function ($query) {
+            $query->with('Commodity');
+        }, 'OrderAddress'])
             ->where('state', 1)
             ->where('user_id', $user_id)
-            ->select();
+            ->order('o_id desc')
+            ->select()->toArray();
         if (!$data1) {
             $data1 = [];
+        } else {
+            foreach ($data1 as &$v) {
+                foreach ($v['order_commodity_model'] as &$n) {
+                    $commodity = CommodityModel::where('c_id', $n['c_id'])->field('c_name')->find();
+                    if (!$commodity) {
+                        $n['c_name'] = '已下架商品';
+                    } else {
+                        $n['c_name'] = $commodity['c_name'];
+                    }
+                    $n['c_money'] = $n['c_vipprice'] * $n['buy_number'];
+                    $n['money'] = $n['c_vipprice'] * $n['buy_number'] + $n['c_freight'];
+                    $n['freight'] = $n['c_freight'] * $n['buy_number'];
+                }
+            }
         }
         //待发货订单
         $data2 = $this->with(['OrderCommodityModel', 'OrderAddress'])
             ->where('state', 2)
             ->where('user_id', $user_id)
-            ->select();
+            ->order('o_id desc')
+            ->select()->toArray();
         if (!$data2) {
             $data2 = [];
+        } else {
+            foreach ($data2 as &$v) {
+                foreach ($v['order_commodity_model'] as &$n) {
+                    $commodity = CommodityModel::where('c_id', $n['c_id'])->field('c_name')->find();
+                    if (!$commodity) {
+                        $n['c_name'] = '已下架商品';
+                    } else {
+                        $n['c_name'] = $commodity['c_name'];
+                    }
+                    $n['c_money'] = $n['c_vipprice'] * $n['buy_number'];
+                    $n['money'] = $n['c_vipprice'] * $n['buy_number'] + $n['c_freight'];
+                    $n['freight'] = $n['c_freight'] * $n['buy_number'];
+                }
+            }
         }
         //待收货订单
         $data3 = $this->with(['OrderCommodityModel', 'OrderAddress'])
             ->where('state', 3)
             ->where('user_id', $user_id)
-            ->select();
+            ->order('o_id desc')
+            ->select()->toArray();
         if (!$data3) {
             $data3 = [];
+        } else {
+            foreach ($data3 as &$v) {
+                foreach ($v['order_commodity_model'] as &$n) {
+                    $commodity = CommodityModel::where('c_id', $n['c_id'])->field('c_name')->find();
+                    if (!$commodity) {
+                        $n['c_name'] = '已下架商品';
+                    } else {
+                        $n['c_name'] = $commodity['c_name'];
+                    }
+                    $n['c_money'] = $n['c_vipprice'] * $n['buy_number'];
+                    $n['money'] = $n['c_vipprice'] * $n['buy_number'] + $n['c_freight'];
+                    $n['freight'] = $n['c_freight'] * $n['buy_number'];
+                }
+            }
         }
         //订单取消
         $data5 = $this->with(['OrderCommodityModel', 'OrderAddress'])
             ->where('state', 5)
             ->where('user_id', $user_id)
-            ->select();
+            ->order('o_id desc')
+            ->select()->toArray();
         if (!$data5) {
             $data5 = [];
+        } else {
+            foreach ($data5 as &$v) {
+                foreach ($v['order_commodity_model'] as &$n) {
+                    $commodity = CommodityModel::where('c_id', $n['c_id'])->field('c_name')->find();
+                    if (!$commodity) {
+                        $n['c_name'] = '已下架商品';
+                    } else {
+                        $n['c_name'] = $commodity['c_name'];
+                    }
+                    $n['c_money'] = $n['c_vipprice'] * $n['buy_number'];
+                    $n['money'] = $n['c_vipprice'] * $n['buy_number'] + $n['c_freight'];
+                    $n['freight'] = $n['c_freight'] * $n['buy_number'];
+                }
+            }
         }
         //已完成订单
         $data6 = $this->with(['OrderCommodityModel', 'OrderAddress'])
             ->where('state', 6)
             ->where('user_id', $user_id)
-            ->select();
+            ->order('o_id desc')
+            ->select()->toArray();
         if (!$data6) {
             $data6 = [];
+        } else {
+            foreach ($data6 as &$v) {
+                foreach ($v['order_commodity_model'] as &$n) {
+                    $commodity = CommodityModel::where('c_id', $n['c_id'])->field('c_name')->find();
+                    if (!$commodity) {
+                        $n['c_name'] = '已下架商品';
+                    } else {
+                        $n['c_name'] = $commodity['c_name'];
+                    }
+                    $n['c_money'] = $n['c_vipprice'] * $n['buy_number'];
+                    $n['money'] = $n['c_vipprice'] * $n['buy_number'] + $n['c_freight'];
+                    $n['freight'] = $n['c_freight'] * $n['buy_number'];
+                }
+            }
         }
         //退款售后
         $data4 = $this->with(['OrderCommodityModel', 'OrderAddress'])
             ->where('state', 4)
             ->where('user_id', $user_id)
-            ->select();
+            ->order('o_id desc')
+            ->select()->toArray();
         if (!$data4) {
             $data4 = [];
+        } else {
+            foreach ($data4 as &$v) {
+                foreach ($v['order_commodity_model'] as &$n) {
+                    $commodity = CommodityModel::where('c_id', $n['c_id'])->field('c_name')->find();
+                    if (!$commodity) {
+                        $n['c_name'] = '已下架商品';
+                    } else {
+                        $n['c_name'] = $commodity['c_name'];
+                    }
+                    $n['c_money'] = $n['c_vipprice'] * $n['buy_number'];
+                    $n['money'] = $n['c_vipprice'] * $n['buy_number'] + $n['c_freight'];
+                    $n['freight'] = $n['c_freight'] * $n['buy_number'];
+                }
+            }
         }
         return json(['code' => 200, 'msg' => '', 'allorder' => $data, 'daizhifu' => $data1, 'daifahuo' => $data2, 'daishouhuo' => $data3, 'quxiao' => $data5, 'yiwancheng' => $data6, 'tuikuan' => $data4]);
     }
@@ -282,6 +412,7 @@ class OrderModel extends Model
     {
         return $this->hasOne('OrderAddress', 'o_id', 'o_id');
     }
+
     public function Torder()
     {
         return $this->hasOne('Torder', 'o_id', 'o_id');

+ 4 - 4
application/common/lib/Promote.php

@@ -27,16 +27,16 @@ class Promote
             $myBossInvVipUserNum = UsersModel::where('user_id', $myRecUserId)->value('user_vip_count');
 
             if ($myBossInvVipUserNum == 5 && $myBossInvUserNum == 50) {
-                $upd = UsersModel::where('user_id', $myRecUserId)->update(['user_level' => 3]);
+                $upd = UsersModel::where('user_id', $myRecUserId)->update(['user_level' => 2]);
             }
             if ($myBossInvVipUserNum == 20 && $myBossInvUserNum == 300) {
-                $upd = UsersModel::where('user_id', $myRecUserId)->update(['user_level' => 4]);
+                $upd = UsersModel::where('user_id', $myRecUserId)->update(['user_level' => 3]);
             }
             if ($myBossInvVipUserNum == 35 && $myBossInvUserNum == 700) {
-                $upd = UsersModel::where('user_id', $myRecUserId)->update(['user_level' => 5]);
+                $upd = UsersModel::where('user_id', $myRecUserId)->update(['user_level' => 4]);
             }
             if ($myBossInvVipUserNum == 50 && $myBossInvUserNum == 1300) {
-                $upd = UsersModel::where('user_id', $myRecUserId)->update(['user_level' => 6]);
+                $upd = UsersModel::where('user_id', $myRecUserId)->update(['user_level' => 5]);
             }
             return true;
         }

+ 50 - 0
public/assets/js/backend/agreemen/setbean.js

@@ -0,0 +1,50 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'agreemen/setbean/index' + location.search,
+                    add_url: 'agreemen/setbean/add',
+                    edit_url: 'agreemen/setbean/edit',
+                    //del_url: 'agreemen/setbean/del',
+                    multi_url: 'agreemen/setbean/multi',
+                    table: 'setbean',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'b_id',
+                sortName: 'b_id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'b_id', title: __('B_id')},
+                        {field: 'num', title: __('Num')},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});

+ 58 - 0
public/assets/js/backend/cash/cashlog.js

@@ -0,0 +1,58 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'cash/cashlog/index' + location.search,
+                    add_url: 'cash/cashlog/add',
+                   // edit_url: 'cash/cashlog/edit',
+                    del_url: 'cash/cashlog/del',
+                    multi_url: 'cash/cashlog/multi',
+                    table: 'cash_log',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 't_id',
+                sortName: 't_id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 't_id', title: __('T_id')},
+                        {field: 'users.user_nickname', title: __('Users.user_nickname')},
+                        {field: 'users.user_tel', title: __('Users.user_tel')},
+                        {field: 'users.user_avatar', title: __('Users.user_avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image},
+                        {field: 'money', title: __('提现金额'), operate:'BETWEEN'},
+                        {field: 'state', title: __('状态')},
+                        {field: 'create_time', title: __('Create_time')},
+                        {field: 'number', title: __('Number')},
+                        {field: 'reason', title: __('Reason')},
+                        {field: 'admin_look', title: __('Admin_look')},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});

+ 52 - 0
public/assets/js/backend/edition.js

@@ -0,0 +1,52 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'edition/index' + location.search,
+                    add_url: 'edition/add',
+                    edit_url: 'edition/edit',
+                    del_url: 'edition/del',
+                    multi_url: 'edition/multi',
+                    table: 'edition',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'e_id',
+                sortName: 'e_id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'e_id', title: __('E_id')},
+                        {field: 'edition', title: __('Edition')},
+                        {field: 'url', title: __('Url')},
+                        {field: 'erweima_image', title: __('Erweima_image'), events: Table.api.events.image, formatter: Table.api.formatter.image},
+                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                    ]
+                ]
+            });
+
+            // 为表格绑定事件
+            Table.api.bindevent(table);
+        },
+        add: function () {
+            Controller.api.bindevent();
+        },
+        edit: function () {
+            Controller.api.bindevent();
+        },
+        api: {
+            bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
+            }
+        }
+    };
+    return Controller;
+});

+ 43 - 9
public/assets/js/backend/users/users.js

@@ -27,15 +27,49 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'user_id', title: __('User_id')},
                         {field: 'user_nickname', title: __('User_nickname')},
                         {field: 'user_tel', title: __('User_tel')},
-                        {field: 'user_avatar', title: __('User_avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image},
-                        {field: 'user_level', title: __('等级'),operate: false, formatter:Table.api.formatter.status, searchList:{1: '普通用户', 2: '店长会员', 3: '经理会员', 4: '总监会员 ', 5 : '董事会员' }},
-                        {field: 'user_money', title: __('User_money'), operate:'BETWEEN'},
-                        {field: 'user_redbean', title: __('User_redbean'), operate:'BETWEEN'},
-                        {field: 'user_whitebean', title: __('User_whitebean'), operate:'BETWEEN'},
-                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'create_time', formatter: Table.api.formatter.datetime},
-                        {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'update_time', formatter: Table.api.formatter.datetime},
-                        {field: 'status_switch', title: __('状态'), searchList: {1:__('启用'),0:__('禁用')}, formatter: Table.api.formatter.toggle},
-                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
+                        {
+                            field: 'user_avatar',
+                            title: __('User_avatar'),
+                            events: Table.api.events.image,
+                            formatter: Table.api.formatter.image
+                        },
+                        {
+                            field: 'user_level',
+                            title: __('等级'),
+                            operate: false,
+                            formatter: Table.api.formatter.status,
+                            searchList: {1: '普通用户', 2: '店长会员', 3: '经理会员', 4: '总监会员 ', 5: '董事会员', 6: 'vip会员'}
+                        },
+                        {field: 'user_money', title: __('User_money'), operate: 'BETWEEN'},
+                        {field: 'user_redbean', title: __('User_redbean'), operate: 'BETWEEN'},
+                        {field: 'user_whitebean', title: __('User_whitebean'), operate: 'BETWEEN'},
+                        {
+                            field: 'create_time',
+                            title: __('Create_time'),
+                            operate: 'RANGE',
+                            addclass: 'create_time',
+                            formatter: Table.api.formatter.datetime
+                        },
+                        {
+                            field: 'update_time',
+                            title: __('Update_time'),
+                            operate: 'RANGE',
+                            addclass: 'update_time',
+                            formatter: Table.api.formatter.datetime
+                        },
+                        {
+                            field: 'status_switch',
+                            title: __('状态'),
+                            searchList: {1: __('启用'), 0: __('禁用')},
+                            formatter: Table.api.formatter.toggle
+                        },
+                        {
+                            field: 'operate',
+                            title: __('Operate'),
+                            table: table,
+                            events: Table.api.events.operate,
+                            formatter: Table.api.formatter.operate
+                        }
                     ]
                 ]
             });

BIN
public/uploads/logo.jpg


BIN
public/uploads/logo.png