18315626215 5 anos atrás
pai
commit
31e67b82b5
92 arquivos alterados com 3910 adições e 678 exclusões
  1. 76 0
      application/admin/controller/agreemen/Privacy.php
  2. 154 0
      application/admin/controller/order/Order.php
  3. 89 0
      application/admin/controller/order/Torder.php
  4. 5 0
      application/admin/lang/zh-cn/agreemen/privacy.php
  5. 25 0
      application/admin/lang/zh-cn/order/order.php
  6. 25 0
      application/admin/lang/zh-cn/order/torder.php
  7. 40 0
      application/admin/model/Equity.php
  8. 17 0
      application/admin/model/OrderAddress.php
  9. 40 0
      application/admin/model/QueueConfig.php
  10. 36 0
      application/admin/model/QueueModel.php
  11. 46 0
      application/admin/model/RechargeModel.php
  12. 12 0
      application/admin/model/Users.php
  13. 32 0
      application/admin/model/Viplog.php
  14. 40 0
      application/admin/model/agreemen/Agreem.php
  15. 40 0
      application/admin/model/agreemen/Courstomer.php
  16. 40 0
      application/admin/model/agreemen/Coustomer.php
  17. 40 0
      application/admin/model/agreemen/Privacy.php
  18. 40 0
      application/admin/model/agreemen/Querstion.php
  19. 40 0
      application/admin/model/chart/Chart.php
  20. 40 0
      application/admin/model/commodity/Commodity.php
  21. 40 0
      application/admin/model/ctype/Ctype.php
  22. 92 0
      application/admin/model/order/Order.php
  23. 98 0
      application/admin/model/order/Torder.php
  24. 4 0
      application/admin/model/users/Users.php
  25. 2 2
      application/admin/view/agreemen/courstomer/add.html
  26. 2 2
      application/admin/view/agreemen/courstomer/edit.html
  27. 1 1
      application/admin/view/agreemen/courstomer/index.html
  28. 16 0
      application/admin/view/agreemen/privacy/add.html
  29. 16 0
      application/admin/view/agreemen/privacy/edit.html
  30. 35 0
      application/admin/view/agreemen/privacy/index.html
  31. 2 2
      application/admin/view/commodity/commodity/add.html
  32. 2 2
      application/admin/view/commodity/commodity/edit.html
  33. 100 0
      application/admin/view/order/order/add.html
  34. 104 0
      application/admin/view/order/order/edit.html
  35. 35 0
      application/admin/view/order/order/index.html
  36. 41 0
      application/admin/view/order/order/ordercommodityinfo.html
  37. 100 0
      application/admin/view/order/torder/add.html
  38. 100 0
      application/admin/view/order/torder/edit.html
  39. 35 0
      application/admin/view/order/torder/index.html
  40. 42 0
      application/admin/view/order/torder/torderinfo.html
  41. 7 5
      application/api/controller/Buycar.php
  42. 23 4
      application/api/controller/Commodity.php
  43. 141 141
      application/api/controller/Common.php
  44. 72 72
      application/api/controller/Demo.php
  45. 101 101
      application/api/controller/Ems.php
  46. 58 0
      application/api/controller/Forgetpwd.php
  47. 12 0
      application/api/controller/Index.php
  48. 174 21
      application/api/controller/Login.php
  49. 229 47
      application/api/controller/Order.php
  50. 54 0
      application/api/controller/Plan.php
  51. 151 60
      application/api/controller/Register.php
  52. 148 0
      application/api/controller/Search.php
  53. 101 101
      application/api/controller/Sms.php
  54. 41 41
      application/api/controller/Token.php
  55. 143 37
      application/api/controller/User.php
  56. 121 0
      application/api/controller/Wechatwebopenid.php
  57. 39 8
      application/api/model/Cashwechat.php
  58. 97 0
      application/api/model/Logistics.php
  59. 116 5
      application/api/model/OrderModel.php
  60. 9 0
      application/api/model/SearchModel.php
  61. 13 0
      application/api/model/Torder.php
  62. 17 0
      application/api/validate/Users.php
  63. 11 11
      extend/alipay/aop/request/AftAifinFireeyeOcrImageQueryRequest.php
  64. 11 11
      extend/alipay/aop/request/AftFinsecureRiskplusSecurityPolicyQueryRequest.php
  65. 21 0
      public/assets/js/backend-init.js
  66. 2 2
      public/assets/js/backend/agreemen/courstomer.js
  67. 2 2
      public/assets/js/backend/agreemen/coustomer.js
  68. 50 0
      public/assets/js/backend/agreemen/privacy.js
  69. 89 0
      public/assets/js/backend/order/order.js
  70. 113 0
      public/assets/js/backend/order/torder.js
  71. BIN
      public/uploads/20191211/19449656a3c60c225cd10ef46ecec9ac.jpg
  72. BIN
      public/uploads/20191211/4aef00e619b3f8d90ddd40e949353cd0.jpg
  73. BIN
      public/uploads/20191211/5032d1b23c4f1897abd7047c01d6325e.jpg
  74. BIN
      public/uploads/20191214/19449656a3c60c225cd10ef46ecec9ac.jpg
  75. BIN
      public/uploads/20191214/4aef00e619b3f8d90ddd40e949353cd0.jpg
  76. BIN
      public/uploads/20191214/5032d1b23c4f1897abd7047c01d6325e.jpg
  77. BIN
      public/uploads/20191214/6aefece60c8256c50a65c0c7e6c77001.jpg
  78. BIN
      public/uploads/20191214/8370dbcc8ce9c7a4a239439b9e8367cf.jpg
  79. BIN
      public/uploads/20191218/249708bad4ded576fbdd20eac028b87d.jpg
  80. BIN
      public/uploads/20191218/4aef00e619b3f8d90ddd40e949353cd0.jpg
  81. BIN
      public/uploads/20191218/5032d1b23c4f1897abd7047c01d6325e.jpg
  82. BIN
      public/uploads/20191218/8370dbcc8ce9c7a4a239439b9e8367cf.jpg
  83. BIN
      public/uploads/20191221/4aef00e619b3f8d90ddd40e949353cd0.jpg
  84. BIN
      public/uploads/20191230/19449656a3c60c225cd10ef46ecec9ac.jpg
  85. BIN
      public/uploads/20191230/249708bad4ded576fbdd20eac028b87d.jpg
  86. BIN
      public/uploads/20191230/45f68e7a5588b7b592eb1d31c36a5d0a.jpg
  87. BIN
      public/uploads/20191230/4aef00e619b3f8d90ddd40e949353cd0.jpg
  88. BIN
      public/uploads/20191230/5032d1b23c4f1897abd7047c01d6325e.jpg
  89. BIN
      public/uploads/20191230/62bdfee64a503407c6e6181a6e759b45.jpg
  90. BIN
      public/uploads/20191230/6aefece60c8256c50a65c0c7e6c77001.jpg
  91. BIN
      public/uploads/20191230/8370dbcc8ce9c7a4a239439b9e8367cf.jpg
  92. BIN
      public/uploads/logo.jpg

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

@@ -0,0 +1,76 @@
+<?php
+
+namespace app\admin\controller\agreemen;
+
+use app\common\controller\Backend;
+
+/**
+ * 隐私协议管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Privacy extends Backend
+{
+    
+    /**
+     * Privacy模型对象
+     * @var \app\admin\model\agreemen\Privacy
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\agreemen\Privacy;
+
+    }
+    
+    /**
+     * 默认生成的控制器所继承的父类中有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(['p_id','content']);
+                
+            }
+            $list = collection($list)->toArray();
+            $result = array("total" => $total, "rows" => $list);
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+}

+ 154 - 0
application/admin/controller/order/Order.php

@@ -0,0 +1,154 @@
+<?php
+
+namespace app\admin\controller\order;
+
+use app\admin\model\commodity\Commodity;
+use app\common\controller\Backend;
+use think\Db;
+use think\Exception;
+use think\exception\PDOException;
+use think\exception\ValidateException;
+
+/**
+ * 订单管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Order extends Backend
+{
+    
+    /**
+     * Order模型对象
+     * @var \app\admin\model\order\Order
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\order\Order;
+
+    }
+    
+    /**
+     * 默认生成的控制器所继承的父类中有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(['orderaddress','users'])
+                    ->where($where)
+                    ->where('state', '>' ,1)
+                    ->where('state', 'neq' ,4)
+                    ->order($sort, $order)
+                    ->count();
+
+            $list = $this->model
+                    ->with(['orderaddress','users'])
+                    ->where($where)
+                    ->where('state', '>' ,1)
+                    ->where('state', 'neq' ,4)
+                    ->order($sort, $order)
+                    ->limit($offset, $limit)
+                    ->select();
+
+            foreach ($list as $row) {
+                $row->visible(['o_id','money','freight','number','create_time','pay_time','whitebeon','state','wuliu_number','wuliu_company','type']);
+                $row->visible(['orderaddress']);
+				$row->getRelation('orderaddress')->visible(['a_name','a_tel','a_city','a_area']);
+				$row->visible(['users']);
+				$row->getRelation('users')->visible(['user_nickname']);
+            }
+            $list = collection($list)->toArray();
+            $result = array("total" => $total, "rows" => $list);
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+    /**
+     * 编辑
+     */
+    public function edit($ids = null)
+    {
+        $row = $this->model->get($ids);
+        if (!$row) {
+            $this->error(__('No Results were found'));
+        }
+        $adminIds = $this->getDataLimitAdminIds();
+        if (is_array($adminIds)) {
+            if (!in_array($row[$this->dataLimitField], $adminIds)) {
+                $this->error(__('You have no permission'));
+            }
+        }
+        if ($this->request->isPost()) {
+            $params = $this->request->post("row/a");
+            $company = Db::name('company')->where('no',$params['wuliu_com'])->find();
+            $params['wuliu_company'] = $company['com'];
+            $params['state'] = 3;
+            $params['f_time'] = date("Y-m-d H:i:s", time());
+            if ($params) {
+                $params = $this->preExcludeFields($params);
+                $result = false;
+                Db::startTrans();
+                try {
+                    //是否采用模型验证
+                    if ($this->modelValidate) {
+                        $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+                        $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
+                        $row->validateFailException(true)->validate($validate);
+                    }
+                    $result = $row->allowField(true)->save($params);
+                    Db::commit();
+                } catch (ValidateException $e) {
+                    Db::rollback();
+                    $this->error($e->getMessage());
+                } catch (PDOException $e) {
+                    Db::rollback();
+                    $this->error($e->getMessage());
+                } catch (Exception $e) {
+                    Db::rollback();
+                    $this->error($e->getMessage());
+                }
+                if ($result !== false) {
+                    $this->success();
+                } else {
+                    $this->error(__('No rows were updated'));
+                }
+            }
+            $this->error(__('Parameter %s can not be empty', ''));
+        }
+        $this->view->assign("row", $row);
+        $company = Db::name('company')->select();
+        return $this->view->fetch('edit', ['company' => $company]);
+    }
+    // 订单商品详情
+    public function orderCommodityInfo($ids)
+    {
+        // 查出订单商品表的商品信息
+        $c_id = Db::name('order_commodity')->where('o_id',$ids)->select();
+        foreach ($c_id as &$v) {
+            $v['commodity'] = Commodity::where('c_id',$v['c_id'])->find();
+        }
+        return $this->fetch('ordercommodityinfo', ['data' => $c_id]);
+    }
+}

+ 89 - 0
application/admin/controller/order/Torder.php

@@ -0,0 +1,89 @@
+<?php
+
+namespace app\admin\controller\order;
+
+use app\common\controller\Backend;
+use think\Db;
+
+/**
+ * 订单管理
+ *
+ * @icon fa fa-circle-o
+ */
+class Torder extends Backend
+{
+    
+    /**
+     * Torder模型对象
+     * @var \app\admin\model\order\Torder
+     */
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = new \app\admin\model\order\Torder;
+
+    }
+    
+    /**
+     * 默认生成的控制器所继承的父类中有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(['orderaddress','users'])
+                    ->where($where)
+                    ->where('state',4)
+                    ->order($sort, $order)
+                    ->count();
+
+            $list = $this->model
+                    ->with(['orderaddress','users'])
+                    ->where($where)
+                    ->where('state',4)
+                    ->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']);
+				$row->getRelation('orderaddress')->visible(['a_name','a_tel','a_city','a_area']);
+				$row->visible(['users']);
+				$row->getRelation('users')->visible(['user_nickname']);
+            }
+            $list = collection($list)->toArray();
+            $result = array("total" => $total, "rows" => $list);
+
+            return json($result);
+        }
+        return $this->view->fetch();
+    }
+    //查看退款详情
+    public function torderinfo($ids)
+    {
+        $data = Db::name('t_order')->where('o_id',$ids)->find();
+        $data['images'] = explode(',',$data['images']);
+        return $this->fetch('torderinfo', ['data' => $data]);
+    }
+}

+ 5 - 0
application/admin/lang/zh-cn/agreemen/privacy.php

@@ -0,0 +1,5 @@
+<?php
+
+return [
+    'Content' => '隐私协议表'
+];

+ 25 - 0
application/admin/lang/zh-cn/order/order.php

@@ -0,0 +1,25 @@
+<?php
+
+return [
+    'O_id'                => '订单',
+    'User_id'             => '用户ID',
+    'Money'               => '总价格',
+    'Freight'             => '运费',
+    'Number'              => '订单编号',
+    'Create_time'         => '订单创建时间',
+    'Pay_time'            => '订单支付时间',
+    'F_time'              => '发货时间',
+    'Whitebeon'           => '奖励的白豆',
+    'State'               => '状态1待付款 2待发货 3待收货 4退款售后 5订单已取消  6交易成功 ',
+    'Tuikuan_state'       => '1退款成功2退款失败3退款中',
+    'Wuliu_number'        => '物流编号',
+    'Wuliu_company'       => '物流公司',
+    'Wuliu_com'           => '快公司编号',
+    'Type'                => '0余额支付1微信支付',
+    'State_save'          => '退款时的订单状态',
+    'Orderaddress.a_name' => '收货人姓名',
+    'Orderaddress.a_tel'  => '收货手机号',
+    'Orderaddress.a_city' => '城市',
+    'Orderaddress.a_area' => '详细地址',
+    'Users.user_nickname' => '姓名'
+];

+ 25 - 0
application/admin/lang/zh-cn/order/torder.php

@@ -0,0 +1,25 @@
+<?php
+
+return [
+    'O_id'                => '订单',
+    'User_id'             => '用户ID',
+    'Money'               => '总价格',
+    'Freight'             => '运费',
+    'Number'              => '订单编号',
+    'Create_time'         => '订单创建时间',
+    'Pay_time'            => '订单支付时间',
+    'F_time'              => '发货时间',
+    'Whitebeon'           => '奖励的白豆',
+    'State'               => '状态1待付款 2待发货 3待收货 4退款售后 5订单已取消  6交易成功 ',
+    'Tuikuan_state'       => '1退款成功2退款失败3退款中',
+    'Wuliu_number'        => '物流编号',
+    'Wuliu_company'       => '物流公司',
+    'Wuliu_com'           => '快公司编号',
+    'Type'                => '0余额支付1微信支付',
+    'State_save'          => '退款时的订单状态',
+    'Orderaddress.a_name' => '收货人姓名',
+    'Orderaddress.a_tel'  => '收货手机号',
+    'Orderaddress.a_city' => '城市',
+    'Orderaddress.a_area' => '详细地址',
+    'Users.user_nickname' => '姓名'
+];

+ 40 - 0
application/admin/model/Equity.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class Equity extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'member_equity';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+}

+ 17 - 0
application/admin/model/OrderAddress.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+class OrderAddress extends Model
+{
+    // 表名
+    protected $name = 'order_address';
+
+    public function order()
+    {
+        return $this->belongsTo('app\admin\model\order','o_id', 'o_id');
+    }
+
+}

+ 40 - 0
application/admin/model/QueueConfig.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class QueueConfig extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'queue_config';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+}

+ 36 - 0
application/admin/model/QueueModel.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class QueueModel extends Model
+{
+    // 表名
+    protected $name = 'queue_log';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+    public function getPayTypeAttr($value)
+    {
+        $status = ['1' => '余额', '2' => '微信', '3' => '支付宝'];
+        return $status[$value];
+    }
+    public function getPayStatusAttr($value)
+    {
+        $status = ['0' => '否', '1' => '是'];
+        return $status[$value];
+    }
+}

+ 46 - 0
application/admin/model/RechargeModel.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class RechargeModel extends Model
+{
+    // 表名
+    protected $name = 'recharge_log';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+    public function getIsDiscountAttr($value)
+    {
+        $status = ['0' => '否', '1' => '是'];
+        return $status[$value];
+    }
+    public function getPayStatusAttr($value)
+    {
+        $status = ['0' => '否', '1' => '是'];
+        return $status[$value];
+    }
+    public function getRechargeStatusAttr($value)
+    {
+        $status = ['0' => '充值失败', '1' => '充值中', '2' => '充值成功'];
+        return $status[$value];
+    }
+    public function getPayTypeAttr($value)
+    {
+        $status = ['1' => '微信', '2' => '支付宝'];
+        return $status[$value];
+    }
+}

+ 12 - 0
application/admin/model/Users.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace app\admin\model\order;
+
+use think\Model;
+
+class Users extends Model
+{
+    // 表名
+    protected $name = 'users';
+    
+}

+ 32 - 0
application/admin/model/Viplog.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace app\admin\model;
+
+use think\Model;
+
+
+class Viplog extends Model
+{
+    // 表名
+    protected $name = 'vip_buy_log';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+    public function getPayStatusAttr($value)
+    {
+        $status = ['0' => '未支付', '1' => '已支付'];
+        return $status[$value];
+    }
+
+}

+ 40 - 0
application/admin/model/agreemen/Agreem.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\admin\model\agreemen;
+
+use think\Model;
+
+
+class Agreem extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'agreement';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+}

+ 40 - 0
application/admin/model/agreemen/Courstomer.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\admin\model\agreemen;
+
+use think\Model;
+
+
+class Courstomer extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'coustomer';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+}

+ 40 - 0
application/admin/model/agreemen/Coustomer.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\admin\model\agreemen;
+
+use think\Model;
+
+
+class Coustomer extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'coustomer';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+}

+ 40 - 0
application/admin/model/agreemen/Privacy.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\admin\model\agreemen;
+
+use think\Model;
+
+
+class Privacy extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'privacy';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+}

+ 40 - 0
application/admin/model/agreemen/Querstion.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\admin\model\agreemen;
+
+use think\Model;
+
+
+class Querstion extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'question';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+}

+ 40 - 0
application/admin/model/chart/Chart.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\admin\model\chart;
+
+use think\Model;
+
+
+class Chart extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'chart';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+}

+ 40 - 0
application/admin/model/commodity/Commodity.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\admin\model\commodity;
+
+use think\Model;
+
+
+class Commodity extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'commodity';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+}

+ 40 - 0
application/admin/model/ctype/Ctype.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace app\admin\model\ctype;
+
+use think\Model;
+
+
+class Ctype extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'ctype';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+
+    ];
+    
+
+    
+
+
+
+
+
+
+
+}

+ 92 - 0
application/admin/model/order/Order.php

@@ -0,0 +1,92 @@
+<?php
+
+namespace app\admin\model\order;
+
+use think\Model;
+
+
+class Order extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'order';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'create_time_text',
+        'pay_time_text',
+        'f_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 = ['1' => '代付款',2 => '代发货', '3' => '待收货', '4' => '退款订单', '5' => "已取消]" , 6=> '已完成'];
+       return  $state[$value];
+    }
+    public function getTypeAttr($value)
+    {
+        $state = ['0' => '余额支付',1 => '微信支付'];
+        return  $state[$value];
+    }
+    public function getPayTimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['pay_time']) ? $data['pay_time'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+
+    public function getFTimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['f_time']) ? $data['f_time'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+    protected function setCreateTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+    protected function setPayTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+    protected function setFTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+
+    public function OrderAddress()
+    {
+        return $this->belongsTo('app\admin\model\OrderAddress', 'o_id', 'o_id', [], 'LEFT')->setEagerlyType(0);
+    }
+
+
+    public function users()
+    {
+        return $this->belongsTo('app\admin\model\users\Users', 'user_id', 'user_id', [], 'LEFT')->setEagerlyType(0);
+    }
+}

+ 98 - 0
application/admin/model/order/Torder.php

@@ -0,0 +1,98 @@
+<?php
+
+namespace app\admin\model\order;
+
+use think\Model;
+
+
+class Torder extends Model
+{
+
+    
+
+    
+
+    // 表名
+    protected $name = 'order';
+    
+    // 自动写入时间戳字段
+    protected $autoWriteTimestamp = false;
+
+    // 定义时间戳字段名
+    protected $createTime = false;
+    protected $updateTime = false;
+    protected $deleteTime = false;
+
+    // 追加属性
+    protected $append = [
+        'create_time_text',
+        'pay_time_text',
+        'f_time_text'
+    ];
+
+
+
+
+    public function getStateAttr($value)
+    {
+        $state = ['1' => '代付款',2 => '代发货', '3' => '待收货', '4' => '退款订单', '5' => "已取消]" , 6=> '已完成'];
+        return  $state[$value];
+    }
+    public function getTuikuanStateAttr($value)
+    {
+        $state = ['1' => '退款成功',2 => '退款失败', '3' => '退款中'];
+        return  $state[$value];
+    }
+    public function getTypeAttr($value)
+    {
+        $state = ['0' => '余额支付',1 => '微信支付'];
+        return  $state[$value];
+    }
+
+    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 getPayTimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['pay_time']) ? $data['pay_time'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+
+    public function getFTimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['f_time']) ? $data['f_time'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+    protected function setCreateTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+    protected function setPayTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+    protected function setFTimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
+
+
+    public function OrderAddress()
+    {
+        return $this->belongsTo('app\admin\model\OrderAddress', 'o_id', 'o_id', [], 'LEFT')->setEagerlyType(0);
+    }
+
+
+    public function users()
+    {
+        return $this->belongsTo('app\admin\model\users\Users', 'user_id', 'user_id', [], 'LEFT')->setEagerlyType(0);
+    }
+}

+ 4 - 0
application/admin/model/users/Users.php

@@ -57,5 +57,9 @@ class Users extends Model
         return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
     }
 
+    public function order()
+    {
+        return $this->belongsTo('app\admin\model\order','user_id','user_id');
+    }
 
 }

+ 2 - 2
application/admin/view/agreemen/courstomer/add.html

@@ -7,13 +7,13 @@
         </div>
     </div>
     <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('C_type')}:</label>
+        <label class="control-label col-xs-12 col-sm-2">电话:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-c_type" data-rule="required" class="form-control" name="row[c_type]" type="text">
         </div>
     </div>
     <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('C_number')}:</label>
+        <label class="control-label col-xs-12 col-sm-2">微信或QQ:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-c_number" data-rule="required" class="form-control" name="row[c_number]" type="text">
         </div>

+ 2 - 2
application/admin/view/agreemen/courstomer/edit.html

@@ -7,13 +7,13 @@
         </div>
     </div>
     <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('C_type')}:</label>
+        <label class="control-label col-xs-12 col-sm-2">电话:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-c_type" data-rule="required" class="form-control" name="row[c_type]" type="text" value="{$row.c_type|htmlentities}">
         </div>
     </div>
     <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('C_number')}:</label>
+        <label class="control-label col-xs-12 col-sm-2">qq或者微信:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-c_number" data-rule="required" class="form-control" name="row[c_number]" type="text" value="{$row.c_number|htmlentities}">
         </div>

+ 1 - 1
application/admin/view/agreemen/courstomer/index.html

@@ -7,7 +7,7 @@
                 <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/courstomer/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+<!--                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('agreemen/courstomer/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/courstomer/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/courstomer/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
                         <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('agreemen/courstomer/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>

+ 16 - 0
application/admin/view/agreemen/privacy/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">{:__('Content')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <textarea id="c-content" class="form-control editor" rows="5" name="row[content]" cols="50"></textarea>
+        </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/privacy/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">{:__('Content')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <textarea id="c-content" class="form-control editor" rows="5" name="row[content]" cols="50">{$row.content|htmlentities}</textarea>
+        </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/privacy/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/privacy/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/privacy/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/privacy/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('agreemen/privacy/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/privacy/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/privacy/edit')}" 
+                           data-operate-del="{:$auth->check('agreemen/privacy/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 2 - 2
application/admin/view/commodity/commodity/add.html

@@ -1,7 +1,7 @@
 <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">{:__('C_name')}:</label>
+        <label class="control-label col-xs-12 col-sm-2">商品关键字:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-c_name" data-rule="required" class="form-control" name="row[c_name]" type="text">
         </div>
@@ -15,7 +15,7 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('C_title_content')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <textarea id="c-c_title_content" data-rule="required" class="form-control editor" rows="5" name="row[c_title_content]" cols="50"></textarea>
+            <textarea id="c-c_title_content" data-rule="required" class="form-control" rows="5" name="row[c_title_content]" cols="50"></textarea>
         </div>
     </div>
     <div class="form-group">

+ 2 - 2
application/admin/view/commodity/commodity/edit.html

@@ -1,7 +1,7 @@
 <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">{:__('C_name')}:</label>
+        <label class="control-label col-xs-12 col-sm-2">商品关键字:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-c_name" data-rule="required" class="form-control" name="row[c_name]" type="text" value="{$row.c_name|htmlentities}">
         </div>
@@ -15,7 +15,7 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('C_title_content')}:</label>
         <div class="col-xs-12 col-sm-8">
-            <textarea id="c-c_title_content" data-rule="required" class="form-control editor" rows="5" name="row[c_title_content]" cols="50">{$row.c_title_content|htmlentities}</textarea>
+            <textarea id="c-c_title_content" data-rule="required" class="form-control" rows="5" name="row[c_title_content]" cols="50">{$row.c_title_content|htmlentities}</textarea>
         </div>
     </div>
 

+ 100 - 0
application/admin/view/order/order/add.html

@@ -0,0 +1,100 @@
+<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">{:__('Freight')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-freight" class="form-control" step="0.01" name="row[freight]" type="number">
+        </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="number">
+        </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" 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">{:__('Pay_time')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-pay_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[pay_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">{:__('F_time')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-f_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[f_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">{:__('Whitebeon')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-whitebeon" class="form-control" name="row[whitebeon]" 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">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Tuikuan_state')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-tuikuan_state" class="form-control" name="row[tuikuan_state]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Wuliu_number')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-wuliu_number" class="form-control" name="row[wuliu_number]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Wuliu_company')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-wuliu_company" class="form-control" name="row[wuliu_company]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Wuliu_com')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-wuliu_com" class="form-control" name="row[wuliu_com]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-type" class="form-control" name="row[type]" type="number">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('State_save')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-state_save" class="form-control" name="row[state_save]" type="number">
+        </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>

+ 104 - 0
application/admin/view/order/order/edit.html

@@ -0,0 +1,104 @@
+<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">{:__('Freight')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-freight" class="form-control" step="0.01" name="row[freight]" type="number" value="{$row.freight|htmlentities}">-->
+<!--        </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="number" value="{$row.number|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" 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">{:__('Pay_time')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-pay_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[pay_time]" type="text" value="{:$row.pay_time?datetime($row.pay_time):''}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('F_time')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-f_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[f_time]" type="text" value="{:$row.f_time?datetime($row.f_time):''}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Whitebeon')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-whitebeon" class="form-control" name="row[whitebeon]" type="number" value="{$row.whitebeon|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">{:__('Tuikuan_state')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-tuikuan_state" class="form-control" name="row[tuikuan_state]" type="number" value="{$row.tuikuan_state|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Wuliu_number')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-wuliu_number" class="form-control" name="row[wuliu_number]" type="text" value="{$row.wuliu_number|htmlentities}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Wuliu_company')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <select id="c-wuliu_company" class="form-control" name="row[wuliu_com]">
+                {volist name="company" id="company"}
+                <option value="{$company.no}" {if $company.no == $row.wuliu_com} selected {/if}>{$company.com}</option>
+                {/volist}
+            </select>
+        </div>
+    </div>
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Wuliu_com')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-wuliu_com" class="form-control" name="row[wuliu_com]" type="text" value="{$row.wuliu_com|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-type" class="form-control" name="row[type]" type="number" value="{$row.type|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('State_save')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-state_save" class="form-control" name="row[state_save]" type="number" value="{$row.state_save|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/order/order/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('order/order/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('order/order/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('order/order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('order/order/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('order/order/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('order/order/edit')}" 
+                           data-operate-del="{:$auth->check('order/order/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 41 - 0
application/admin/view/order/order/ordercommodityinfo.html

@@ -0,0 +1,41 @@
+{volist name="data" id="item" key ="k"}
+<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+    商品{$k}
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">商品名:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input  data-rule="required" class="form-control"  type="text" value="{$item['commodity']['c_name']}" readonly>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">颜色:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input  data-rule="required" class="form-control"  type="text" value="{$item.name}" readonly>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">规格:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input  data-rule="required" class="form-control"  type="text" value="{$item.p_name}" readonly>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">价格:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input  data-rule="required" class="form-control"  type="text" value="{$item.c_vipprice}" readonly>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">购买数量:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input  data-rule="required" class="form-control"  type="text" value="{$item.buy_number}" readonly>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">商品图片:</label>
+        <div class="col-xs-12 col-sm-8">
+            <img src="{$item.color}" data-tips-image  alt="点击查看大图" style="width: 80px;height: 80px">
+        </div>
+    </div>
+</form>
+{/volist}

+ 100 - 0
application/admin/view/order/torder/add.html

@@ -0,0 +1,100 @@
+<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">{:__('Freight')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-freight" class="form-control" step="0.01" name="row[freight]" type="number">
+        </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="number">
+        </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" 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">{:__('Pay_time')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-pay_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[pay_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">{:__('F_time')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-f_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[f_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">{:__('Whitebeon')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-whitebeon" class="form-control" name="row[whitebeon]" 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">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Tuikuan_state')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-tuikuan_state" class="form-control" name="row[tuikuan_state]" type="number" value="0">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Wuliu_number')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-wuliu_number" class="form-control" name="row[wuliu_number]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Wuliu_company')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-wuliu_company" class="form-control" name="row[wuliu_company]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Wuliu_com')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-wuliu_com" class="form-control" name="row[wuliu_com]" type="text">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-type" class="form-control" name="row[type]" type="number">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('State_save')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-state_save" class="form-control" name="row[state_save]" type="number">
+        </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>

+ 100 - 0
application/admin/view/order/torder/edit.html

@@ -0,0 +1,100 @@
+<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">{:__('Freight')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-freight" class="form-control" step="0.01" name="row[freight]" type="number" value="{$row.freight|htmlentities}">-->
+<!--        </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="number" value="{$row.number|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" 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">{:__('Pay_time')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-pay_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[pay_time]" type="text" value="{:$row.pay_time?datetime($row.pay_time):''}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('F_time')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-f_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[f_time]" type="text" value="{:$row.f_time?datetime($row.f_time):''}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Whitebeon')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-whitebeon" class="form-control" name="row[whitebeon]" type="number" value="{$row.whitebeon|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">{:__('Tuikuan_state')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-tuikuan_state" class="form-control" name="row[tuikuan_state]" type="number" value="{$row.tuikuan_state|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Wuliu_number')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-wuliu_number" class="form-control" name="row[wuliu_number]" type="text" value="{$row.wuliu_number|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Wuliu_company')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-wuliu_company" class="form-control" name="row[wuliu_company]" type="text" value="{$row.wuliu_company|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Wuliu_com')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-wuliu_com" class="form-control" name="row[wuliu_com]" type="text" value="{$row.wuliu_com|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-type" class="form-control" name="row[type]" type="number" value="{$row.type|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('State_save')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-state_save" class="form-control" name="row[state_save]" type="number" value="{$row.state_save|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/order/torder/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('order/torder/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('order/torder/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('order/torder/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
+                        <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('order/torder/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('order/torder/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('order/torder/edit')}" 
+                           data-operate-del="{:$auth->check('order/torder/del')}" 
+                           width="100%">
+                    </table>
+                </div>
+            </div>
+
+        </div>
+    </div>
+</div>

+ 42 - 0
application/admin/view/order/torder/torderinfo.html

@@ -0,0 +1,42 @@
+
+<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">商品名:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input  data-rule="required" class="form-control"  type="text" value="{$data.reason}" readonly>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">退款原因:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input  data-rule="required" class="form-control"  type="text" value="{$data.reason}" readonly>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">退款金额:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input  data-rule="required" class="form-control"  type="text" value="{$data.money}" readonly>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">文字说明:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input  data-rule="required" class="form-control"  type="text" value="{$data.content}" readonly>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">申请时间:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input  data-rule="required" class="form-control"  type="text" value="{$data.create_time}" readonly>
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">图片:</label>
+        <div class="col-xs-12 col-sm-8">
+            {volist name="$data.images" id="item"}
+            <img src="{$item}" data-tips-image  alt="点击查看大图" style="width: 80px;height: 80px">
+            {/volist}
+        </div>
+    </div>
+</form>

+ 7 - 5
application/api/controller/Buycar.php

@@ -31,8 +31,11 @@ class Buycar extends APi
         if (is_string($validata)) {
             return $this->result($validata, [], 100);
         }
+        $where = array(
+            'user_id' => $parames['user_id']
+        );
         $data = BuycarModel::with('commodity')
-            ->where($parames)
+            ->where($where)
             ->select();
 //        $data = BuycarModel::where('user_id',$parames['user_id'])
 //            ->alias('b')
@@ -90,6 +93,7 @@ class Buycar extends APi
         }
         $list = $params;
         unset($list['number']);
+        unset($list['token']);
         $issetcar = BuycarModel::where($list)->find(); //判断购物车是否已存在此商品
         if ($issetcar) { //存在的话把数量加上
             $addnumber = BuycarModel::where('k_id',$issetcar['k_id'])->setInc('number',$params['number']);
@@ -98,8 +102,6 @@ class Buycar extends APi
             } else {
                 return $this->result('添加失败', '', 100);
             }
-        } else {
-            echo 1111;die;
         }
         $model = new BuycarModel();
         $addCar = $model->allowField(true)->save($params);
@@ -125,8 +127,8 @@ class Buycar extends APi
         if (is_string($validata)) {
             return $this->result($validata,[],100);
         }
-        foreach ($params as $v) {
-            $del = BuycarModel::where('k_id',$v['id'])->delete();
+        foreach ($params['list'] as $v) {
+            $del = BuycarModel::where('k_id',$v['k_id'])->delete();
         }
         return $this->result('删除成功',[],200);
     }

+ 23 - 4
application/api/controller/Commodity.php

@@ -18,14 +18,18 @@ class Commodity extends Api
     /**
      * 全部商品
      * @ApiMethod   (POST)
+     * @param string $page 第几页
      */
     public function commodityIndex()
     {
+        $page = $this->request->post('page');
+        if (!isset($page)) {
+            $page = 0;
+        }
         $where = array(
             'c_state_switch' => 1,
         );
-        $data = CommodityModel::where($where)->order('c_sort desc')->select()->toArray();
-        $data = $this->commodityimage($data, 'c_images');
+        $data = CommodityModel::where($where)->order('c_sort desc')->page($page,5)->select()->toArray();
         if ($data) {
             return $this->result('', $data, 200);
         } else {
@@ -35,10 +39,14 @@ class Commodity extends Api
 
     /**
      * 商品类型
+     * @ApiMethod   (POST)
      */
     public function typeIndex()
     {
         $data = Db::name('ctype')->select();
+        $commodioty[0]['t_id'] = 0;
+        $commodioty[0]['t_name'] = '全部';
+        $data = array_merge($commodioty,$data);
         if ($data) {
             return $this->result('', $data, 200);
         } else {
@@ -50,6 +58,7 @@ class Commodity extends Api
      * 分类下的商品
      * @ApiMethod   (POST)
      * @param string $t_id 分类id
+     * @param string $page 第几页
      */
     public function typeCommodity()
     {
@@ -65,7 +74,14 @@ class Commodity extends Api
         if (is_string($validata)) {
             return $this->result($validata, [], 100);
         }
-        $data = CommodityModel::where('c_type', $params['t_id'])->order('c_sort desc')->select()->toArray();
+        $page = $this->request->post('page');
+        if (!isset($page)) {
+            $page = 0;
+        }
+        $where = array(
+            'c_state_switch' => 1,
+        );
+        $data = CommodityModel::where('c_type', $params['t_id'])->order('c_sort desc')->page($page,5)->select()->toArray();
         if ($data) {
             return $this->result('', $data, 200);
         } else {
@@ -108,7 +124,10 @@ class Commodity extends Api
                     'c_id'    => $params['c_id'],
                 );//足迹
                 $foot = new Foot();
-                $addFoot = $foot->allowField(true)->save($footdata);//添加足迹
+                $is_foot = Foot::where($footdata)->find(); //监看是否浏览过了
+                if (!$is_foot) {
+                    $addFoot = $foot->allowField(true)->save($footdata);//添加足迹
+                }
                 return $this->result('', $data, '200');
             }
         } else {

+ 141 - 141
application/api/controller/Common.php

@@ -1,142 +1,142 @@
 <?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-use app\common\model\Area;
-use app\common\model\Version;
-use fast\Random;
-use think\Config;
-
-/**
- * 公共接口
- */
-class Common extends Api
-{
-    protected $noNeedLogin = ['init'];
-    protected $noNeedRight = '*';
-
-    /**
-     * 加载初始化
-     *
-     * @param string $version 版本号
-     * @param string $lng     经度
-     * @param string $lat     纬度
-     */
-    public function init()
-    {
-        if ($version = $this->request->request('version')) {
-            $lng = $this->request->request('lng');
-            $lat = $this->request->request('lat');
-            $content = [
-                'citydata'    => Area::getCityFromLngLat($lng, $lat),
-                'versiondata' => Version::check($version),
-                'uploaddata'  => Config::get('upload'),
-                'coverdata'   => Config::get("cover"),
-            ];
-            $this->success('', $content);
-        } else {
-            $this->error(__('Invalid parameters'));
-        }
-    }
-
-    /**
-     * 上传文件
-     * @ApiMethod (POST)
-     * @param File $file 文件流
-     */
-    public function upload()
-    {
-        $file = $this->request->file('file');
-        if (empty($file)) {
-            $this->error(__('No file upload or server upload limit exceeded'));
-        }
-
-        //判断是否已经存在附件
-        $sha1 = $file->hash();
-
-        $upload = Config::get('upload');
-
-        preg_match('/(\d+)(\w+)/', $upload['maxsize'], $matches);
-        $type = strtolower($matches[2]);
-        $typeDict = ['b' => 0, 'k' => 1, 'kb' => 1, 'm' => 2, 'mb' => 2, 'gb' => 3, 'g' => 3];
-        $size = (int)$upload['maxsize'] * pow(1024, isset($typeDict[$type]) ? $typeDict[$type] : 0);
-        $fileInfo = $file->getInfo();
-        $suffix = strtolower(pathinfo($fileInfo['name'], PATHINFO_EXTENSION));
-        $suffix = $suffix && preg_match("/^[a-zA-Z0-9]+$/", $suffix) ? $suffix : 'file';
-
-        $mimetypeArr = explode(',', strtolower($upload['mimetype']));
-        $typeArr = explode('/', $fileInfo['type']);
-
-        //禁止上传PHP和HTML文件
-        if (in_array($fileInfo['type'], ['text/x-php', 'text/html']) || in_array($suffix, ['php', 'html', 'htm'])) {
-            $this->error(__('Uploaded file format is limited'));
-        }
-        //验证文件后缀
-        if ($upload['mimetype'] !== '*' &&
-            (
-                !in_array($suffix, $mimetypeArr)
-                || (stripos($typeArr[0] . '/', $upload['mimetype']) !== false && (!in_array($fileInfo['type'], $mimetypeArr) && !in_array($typeArr[0] . '/*', $mimetypeArr)))
-            )
-        ) {
-            $this->error(__('Uploaded file format is limited'));
-        }
-        //验证是否为图片文件
-        $imagewidth = $imageheight = 0;
-        if (in_array($fileInfo['type'], ['image/gif', 'image/jpg', 'image/jpeg', 'image/bmp', 'image/png', 'image/webp']) || in_array($suffix, ['gif', 'jpg', 'jpeg', 'bmp', 'png', 'webp'])) {
-            $imgInfo = getimagesize($fileInfo['tmp_name']);
-            if (!$imgInfo || !isset($imgInfo[0]) || !isset($imgInfo[1])) {
-                $this->error(__('Uploaded file is not a valid image'));
-            }
-            $imagewidth = isset($imgInfo[0]) ? $imgInfo[0] : $imagewidth;
-            $imageheight = isset($imgInfo[1]) ? $imgInfo[1] : $imageheight;
-        }
-        $replaceArr = [
-            '{year}'     => date("Y"),
-            '{mon}'      => date("m"),
-            '{day}'      => date("d"),
-            '{hour}'     => date("H"),
-            '{min}'      => date("i"),
-            '{sec}'      => date("s"),
-            '{random}'   => Random::alnum(16),
-            '{random32}' => Random::alnum(32),
-            '{filename}' => $suffix ? substr($fileInfo['name'], 0, strripos($fileInfo['name'], '.')) : $fileInfo['name'],
-            '{suffix}'   => $suffix,
-            '{.suffix}'  => $suffix ? '.' . $suffix : '',
-            '{filemd5}'  => md5_file($fileInfo['tmp_name']),
-        ];
-        $savekey = $upload['savekey'];
-        $savekey = str_replace(array_keys($replaceArr), array_values($replaceArr), $savekey);
-
-        $uploadDir = substr($savekey, 0, strripos($savekey, '/') + 1);
-        $fileName = substr($savekey, strripos($savekey, '/') + 1);
-        //
-        $splInfo = $file->validate(['size' => $size])->move(ROOT_PATH . '/public' . $uploadDir, $fileName);
-        if ($splInfo) {
-            $params = array(
-                'admin_id'    => 0,
-                'user_id'     => (int)$this->auth->id,
-                'filesize'    => $fileInfo['size'],
-                'imagewidth'  => $imagewidth,
-                'imageheight' => $imageheight,
-                'imagetype'   => $suffix,
-                'imageframes' => 0,
-                'mimetype'    => $fileInfo['type'],
-                'url'         => $uploadDir . $splInfo->getSaveName(),
-                'uploadtime'  => time(),
-                'storage'     => 'local',
-                'sha1'        => $sha1,
-            );
-            $attachment = model("attachment");
-            $attachment->data(array_filter($params));
-            $attachment->save();
-            \think\Hook::listen("upload_after", $attachment);
-            $this->success(__('Upload successful'), [
-                'url' => $uploadDir . $splInfo->getSaveName()
-            ]);
-        } else {
-            // 上传失败获取错误信息
-            $this->error($file->getError());
-        }
-    }
-}
+//
+//namespace app\api\controller;
+//
+//use app\common\controller\Api;
+//use app\common\model\Area;
+//use app\common\model\Version;
+//use fast\Random;
+//use think\Config;
+//
+///**
+// * 公共接口
+// */
+//class Common extends Api
+//{
+//    protected $noNeedLogin = ['init'];
+//    protected $noNeedRight = '*';
+//
+//    /**
+//     * 加载初始化
+//     *
+//     * @param string $version 版本号
+//     * @param string $lng     经度
+//     * @param string $lat     纬度
+//     */
+//    public function init()
+//    {
+//        if ($version = $this->request->request('version')) {
+//            $lng = $this->request->request('lng');
+//            $lat = $this->request->request('lat');
+//            $content = [
+//                'citydata'    => Area::getCityFromLngLat($lng, $lat),
+//                'versiondata' => Version::check($version),
+//                'uploaddata'  => Config::get('upload'),
+//                'coverdata'   => Config::get("cover"),
+//            ];
+//            $this->success('', $content);
+//        } else {
+//            $this->error(__('Invalid parameters'));
+//        }
+//    }
+//
+//    /**
+//     * 上传文件
+//     * @ApiMethod (POST)
+//     * @param File $file 文件流
+//     */
+//    public function upload()
+//    {
+//        $file = $this->request->file('file');
+//        if (empty($file)) {
+//            $this->error(__('No file upload or server upload limit exceeded'));
+//        }
+//
+//        //判断是否已经存在附件
+//        $sha1 = $file->hash();
+//
+//        $upload = Config::get('upload');
+//
+//        preg_match('/(\d+)(\w+)/', $upload['maxsize'], $matches);
+//        $type = strtolower($matches[2]);
+//        $typeDict = ['b' => 0, 'k' => 1, 'kb' => 1, 'm' => 2, 'mb' => 2, 'gb' => 3, 'g' => 3];
+//        $size = (int)$upload['maxsize'] * pow(1024, isset($typeDict[$type]) ? $typeDict[$type] : 0);
+//        $fileInfo = $file->getInfo();
+//        $suffix = strtolower(pathinfo($fileInfo['name'], PATHINFO_EXTENSION));
+//        $suffix = $suffix && preg_match("/^[a-zA-Z0-9]+$/", $suffix) ? $suffix : 'file';
+//
+//        $mimetypeArr = explode(',', strtolower($upload['mimetype']));
+//        $typeArr = explode('/', $fileInfo['type']);
+//
+//        //禁止上传PHP和HTML文件
+//        if (in_array($fileInfo['type'], ['text/x-php', 'text/html']) || in_array($suffix, ['php', 'html', 'htm'])) {
+//            $this->error(__('Uploaded file format is limited'));
+//        }
+//        //验证文件后缀
+//        if ($upload['mimetype'] !== '*' &&
+//            (
+//                !in_array($suffix, $mimetypeArr)
+//                || (stripos($typeArr[0] . '/', $upload['mimetype']) !== false && (!in_array($fileInfo['type'], $mimetypeArr) && !in_array($typeArr[0] . '/*', $mimetypeArr)))
+//            )
+//        ) {
+//            $this->error(__('Uploaded file format is limited'));
+//        }
+//        //验证是否为图片文件
+//        $imagewidth = $imageheight = 0;
+//        if (in_array($fileInfo['type'], ['image/gif', 'image/jpg', 'image/jpeg', 'image/bmp', 'image/png', 'image/webp']) || in_array($suffix, ['gif', 'jpg', 'jpeg', 'bmp', 'png', 'webp'])) {
+//            $imgInfo = getimagesize($fileInfo['tmp_name']);
+//            if (!$imgInfo || !isset($imgInfo[0]) || !isset($imgInfo[1])) {
+//                $this->error(__('Uploaded file is not a valid image'));
+//            }
+//            $imagewidth = isset($imgInfo[0]) ? $imgInfo[0] : $imagewidth;
+//            $imageheight = isset($imgInfo[1]) ? $imgInfo[1] : $imageheight;
+//        }
+//        $replaceArr = [
+//            '{year}'     => date("Y"),
+//            '{mon}'      => date("m"),
+//            '{day}'      => date("d"),
+//            '{hour}'     => date("H"),
+//            '{min}'      => date("i"),
+//            '{sec}'      => date("s"),
+//            '{random}'   => Random::alnum(16),
+//            '{random32}' => Random::alnum(32),
+//            '{filename}' => $suffix ? substr($fileInfo['name'], 0, strripos($fileInfo['name'], '.')) : $fileInfo['name'],
+//            '{suffix}'   => $suffix,
+//            '{.suffix}'  => $suffix ? '.' . $suffix : '',
+//            '{filemd5}'  => md5_file($fileInfo['tmp_name']),
+//        ];
+//        $savekey = $upload['savekey'];
+//        $savekey = str_replace(array_keys($replaceArr), array_values($replaceArr), $savekey);
+//
+//        $uploadDir = substr($savekey, 0, strripos($savekey, '/') + 1);
+//        $fileName = substr($savekey, strripos($savekey, '/') + 1);
+//        //
+//        $splInfo = $file->validate(['size' => $size])->move(ROOT_PATH . '/public' . $uploadDir, $fileName);
+//        if ($splInfo) {
+//            $params = array(
+//                'admin_id'    => 0,
+//                'user_id'     => (int)$this->auth->id,
+//                'filesize'    => $fileInfo['size'],
+//                'imagewidth'  => $imagewidth,
+//                'imageheight' => $imageheight,
+//                'imagetype'   => $suffix,
+//                'imageframes' => 0,
+//                'mimetype'    => $fileInfo['type'],
+//                'url'         => $uploadDir . $splInfo->getSaveName(),
+//                'uploadtime'  => time(),
+//                'storage'     => 'local',
+//                'sha1'        => $sha1,
+//            );
+//            $attachment = model("attachment");
+//            $attachment->data(array_filter($params));
+//            $attachment->save();
+//            \think\Hook::listen("upload_after", $attachment);
+//            $this->success(__('Upload successful'), [
+//                'url' => $uploadDir . $splInfo->getSaveName()
+//            ]);
+//        } else {
+//            // 上传失败获取错误信息
+//            $this->error($file->getError());
+//        }
+//    }
+//}

+ 72 - 72
application/api/controller/Demo.php

@@ -1,73 +1,73 @@
 <?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-
-/**
- * 示例接口
- */
-class Demo extends Api
-{
-
-    //如果$noNeedLogin为空表示所有接口都需要登录才能请求
-    //如果$noNeedRight为空表示所有接口都需要验证权限才能请求
-    //如果接口已经设置无需登录,那也就无需鉴权了
-    //
-    // 无需登录的接口,*表示全部
-    protected $noNeedLogin = ['test', 'test1'];
-    // 无需鉴权的接口,*表示全部
-    protected $noNeedRight = ['test2'];
-
-    /**
-     * 测试方法
-     *
-     * @ApiTitle    (测试名称)
-     * @ApiSummary  (测试描述信息)
-     * @ApiMethod   (POST)
-     * @ApiRoute    (/api/demo/test/id/{id}/name/{name})
-     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
-     * @ApiParams   (name="id", type="integer", required=true, description="会员ID")
-     * @ApiParams   (name="name", type="string", required=true, description="用户名")
-     * @ApiParams   (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据")
-     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
-     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
-     * @ApiReturnParams   (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据返回")
-     * @ApiReturn   ({
-         'code':'1',
-         'msg':'返回成功'
-        })
-     */
-    public function test()
-    {
-        $this->success('返回成功', $this->request->param());
-    }
-
-    /**
-     * 无需登录的接口
-     *
-     */
-    public function test1()
-    {
-        $this->success('返回成功', ['action' => 'test1']);
-    }
-
-    /**
-     * 需要登录的接口
-     *
-     */
-    public function test2()
-    {
-        $this->success('返回成功', ['action' => 'test2']);
-    }
-
-    /**
-     * 需要登录且需要验证有相应组的权限
-     *
-     */
-    public function test3()
-    {
-        $this->success('返回成功', ['action' => 'test3']);
-    }
-
-}
+//
+//namespace app\api\controller;
+//
+//use app\common\controller\Api;
+//
+///**
+// * 示例接口
+// */
+//class Demo extends Api
+//{
+//
+//    //如果$noNeedLogin为空表示所有接口都需要登录才能请求
+//    //如果$noNeedRight为空表示所有接口都需要验证权限才能请求
+//    //如果接口已经设置无需登录,那也就无需鉴权了
+//    //
+//    // 无需登录的接口,*表示全部
+//    protected $noNeedLogin = ['test', 'test1'];
+//    // 无需鉴权的接口,*表示全部
+//    protected $noNeedRight = ['test2'];
+//
+//    /**
+//     * 测试方法
+//     *
+//     * @ApiTitle    (测试名称)
+//     * @ApiSummary  (测试描述信息)
+//     * @ApiMethod   (POST)
+//     * @ApiRoute    (/api/demo/test/id/{id}/name/{name})
+//     * @ApiHeaders  (name=token, type=string, required=true, description="请求的Token")
+//     * @ApiParams   (name="id", type="integer", required=true, description="会员ID")
+//     * @ApiParams   (name="name", type="string", required=true, description="用户名")
+//     * @ApiParams   (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据")
+//     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
+//     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
+//     * @ApiReturnParams   (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据返回")
+//     * @ApiReturn   ({
+//         'code':'1',
+//         'msg':'返回成功'
+//        })
+//     */
+//    public function test()
+//    {
+//        $this->success('返回成功', $this->request->param());
+//    }
+//
+//    /**
+//     * 无需登录的接口
+//     *
+//     */
+//    public function test1()
+//    {
+//        $this->success('返回成功', ['action' => 'test1']);
+//    }
+//
+//    /**
+//     * 需要登录的接口
+//     *
+//     */
+//    public function test2()
+//    {
+//        $this->success('返回成功', ['action' => 'test2']);
+//    }
+//
+//    /**
+//     * 需要登录且需要验证有相应组的权限
+//     *
+//     */
+//    public function test3()
+//    {
+//        $this->success('返回成功', ['action' => 'test3']);
+//    }
+//
+//}

+ 101 - 101
application/api/controller/Ems.php

@@ -1,102 +1,102 @@
 <?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-use app\common\library\Ems as Emslib;
-use app\common\model\User;
-
-/**
- * 邮箱验证码接口
- */
-class Ems extends Api
-{
-    protected $noNeedLogin = '*';
-    protected $noNeedRight = '*';
-
-    public function _initialize()
-    {
-        parent::_initialize();
-        \think\Hook::add('ems_send', function ($params) {
-            $obj = \app\common\library\Email::instance();
-            $result = $obj
-                ->to($params->email)
-                ->subject('验证码')
-                ->message("你的验证码是:" . $params->code)
-                ->send();
-            return $result;
-        });
-    }
-
-    /**
-     * 发送验证码
-     *
-     * @param string $email 邮箱
-     * @param string $event 事件名称
-     */
-    public function send()
-    {
-        $email = $this->request->request("email");
-        $event = $this->request->request("event");
-        $event = $event ? $event : 'register';
-
-        $last = Emslib::get($email, $event);
-        if ($last && time() - $last['createtime'] < 60) {
-            $this->error(__('发送频繁'));
-        }
-        if ($event) {
-            $userinfo = User::getByEmail($email);
-            if ($event == 'register' && $userinfo) {
-                //已被注册
-                $this->error(__('已被注册'));
-            } elseif (in_array($event, ['changeemail']) && $userinfo) {
-                //被占用
-                $this->error(__('已被占用'));
-            } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
-                //未注册
-                $this->error(__('未注册'));
-            }
-        }
-        $ret = Emslib::send($email, null, $event);
-        if ($ret) {
-            $this->success(__('发送成功'));
-        } else {
-            $this->error(__('发送失败'));
-        }
-    }
-
-    /**
-     * 检测验证码
-     *
-     * @param string $email   邮箱
-     * @param string $event   事件名称
-     * @param string $captcha 验证码
-     */
-    public function check()
-    {
-        $email = $this->request->request("email");
-        $event = $this->request->request("event");
-        $event = $event ? $event : 'register';
-        $captcha = $this->request->request("captcha");
-
-        if ($event) {
-            $userinfo = User::getByEmail($email);
-            if ($event == 'register' && $userinfo) {
-                //已被注册
-                $this->error(__('已被注册'));
-            } elseif (in_array($event, ['changeemail']) && $userinfo) {
-                //被占用
-                $this->error(__('已被占用'));
-            } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
-                //未注册
-                $this->error(__('未注册'));
-            }
-        }
-        $ret = Emslib::check($email, $captcha, $event);
-        if ($ret) {
-            $this->success(__('成功'));
-        } else {
-            $this->error(__('验证码不正确'));
-        }
-    }
-}
+//
+//namespace app\api\controller;
+//
+//use app\common\controller\Api;
+//use app\common\library\Ems as Emslib;
+//use app\common\model\User;
+//
+///**
+// * 邮箱验证码接口
+// */
+//class Ems extends Api
+//{
+//    protected $noNeedLogin = '*';
+//    protected $noNeedRight = '*';
+//
+//    public function _initialize()
+//    {
+//        parent::_initialize();
+//        \think\Hook::add('ems_send', function ($params) {
+//            $obj = \app\common\library\Email::instance();
+//            $result = $obj
+//                ->to($params->email)
+//                ->subject('验证码')
+//                ->message("你的验证码是:" . $params->code)
+//                ->send();
+//            return $result;
+//        });
+//    }
+//
+//    /**
+//     * 发送验证码
+//     *
+//     * @param string $email 邮箱
+//     * @param string $event 事件名称
+//     */
+//    public function send()
+//    {
+//        $email = $this->request->request("email");
+//        $event = $this->request->request("event");
+//        $event = $event ? $event : 'register';
+//
+//        $last = Emslib::get($email, $event);
+//        if ($last && time() - $last['createtime'] < 60) {
+//            $this->error(__('发送频繁'));
+//        }
+//        if ($event) {
+//            $userinfo = User::getByEmail($email);
+//            if ($event == 'register' && $userinfo) {
+//                //已被注册
+//                $this->error(__('已被注册'));
+//            } elseif (in_array($event, ['changeemail']) && $userinfo) {
+//                //被占用
+//                $this->error(__('已被占用'));
+//            } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
+//                //未注册
+//                $this->error(__('未注册'));
+//            }
+//        }
+//        $ret = Emslib::send($email, null, $event);
+//        if ($ret) {
+//            $this->success(__('发送成功'));
+//        } else {
+//            $this->error(__('发送失败'));
+//        }
+//    }
+//
+//    /**
+//     * 检测验证码
+//     *
+//     * @param string $email   邮箱
+//     * @param string $event   事件名称
+//     * @param string $captcha 验证码
+//     */
+//    public function check()
+//    {
+//        $email = $this->request->request("email");
+//        $event = $this->request->request("event");
+//        $event = $event ? $event : 'register';
+//        $captcha = $this->request->request("captcha");
+//
+//        if ($event) {
+//            $userinfo = User::getByEmail($email);
+//            if ($event == 'register' && $userinfo) {
+//                //已被注册
+//                $this->error(__('已被注册'));
+//            } elseif (in_array($event, ['changeemail']) && $userinfo) {
+//                //被占用
+//                $this->error(__('已被占用'));
+//            } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
+//                //未注册
+//                $this->error(__('未注册'));
+//            }
+//        }
+//        $ret = Emslib::check($email, $captcha, $event);
+//        if ($ret) {
+//            $this->success(__('成功'));
+//        } else {
+//            $this->error(__('验证码不正确'));
+//        }
+//    }
+//}

+ 58 - 0
application/api/controller/Forgetpwd.php

@@ -0,0 +1,58 @@
+<?php
+namespace app\api\controller;
+use app\api\model\UsersModel;
+use app\common\controller\Api;
+use think\Cache;
+use think\Controller;
+use think\Db;
+use think\exception\HttpResponseException;
+use think\Request;
+use think\Response;
+
+/**
+ * 忘记密码
+ */
+class Forgetpwd extends Controller
+{
+    protected $noNeedRight = '*';
+    protected $noNeedLogin = '*';
+
+    /**
+     * 忘记密码
+     * @ApiMethod   (POST)
+     * @param string $user_tel 用户手机号
+     * @param string $user-pwd 密码
+     * @param string $code 验证码
+     */
+    public function forgetPwd()
+    {
+        $params = $this->request->post();
+        $check = '/^(1(([35789][0-9])|(47)))\d{8}$/';
+        if (!preg_match($check, $params['user_tel'])) {
+            return json(['code' => 100, 'msg' => '手机号不合法','data' => []]);
+        }
+        $is_tel = UsersModel::where('user_tel',$params['user_tel'])->find();
+        if (!$is_tel) {
+            return json(['code' => 100, 'msg' => '密码相同','data' => []]);
+        }
+        if (!Cache::get($params['code'])) {
+            return json(['code' => 100, 'msg' => '验证码错误','data' => []]);
+        }
+        if (!isset($params['user_pwd']) || !isset($params['code'])) {
+            return json(['code' => 100, 'msg' => '密码相同','data' => []]);
+        }
+        $params['user_pwd'] = sha1(md5($params['user_pwd']));
+        //验证密码是否已存在
+        $is_pwd = Db::name('users')->where('user_tel',$params['user_tel'])->where('user_pwd', $params['user_pwd'])->find();
+        if ($is_pwd) {
+            return json(['code' => 100, 'msg' => '密码相同','data' => []]);
+        }
+        $updPwd = Db::name('users')->where('user_tel',$params['user_tel'])->update(['user_pwd' => $params['user_pwd']]);
+        if ($updPwd) {
+            Cache::rm($params['code']);
+            return json(['code' => 200, 'msg' => '修改成功','data' => []]);
+        } else {
+            return json(['code' => 100, 'msg' => '修改失败','data' => []]);
+        }
+    }
+}

+ 12 - 0
application/api/controller/Index.php

@@ -4,6 +4,7 @@ namespace app\api\controller;
 
 use app\api\model\CommodityModel;
 use app\common\controller\Api;
+use think\Cache;
 use think\Db;
 
 /**
@@ -43,4 +44,15 @@ class Index extends Api
             return $this->result('暂无商品',[],100);
         }
     }
+
+    public function index()
+    {
+        $params = input();
+        Cache::set('aaa',$params);
+    }
+
+    public function aa()
+    {
+        halt(Cache::get('aaa'));
+    }
 }

+ 174 - 21
application/api/controller/Login.php

@@ -5,22 +5,24 @@ namespace app\api\controller;
 use app\api\model\UsersModel;
 use app\common\controller\Api;
 use fast\Random;
+use think\Cache;
+use think\Controller;
 use think\Db;
+use think\Loader;
 
 /**
  * 登录接口
  */
-class Login extends Api
+class Login extends Controller
 {
     protected $noNeedLogin = '*';
     protected $noNeedRight = '*';
 
     /**
-     * 会员登录
+     * 手机号登录
      * @ApiMethod   (POST)
      * @param string $user_tel 账号
      * @param string $user_pwd 密码
-     * @param string $user_openid qq或者微信openID
      */
     public function Login()
     {
@@ -28,7 +30,6 @@ class Login extends Api
         $rules = [
             'user_tel' => 'require|max:11|number|min:11',
             'user_pwd' => 'require|max:25|min:6',
-            'token'    => 'require'
         ];
         $msg = [
             'user_tel.require' => '手机号不能为空',
@@ -36,7 +37,6 @@ class Login extends Api
             'user_tel.min'     => '手机号长度不正确',
             'user_tel.number'  => '手机号必须为数字',
             'user_pwd.require' => '密码不能为空',
-            'token.require'    => 'token不能为空',
             'user_pwd.max'     => '密码长度过长',
             'user_pwd.min'     => '密码长度不足',
         ];
@@ -46,31 +46,183 @@ class Login extends Api
         if (isset($data['user_tel']) && isset($data['user_pwd'])) {
             $validata = $this->validate($data, $rules, $msg); //验证数据规则
             if (is_string($validata)) {
-                return $this->result($validata, [], 100);
+                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']));                                                              //加密验证密码
-                $validatapwd = UsersModel::where('user_pwd', $data['user_pwd'])->where('user_tel', $data['user_tel'])->find(); //判断密码是否正确
-                $validatapwd['token'] = self::settoken($validatapwd['user_id']);
+                $data['user_pwd'] = sha1(md5($data['user_pwd']));                                                                                //加密验证密码
+                $where = array(
+                  'user_tel' => $data['user_tel'],
+                  'user_pwd' => $data['user_pwd'],
+                );
+                $validatapwd = Db::name('users')->where($data)->field('user_id')->find(); //判断密码是否正确
                 if ($validatapwd) {
-                    return $this->result('登录成功,欢迎回来', $validatapwd, 200);
+                    $validatapwd['token'] = self::settoken($validatapwd['user_id']);
+                    return json(['code' => 200, 'msg' => '登陆成功,欢迎回来哦','data' => $validatapwd]);
                 } else {
-                    return $this->result('密码错误', [], 100);
+                    return json(['code' => 100, 'msg' => '密码错误','data' => []]);
                 }
             } else {
-                return $this->result('手机号不存在', [], 100);
+                return json(['code' => 100, 'msg' => '手机号不存在','data' => []]);
             }
         }
-        if (isset($data['user_openid'])) {
-            $validataopenid = UsersModel::where('user_openid', $data['user_openid'])->find();  //判断QQ或者微信登录的openid是否正确
-            if ($validataopenid) {
-                return $this->result('登陆成功,欢迎回来', $validataopenid, 200);
+
+
+    }
+
+    /**
+     * 微信登录
+     * @ApiMethod   (POST)
+     * @param string $user_nickname 昵称
+     * @param string $user_avatar 头像
+     * @param string $user_unionid unionID
+     */
+    public function wechatLogin()
+    {
+        $params = $this->request->post();
+        $rules = [
+            'user_nickname' => 'require',
+            'user_avatar'   => 'require',
+            'user_unionid'  => 'require',
+        ];
+        $msg = [
+            'user_nickname.require' => '昵称未获取',
+            'user_avatar.require'   => '头像未获取',
+            'user_unionid.require'  => '开放id未获取',
+        ];
+        $validata = $this->validate($params, $rules, $msg);
+        if (is_string($validata)) {
+            return json(['code' => 100, 'msg' => '','data' => $validata]);
+        }
+        $validataopenid = UsersModel::where('user_unionid', $params['user_unionid'])->field('user_id')->find();  //判断QQ或者微信登录的openid是否正确
+        if ($validataopenid) {
+            $validataopenid['token'] = self::settoken($validataopenid['user_id']);
+            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 $this->result('暂无该用户', [], 100);
+                return json(['code' => 100, 'msg' => '登录失败','data' => []]);
             }
         }
-
+    }
+    /**
+     * QQ登录
+     * @ApiMethod   (POST)
+     * @param string $user_nickname 昵称
+     * @param string $user_avatar 头像
+     * @param string $user_unionid unionID
+     */
+    public function qqLogin()
+    {
+        $params = $this->request->post();
+        $rules = [
+            'user_nickname' => 'require',
+            'user_avatar'   => 'require',
+            'user_unionid'  => 'require',
+        ];
+        $msg = [
+            'user_nickname.require' => '昵称未获取',
+            'user_avatar.require'   => '头像未获取',
+            'user_unionid.require'  => '开放id未获取',
+        ];
+        $validata = $this->validate($params, $rules, $msg);
+        if (is_string($validata)) {
+            return json(['code' => 100, 'msg' => '','data' => $validata]);
+        }
+        $validataopenid = UsersModel::where('user_unionid', $params['user_unionid'])->field('user_id')->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' => []]);
+            }
+        }
+    }
+    /**
+     * 添加登录手机号登录
+     * @ApiMethod   (POST)
+     * @param string $user_id 用户ID
+     * @param string $user_tel 用户手机号
+     * @param string $code 验证码
+     * @param string $user_tjtel 用户手机号
+     */
+    public function addUserTel()
+    {
+        $params = $this->request->post();
+        $rules = [
+            'user_id'    => 'require|number',
+            'code'       => 'require|number',
+            'user_tel'   => 'require|number',
+            'user_tjtel' => 'require|number',
+            'token'      => 'require',
+        ];
+        $msg = [
+            'user_id.require'    => '网络错误1',
+            'code .require'      => '网络错误2',
+            'user_tel.require'   => '手机号不能为空',
+            'user_tjtel.require' => '推荐人手机号不能为空',
+            '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' => []]);
+        }
+        $check = '/^(1(([35789][0-9])|(47)))\d{8}$/';
+        if (!preg_match($check, $params['user_tel'])) {
+            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' => []]);
+        }
+        //判断验证码是否正确
+        if (!Cache::get($params['code'])) {
+            return json(['code' => 100, 'msg' => '验证码不正确','data' => []]);
+        }
+        Cache::rm($params['code']);
+        $upddata = array(
+            'user_tel'   => $params['user_tel'],
+            'user_tjtel' => $params['user_tjtel'],
+            'type'       => 1,
+        );
+        $updUser_tel = Db::name('users')->where('user_id', $params['user_id'])->update($upddata);
+        if ($updUser_tel) {
+            $token = self::settoken($params['user_id']);
+            $res = array(
+                "user_id" => $params['user_id'],
+                "token"   => $token,
+            );
+            return json(['code' => 200, 'msg' => '绑定成功','data' => []]);
+        } else {
+            Db::name('users')->where('user_id',$params['user_id'])->delete(); // 绑定失败删除此用户
+            return json(['code' => 100, 'msg' => '绑定失败','data' => []]);
+        }
     }
 
     /**
@@ -84,7 +236,7 @@ class Login extends Api
         $tel = UsersModel::where('user_tel', $tel)->find();
         $num = count($tel);
         if ($num > 0) {
-            return $this->result('手机号已存在', [], 100);
+            return json(['code' => 100, 'msg' => '手机号已存在','data' => []]);
         }
     }
 
@@ -96,11 +248,12 @@ class Login extends Api
     {
         $data = Db::name('agreement')->where('type', 0)->find();
         if ($data) {
-            return $this->result('', $data, 200);
+            return json(['code' => 200, 'msg' => '绑定成功','data' => $data]);
         } else {
-            return $this->result('网络错误', [], 100);
+            return json(['code' => 100, 'msg' => '网络错误','data' => []]);
         }
     }
+
     /**
      * 生成token
      *

+ 229 - 47
application/api/controller/Order.php

@@ -3,7 +3,10 @@
 namespace app\api\controller;
 
 use app\api\model\Commoditycolor;
+use app\api\model\Logistics;
 use app\api\model\OrderModel;
+use app\api\model\Torder;
+use app\api\model\UsersModel;
 use app\common\controller\Api;
 use think\Db;
 
@@ -141,57 +144,53 @@ class Order extends Api
      * @param string $user_id 用户id
      * @param string $money 总价
      * @param string $a_id 地址id
-     * @param string $a_tel 收货手机号
-     * @param string $a_name 收货姓名
-     * @param string $area 收货地址
-     * @param string $city 城市
      * @param string $freight 运费
      * @param string $whitebean 总白豆数
      * @param string $create_time 创建时间
      * @param string $number 编号
+     * @param string $user_paypwd 余额支付密码
      * @param string $type 0余额支付1第四方支付
      */
     public function orderPay()
     {
         $parames = $this->request->post();
         $rules = [
-            'pre_id'    => 'require|number',
-            'user_id'   => 'require',
-            'money'     => 'require',
-            'a_id'      => 'require',
-            'a_tel'     => 'require',
-            'a_name'    => 'require',
-            'area'      => 'require',
-            'city'      => 'require',
-            'freight'   => 'require',
-            'whitebean' => 'require',
-            'type'      => 'require|max:1',
+            'pre_id'      => 'require|number',
+            'user_id'     => 'require',
+            'money'       => 'require',
+            'a_id'        => 'require',
+            'freight'     => 'require',
+            'whitebean'   => 'require',
+            'user_paypwd' => 'require',
+            'type'        => 'require|max:1',
         ];
         $msg = [
-            'pre_id.require' => '网络错误1',
-            'user_id.require' => '网络错误2',
-            'money.require' => '网络错误3',
-            'a_id.require' => '网络错误4',
-            'a_tel.require' => '网络错误5',
-            'a_name.require' => '网络错误6',
-            'area.require' => '网络错误7',
-            'city.require' => '网络错误8',
-            'freight.require' => '网络错误9',
-            'whitebean.require' => '网络错误10',
-            'type.require' => '网络错误11',
-            'type.max' => '网络错误12',
-            'pre_id.number' => '网络错误13',
+            'pre_id.require'      => '网络错误1',
+            'user_id.require'     => '网络错误2',
+            'money.require'       => '网络错误3',
+            'a_id.require'        => '网络错误4',
+            'freight.require'     => '网络错误9',
+            'whitebean.require'   => '网络错误10',
+            'user_paypwd.require' => '网络错误10',
+            'type.require'        => '网络错误11',
+            'type.max'            => '网络错误12',
+            'pre_id.number'       => '网络错误13',
         ];
-        $validata = $this->validate($parames,$rules,$msg);
+        $validata = $this->validate($parames, $rules, $msg);
         if (is_string($validata)) {
-            return $this->result($validata,[],100);
+            return $this->result($validata, [], 100);
         }
-         $order = new OrderModel();
+        $order = new OrderModel();
         if ($parames['type'] == 0) {
             $res = $order->userMoneyPay($parames);
-           return $res;
+            return $res;
+        }
+        if ($parames['type'] == 1) {
+            $res = $order->wechatOrder($parames);
+            return $res;
         }
     }
+
     /**
      * 全部订单
      * @ApiMethod   (POST)
@@ -201,12 +200,13 @@ class Order extends Api
     {
         $user_id = $this->request->post('user_id');
         if (!isset($user_id)) {
-            return $this->result('网络错误','',100);
+            return $this->result('网络错误', '', 100);
         }
         $order = new OrderModel();
         $data = $order->allOrder($user_id);
         return $data;
     }
+
     /**
      * 确认收货
      * @ApiMethod   (POST)
@@ -216,15 +216,18 @@ class Order extends Api
     {
         $o_id = $this->request->post('o_id');
         if (!isset($o_id)) {
-            return $this->result('网络错误','',100);
+            return $this->result('网络错误', '', 100);
         }
-        $updOrder = OrderModel::where('o_id',$o_id)->update(['state' => 6]);
-        if ($updOrder) {
-            return $this->result('收货成功','', 200);
+        $order = Db::name('order')->where('o_id',$o_id)->find();
+        $updOrder = OrderModel::where('o_id', $o_id)->update(['state' => 6]);
+        $updUserWhitebean = Db::name('users')->where('user_id',$order['user_id'])->setInc('user_whitebean',$order['whitebeon']);
+        if ($updOrder&&$updUserWhitebean) {
+            return $this->result('收货成功', '', 200);
         } else {
-            return $this->result('网络错误','',100);
+            return $this->result('网络错误', '', 100);
         }
-     }
+    }
+
     /**
      * 取消订单
      * @ApiMethod   (POST)
@@ -234,15 +237,16 @@ class Order extends Api
     {
         $o_id = $this->request->post('o_id');
         if (!isset($o_id)) {
-            return $this->result('网络错误','',100);
+            return $this->result('网络错误', '', 100);
         }
-        $updOrder = OrderModel::where('o_id',$o_id)->update(['state' => 5]);
+        $updOrder = OrderModel::where('o_id', $o_id)->update(['state' => 5]);
         if ($updOrder) {
-            return $this->result('取消成功','', 200);
+            return $this->result('取消成功', '', 200);
         } else {
-            return $this->result('网络错误','',100);
+            return $this->result('网络错误', '', 100);
         }
     }
+
     /**
      * 删除订单
      * @ApiMethod   (POST)
@@ -252,13 +256,191 @@ class Order extends Api
     {
         $o_id = $this->request->post('o_id');
         if (!isset($o_id)) {
-            return $this->result('网络错误','',100);
+            return $this->result('网络错误', '', 100);
         }
-        $updOrder = OrderModel::where('o_id',$o_id)->delete();
+        $updOrder = OrderModel::where('o_id', $o_id)->delete();
         if ($updOrder) {
-            return $this->result('删除成功','', 200);
+            return $this->result('删除成功', '', 200);
+        } else {
+            return $this->result('网络错误', '', 100);
+        }
+    }
+
+    /**
+     * 各种订单详情
+     * @ApiMethod   (POST)
+     * @param string $o_id 订单id
+     */
+    public function orderInfo()
+    {
+        $o_id = $this->request->post('o_id');
+        if (!$o_id) {
+            return $this->result('网络错误', [], 100);
+        }
+        $orderInfo = OrderModel::with(['OrderCommodityModel', 'OrderAddress'])->where('o_id', $o_id)->find();
+        if ($orderInfo) {
+            return $this->result('', $orderInfo, 200);
         } else {
-            return $this->result('网络错误','',100);
+            return $this->result('网络错误', [], 100);
+        }
+    }
+
+    /**
+     * 查看物流
+     * @ApiMethod   (POST)
+     * @param string $o_id 订单id
+     */
+    public function logistics()
+    {
+        $o_id = $this->request->post('o_id');
+        if (!$o_id) {
+            return $this->result('网络错误', [], 100);
+        }
+        $order = OrderModel::with(['OrderCommodityModel', 'OrderAddress'])->where('o_id', $o_id)->find();
+        $model = new Logistics();
+        $res = $model->logistics($order);
+        return $res;
+    }
+    /**
+     * 退款订单显示
+     * @ApiMethod   (POST)
+     * @param string $o_id 订单id
+     */
+    public function torderIndex()
+    {
+        $o_id = $this->request->post('o_id');
+        if (!isset($o_id)) {
+            return $this->result('网络错误','', 100);
+        }
+        $orderInfo = OrderModel::with(['OrderCommodityModel', 'OrderAddress'])->where('o_id', $o_id)->find();
+        if ($orderInfo) {
+            return $this->result('', $orderInfo, 200);
+        } else {
+            return $this->result('网络错误', [], 100);
+        }
+    }
+    /**
+     * 退款提交
+     * @ApiMethod   (POST)
+     * @param string $o_id 订单id
+     * @param string $reason 原因
+     * @param string $money 金额
+     * @param string $content 说明
+     * @param string $files 图片
+     */
+    public function subTorder()
+    {
+        $params = $this->request->post();
+        if (!isset($params['o_id'])) {
+            return $this->result('网络错误', [], 100);
+        }
+        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(
+            'state' => 4,
+            'tuikuan_state' => 3,
+            'state_save' => $order['state']
+        );
+        $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);
+        $model = new Torder();
+        $subTorder = $model->allowField(true)->save($params);
+        if ($subTorder) {
+            return $this->result('申请退款成功',[],200);
+        } else {
+            return $this->result('申请失败',[] ,100);
+        }
+    }
+    /**
+     * 取消退款
+     * @ApiMethod   (POST)
+     * @param string $o_id 订单id
+     */
+    public function cancleTorder()
+    {
+        $o_id =$this->request->post('o_id');
+        if (!isset($o_id)) {
+            return $this->result('网络错误', [], 100);
+        }
+        $order = OrderModel::where('o_id',$o_id)->find();
+        if (!$order) {
+            return $this->result('未找到该订单', [], 100);
+        }
+        // 修改成为退款之前的状态
+        $updOrder = OrderModel::where('o_id',$o_id)->update(['state' => $order['state_save']]);
+        if ($updOrder) {
+            return $this->result('取消成功', [], 200);
+        } else {
+            return $this->result('失败', [] , 100);
+        }
+    }
+    /**
+     * 退款订单详情
+     * @ApiMethod   (POST)
+     * @param string $o_id 订单id
+     */
+    public function torderInfo()
+    {
+        $o_id =$this->request->post('o_id');
+        if (!isset($o_id)) {
+            return $this->result('网络错误', [], 100);
+        }
+        $orderInfo = OrderModel::with(['OrderCommodityModel', 'OrderAddress','Torder'])->where('o_id', $o_id)->find();
+        if ($orderInfo) {
+            return $this->result('', $orderInfo, 200);
+        } else {
+            return $this->result('未找到该订单', [] , 100);
+        }
+    }
+    /**
+     * 微信订单支付回调
+     * 可以通过@ApiInternal忽略请求的方法
+     * @ApiInternal
+     */
+    public function order_notify()
+    {
+        //获取返回的xml格式数据
+        $payXml = file_get_contents("php://input");
+        //将xml格式转化为json格式
+        $jsonXml = json_encode(simplexml_load_string($payXml, 'SimpleXMLElement', LIBXML_NOCDATA));
+        //将json格式转成数组格式 $result['out_trade_no']
+        $result = json_decode($jsonXml, true);
+        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) {
+                return "<xml>
+                      <return_code><![CDATA[SUCCESS]]></return_code>
+                      <return_msg><![CDATA[OK]]></return_msg>
+                    </xml>";
+            }
+
         }
     }
 }

+ 54 - 0
application/api/controller/Plan.php

@@ -0,0 +1,54 @@
+<?php
+namespace app\api\controller;
+
+use app\api\model\UsersModel;
+use think\Controller;
+use think\Db;
+
+/**
+ * 宝塔计划任务类
+ * @ApiInternal
+ * Class Plan
+ * @package app\api\controller
+ */
+class Plan extends Controller
+{
+    // 每月清空VIP开通限制 /api/plan/clearVipData
+    public function clearVipData()
+    {
+        $ids = UsersModel::field('user_id')->select();
+        $ip = $this->request->ip();
+
+        foreach ($ids as $v) {
+            UsersModel::where('user_id', $v['user_id'])->update(['vip_use_num' => 0, 'vip_discount_quota' => 0]);
+        }
+
+        $info = array(
+            'desc' => '每月清空VIP开通限制',
+            'status' => '成功',
+            'ip' => $ip,
+            'time' => date('Y-m-d H:i:s' ,time())
+        );
+
+        Db::name('plan_log')->insert($info);
+    }
+    // 清空今日已用的基础排队次数 /api/plan/clearTodayQueueUseNum
+    public function clearTodayQueueUseNum()
+    {
+        $ids = UsersModel::field('user_id')->select();
+        $ip = $this->request->ip();
+
+        foreach ($ids as $v) {
+            UsersModel::where('user_id', $v['user_id'])->update(['queue_num_today' => 0]);
+        }
+
+        $info = array(
+            'desc' => '每天清空已用基础排队次数',
+            'status' => '成功',
+            'ip' => $ip,
+            'time' => date('Y-m-d H:i:s' ,time())
+        );
+
+        Db::name('plan_log')->insert($info);
+    }
+}

+ 151 - 60
application/api/controller/Register.php

@@ -4,12 +4,15 @@ namespace app\api\controller;
 
 use app\api\model\UsersModel;
 use app\common\controller\Api;
+use fast\Random;
 use think\Cache;
+use think\Controller;
+use think\Db;
 
 /**
  * 注册接口
  */
-class Register extends Api
+class Register extends Controller
 {
     protected $noNeedRight = '*';
     protected $noNeedLogin = '*';
@@ -21,10 +24,7 @@ class Register extends Api
      * @param string $code 验证码
      * @param string $user_tjtel 推荐人手机号
      * @param string $user_pwd 密码
-     * @param string $type 注册方式0手机号1QQ或微信
-     * @param string $user_avatar 头像
-     * @param string $user_openID QQ或微信开放id
-     * @param string $user_nickname QQ或微信开放姓名
+     * @param string $type 默认0
      */
     public function register()
     {
@@ -35,21 +35,22 @@ class Register extends Api
                 if (isset($params['user_tjtel'])) {  //验证推荐人手机号
                     $issetTjTel = UsersModel::where('user_tel', $params['user_tjtel'])->find();
                     if (!$issetTjTel) {
-                        return $this->result('未找到推荐人手机号', '', 100);
+                        return json(['code' => 100, 'msg' => '未找到推荐人手机号','data' => []]);
                     }
+                    $addUserMember = Db::name('Users')->where('user_tel', $params['user_tjtel'])->setInc('user_member_count', 1); // 给上机的下级成员总数加1
                 } else {
-                    return $this->result('请填写推荐人手机号', [], 100);
+                    return json(['code' => 100, 'msg' => '请填写推荐人手机号','data' => []]);
                 }
                 if (isset($params['user_tel'])) {  //验证用户手机号
                     $issetTjTel = UsersModel::where('user_tel', $params['user_tel'])->find();
                     if ($issetTjTel) {
-                        return $this->result('此手机号已被注册', '', 100);
+                        return json(['code' => 100, 'msg' => '此手机号已被注册','data' => []]);
                     }
                 } else {
-                    return $this->result('请填写手机号', [], 100);
+                    return json(['code' => 100, 'msg' => '请填写手机号','data' => []]);
                 }
                 if (!isset($params['code']) || !Cache::get($params['code'])) {  //验证验证码是否错误
-                    return $this->result('验证码错误', '', 100);
+                    return json(['code' => 100, 'msg' => '验证码错误','data' => []]);
                 }
                 $userModel = new UsersModel(); //实例化usermodel
                 if ($params['type'] == 0) {  //使用手机号注册
@@ -66,13 +67,13 @@ class Register extends Api
                     ];
                     $validata = $this->validate($params, $rules, $msg);
                     if (is_string($validata)) {
-                        return $this->result($validata, [], 100);
+                        return json(['code' => 100, 'msg' => $validata,'data' => []]);
                     }
                     $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.img',
+                        'user_avatar'   => config('site.httpurl') . '/uploads/logo.jpg',
                         'create_time'   => date('Y-m-d H:i:s', time()),
                         'user_tjtel'    => $params['user_tjtel'],
                         'type'          => $params['type'],
@@ -80,51 +81,129 @@ class Register extends Api
                     $addUser = $userModel->allowField(true)->save($data);
                     if ($addUser) {
                         Cache::rm($params['code']);//删除验证码缓存
-                        return $this->result('注册成功', [], 200);
+                        return json(['code' => 200, 'msg' => '注册成功','data' => []]);
                     } else {
-                        return $this->result('注册失败', [], 100);
-                    }
-                }
-                if ($params['type'] > 1) {
-                    $rules = [
-                        'user_nickname' => 'require',
-                        'user_avatar'   => 'require',
-                        'user_openid'   => 'require',
-                    ];
-                    $msg = [
-                        'user_nickname.require' => '昵称未获取',
-                        'user_avatar.require'   => '头像未获取',
-                        'user_openid.require'   => '开放id未获取',
-                    ];
-                    $validata = $this->validate($params, $rules, $msg);
-                    if (is_string($validata)) {
-                        return $this->result($validata, [], 100);
-                    }
-                    $data = array(
-                        'user_nickname' => $params['user_nickname'],
-                        'user_tel'      => $params['user_tel'],
-                        'user_pwd'      => '无',
-                        'user_avatar'   => $params['user_avatar'],
-                        'create_time'   => date('Y-m-d H:i:s', time()),
-                        'user_tjtel'    => $params['user_tjtel'],
-                        'user_openid'   => $params['user_openid'],
-                        'type'          => $params['type'],
-                    );
-                    $addUser = $userModel->allowField(true)->save($data);
-                    if ($addUser) {
-                        Cache::rm($params['code']);//删除验证码缓存
-                        return $this->result('注册成功', [], 200);
-                    } else {
-                        return $this->result('注册失败', [], 100);
+                        return json(['code' => 100, 'msg' => '注册失败','data' => []]);
                     }
                 }
             } else {
-                return $this->result('手机号不合法', '', 100);
+                return json(['code' => 100, 'msg' => '手机号不合法','data' => []]);
             }
         } else {
-            return $this->result('手机号不存在', '', 100);
+            return json(['code' => 100, 'msg' => '手机号不存在','data' => []]);
+        }
+
+    }
+
+    /**
+     * QQ微信注册
+     * @ApiMethod   (POST)
+     * @param string $type 默认1
+     * @param string $user_avatar 头像
+     * @param string $user_uniodid QQ或微信开放id
+     * @param string $user_nickname QQ或微信开放姓名
+     */
+    public function wechatRegister()
+    {
+        $params = $this->request->post();
+        $rules = [
+            'user_nickname' => 'require',
+            'user_avatar'   => 'require',
+            'user_unionid'  => 'require',
+            'type'          => 'require',
+        ];
+        $msg = [
+            'user_nickname.require' => '昵称未获取',
+            'user_avatar.require'   => '头像未获取',
+            'user_unionid.require'  => '开放id未获取',
+            'type.require'          => '开放id未获取',
+        ];
+        $validata = $this->validate($params, $rules, $msg);
+        if (is_string($validata)) {
+            return json(['code' => 200, 'msg' => '','data' => $validata]);
+        }
+        $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'          => $params['type'],
+        );
+        $addUser = Db::name('Users')->insertGetId($data);
+        $token = self::settoken($addUser);
+        $res = array(
+            'user_id' => $addUser,
+            'token'   => $token,
+        );
+        if ($addUser) {
+            return json(['code' => 20, '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 用户手机号
+     */
+    public function addTel()
+    {
+        $params = $this->request->post();
+        $rules = [
+            'user_id'    => 'require|number',
+            'code'       => 'require|number',
+            'user_tel'   => 'require|number',
+            'user_tjtel' => 'require|number',
+        ];
+        $msg = [
+            'user_id.require'    => '网络错误1',
+            'code .require'      => '网络错误2',
+            'user_tel.require'   => '手机号不能为空',
+            'user_tjtel.require' => '推荐人手机号不能为空',
+            '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' => []]);
+        }
+        $check = '/^(1(([35789][0-9])|(47)))\d{8}$/';
+        if (!preg_match($check, $params['user_tel'])) {
+            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' => []]);
+        }
+        //判断验证码是否正确
+        if (!Cache::get($params['code'])) {
+            return json(['code' => 100, 'msg' => '验证码不正确','data' => []]);
+        }
+        Cache::rm($params['code']);
+        $upddata = array(
+            'user_tel'   => $params['user_tel'],
+            'user_tjtel' => $params['user_tjtel'],
+            'type'       => 1,
+        );
+        $updUser_tel = Db::name('users')->where('user_id', $params['user_id'])->update($upddata);
+        if ($updUser_tel) {
+            $token = self::settoken($params['user_id']);
+            $res = array(
+                "user_id" => $params['user_id'],
+                "token"   => $token,
+            );
+            return json(['code' => 200, 'msg' => '绑定成功','data' => []]);
+        } else {
+            Db::name('users')->where('user_id', $params['user_id'])->delete(); // 绑定失败删除此用户
+            return json(['code' => 100, 'msg' => '绑定失败','data' => []]);
+        }
     }
 
     /**
@@ -140,9 +219,6 @@ class Register extends Api
         if (isset($params['user_tel'])) {
             if (preg_match($check, $params['user_tel'])) {
                 $issettel = UsersModel::where('user_tel', $params['user_tel'])->find(); //判断手机号是否存在
-                if ($issettel) {
-                    return $this->result('该手机号已存在', [], 100);
-                }
                 $code = $this->setCode();
                 $tpl_value = '#code#=' . $code . '&#company#=优享街';
                 $smsConf = array(
@@ -156,22 +232,21 @@ class Register extends Api
                     $result = json_decode($content, true);
                     $error_code = $result['error_code'];
                     if ($error_code == 0) {
-                        return $this->result('发送成功', $code, '200');
+                        return json(['code' => 200, 'msg' => '发送成功','data' => $code]);
                     } else {
-                        return $this->result('请求失败', [], '100');
+                        return json(['code' => 100, 'msg' => '请求失败','data' => []]);
                     }
                 }
             } else {
-                return $this->result('手机号不合法', [], 100);
+                return json(['code' => 100, 'msg' => '手机号不合法','data' => []]);
             }
         } else {
-            return $this->result('手机号不能为空', [], 100);
+            return json(['code' => 100, 'msg' => '手机号不能为空','data' => []]);
         }
     }
-    //发送短信
-
     /**
      * 请求接口返回内容
+     * @ApiInternal
      * @param string $url [请求的URL地址]
      * @param string $params [请求的参数]
      * @param int $ipost [是否采用POST形式]
@@ -207,8 +282,13 @@ class Register extends Api
         curl_close($ch);
         return $response;
     }
-
     //生成唯一六位随机数
+    /**
+     * 生成唯一六位随机数
+     *
+     * 可以通过@ApiInternal忽略请求的方法
+     * @ApiInternal
+     */
     public function setCode()
     {
         $code = rand('1000', '9999');
@@ -218,5 +298,16 @@ class Register extends Api
         Cache::set($code, $code, 600);
         return $code;
     }
-
+    /**
+     * 生成token
+     *
+     * 可以通过@ApiInternal忽略请求的方法
+     * @ApiInternal
+     */
+    public function settoken($user_id)
+    {
+        $token = Random::uuid();
+        \app\common\library\Token::set($token, $user_id, 0);
+        return $tokenInfo = \app\common\library\Token::get($token);
+    }
 }

+ 148 - 0
application/api/controller/Search.php

@@ -0,0 +1,148 @@
+<?php
+
+namespace app\api\controller;
+
+use app\api\model\CommodityModel;
+use app\api\model\SearchModel;
+use app\common\controller\Api;
+
+/**
+ * 商品搜索
+ */
+class Search extends Api
+{
+    protected $noNeedRight = '*';
+    protected $noNeedLogin = '*';
+
+    /**
+     * 搜索历史显示
+     * @ApiMethod   (POST)
+     * @param string $user_id 用户id
+     */
+    public function serachIndex()
+    {
+        $user_id = $this->request->post('user_id');
+        if (!$user_id) {
+            return $this->result('网络错误', [], 100);
+        }
+        $data = SearchModel::where('user_id', $user_id)->group('content')->select();
+        if ($data) {
+            return $this->result('', $data, 200);
+        } else {
+            return $this->result('暂无数据', [], 100);
+        }
+    }
+
+    /**
+     * 清空历史记录
+     * @ApiMethod   (POST)
+     * @param string $user_id 用户id
+     */
+    public function serachEmpty()
+    {
+        $user_id = $this->request->post('user_id');
+        if (!$user_id) {
+            return $this->result('网络错误', [], 100);
+        }
+        $del = SearchModel::where('user_id', $user_id)->delete();
+        if ($del) {
+            return $this->result('成功', [], 200);
+        } else {
+            return $this->result('失败', [], 100);
+        }
+    }
+
+    /**
+     * 关键词显示
+     * @ApiMethod   (POST)
+     * @param string $content 文字
+     */
+    public function keyIndex()
+    {
+        $content = $this->request->post('content');
+        if (!$content) {
+            return $this->result('网络错误', [], 100);
+        }
+        $where['c_name'] = ['like', "%" . $content . '%'];
+        $data = CommodityModel::where($where)->field('c_name')->group('c_name')->select();
+        if ($data) {
+            return $this->result('', $data, 200);
+        } else {
+            return $this->result('暂无数据', [], 100);
+        }
+    }
+
+    /**
+     * 使用关键词查询
+     * @ApiMethod   (POST)
+     * @param string $content 文字
+     * @param string $user_id 用户ID
+     * @param string $page 页数
+     */
+    public function searchKey()
+    {
+        $content = $this->request->post('content');
+        $user_id = $this->request->post('user_id');
+        $page = $this->request->post('page');
+        if (!isset($page)) {
+            $page = 0;
+        }
+        if (!$user_id) {
+            return $this->result('网络错误', [], 100);
+        }
+        if (!$content) {
+            return $this->result('网络错误', [], 100);
+        }
+        $where['c_name'] = ['like', "%" . $content . "%"];
+        $data = CommodityModel::where($where)->page($page, 5)->select();
+        $params = array(
+            'user_id' => $user_id,
+            'content' => $content,
+            'type'    => 1,
+        );
+        $model = new SearchModel();
+        $addSearch = $model->allowField(true)->save($params);
+        if ($data) {
+            return $this->result('', $data, 200);
+        } else {
+            return $this->result('暂无数据', [], 100);
+        }
+    }
+
+    /**
+     * 不使用关键词查询
+     * @ApiMethod   (POST)
+     * @param string $content 文字
+     * @param string $user_id 用户ID
+     * @param string $page 页数
+     */
+    public function searchTitle()
+    {
+        $content = $this->request->post('content');
+        $user_id = $this->request->post('user_id');
+        $page = $this->request->post('page');
+        if (!isset($page)) {
+            $page = 0;
+        }
+        if (!$user_id) {
+            return $this->result('网络错误', [], 100);
+        }
+        if (!$content) {
+            return $this->result('网络错误', [], 100);
+        }
+        $where['c_title_content'] = ['like', "%" . $content . "%"];
+        $data = CommodityModel::where($where)->page($page, 5)->select();
+        $params = array(
+            'user_id' => $user_id,
+            'content' => $content,
+            'type'    => 2,
+        );
+        $model = new SearchModel();
+        $addSearch = $model->allowField(true)->save($params);
+        if ($data) {
+            return $this->result('', $data, 200);
+        } else {
+            return $this->result('暂无数据', [], 100);
+        }
+    }
+}

+ 101 - 101
application/api/controller/Sms.php

@@ -1,102 +1,102 @@
 <?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-use app\common\library\Sms as Smslib;
-use app\common\model\User;
-use think\Hook;
-
-/**
- * 手机短信接口
- */
-class Sms extends Api
-{
-    protected $noNeedLogin = '*';
-    protected $noNeedRight = '*';
-
-    /**
-     * 发送验证码
-     *
-     * @param string $mobile 手机号
-     * @param string $event 事件名称
-     */
-    public function send()
-    {
-        $mobile = $this->request->request("mobile");
-        $event = $this->request->request("event");
-        $event = $event ? $event : 'register';
-
-        if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) {
-            $this->error(__('手机号不正确'));
-        }
-        $last = Smslib::get($mobile, $event);
-        if ($last && time() - $last['createtime'] < 60) {
-            $this->error(__('发送频繁'));
-        }
-        $ipSendTotal = \app\common\model\Sms::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
-        if ($ipSendTotal >= 5) {
-            $this->error(__('发送频繁'));
-        }
-        if ($event) {
-            $userinfo = User::getByMobile($mobile);
-            if ($event == 'register' && $userinfo) {
-                //已被注册
-                $this->error(__('已被注册'));
-            } elseif (in_array($event, ['changemobile']) && $userinfo) {
-                //被占用
-                $this->error(__('已被占用'));
-            } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
-                //未注册
-                $this->error(__('未注册'));
-            }
-        }
-        if (!Hook::get('sms_send')) {
-            $this->error(__('请在后台插件管理安装短信验证插件'));
-        }
-        $ret = Smslib::send($mobile, null, $event);
-        if ($ret) {
-            $this->success(__('发送成功'));
-        } else {
-            $this->error(__('发送失败,请检查短信配置是否正确'));
-        }
-    }
-
-    /**
-     * 检测验证码
-     *
-     * @param string $mobile 手机号
-     * @param string $event 事件名称
-     * @param string $captcha 验证码
-     */
-    public function check()
-    {
-        $mobile = $this->request->request("mobile");
-        $event = $this->request->request("event");
-        $event = $event ? $event : 'register';
-        $captcha = $this->request->request("captcha");
-
-        if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) {
-            $this->error(__('手机号不正确'));
-        }
-        if ($event) {
-            $userinfo = User::getByMobile($mobile);
-            if ($event == 'register' && $userinfo) {
-                //已被注册
-                $this->error(__('已被注册'));
-            } elseif (in_array($event, ['changemobile']) && $userinfo) {
-                //被占用
-                $this->error(__('已被占用'));
-            } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
-                //未注册
-                $this->error(__('未注册'));
-            }
-        }
-        $ret = Smslib::check($mobile, $captcha, $event);
-        if ($ret) {
-            $this->success(__('成功'));
-        } else {
-            $this->error(__('验证码不正确'));
-        }
-    }
-}
+//
+//namespace app\api\controller;
+//
+//use app\common\controller\Api;
+//use app\common\library\Sms as Smslib;
+//use app\common\model\User;
+//use think\Hook;
+//
+///**
+// * 手机短信接口
+// */
+//class Sms extends Api
+//{
+//    protected $noNeedLogin = '*';
+//    protected $noNeedRight = '*';
+//
+//    /**
+//     * 发送验证码
+//     *
+//     * @param string $mobile 手机号
+//     * @param string $event 事件名称
+//     */
+//    public function send()
+//    {
+//        $mobile = $this->request->request("mobile");
+//        $event = $this->request->request("event");
+//        $event = $event ? $event : 'register';
+//
+//        if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) {
+//            $this->error(__('手机号不正确'));
+//        }
+//        $last = Smslib::get($mobile, $event);
+//        if ($last && time() - $last['createtime'] < 60) {
+//            $this->error(__('发送频繁'));
+//        }
+//        $ipSendTotal = \app\common\model\Sms::where(['ip' => $this->request->ip()])->whereTime('createtime', '-1 hours')->count();
+//        if ($ipSendTotal >= 5) {
+//            $this->error(__('发送频繁'));
+//        }
+//        if ($event) {
+//            $userinfo = User::getByMobile($mobile);
+//            if ($event == 'register' && $userinfo) {
+//                //已被注册
+//                $this->error(__('已被注册'));
+//            } elseif (in_array($event, ['changemobile']) && $userinfo) {
+//                //被占用
+//                $this->error(__('已被占用'));
+//            } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
+//                //未注册
+//                $this->error(__('未注册'));
+//            }
+//        }
+//        if (!Hook::get('sms_send')) {
+//            $this->error(__('请在后台插件管理安装短信验证插件'));
+//        }
+//        $ret = Smslib::send($mobile, null, $event);
+//        if ($ret) {
+//            $this->success(__('发送成功'));
+//        } else {
+//            $this->error(__('发送失败,请检查短信配置是否正确'));
+//        }
+//    }
+//
+//    /**
+//     * 检测验证码
+//     *
+//     * @param string $mobile 手机号
+//     * @param string $event 事件名称
+//     * @param string $captcha 验证码
+//     */
+//    public function check()
+//    {
+//        $mobile = $this->request->request("mobile");
+//        $event = $this->request->request("event");
+//        $event = $event ? $event : 'register';
+//        $captcha = $this->request->request("captcha");
+//
+//        if (!$mobile || !\think\Validate::regex($mobile, "^1\d{10}$")) {
+//            $this->error(__('手机号不正确'));
+//        }
+//        if ($event) {
+//            $userinfo = User::getByMobile($mobile);
+//            if ($event == 'register' && $userinfo) {
+//                //已被注册
+//                $this->error(__('已被注册'));
+//            } elseif (in_array($event, ['changemobile']) && $userinfo) {
+//                //被占用
+//                $this->error(__('已被占用'));
+//            } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
+//                //未注册
+//                $this->error(__('未注册'));
+//            }
+//        }
+//        $ret = Smslib::check($mobile, $captcha, $event);
+//        if ($ret) {
+//            $this->success(__('成功'));
+//        } else {
+//            $this->error(__('验证码不正确'));
+//        }
+//    }
+//}

+ 41 - 41
application/api/controller/Token.php

@@ -1,42 +1,42 @@
 <?php
-
-namespace app\api\controller;
-
-use app\common\controller\Api;
-use fast\Random;
-
-/**
- * Token接口
- */
-class Token extends Api
-{
-    protected $noNeedLogin = [];
-    protected $noNeedRight = '*';
-
-    /**
-     * 检测Token是否过期
-     *
-     */
-    public function check()
-    {
-        $token = $this->auth->getToken();
-        $tokenInfo = \app\common\library\Token::get($token);
-        $this->success('', ['token' => $tokenInfo['token'], 'expires_in' => $tokenInfo['expires_in']]);
-    }
-
-    /**
-     * 刷新Token
-     *
-     */
-    public function refresh()
-    {
-        //删除源Token
-        $token = $this->auth->getToken();
-        \app\common\library\Token::delete($token);
-        //创建新Token
-        $token = Random::uuid();
-        \app\common\library\Token::set($token, $this->auth->id, 2592000);
-        $tokenInfo = \app\common\library\Token::get($token);
-        $this->success('', ['token' => $tokenInfo['token'], 'expires_in' => $tokenInfo['expires_in']]);
-    }
-}
+//
+//namespace app\api\controller;
+//
+//use app\common\controller\Api;
+//use fast\Random;
+//
+///**
+// * Token接口
+// */
+//class Token extends Api
+//{
+//    protected $noNeedLogin = [];
+//    protected $noNeedRight = '*';
+//
+//    /**
+//     * 检测Token是否过期
+//     *
+//     */
+//    public function check()
+//    {
+//        $token = $this->auth->getToken();
+//        $tokenInfo = \app\common\library\Token::get($token);
+//        $this->success('', ['token' => $tokenInfo['token'], 'expires_in' => $tokenInfo['expires_in']]);
+//    }
+//
+//    /**
+//     * 刷新Token
+//     *
+//     */
+//    public function refresh()
+//    {
+//        //删除源Token
+//        $token = $this->auth->getToken();
+//        \app\common\library\Token::delete($token);
+//        //创建新Token
+//        $token = Random::uuid();
+//        \app\common\library\Token::set($token, $this->auth->id, 2592000);
+//        $tokenInfo = \app\common\library\Token::get($token);
+//        $this->success('', ['token' => $tokenInfo['token'], 'expires_in' => $tokenInfo['expires_in']]);
+//    }
+//}

+ 143 - 37
application/api/controller/User.php

@@ -44,6 +44,8 @@ class User extends Api
         $data = UsersModel::where('user_id', $user_id)->find();
         $data['daifahuo'] = 1;
         $data['daishouhuo'] = 1;
+        $data['tuikuan'] = 1;
+        $data['daifukuan'] = 1;
         if ($data) {
             return $this->result('', $data, 200);
         } else {
@@ -270,7 +272,7 @@ class User extends Api
         if (!isset($user_id)) {
             return $this->result('网络错误', [], 100);
         }
-        $data = Address::where('user_id', $user_id)->select();
+        $data = Address::where('user_id', $user_id)->order('is_default desc')->select();
         if ($data) {
             return $this->result('', $data, 200);
         } else {
@@ -286,6 +288,9 @@ class User extends Api
      * @param string $a_tel 手机号
      * @param string $city 城市
      * @param string $area 详细地址
+     * @param string $city_province 省的地标
+     * @param string $city_city 市的地标
+     * @param string $city_area 区的地标
      * @param string $is_default 1默认0不默认
      */
     public function addressAdd()
@@ -320,6 +325,10 @@ class User extends Api
         } else {
             return $this->result('手机号不能为空', [], 100);
         }
+        if ($params['is_default'] == 1) {
+            // 如果添加一个默认地址德华,先把所有地址改为非默认
+            $updallstate = Db::name('address')->where('user_id', $params['user_id'])->update(['is_default' => 0]);
+        }
         $model = new Address();
         $addressAdd = $model->allowField(true)->save($params);
         if ($addressAdd) {
@@ -333,11 +342,14 @@ class User extends Api
      * 地址修改
      * @ApiMethod   (POST)
      * @param string $a_id 地址id
+     * @param string $user_id 用户id
      * @param string $a_name 姓名
      * @param string $a_tel 手机号
      * @param string $city 城市
+     * @param string $city_province 省的地标
+     * @param string $city_city 市的地标
+     * @param string $city_area 区的地标
      * @param string $area 详细地址
-     * @param string $is_default 1默认0不默认
      */
     public function addressUpd()
     {
@@ -349,6 +361,10 @@ class User extends Api
         if (!isset($params['a_id'])) {
             return $this->result('网络错误', [], 100);
         }
+        if (isset($params['is_default']) && $params['is_default'] == 1) {
+            // 如果添加一个默认地址德华,先把所有地址改为非默认
+            $updallstate = Db::name('address')->where('user_id', $params['user_id'])->update(['is_default' => 0]);
+        }
         $model = new Address();
         $addressUpd = $model->allowField(true)->save($params, ['a_id' => $params['a_id']]);
         if ($addressUpd) {
@@ -359,6 +375,45 @@ class User extends Api
     }
 
     /**
+     * 地址改为默认
+     * @ApiMethod   (POST)
+     * @param string $a_id 地址id
+     * @param string $user_id 用户id
+     * @param string $is_default 0否1是
+     */
+    public function is_default()
+    {
+        $params = $this->request->post();
+        if (!isset($params['a_id']) || !isset($params['is_default'])) {
+            return $this->result('网络错误', '', 100);
+        }
+        // 如果要改为默认,判断是否存在默认了
+        if ($params['is_default'] == 1) {
+            $where = array(
+                'user_id'    => $params['user_id'],
+                'is_default' => 1
+            );
+            // 先把所有的都地址改为非默认
+            $updallstate = Db::name('address')->where('user_id', $params['user_id'])->update(['is_default' => 0]);
+            //在把选中的地址改为默认
+            $addressUpd = Db::name('address')->where('a_id', $params['a_id'])->update(['is_default' => 1]);
+            if ($addressUpd) {
+                return $this->result('修改成功', '', 200);
+            } else {
+                return $this->result('修改失败', '', 100);
+            }
+        } //改为取消默认
+        else {
+            $addressUpd = Db::name('address')->where('a_id', $params['a_id'])->update(['is_default' => 0]);
+            if ($addressUpd) {
+                return $this->result('修改成功', '', 200);
+            } else {
+                return $this->result('修改失败', '', 100);
+            }
+        }
+    }
+
+    /**
      * 地址删除
      * @ApiMethod   (POST)
      * @param string $a_id 地址id
@@ -413,7 +468,7 @@ class User extends Api
     }
 
     /**
-     * 我的红豆
+     * 红豆兑换
      * @ApiMethod   (POST)
      * @param string $user_id 用户id
      * @param string $user_redbean 兑换个数
@@ -472,7 +527,24 @@ class User extends Api
             return $this->result('网络错误', '', 100);
         }
     }
-
+    /**
+     * 我的余额提现记录
+     * @ApiMethod   (POST)
+     * @param string $user_id 用户id
+     */
+    public function moneyRecord()
+    {
+        $params = $this->request->post();
+        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();
+        if ($data) {
+            return $this->result('', $data, 200);
+        } else {
+            return $this->result('暂无数据', [], 100);
+        }
+    }
     /**
      * 我的红豆兑换记录
      * @ApiMethod   (POST)
@@ -484,7 +556,7 @@ class User extends Api
         if (!isset($params['user_id'])) {
             return $this->result('网络错误', [], 100);
         }
-        $data = Record::where('user_id', $params['user_id'])->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 {
@@ -580,55 +652,89 @@ class User extends Api
             'user_id.number'  => '网络错误',
             'money.number'    => '网络错误',
         ];
-        $validata = $this->validate($params,$rules,$msg);
+        $validata = $this->validate($params, $rules, $msg);
         if (is_string($validata)) {
-            return $this->result($validata,[],100);
+            return $this->result($validata, [], 100);
         }
-        if(!preg_match("/^[1-9][0-9]*$/" ,$params['money'])){
-            return $this->result('请输入正整数',[],100);
+        // 正则验证金额为正整数
+        if (!preg_match("/^[1-9][0-9]*$/", $params['money'])) {
+            return $this->result('请输入正整数', [], 100);
         }
-//        //检测提现金额表中是否有这个金额
-        $is_money = Db::name('cash_money')->where('money',$params['money'])->find();
+        //检测提现金额表中是否有这个金额
+        $is_money = Db::name('cash_money')->where('money', $params['money'])->find();
 //        if (!$is_money) {
-//            return $this->result('该金额暂不支持提现',[],100);
+//            return $this->result('该金额暂不支持提现', [], 100);
 //        }
-//        //判断是否该提现这个次数了
-        $user_cash_level = UsersModel::where('user_id',$params['user_id'])->find();
+        //判断是否该提现这个次数了
+        $user_cash_level = UsersModel::where('user_id', $params['user_id'])->find();
 //        if ($user_cash_level) {
 //            if ($user_cash_level['cash_level'] + 1 != 9) { //最后一个不算
-//                if($is_money['c_id'] != $user_cash_level['cash_level'] + 1) {
-//                    return $this->result('请按照顺序提现',[],100);
+//                if ($is_money['c_id'] != $user_cash_level['cash_level'] + 1) {
+//                    return $this->result('请按照顺序提现', [], 100);
 //                }
 //            }
 //        }
+        // 判断余额
         if ($user_cash_level['user_money'] < $params['money']) {
-            return $this->result('余额不足',[],100);
+            return $this->result('余额不足', [], 100);
         }
-        if ($user_cash_level['type'] != 1) {
-            return $this->result('请先微信授权在提现',[],100);
+        // 判断是否微信网页受过权
+        if ($user_cash_level['user_openid'] == '') {
+            return $this->result('请先微信网页授权在提现', [], 10);
         }
+        // 开启事务
         Db::startTrans();
-        try{
-            $updMoney = UsersModel::where('user_id',$params['user_id'])->setDec('user_money',$params['money']);
+        try {
+            // 减少用户余额
+            $updMoney = UsersModel::where('user_id', $params['user_id'])->setDec('user_money', $params['money']);
+            // 关闭事务
             Db::commit();
         } catch (\Exception $e) {
+            // 回滚
             Db::rollback();
-            return $this->result('网络错误,提现失败',[],100);
-        }
-        if ($updMoney) {
-            $number = rand(100,999).time();
-            $data = [
-                'user_id' => $params['user_id'],
-                'money' => $params['money'],
-                'state' => 1,
-                'create_time' => date('Y-m-d H:i:s',time()),
-                'number' => $number,
-            ];
-            $add_log = Db::name('cash_log')->insert($data);
-            $cashWeChat = new Cashwechat();
-            $res = $cashWeChat->sendMoney(1,"oRrdQt-L9A0WfDGT-nwHC24Er0tI",'余额提现',$user_cash_level['user_nickname'],$number);
-
-            return $res;
+            return $this->result('网络错误,提现失败', [], 100);
+        }
+        if (!$updMoney) {
+            return $this->result('网络错误', [], 100);
+        }
+        // 生成订单号
+        $number = rand(100, 999) . time();
+        $data = [
+            'user_id'     => $params['user_id'],
+            'money'       => $params['money'],
+            'state'       => 1,
+            'create_time' => date('Y-m-d H:i:s', time()),
+            'number'      => $number,
+        ];
+        // 添加提现记录
+        $add_log = Db::name('cash_log')->insert($data);
+        if (!$add_log) {
+            return $this->result('网络错误', [], 100);
         }
+        // 实例化企业付款到零钱类
+        $cashWeChat = new Cashwechat();
+        // 调用企业付款接口接口
+        $res = $cashWeChat->sendMoney($params['money'], $user_cash_level['user_openid'], '余额提现', $user_cash_level['user_nickname'], $number);
+        return $res;
+    }
+
+    /**
+     * 隐私协议
+     * @ApiMethod   (POST)
+     */
+    public function privacy()
+    {
+        $data = Db::name('privacy')->find();
+        return json(['code' => 200, 'msg' => '', 'data' => $data]);
+    }
+
+    /**
+     * 邀请二维码
+     * @ApiMethod   (POST)
+     */
+    public function weweima()
+    {
+        $url = "http://file02.16sucai.com/d/file/2015/0128/8b0f093a8edea9f7e7458406f19098af.jpg";
+        return json(['code' => 200, 'msg' => '', 'data' => $url]);
     }
 }

+ 121 - 0
application/api/controller/Wechatwebopenid.php

@@ -0,0 +1,121 @@
+<?php
+
+namespace app\api\controller;
+
+use app\api\model\UsersModel;
+use think\Controller;
+
+/**
+ * 微信公众号网页授权
+ */
+class Wechatwebopenid extends Controller
+{
+    /**
+     * 获取回调地址
+     */
+    public function unity_url()
+    {
+        $data = config('site.httpurl') . '/api/Wechatwebopenid/insertcode';
+        return json(['data' => $data, 'code' => 200]);
+    }
+
+    /**
+     * 接受code
+     * @ApiInternal // 生成接口时忽略此方法
+     */
+    public function insertcode()
+    {
+        $code = input('code');
+        $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' => '网络错误']);
+            }
+        }
+        //防止过期。刷新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' => '网络错误']);
+            }
+        }
+        //拉取用户信息
+        $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' => '网络错误']);
+        }
+    }
+
+    /**
+     * 通过code换取网页授权access_token
+     * @ApiInternal // 生成接口时忽略此方法
+     */
+    public function getAccess_token($code, $appid, $secret)
+    {
+        //设置请求之地
+        $access_token_url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' . $appid . '&secret=' . $secret . '&code=' . $code . '&grant_type=authorization_code';
+        $ch = curl_init();                                //初始化CURL句柄
+        curl_setopt($ch, CURLOPT_URL, $access_token_url); //设置请求的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);
+    }
+
+    /**
+     * 防止过期刷新token
+     * @ApiInternal // 生成接口时忽略此方法
+     */
+    public function refresh_token($appid, $refresh_token)
+    {
+        //设置请求之地
+        $refresh_token = 'https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=' . $appid . '&grant_type=refresh_token&refresh_token=' . $refresh_token;
+        $ch = curl_init();                                //初始化CURL句柄
+        curl_setopt($ch, CURLOPT_URL, $refresh_token);    //设置请求的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);
+    }
+
+    /**
+     * 拉取用户信息
+     * @ApiInternal // 生成接口时忽略此方法
+     */
+    public function userInfo($access_token, $appid)
+    {
+        //设置请求之地
+        $userInfo = 'https://api.weixin.qq.com/sns/userinfo?access_token=' . $access_token . '&openid=' . $appid . '&lang=zh_CN';
+        $ch = curl_init();                                //初始化CURL句柄
+        curl_setopt($ch, CURLOPT_URL, $userInfo);         //设置请求的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);
+    }
+}

+ 39 - 8
application/api/model/Cashwechat.php

@@ -1,15 +1,16 @@
 <?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){
-//        $total_amount = (100) * $amount;
-        $total_amount = $amount;
+        $total_amount = (100) * $amount;
+//        $total_amount = $amount;
         $data=array(
-            'mch_appid'=> 'wx032e75bf42061b96',//商户账号appid
+            'mch_appid'=> 'wxa372e8ef8a6f0e1d',//商户账号appid
             'mchid'=> '1550903451',//商户号
             'nonce_str'=> $this->createNoncestr(),//随机字符串
             'partner_trade_no'=> $number,//商户订单号
@@ -33,12 +34,42 @@ class Cashwechat extends Model
         $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);
-        halt($responseObj);
-        echo $res= $responseObj->return_code;  //SUCCESS  如果返回来SUCCESS,则发生成功,处理自己的逻辑
-        halt($res);
-        return $res;
+        $data = json_encode($responseObj);
+        $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(); //查出提现记录
+        if ($data['return_code'] == "SUCCESS" && $data['result_code'] == 'SUCCESS') {
+            if ($cash_log) {
+                // 查出用户信息
+                $user = UsersModel::where('user_id',$cash_log['user_id'])->find();
+                //修改状态为成功
+                $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);
+                }
+                if ($updCashstate) {
+                    return json(['code' => 200, 'msg' => '提现成功']);
+                }
+            }
+        }
+        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]);
+            $msg = array(
+                'reason' => '提现失败,请联系客服',
+                'admin_look' => $data['err_code_des']
+            );
+            // 写入提现失败原因
+            $reason = Db::name('cash_log')->where('number',$number)->update($msg);
+            if ($updCashstate&&$updUserMOney&&$reason) {
+                return json(['code' => 200, 'msg' => '提现失败']);
+            }
+        }
     }
 
     public function createNoncestr($length =32){

+ 97 - 0
application/api/model/Logistics.php

@@ -0,0 +1,97 @@
+<?php
+namespace app\api\model;
+use think\Model;
+
+/*
+ * 查看物流
+ */
+class Logistics extends Model
+{
+    private $appkey = "3be319b58697756c60b5bb090ee9edf5"; //申请的快递查询APPKEY
+
+    private $queryUrl = 'http://v.juhe.cn/exp/index';
+
+    private $comUrl = 'http://v.juhe.cn/exp/com';
+
+    public function logistics($order)
+    {
+        $result = $this->query($order['wuliu_com'],$order['wuliu_number']); //执行查询
+
+        if($result['error_code'] == 0){//查询成功
+            $list = $result['result']['list'];
+            return json(['data' => $result['result'],'order' => $order,'msg' => '', 'code' => 200]);
+        }else{
+            echo "获取失败,原因:".$result['reason'];
+            return json(['msg' => $result['reason'], 'data' => '', 'code' => 100]);
+        }
+   }
+    /**
+     * 返回支持的快递公司公司列表
+     * @return array
+     */
+    public function getComs(){
+        $params = 'key='.$this->appkey;
+        $content = $this->juhecurl($this->comUrl,$params);
+        return $this->_returnArray($content);
+    }
+
+    public function query($com,$no){
+        $params = array(
+            'key' => $this->appkey,
+            'com'  => $com,
+            'no' => $no
+        );
+        $content = $this->juhecurl($this->queryUrl,$params,1);
+        return $this->_returnArray($content);
+    }
+
+    /**
+     * 将JSON内容转为数据,并返回
+     * @param string $content [内容]
+     * @return array
+     */
+    public function _returnArray($content){
+        return json_decode($content,true);
+    }
+
+    /**
+     * 请求接口返回内容
+     * @param  string $url [请求的URL地址]
+     * @param  string $params [请求的参数]
+     * @param  int $ipost [是否采用POST形式]
+     * @return  string
+     */
+    public function juhecurl($url,$params=false,$ispost=0){
+        $httpInfo = array();
+        $ch = curl_init();
+
+        curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
+        curl_setopt( $ch, CURLOPT_USERAGENT , 'JuheData' );
+        curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );
+        curl_setopt( $ch, CURLOPT_TIMEOUT , 60);
+        curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
+        if( $ispost )
+        {
+            curl_setopt( $ch , CURLOPT_POST , true );
+            curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
+            curl_setopt( $ch , CURLOPT_URL , $url );
+        }
+        else
+        {
+            if($params){
+                curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
+            }else{
+                curl_setopt( $ch , CURLOPT_URL , $url);
+            }
+        }
+        $response = curl_exec( $ch );
+        if ($response === FALSE) {
+            //echo "cURL Error: " . curl_error($ch);
+            return false;
+        }
+        $httpCode = curl_getinfo( $ch , CURLINFO_HTTP_CODE );
+        $httpInfo = array_merge( $httpInfo , curl_getinfo( $ch ) );
+        curl_close( $ch );
+        return $response;
+    }
+}

+ 116 - 5
application/api/model/OrderModel.php

@@ -2,6 +2,7 @@
 
 namespace app\api\model;
 
+use app\common\lib\WxPay;
 use think\Db;
 use think\Model;
 
@@ -15,6 +16,9 @@ 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']) {
+            return json(['code' => 100, 'msg' => '支付密码不正确', 'data' => '']);
+        }
         if (!$userInfo) {
             return json(['code' => 100, 'msg' => '网络错误', 'data' => '']);
         }
@@ -26,6 +30,9 @@ class OrderModel extends Model
         if ($userInfo['user_money'] < $params['money']) {
             return json(['code' => 100, 'msg' => '您的余额不足', 'data' => '']);
         }
+        if ($userInfo['user_paypwd'] == '') {
+            return json(['code' => 60, 'msg' => '还未设置支付密码,请去设置', 'data' => '']);
+        }
         Db::startTrans();
         try {
             //扣除用户余额
@@ -54,6 +61,7 @@ class OrderModel extends Model
             'whitebeon'   => $whitebean,
             'pay_time'    => date("Y-m-d H:i:s", time()),
             'state'       => 2,
+            'type'        => $params['type'],
         );
         //生成已支付订单
         $addOrderId = Db::name('order')->insertGetId($orderdata);
@@ -61,12 +69,18 @@ class OrderModel extends Model
             return json(['code' => 100, 'msg' => '订单生成失败', 'data' => '']);
         }
         $list = $params['list'];
+        //循环加入奖励的白豆
+        $whitebean = 0;  // 白豆初始化
+        foreach ($list as &$v) {
+            $commodity = CommodityModel::where('c_id', $v['c_id'])->find()->toArray(); // 查出商品详情
+            $whitebean = $commodity['c_whitebean'] + $whitebean;
+        }
         //创建订单商品信息
         foreach ($list as &$v) {
             $commoditycolor = Commoditycolor::where('colorid', $v['colorid'])->find()->toArray();                     //查 出商品颜色表参数
             $parameter = Parameter::where('p_id', $v['p_id'])->find()->toArray();                                     // 查出商品规格表参数
             $commodity = CommodityModel::where('c_id', $v['c_id'])->field('c_vipprice,c_freight')->find()->toArray(); // 查出商品价格和运费
-            $v = array_merge($commoditycolor, $parameter, $commodity, $v);                                            // 合并颜色表、规格表、商品表、以及传过来的数据
+            $v = array_merge($commoditycolor, $parameter, $commodity, $v);
             $order_commodity_data = array(
                 'c_id'       => $v['c_id'],
                 'p_id'       => $v['p_id'],
@@ -86,12 +100,13 @@ class OrderModel extends Model
             return json(['code' => 100, 'msg' => '网络错误', 'data' => '']);
         }
         //创建地址信息
+        $address = Address::where('a_id', $params['a_id'])->find();
         $order_address = array(
             'a_id'   => $params['a_id'],
-            'a_name' => $params['a_name'],
-            'a_tel'  => $params['a_tel'],
-            'a_city' => $params['city'],
-            'a_area' => $params['area'],
+            'a_name' => $address['a_name'],
+            'a_tel'  => $address['a_tel'],
+            'a_city' => $address['city'],
+            'a_area' => $address['area'],
             'o_id'   => $addOrderId
         );
         //订单地址添加
@@ -103,6 +118,98 @@ class OrderModel extends Model
         }
     }
 
+    /*
+     * 订单微信支付
+     */
+    public function wechatOrder($params)
+    {
+        $userInfo = UsersModel::where('user_id', $params['user_id'])->find();
+        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' => '']);
+        }
+        //创建订单信息
+        $orderdata = array(
+            'user_id'     => $params['user_id'],
+            'money'       => $params['money'],
+            'freight'     => $params['freight'],
+            'number'      => $params['number'],
+            'create_time' => $params['create_time'],
+            'whitebeon'   => $params['whitebean'],
+            'pay_time'    => date("Y-m-d H:i:s", time()),
+            'state'       => 1,
+            'type'        => $params['type'],
+        );
+        //生成已支付订单
+        $addOrderId = Db::name('order')->insertGetId($orderdata);
+        if (!$addOrderId) {
+            return json(['code' => 100, 'msg' => '订单生成失败', 'data' => '']);
+        }
+        $list = $params['list'];
+        //创建订单商品信息
+        foreach ($list as &$v) {
+            $commoditycolor = Commoditycolor::where('colorid', $v['colorid'])->find()->toArray();                     //查 出商品颜色表参数
+            $parameter = Parameter::where('p_id', $v['p_id'])->find()->toArray();                                     // 查出商品规格表参数
+            $commodity = CommodityModel::where('c_id', $v['c_id'])->field('c_vipprice,c_freight')->find()->toArray(); // 查出商品价格和运费
+            $v = array_merge($commoditycolor, $parameter, $commodity, $v);
+            $order_commodity_data = array(
+                'c_id'       => $v['c_id'],
+                'p_id'       => $v['p_id'],
+                'colorid'    => $v['colorid'],
+                'name'       => $v['name'],
+                'p_name'     => $v['p_name'],
+                'color'      => $v['color'],
+                'buy_number' => $v['buy_number'],
+                'c_vipprice' => $v['c_vipprice'],
+                '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' => '']);
+        }
+        //创建地址信息
+        $address = Address::where('a_id', $params['a_id'])->find();
+        $order_address = array(
+            'a_id'   => $params['a_id'],
+            'a_name' => $address['a_name'],
+            'a_tel'  => $address['a_tel'],
+            'a_city' => $address['city'],
+            'a_area' => $address['area'],
+            'o_id'   => $addOrderId
+        );
+        //订单地址添加
+        $add_order_address = Db::name('order_address')->insert($order_address);
+        if (!$add_order_address) {
+            return json(['code' => 200, 'msg' => '下单失败', 'data' => $addOrderId]);
+        }
+        //获取微信pre_id
+        $wxpay = new WxPay();
+        $body = "商品支付";
+        $total_fee = $params['money'];
+        $out_trade_no = $params['number'];
+        $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['o_id'] = $addOrderId;
+                return json(['data' => $result, 'msg' => '', 'code' => 200]);
+            } else {
+                return json(['data' => [], 'msg' => '拉取失败', 'code' => 100]);
+            }
+        } else {
+            return json(['data' => [], 'msg' => '拉取失败', 'code' => 100]);
+        }
+
+    }
+
     /**
      * 全部订单
      */
@@ -175,4 +282,8 @@ class OrderModel extends Model
     {
         return $this->hasOne('OrderAddress', 'o_id', 'o_id');
     }
+    public function Torder()
+    {
+        return $this->hasOne('Torder', 'o_id', 'o_id');
+    }
 }

+ 9 - 0
application/api/model/SearchModel.php

@@ -0,0 +1,9 @@
+<?php
+namespace app\api\model;
+use think\Model;
+
+class SearchModel extends Model
+{
+    protected $name = "search";
+
+}

+ 13 - 0
application/api/model/Torder.php

@@ -0,0 +1,13 @@
+<?php
+namespace app\api\model;
+use think\Model;
+
+class Torder extends Model
+{
+    protected $name = 't_order';
+
+    public function Order()
+    {
+        return $this->belongsTo('order','o_id','o_id');
+    }
+}

+ 17 - 0
application/api/validate/Users.php

@@ -0,0 +1,17 @@
+<?php
+namespace app\api\validate;
+use think\Validate;
+
+/**
+ * 用户模型验证
+ */
+class Users extends Validate
+{
+//    protected $rule = [
+//        'user_tel','require|max:11|/^1[3-8]{1}[0-9]{9}$/','请输入用户手机号码|手机号码最多不能超过11个字符|手机号码格式不正确',
+//        'user_tjtel','require|max:11|/^1[3-8]{1}[0-9]{9}$/','请输入推荐人手机号码|手机号码最多不能超过11个字符|手机号码格式不正确',
+//    ];
+      protected $rule = [
+          'user_id' => 'require|number',
+      ];
+}

+ 11 - 11
extend/alipay/aop/request/AftAifinFireeyeOcrImageQueryRequest.php

@@ -6,10 +6,10 @@
  * @since 1.0, 2019-01-07 20:51:15
  */
 class AftAifinFireeyeOcrImageQueryRequest
-{
-	/** 
-	 * OCR火眼识别
-	 **/
+{
+	/** 
+	 * OCR火眼识别
+	 **/
 	private $bizContent;
 
 	private $apiParas = array();
@@ -21,16 +21,16 @@ class AftAifinFireeyeOcrImageQueryRequest
 	private $returnUrl;
     private $needEncrypt=false;
 
-	
+	
 	public function setBizContent($bizContent)
-	{
-		$this->bizContent = $bizContent;
-		$this->apiParas["biz_content"] = $bizContent;
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
 	}
-
+
 	public function getBizContent()
-	{
-		return $this->bizContent;
+	{
+		return $this->bizContent;
 	}
 
 	public function getApiMethodName()

+ 11 - 11
extend/alipay/aop/request/AftFinsecureRiskplusSecurityPolicyQueryRequest.php

@@ -6,10 +6,10 @@
  * @since 1.0, 2019-01-07 20:51:15
  */
 class AftFinsecureRiskplusSecurityPolicyQueryRequest
-{
-	/** 
-	 * 策略咨询服务输出
-	 **/
+{
+	/** 
+	 * 策略咨询服务输出
+	 **/
 	private $bizContent;
 
 	private $apiParas = array();
@@ -21,16 +21,16 @@ class AftFinsecureRiskplusSecurityPolicyQueryRequest
 	private $returnUrl;
     private $needEncrypt=false;
 
-	
+	
 	public function setBizContent($bizContent)
-	{
-		$this->bizContent = $bizContent;
-		$this->apiParas["biz_content"] = $bizContent;
+	{
+		$this->bizContent = $bizContent;
+		$this->apiParas["biz_content"] = $bizContent;
 	}
-
+
 	public function getBizContent()
-	{
-		return $this->bizContent;
+	{
+		return $this->bizContent;
 	}
 
 	public function getApiMethodName()

+ 21 - 0
public/assets/js/backend-init.js

@@ -1,3 +1,24 @@
 define(['backend'], function (Backend) {
     
+});
+$('body').on('click', '[data-tips-image]', function () {
+    var img = new Image();
+    var imgWidth = this.getAttribute('data-width') || '480px';
+    img.onload = function () {
+        var $content = $(img).appendTo('body').css({background: '#fff', width: imgWidth, height: 'auto'});
+        Layer.open({
+            type: 1, area: imgWidth, title: false, closeBtn: 1,
+            skin: 'layui-layer-nobg', shadeClose: true, content: $content,
+            end: function () {
+                $(img).remove();
+            },
+            success: function () {
+
+            }
+        });
+    };
+    img.onerror = function (e) {
+
+    };
+    img.src = this.getAttribute('data-tips-image') || this.src;
 });

+ 2 - 2
public/assets/js/backend/agreemen/courstomer.js

@@ -25,8 +25,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'c_id', title: __('C_id')},
-                        {field: 'c_type', title: __('C_type')},
-                        {field: 'c_number', title: __('C_number')},
+                        {field: 'c_type', title: __('电话')},
+                        {field: 'c_number', title: __('QQ或者微信')},
                         {field: 'c_image', title: __('C_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}
                     ]

+ 2 - 2
public/assets/js/backend/agreemen/coustomer.js

@@ -25,8 +25,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     [
                         {checkbox: true},
                         {field: 'c_id', title: __('C_id')},
-                        {field: 'c_type', title: __('C_type')},
-                        {field: 'c_number', title: __('C_number')},
+                        {field: 'c_type', title: __('电话')},
+                        {field: 'c_number', title: __('QQ或者微信')},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]

+ 50 - 0
public/assets/js/backend/agreemen/privacy.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/privacy/index' + location.search,
+                    add_url: 'agreemen/privacy/add',
+                    edit_url: 'agreemen/privacy/edit',
+                    del_url: 'agreemen/privacy/del',
+                    multi_url: 'agreemen/privacy/multi',
+                    table: 'privacy',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'p_id',
+                sortName: 'p_id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'p_id', title: __('P_id')},
+                        {field: 'content', title: __('协议而容')},
+                        {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;
+});

+ 89 - 0
public/assets/js/backend/order/order.js

@@ -0,0 +1,89 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'order/order/index' + location.search,
+                    add_url: 'order/order/add',
+                    edit_url: 'order/order/edit',
+                    del_url: 'order/order/del',
+                    multi_url: 'order/order/multi',
+                    table: 'order',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'o_id',
+                sortName: 'o_id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'o_id', title: __('O_id')},
+                        {field: 'users.user_nickname', title: __('Users.user_nickname')},
+                        {
+                            field: 'buttons',
+                            width: "120px",
+                            title: __('按钮组'),
+                            table: table,
+                            events: Table.api.events.operate,
+                            buttons: [
+                                {
+                                    name: 'detail',
+                                    text: __('点击查看购买详情'),
+                                    title: __('购买详情'),
+                                    classname: 'btn btn-xs btn-primary btn-dialog',
+                                    icon: 'fa fa-list',
+                                    url: "order/order/orderCommodityInfo",
+                                    callback: function (data) {
+                                        Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
+                                    },
+                                    visible: function (row) {
+                                        //返回true时按钮显示,返回false隐藏
+                                        return true;
+                                    }
+                                },
+                            ],
+                            formatter: Table.api.formatter.buttons
+                        },
+                        {field: 'money', title: __('Money'), operate:'BETWEEN'},
+                        {field: 'freight', title: __('Freight'), operate:'BETWEEN'},
+                        {field: 'number', title: __('Number')},
+                        {field: 'whitebeon', title: __('Whitebeon'), operate:'BETWEEN'},
+                        {field: 'state', title: __('订单状态')},
+                        {field: 'orderaddress.a_name', title: __('Orderaddress.a_name')},
+                        {field: 'orderaddress.a_tel', title: __('Orderaddress.a_tel')},
+                        {field: 'orderaddress.a_city', title: __('Orderaddress.a_city')},
+                        {field: 'orderaddress.a_area', title: __('Orderaddress.a_area')},
+                        {field: 'create_time', title: __('Create_time')},
+                        {field: 'pay_time', title: __('Pay_time')},
+                        {field: 'wuliu_number', title: __('Wuliu_number')},
+                        {field: 'wuliu_company', title: __('Wuliu_company')},
+                        {field: 'type', title: __('支付方式')},
+                        {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;
+});

+ 113 - 0
public/assets/js/backend/order/torder.js

@@ -0,0 +1,113 @@
+define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
+
+    var Controller = {
+        index: function () {
+            // 初始化表格参数配置
+            Table.api.init({
+                extend: {
+                    index_url: 'order/torder/index' + location.search,
+                    add_url: 'order/torder/add',
+                    edit_url: 'order/torder/edit',
+                    del_url: 'order/torder/del',
+                    multi_url: 'order/torder/multi',
+                    table: 'order',
+                }
+            });
+
+            var table = $("#table");
+
+            // 初始化表格
+            table.bootstrapTable({
+                url: $.fn.bootstrapTable.defaults.extend.index_url,
+                pk: 'o_id',
+                sortName: 'o_id',
+                columns: [
+                    [
+                        {checkbox: true},
+                        {field: 'o_id', title: __('O_id')},
+                        {field: 'users.user_nickname', title: __('用户昵称')},
+                        {
+                            field: 'buttons',
+                            width: "120px",
+                            title: __('按钮组'),
+                            table: table,
+                            events: Table.api.events.operate,
+                            buttons: [
+                                {
+                                    name: 'detail',
+                                    text: __('商品详情'),
+                                    title: __('点击查看商品详情'),
+                                    classname: 'btn btn-xs btn-primary btn-dialog',
+                                    icon: 'fa fa-list',
+                                    url: "order/order/orderCommodityInfo",
+                                    callback: function (data) {
+                                        Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
+                                    },
+                                    visible: function (row) {
+                                        //返回true时按钮显示,返回false隐藏
+                                        return true;
+                                    }
+                                },
+                            ],
+                            formatter: Table.api.formatter.buttons
+                        },
+                        {
+                            field: 'buttons',
+                            width: "120px",
+                            title: __('退款详情'),
+                            table: table,
+                            events: Table.api.events.operate,
+                            buttons: [
+                                {
+                                    name: 'detail',
+                                    text: __('点击查看退款原因'),
+                                    title: __('购买详情'),
+                                    classname: 'btn btn-xs btn-primary btn-dialog',
+                                    icon: 'fa fa-list',
+                                    url: "order/torder/torderinfo",
+                                    callback: function (data) {
+                                        Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
+                                    },
+                                    visible: function (row) {
+                                        //返回true时按钮显示,返回false隐藏
+                                        return true;
+                                    }
+                                },
+                            ],
+                            formatter: Table.api.formatter.buttons
+                        },
+                        {field: 'money', title: __('Money'), operate:'BETWEEN'},
+                        {field: 'freight', title: __('Freight'), operate:'BETWEEN'},
+                        {field: 'number', title: __('Number')},
+                        {field: 'create_time', title: __('Create_time')},
+                        {field: 'pay_time', title: __('Pay_time')},
+                        {field: 'f_time', title: __('F_time')},
+                        {field: 'whitebeon', title: __('Whitebeon'), operate:'BETWEEN'},
+                        {field: 'type', title: __('支付方式')},
+                        {field: 'tuikuan_state', title: __('退款进度')},
+                        {field: 'orderaddress.a_name', title: __('Orderaddress.a_name')},
+                        {field: 'orderaddress.a_tel', title: __('Orderaddress.a_tel')},
+                        {field: 'orderaddress.a_city', title: __('Orderaddress.a_city')},
+                        {field: 'orderaddress.a_area', title: __('Orderaddress.a_area')},
+                        {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;
+});

BIN
public/uploads/20191211/19449656a3c60c225cd10ef46ecec9ac.jpg


BIN
public/uploads/20191211/4aef00e619b3f8d90ddd40e949353cd0.jpg


BIN
public/uploads/20191211/5032d1b23c4f1897abd7047c01d6325e.jpg


BIN
public/uploads/20191214/19449656a3c60c225cd10ef46ecec9ac.jpg


BIN
public/uploads/20191214/4aef00e619b3f8d90ddd40e949353cd0.jpg


BIN
public/uploads/20191214/5032d1b23c4f1897abd7047c01d6325e.jpg


BIN
public/uploads/20191214/6aefece60c8256c50a65c0c7e6c77001.jpg


BIN
public/uploads/20191214/8370dbcc8ce9c7a4a239439b9e8367cf.jpg


BIN
public/uploads/20191218/249708bad4ded576fbdd20eac028b87d.jpg


BIN
public/uploads/20191218/4aef00e619b3f8d90ddd40e949353cd0.jpg


BIN
public/uploads/20191218/5032d1b23c4f1897abd7047c01d6325e.jpg


BIN
public/uploads/20191218/8370dbcc8ce9c7a4a239439b9e8367cf.jpg


BIN
public/uploads/20191221/4aef00e619b3f8d90ddd40e949353cd0.jpg


BIN
public/uploads/20191230/19449656a3c60c225cd10ef46ecec9ac.jpg


BIN
public/uploads/20191230/249708bad4ded576fbdd20eac028b87d.jpg


BIN
public/uploads/20191230/45f68e7a5588b7b592eb1d31c36a5d0a.jpg


BIN
public/uploads/20191230/4aef00e619b3f8d90ddd40e949353cd0.jpg


BIN
public/uploads/20191230/5032d1b23c4f1897abd7047c01d6325e.jpg


BIN
public/uploads/20191230/62bdfee64a503407c6e6181a6e759b45.jpg


BIN
public/uploads/20191230/6aefece60c8256c50a65c0c7e6c77001.jpg


BIN
public/uploads/20191230/8370dbcc8ce9c7a4a239439b9e8367cf.jpg


BIN
public/uploads/logo.jpg