牟新芬 3 years ago
parent
commit
9d79b5ebc6
63 changed files with 604 additions and 6272 deletions
  1. 88 0
      app/adminapi/controller/v1/article/Article.php
  2. 0 1
      app/adminapi/controller/v1/cms/.WeDrive
  3. 0 225
      app/adminapi/controller/v1/cms/Article.php
  4. 0 194
      app/adminapi/controller/v1/cms/ArticleCategory.php
  5. 0 132
      app/adminapi/controller/v1/company/Company.php
  6. 90 0
      app/adminapi/controller/v1/course/Course.php
  7. 95 0
      app/adminapi/controller/v1/course/Organ.php
  8. 17 76
      app/adminapi/controller/v1/merchant/Merchant.php
  9. 2 3
      app/adminapi/controller/v1/merchant/Open.php
  10. 1 3
      app/adminapi/controller/v1/merchant/Third.php
  11. 0 1
      app/adminapi/controller/v1/order/.WeDrive
  12. 0 763
      app/adminapi/controller/v1/order/StoreOrder.php
  13. 87 0
      app/adminapi/controller/v1/page/Page.php
  14. 0 1
      app/adminapi/controller/v1/product/.WeDrive
  15. 0 928
      app/adminapi/controller/v1/product/CopyTaobao.php
  16. 0 220
      app/adminapi/controller/v1/product/StoreCategory.php
  17. 0 701
      app/adminapi/controller/v1/product/StoreProduct.php
  18. 0 124
      app/adminapi/controller/v1/product/StoreProductReply.php
  19. 0 95
      app/adminapi/controller/v1/product/StoreProductRule.php
  20. 0 144
      app/adminapi/controller/v1/section/Section.php
  21. 16 0
      app/adminapi/route/article.php
  22. 0 26
      app/adminapi/route/cms.php
  23. 18 0
      app/adminapi/route/course.php
  24. 16 0
      app/adminapi/route/open.php
  25. 0 64
      app/adminapi/route/order.php
  26. 16 0
      app/adminapi/route/page.php
  27. 0 84
      app/adminapi/route/product.php
  28. 0 18
      app/adminapi/route/section.php
  29. 50 0
      app/adminapi/route/third.php
  30. 0 15
      app/badmin/route/route.php
  31. 0 61
      app/badminapi/BadminApiExceptionHandle.php
  32. 0 70
      app/badminapi/README.md
  33. 0 7
      app/badminapi/common.php
  34. 0 1
      app/badminapi/config/.WeDrive
  35. 0 25
      app/badminapi/config/route.php
  36. 0 54
      app/badminapi/controller/AuthController.php
  37. 0 22
      app/badminapi/controller/Common.php
  38. 0 103
      app/badminapi/controller/Login.php
  39. 0 903
      app/badminapi/controller/Report.php
  40. 0 155
      app/badminapi/controller/Template.php
  41. 0 55
      app/badminapi/controller/Test.php
  42. 0 148
      app/badminapi/controller/file/SystemAttachment.php
  43. 0 131
      app/badminapi/controller/file/SystemAttachmentCategory.php
  44. 0 228
      app/badminapi/controller/merchant/Industry.php
  45. 0 24
      app/badminapi/event.php
  46. 0 40
      app/badminapi/middleware/BadminAuthTokenMiddleware.php
  47. 0 33
      app/badminapi/middleware/BadminCkeckRole.php
  48. 0 17
      app/badminapi/provider.php
  49. 0 26
      app/badminapi/route/file.php
  50. 0 22
      app/badminapi/route/industry.php
  51. 0 19
      app/badminapi/route/merchant.php
  52. 0 16
      app/badminapi/route/open.php
  53. 0 21
      app/badminapi/route/report.php
  54. 0 39
      app/badminapi/route/route.php
  55. 0 19
      app/badminapi/route/template.php
  56. 0 50
      app/badminapi/route/third.php
  57. 0 44
      app/badminapi/validates/SystemBAdminValidata.php
  58. 16 7
      app/models/article/ArticleModel.php
  59. 0 50
      app/models/company/DesignerModel.php
  60. 0 50
      app/models/company/ExampleModel.php
  61. 4 14
      app/models/course/CourseModel.php
  62. 44 0
      app/models/course/OrganModel.php
  63. 44 0
      app/models/page/PageModel.php

+ 88 - 0
app/adminapi/controller/v1/article/Article.php

@@ -0,0 +1,88 @@
+<?php
+
+namespace app\adminapi\controller\v1\article;
+
+use app\adminapi\controller\AuthController;
+use app\models\article\ArticleModel;
+use crmeb\services\{UtilService as Util};
+use think\Request;
+
+class Article extends AuthController
+{
+    /**
+     * 显示资源列表
+     *
+     * @return \think\Response
+     */
+    public function index()
+    {
+        $where = Util::getMore([
+            ['page', 1],
+            ['limit', 10],
+            ['title', '']
+        ], $this->request);
+        $list = ArticleModel::systemPage($where);
+        return $this->success($list);
+    }
+
+    /**
+     * 保存新建的资源
+     *
+     * @param \think\Request $request
+     * @return \think\Response
+     */
+    public function save(Request $request)
+    {
+        $data = Util::postMore([
+            ['id', 0],
+            ['title', ''],
+            ['image', ''],
+            ['content', '']
+        ]);
+        $data['add_time'] = time();
+        if ($data['id']) {
+            $id = $data['id'];
+            unset($data['id']);
+            $res = ArticleModel::edit($data, $id, 'id');
+            if($res)
+                return $this->success('修改成功!', ['id' => $id]);
+            else
+                return $this->fail('修改失败!');
+        } else {
+            $res = ArticleModel::create($data);
+            return $this->success('添加成功!', ['id' => $res->id]);
+        }
+    }
+
+    /**
+     * 显示指定的资源
+     *
+     * @param int $id
+     * @return \think\Response
+     */
+    public function read($id)
+    {
+        $info = ArticleModel::getOne($id);
+        return $this->success(compact('info'));
+    }
+
+    /**
+     * 删除指定资源
+     *
+     * @param int $id
+     * @return \think\Response
+     */
+    public function delete($id)
+    {
+        if (!$id) return $this->fail('数据不存在');
+        $res = ArticleModel::get($id);
+        if (!$res) return $this->fail('数据不存在!');
+        if ($res['is_del']) return $this->fail('已删除!');
+        $data['is_del'] = 1;
+        if (ArticleModel::edit($data, $id))
+            return $this->success('删除成功!');
+        else
+            return $this->fail('删除失败,请稍候再试!');
+    }
+
+}

+ 0 - 1
app/adminapi/controller/v1/cms/.WeDrive

@@ -1 +0,0 @@
-/Users/huangjianfeng/WeDrive/六牛科技/源码/CRMEB_PRO_v1.0.0(9)/app/adminapi/controller/v1/cms

+ 0 - 225
app/adminapi/controller/v1/cms/Article.php

@@ -1,225 +0,0 @@
-<?php
-
-namespace app\adminapi\controller\v1\cms;
-
-use app\adminapi\controller\AuthController;
-use crmeb\services\{UtilService as Util};
-use app\models\article\{ArticleCategory as ArticleCategoryModel, Article as ArticleModel};
-use app\models\system\SystemAttachment;
-use think\Request;
-
-/**
- * 文章管理
- * Class Article
- * @package app\adminapi\controller\v1\cms
- */
-class Article extends AuthController
-{
-    /**
-     * 显示资源列表
-     *
-     * @return \think\Response
-     */
-    public function index()
-    {
-        $where = Util::getMore([
-            ['title', ''],
-            ['pid', 0],
-            ['page', 1],
-            ['limit', 10]
-        ], $this->request);
-        $where['cid'] = '';
-        $pid = $where['pid'];
-        $where['merchant'] = 0;//区分是管理员添加的图文显示  0 还是 商户添加的图文显示  1
-        $where['mer_id'] = $this->merId ?: '';
-        $cateList = ArticleCategoryModel::getArticleCategoryList($where['mer_id']);
-        //获取分类列表
-        if (count($cateList)) {
-            $tree = sort_list_tier($cateList);
-            if ($pid) {
-                $pids = Util::getChildrenPid($tree, $pid);
-                $where['cid'] = ltrim($pid . $pids);
-            }
-        }
-        $list = ArticleModel::getAll($where);
-        return $this->success($list);
-    }
-
-    /**
-     *
-     * 显示创建资源表单页.
-     *
-     * @return \think\Response
-     */
-    public function create()
-    {
-        //
-    }
-
-    /**
-     * 保存新建的资源
-     *
-     * @param \think\Request $request
-     * @return \think\Response
-     */
-    public function save(Request $request)
-    {
-        $data = Util::postMore([
-            ['id', 0],
-            ['cid',''],
-            'title',
-            'author',
-            'image_input',
-            'content',
-            'synopsis',
-            'share_title',
-            'share_synopsis',
-            ['visit', 0],
-            ['sort', 0],
-            'url',
-            ['is_banner', 0],
-            ['is_hot', 0],
-            ['status', 1],]);
-        if (!$data['title']) return $this->fail('缺少参数');
-//        $data['cid'] = implode(',', $data['cid']);
-        $content = $data['content'];
-        unset($data['content']);
-        $data['mer_id'] = $this->merId ?: '';
-        if ($data['id']) {
-            $id = $data['id'];
-            unset($data['id']);
-            $res = false;
-            ArticleModel::beginTrans();
-            $res1 = ArticleModel::edit($data, $id, 'id');
-            $res2 = ArticleModel::setContent($id, $content);
-            if ($res1 && $res2) {
-                $res = true;
-            }
-            ArticleModel::checkTrans($res);
-            if ($res)
-                return $this->success('修改成功!', ['id' => $id]);
-            else
-                return $this->fail('修改失败,您并没有修改什么!', ['id' => $id]);
-        } else {
-            $data['add_time'] = time();
-            $data['admin_id'] = $this->adminId;
-//            $data['admin_id'] = 1;
-            $res = false;
-            ArticleModel::beginTrans();
-            $res1 = ArticleModel::create($data);
-            $res2 = false;
-            if ($res1)
-                $res2 = ArticleModel::setContent($res1->id, $content);
-            if ($res1 && $res2) {
-                $res = true;
-            }
-            ArticleModel::checkTrans($res);
-            if ($res)
-                return $this->success('添加成功!', ['id' => $res1->id]);
-            else
-                return $this->success('添加失败!', ['id' => $res1->id]);
-        }
-    }
-
-    /**
-     * 显示指定的资源
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function read($id)
-    {
-        if ($id) {
-            $info = ArticleModel::where('n.id', $id)->alias('n')->field('n.*,c.content')->join('ArticleContent c', 'c.nid=n.id', 'left')->find();
-            if (!$info) return $this->fail('数据不存在!');
-            $info['cid'] = intval($info['cid']);
-        }
-        return $this->success(compact('info'));
-    }
-
-    /**
-     * 显示编辑资源表单页.
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function edit($id)
-    {
-        //
-    }
-
-    /**
-     * 保存更新的资源
-     *
-     * @param \think\Request $request
-     * @param int $id
-     * @return \think\Response
-     */
-    public function update(Request $request, $id)
-    {
-        //
-    }
-
-    /**
-     * 删除指定资源
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function delete($id)
-    {
-        $res = ArticleModel::del($id);
-        if (!$res)
-            return $this->fail('删除失败,请稍候再试!');
-        else
-            return $this->success('删除成功!');
-    }
-
-    //TODO 暂留
-
-    /**
-     * 分类显示列表
-     * $param int $id 分类id
-     * @return mixed
-     */
-    public function merchantIndex($id = 0)
-    {
-        $where = Util::getMore([
-            ['title', '']
-        ], $this->request);
-        if ($id) $where['cid'] = $id;
-        $where['merchant'] = 1;//区分是管理员添加的图文显示  0 还是 商户添加的图文显示  1
-        $where['mer_id'] = $this->merId ?: '';
-        $list = ArticleModel::getAll($where);
-        return $this->success(compact('list'));
-    }
-
-    /**
-     * 关联商品
-     * @param int $id 文章id
-     */
-    public function relation($id = 0)
-    {
-        if (!$id) return $this->fail('缺少参数');
-        list($product_id) = Util::postMore([
-            ['product_id', 0]
-        ], $this->request, true);
-        if (ArticleModel::edit(['product_id' => $product_id], ['id' => $id]))
-            return $this->success('保存成功');
-        else
-            return $this->fail('保存失败');
-    }
-
-    /**
-     * 取消绑定的商品id
-     * @param int $id
-     */
-    public function unrelation($id = 0)
-    {
-        if (!$id) return $this->fail('缺少参数');
-        if (ArticleModel::edit(['product_id' => 0], $id))
-            return $this->success('取消关联成功!');
-        else
-            return $this->fail('取消失败');
-    }
-}

+ 0 - 194
app/adminapi/controller/v1/cms/ArticleCategory.php

@@ -1,194 +0,0 @@
-<?php
-
-namespace app\adminapi\controller\v1\cms;
-
-use app\adminapi\controller\AuthController;
-use think\Request;
-use think\facade\Route as Url;
-use app\models\system\SystemAttachment;
-use crmeb\services\{
-    FormBuilder as Form, UtilService as Util
-};
-use app\models\article\{
-    ArticleCategory as ArticleCategoryModel, Article as ArticleModel
-};
-
-/**
- * 文章分类管理
- * Class ArticleCategory
- * @package app\adminapi\controller\v1\cms
- */
-class ArticleCategory extends AuthController
-{
-    /**
-     * 显示资源列表
-     * @param $type 0-列表形式 1-树形形式
-     * @return \think\Response
-     */
-    public function index()
-    {
-        $where = Util::getMore([
-            ['page', 1],
-            ['limit', 15],
-            ['status', ''],
-            ['title', ''],
-            ['type', 0]
-        ], $this->request);
-        $type = $where['type'];
-        unset($where['type']);
-        $where['mer_id'] = $this->merId ?: '';
-        if ($type) {
-            $data1 = ArticleCategoryModel::getArticleCategoryList($where['mer_id']);
-            $list = ArticleCategoryModel::tidyTree($data1);
-        } else {
-            //查出顶级分类列表 分页根据顶级分类
-            $list = ArticleCategoryModel::systemPage($where);
-        }
-        return $this->success($list);
-    }
-
-    /**
-     * 显示创建资源表单页.
-     *
-     * @return \think\Response
-     */
-    public function create()
-    {
-        $f = array();
-//        $f[] = Form::select('pid', '父级id')->setOptions(function () {
-//            $list = ArticleCategoryModel::getTierList();
-//            $menus[] = ['value' => 0, 'label' => '顶级分类'];
-//            foreach ($list as $menu) {
-//                $menus[] = ['value' => $menu['id'], 'label' => $menu['html'] . $menu['title']];
-//            }
-//            return $menus;
-//        })->filterable(1);
-        $f[] = Form::input('title', '分类名称');
-        $f[] = Form::input('intr', '分类简介')->type('textarea');
-        $f[] = Form::frameImageOne('image', '分类图片', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')))->icon('ios-add')->width('60%')->height('435px');
-        $f[] = Form::number('sort', '排序', 0);
-        $f[] = Form::radio('status', '状态', 1)->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
-        return $this->makePostForm('添加分类', $f, Url::buildUrl('/cms/category'), 'POST');
-    }
-
-    /**
-     * 保存新建的资源
-     *
-     * @param \think\Request $request
-     * @return \think\Response
-     */
-    public function save(Request $request)
-    {
-        $data = Util::postMore([
-            'title',
-            ['pid', 0],
-            'intr',
-            ['new_id', []],
-            ['image', []],
-            ['sort', 0],
-            'status',]);
-        if (!$data['title']) return $this->fail('请输入分类名称');
-        if (count($data['image']) != 1) return $this->fail('请选择分类图片,并且只能上传一张');
-        if ($data['sort'] < 0) return $this->fail('排序不能是负数');
-        $data['add_time'] = time();
-        $data['image'] = $data['image'][0];
-        $new_id = $data['new_id'];
-        unset($data['new_id']);
-        $data['mer_id'] = $this->merId ?: '';
-        $res = ArticleCategoryModel::create($data);
-        if (!ArticleModel::saveBatchCid($res['id'], implode(',', $new_id))) return $this->fail('文章分类添加失败');
-        return $this->success('添加分类成功!');
-    }
-
-    /**
-     * 显示指定的资源
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function read($id)
-    {
-        //
-    }
-
-    /**
-     * 显示编辑资源表单页.
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function edit($id)
-    {
-        if (!$id) return $this->fail('参数错误');
-        $article = ArticleCategoryModel::get($id)->getData();
-        if (!$article) return $this->fail('数据不存在!');
-        $f = array();
-        $f[] = Form::select('pid', '父级id', (string)$article['pid'])->setOptions(function () {
-            $list = ArticleCategoryModel::getTierList();
-            $menus[] = ['value' => 0, 'label' => '顶级分类'];
-            foreach ($list as $menu) {
-                $menus[] = ['value' => $menu['id'], 'label' => $menu['html'] . $menu['title']];
-            }
-            return $menus;
-        })->filterable(1);
-        $f[] = Form::input('title', '分类名称', $article['title']);
-        $f[] = Form::input('intr', '分类简介', $article['intr'])->type('textarea');
-        $f[] = Form::frameImageOne('image', '分类图片', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')), $article['image'])->icon('ios-add')->width('60%')->height('435px');
-        $f[] = Form::number('sort', '排序', 0);
-        $f[] = Form::radio('status', '状态', $article['status'])->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
-        return $this->makePostForm('编辑分类', $f, Url::buildUrl('/cms/category/' . $id), 'PUT');
-    }
-
-    /**
-     * 保存更新的资源
-     *
-     * @param \think\Request $request
-     * @param int $id
-     * @return \think\Response
-     */
-    public function update(Request $request, $id)
-    {
-        $data = Util::postMore([
-            'pid',
-            'title',
-            'intr',
-            ['image', []],
-            ['sort', 0],
-            'status',]);
-        if (!$data['title']) return $this->fail('请输入分类名称');
-        if (count($data['image']) != 1) return $this->fail('请选择分类图片,并且只能上传一张');
-        if ($data['sort'] < 0) return $this->fail('排序不能是负数');
-        $data['image'] = $data['image'][0];
-        if (!ArticleCategoryModel::get($id)) return $this->fail('编辑的记录不存在!');
-        ArticleCategoryModel::edit($data, $id);
-        return $this->success('修改成功!');
-    }
-
-    /**
-     * 删除指定资源
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function delete($id)
-    {
-        $res = ArticleCategoryModel::delArticleCategory($id);
-        if (!$res)
-            return $this->fail(ArticleCategoryModel::getErrorInfo('删除失败,请稍候再试!'));
-        else
-            return $this->success('删除成功!');
-    }
-
-    /**
-     * 修改状态
-     * @param $id
-     * @param $status
-     * @return mixed
-     */
-    public function set_status($id, $status)
-    {
-        if ($status == '' || $id == 0) return $this->fail('参数错误');
-        ArticleCategoryModel::where(['id' => $id])->update(['status' => $status]);
-        return $this->success($status == 0 ? '隐藏成功' : '显示成功');
-    }
-}

+ 0 - 132
app/adminapi/controller/v1/company/Company.php

@@ -1,132 +0,0 @@
-<?php
-
-namespace app\adminapi\controller\v1\company;
-
-use app\adminapi\controller\AuthController;
-use crmeb\services\{UtilService as Util};
-use app\models\section\SectionModel;
-use app\models\company\CompanyModel;
-use app\models\company\ExampleModel;
-use app\models\company\DesignerModel;
-use think\Request;
-
-class Company extends AuthController
-{
-    /**
-     * 显示资源列表
-     *
-     * @return \think\Response
-     */
-    public function index()
-    {
-        $where = Util::getMore([
-            ['title', ''],
-            ['sid', ''],
-            ['page', 1],
-            ['limit', 10]
-        ], $this->request);
-        $list = CompanyModel::systemPage($where);
-        return $this->success($list);
-    }
-
-    /**
-     * 保存新建的资源
-     *
-     * @param \think\Request $request
-     * @return \think\Response
-     */
-    public function save(Request $request)
-    {
-        $data = Util::postMore([
-            ['id', 0],
-            ['sid', ''],
-            ['title', ''],
-            ['logo', ''],
-            ['intro', ''],
-            ['contact', ''],
-            ['phone', ''],
-            ['project', ''],
-            ['slider_image', ''],
-            ['sort', 0],
-            ['status', 1],
-            ['example', []],
-            ['designer', []],
-        ]);
-        if (!$data['title']) return $this->fail('缺少参数');
-        $data['slider_image'] = json_encode($data['slider_image']);
-        $example = $data['example'];
-        $designer = $data['designer'];
-        unset($data['example'], $data['designer']);
-        if ($data['id']) {
-            $id = $data['id'];
-            unset($data['id']);
-            $res = CompanyModel::edit($data, $id, 'id');
-            foreach($example as $key => $value){
-                $example[$key]['cid'] = !empty($value['cid']) ? $value['cid'] : $id;
-            }
-            foreach($designer as $key => $value){
-                $designer[$key]['cid'] = !empty($value['cid']) ? $value['cid'] : $id;
-            }
-            ExampleModel::saveExample($example, $id);
-            DesignerModel::saveDesigner($designer, $id);
-            return $this->success('修改成功!', ['id' => $id]);
-        } else {
-            $data['add_time'] = time();
-            $res = CompanyModel::create($data);
-            foreach($example as $key => $value){
-                $example[$key]['cid'] = (int)($res['id']);
-            }
-            foreach($designer as $key => $value){
-                $designer[$key]['cid'] = (int)($res['id']);
-            }
-            ExampleModel::saveExample($example, $res['id']);
-            DesignerModel::saveDesigner($designer, $res['id']);
-            return $this->success('添加成功!', ['id' => $res->id]);
-        }
-    }
-
-    /**
-     * 显示指定的资源
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function read($id)
-    {
-        $info = CompanyModel::getOne($id);
-        return $this->success(compact('info'));
-    }
-
-    /**
-     * 删除指定资源
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function delete($id)
-    {
-        if (!$id) return $this->fail('数据不存在');
-        $res = CompanyModel::get($id);
-        if (!$res) return $this->fail('数据不存在!');
-        if ($res['is_del']) return $this->fail('已删除!');
-        $data['is_del'] = 1;
-        if (!CompanyModel::edit($data, $id))
-            return $this->fail(CompanyModel::getErrorInfo('删除失败,请稍候再试!'));
-        else
-            return $this->success('删除成功!');
-    }
-
-    /**
-     * 修改状态
-     * @param $id
-     * @param $status
-     * @return mixed
-     */
-    public function set_status($id, $status)
-    {
-        if ($status == '' || $id == 0) return $this->fail('参数错误');
-        CompanyModel::where(['id' => $id])->update(['status' => $status]);
-        return $this->success($status == 0 ? '隐藏成功' : '显示成功');
-    }
-
-}

+ 90 - 0
app/adminapi/controller/v1/course/Course.php

@@ -0,0 +1,90 @@
+<?php
+
+namespace app\adminapi\controller\v1\course;
+
+use app\adminapi\controller\AuthController;
+use app\models\course\CourseModel;
+use crmeb\services\{UtilService as Util};
+use think\Request;
+
+class Course extends AuthController
+{
+    /**
+     * 显示资源列表
+     *
+     * @return \think\Response
+     */
+    public function index()
+    {
+        $where = Util::getMore([
+            ['page', 1],
+            ['limit', 10],
+            ['area', ''],
+            ['title', '']
+        ], $this->request);
+        $list = CourseModel::systemPage($where);
+        return $this->success($list);
+    }
+
+    /**
+     * 保存新建的资源
+     *
+     * @param \think\Request $request
+     * @return \think\Response
+     */
+    public function save(Request $request)
+    {
+        $data = Util::postMore([
+            ['id', 0],
+            ['area', ''],
+            ['title', ''],
+            ['image', ''],
+            ['intro', '']
+        ]);
+        $data['add_time'] = time();
+        if ($data['id']) {
+            $id = $data['id'];
+            unset($data['id']);
+            $res = CourseModel::edit($data, $id, 'id');
+            if($res)
+                return $this->success('修改成功!', ['id' => $id]);
+            else
+                return $this->fail('修改失败!');
+        } else {
+            $res = CourseModel::create($data);
+            return $this->success('添加成功!', ['id' => $res->id]);
+        }
+    }
+
+    /**
+     * 显示指定的资源
+     *
+     * @param int $id
+     * @return \think\Response
+     */
+    public function read($id)
+    {
+        $info = CourseModel::getOne($id);
+        return $this->success(compact('info'));
+    }
+
+    /**
+     * 删除指定资源
+     *
+     * @param int $id
+     * @return \think\Response
+     */
+    public function delete($id)
+    {
+        if (!$id) return $this->fail('数据不存在');
+        $res = CourseModel::get($id);
+        if (!$res) return $this->fail('数据不存在!');
+        if ($res['is_del']) return $this->fail('已删除!');
+        $data['is_del'] = 1;
+        if (CourseModel::edit($data, $id))
+            return $this->success('删除成功!');
+        else
+            return $this->fail('删除失败,请稍候再试!');
+    }
+
+}

+ 95 - 0
app/adminapi/controller/v1/course/Organ.php

@@ -0,0 +1,95 @@
+<?php
+
+namespace app\adminapi\controller\v1\course;
+
+use app\adminapi\controller\AuthController;
+use app\models\course\OrganModel;
+use crmeb\services\{UtilService as Util};
+use think\Request;
+
+class Organ extends AuthController
+{
+    /**
+     * 显示资源列表
+     *
+     * @return \think\Response
+     */
+    public function index()
+    {
+        $where = Util::getMore([
+            ['page', 1],
+            ['limit', 10]
+        ], $this->request);
+        $list = OrganModel::systemPage($where);
+        return $this->success($list);
+    }
+
+    /**
+     * 保存新建的资源
+     *
+     * @param \think\Request $request
+     * @return \think\Response
+     */
+    public function save(Request $request)
+    {
+        $data = Util::postMore([
+            ['id', 0],
+            ['name', ''],
+            ['image', ''],
+            ['contact', ''],
+            ['latlng', ''],
+            ['intro', '']
+        ]);
+        $data['latlng'] = explode(',', $data['latlng']);
+        if (!isset($data['latlng'][0]) || !isset($data['latlng'][1])) return $this->fail('请选择经纬度');
+        $data['latitude'] = $data['latlng'][0];
+        $data['longitude'] = $data['latlng'][1];
+        unset($data['latlng']);
+        $data['add_time'] = time();
+        if ($data['id']) {
+            $id = $data['id'];
+            unset($data['id']);
+            $res = OrganModel::edit($data, $id, 'id');
+            if($res)
+                return $this->success('修改成功!', ['id' => $id]);
+            else
+                return $this->fail('修改失败!');
+        } else {
+            $res = OrganModel::create($data);
+            return $this->success('添加成功!', ['id' => $res->id]);
+        }
+    }
+
+    /**
+     * 显示指定的资源
+     *
+     * @param int $id
+     * @return \think\Response
+     */
+    public function read($id)
+    {
+        $info = OrganModel::getOne($id);
+        $info['latlng'] = $info['latitude'] . ',' . $info['longitude'];
+        return $this->success(compact('info'));
+    }
+
+    /**
+     * 删除指定资源
+     *
+     * @param int $id
+     * @return \think\Response
+     */
+    public function delete($id)
+    {
+        if (!$id) return $this->fail('数据不存在');
+        $res = OrganModel::get($id);
+        if (!$res) return $this->fail('数据不存在!');
+        if ($res['is_del']) return $this->fail('已删除!');
+        $data['is_del'] = 1;
+        if (OrganModel::edit($data, $id))
+            return $this->success('删除成功!');
+        else
+            return $this->fail('删除失败,请稍候再试!');
+    }
+
+}

+ 17 - 76
app/badminapi/controller/merchant/Merchant.php → app/adminapi/controller/v1/merchant/Merchant.php

@@ -1,13 +1,10 @@
 <?php
 <?php
 
 
+namespace app\adminapi\controller\v1\merchant;
 
 
-namespace app\badminapi\controller\merchant;
-
-
-use app\badminapi\controller\AuthController;
+use app\adminapi\controller\AuthController;
 use app\models\merchant\MerchantMiniprogram;
 use app\models\merchant\MerchantMiniprogram;
 use app\models\merchant\Merchant as MerchantModel;
 use app\models\merchant\Merchant as MerchantModel;
-use app\models\merchant\Industry as IndustryModel;
 use app\Request;
 use app\Request;
 use crmeb\basic\BaseModel;
 use crmeb\basic\BaseModel;
 use crmeb\services\UtilService;
 use crmeb\services\UtilService;
@@ -38,41 +35,18 @@ class Merchant extends AuthController
                 function ($val) {
                 function ($val) {
                     return MerchantModel::be(['name' => $val]);
                     return MerchantModel::be(['name' => $val]);
                 }
                 }
-            ], ['请输入店铺名称', '已存在同名店铺']],
-            ['logo', '', '', '', 'empty_check', '请上传店铺Logo'],
-            ['business_license', '', '', '', 'empty_check', '请输入营业执照号'],
-            ['lx_name', '', '', '', 'empty_check', '请输入联系人'],
-            ['phone', '', '', '', 'empty_check', '请输入电话'],
-            ['industry_id', '', '', '', 'empty_check', '请选择所属行业'],
-            ['address', '', '', '', 'empty_check', '', '请填写完整店铺地址'],
-            ['detail_address', '', '', '', 'empty_check', '请填写完整店铺地址'],
-            ['facilities', [], '', '', 'empty_check', '请输入店内设施'],
-            ['day_time', '', '', '', 'empty_check', '请选择营业时间'],
-            ['local', '', '', '', 'empty_check', '请填写商户域名'],
+            ], ['请输入小程序名称', '已存在同名小程序']]
         ], $request, false);
         ], $request, false);
-        BaseModel::beginTrans();
         try {
         try {
-            $data['industry_id'] = implode(',', $data['industry_id']);
-            $data['address'] = implode(',', $data['address']);
-            $data['facilities'] = implode(',', $data['facilities']);
-            $data['day_time'] = implode(' - ', $data['day_time']);
             $data['add_time'] = time();
             $data['add_time'] = time();
-            $data['version'] = 1;
-            $data['valid_time'] = strtotime("+1 year");
-            if ($data['local']) $data['local_md5'] = strtolower(md5($data['local']));
             $res = MerchantModel::create($data);
             $res = MerchantModel::create($data);
-            if ($res) {
-                BaseModel::commitTrans();
-                return app('json')->success('注册商户成功', ['id' => $res->id]);
-            } else {
-                BaseModel::rollbackTrans();
-                return app('json')->fail('注册商户失败');
-            }
+            if ($res)
+                return app('json')->success('添加小程序成功', ['id' => $res->id]);
+            else
+                return app('json')->fail('添加小程序失败');
         } catch (Exception $e) {
         } catch (Exception $e) {
-            BaseModel::rollbackTrans();
             return app('json')->fail($e->getMessage());
             return app('json')->fail($e->getMessage());
         } catch (DbException $e) {
         } catch (DbException $e) {
-            BaseModel::rollbackTrans();
             return app('json')->fail($e->getMessage());
             return app('json')->fail($e->getMessage());
         }
         }
     }
     }
@@ -88,50 +62,25 @@ class Merchant extends AuthController
     {
     {
         $data = UtilService::postMore([
         $data = UtilService::postMore([
             ['name', ''],
             ['name', ''],
-            ['logo', ''],
-            ['business_license', ''],
             ['lx_name', ''],
             ['lx_name', ''],
-            ['phone', ''],
-            ['industry_id', ''],
-            ['address', ''],
-            ['detail_address', ''],
-            ['facilities', []],
-            ['day_time', ''],
-            ['local', ''],
+            ['phone', '']
         ], $request, false);
         ], $request, false);
         if (!($mer_id && MerchantModel::be($mer_id))) {
         if (!($mer_id && MerchantModel::be($mer_id))) {
-            return app('json')->fail('商户不存在');
-        }
-        $update = [];
-        $data['day_time'] = implode(' - ', $data['day_time']);
-        foreach ($data as $k => $v) {
-            if (!empty_check($v)) {
-                if (is_array($v))
-                    $update[$k] = implode(',', $v);
-                else
-                    $update[$k] = $v;
-            }
+            return app('json')->fail('小程序不存在');
         }
         }
-        BaseModel::beginTrans();
         try {
         try {
-            $res = MerchantModel::edit($update, $mer_id);
-            if ($res) {
-                BaseModel::commitTrans();
-                return app('json')->success('编辑商户成功');
-            } else {
-                BaseModel::rollbackTrans();
-                return app('json')->fail('编辑商户失败');
-            }
+            $res = MerchantModel::edit($data, $mer_id);
+            if ($res)
+                return app('json')->success('编辑小程序成功');
+            else
+                return app('json')->fail('编辑小程序失败');
         } catch (Exception $e) {
         } catch (Exception $e) {
-            BaseModel::rollbackTrans();
             return app('json')->fail($e->getMessage());
             return app('json')->fail($e->getMessage());
         } catch (DbException $e) {
         } catch (DbException $e) {
-            BaseModel::rollbackTrans();
             return app('json')->fail($e->getMessage());
             return app('json')->fail($e->getMessage());
         }
         }
     }
     }
 
 
-
     /**
     /**
      * 编辑商户支付信息
      * 编辑商户支付信息
      * @param $mer_id
      * @param $mer_id
@@ -186,10 +135,7 @@ class Merchant extends AuthController
         $where = UtilService::getMore([
         $where = UtilService::getMore([
             ['page', 1],
             ['page', 1],
             ['limit', 10],
             ['limit', 10],
-            ['key_word', ''],
-            ['industry_id', ''],
-            ['version', ''],
-            ['data', ''],
+            ['name', '']
         ], $request, false);
         ], $request, false);
         $list = MerchantModel::getList($where);
         $list = MerchantModel::getList($where);
         return app('json')->success('ok', $list);
         return app('json')->success('ok', $list);
@@ -207,19 +153,14 @@ class Merchant extends AuthController
     public function getMerchantDetail($mer_id, Request $request)
     public function getMerchantDetail($mer_id, Request $request)
     {
     {
         if (!$mer_id) {
         if (!$mer_id) {
-            return app('json')->fail('商户不存在');
+            return app('json')->fail('小程序不存在');
         }
         }
         $merchant = MerchantModel::get($mer_id);
         $merchant = MerchantModel::get($mer_id);
         if (!$merchant) {
         if (!$merchant) {
-            return app('json')->fail('商户不存在');
+            return app('json')->fail('小程序不存在');
         }
         }
         $merchant = $merchant->toArray();
         $merchant = $merchant->toArray();
         $merchant['miniprogram_info'] = ($data = MerchantMiniprogram::vaildWhere()->where('mer_id', $mer_id)->find()) && $data ? $data->toArray() : [];
         $merchant['miniprogram_info'] = ($data = MerchantMiniprogram::vaildWhere()->where('mer_id', $mer_id)->find()) && $data ? $data->toArray() : [];
-        $merchant['industry_name'] = IndustryModel::where('id', 'IN', $merchant['industry_id'])->column('name');
-        $merchant['industry_id'] = $merchant['industry_id'] ? explode(',', $merchant['industry_id']) : [];
-        $merchant['address'] = $merchant['address'] ? explode(',', $merchant['address']) : [];
-        $merchant['facilities'] = $merchant['facilities'] ? explode(',', $merchant['facilities']) : [];
-        $merchant['day_time'] = $merchant['day_time'] ? explode(' - ', $merchant['day_time']) : [];
         return app('json')->success('ok', $merchant);
         return app('json')->success('ok', $merchant);
     }
     }
 
 

+ 2 - 3
app/badminapi/controller/merchant/Open.php → app/adminapi/controller/v1/merchant/Open.php

@@ -1,9 +1,8 @@
 <?php
 <?php
 
 
+namespace app\adminapi\controller\v1\merchant;
 
 
-namespace app\badminapi\controller\merchant;
-
-use app\badminapi\controller\AuthController;
+use app\adminapi\controller\AuthController;
 use app\lib\wx_encode\WXBizMsgCrypt;
 use app\lib\wx_encode\WXBizMsgCrypt;
 use app\models\merchant\MerchantCodeAudit;
 use app\models\merchant\MerchantCodeAudit;
 use app\models\merchant\MerchantMiniprogram;
 use app\models\merchant\MerchantMiniprogram;

+ 1 - 3
app/badminapi/controller/merchant/Third.php → app/adminapi/controller/v1/merchant/Third.php

@@ -1,8 +1,6 @@
 <?php
 <?php
 
 
-
-namespace app\badminapi\controller\merchant;
-
+namespace app\adminapi\controller\v1\merchant;
 
 
 use app\models\merchant\MerchantCodeAudit;
 use app\models\merchant\MerchantCodeAudit;
 use app\models\merchant\MerchantMiniprogram;
 use app\models\merchant\MerchantMiniprogram;

+ 0 - 1
app/adminapi/controller/v1/order/.WeDrive

@@ -1 +0,0 @@
-/Users/huangjianfeng/WeDrive/六牛科技/源码/CRMEB_PRO_v1.0.0(9)/app/adminapi/controller/v1/order

+ 0 - 763
app/adminapi/controller/v1/order/StoreOrder.php

@@ -1,763 +0,0 @@
-<?php
-
-namespace app\adminapi\controller\v1\order;
-
-
-use app\adminapi\controller\AuthController;
-use app\adminapi\validates\order\StoreOrderValidate;
-use Exception;
-use app\models\system\{Express, SystemStore};
-use crmeb\traits\CurdControllerTrait;
-use FormBuilder\exception\FormBuilderException;
-use think\db\exception\DataNotFoundException;
-use think\db\exception\DbException;
-use think\db\exception\ModelNotFoundException;
-use think\response\Json;
-use app\models\user\{UserBill, User};
-use crmeb\repositories\OrderRepository;
-use app\models\store\{StoreOrder as StoreOrderModel, StoreOrderStatus, StorePink};
-use crmeb\services\{CacheService,
-    ExpressService,
-    MiniProgramService,
-    SystemConfigService,
-    WechatService,
-    UtilService,
-    FormBuilder as Form};
-use think\facade\Route as Url;
-
-class StoreOrder extends AuthController
-{
-
-    use CurdControllerTrait;
-
-    protected function initialize()
-    {
-        parent::initialize(); // TODO: Change the autogenerated stub
-        $this->bindModel = StoreOrderModel::class;
-    }
-
-    /**
-     * 获取订单类型数量
-     * @return mixed
-     * @throws Exception
-     */
-    public function chart()
-    {
-        $where = UtilService::getMore([
-            ['data', ''],
-        ], $this->request);
-        $where['mer_id'] = $this->merId;
-        return $this->success(StoreOrderModel::orderCount($where));
-    }
-
-    /**
-     * 获取订单列表
-     * @return mixed
-     * @throws DataNotFoundException
-     * @throws ModelNotFoundException
-     * @throws Exception
-     */
-    public function lst()
-    {
-        $where = UtilService::getMore([
-            ['status', ''],
-            ['real_name', ''],
-            ['is_del', 0],
-            ['data', ''],
-            ['type', ''],
-            ['pay_type', ''],
-            ['order', ''],
-            ['page', 1],
-            ['limit', 10],
-        ], $this->request);
-        $where['mer_id'] = $this->merId;
-        return $this->success(StoreOrderModel::getAdminOrderList($where));
-    }
-
-    /**
-     * 核销码核销
-     * @return mixed
-     * @throws DataNotFoundException
-     * @throws ModelNotFoundException
-     * @throws DbException
-     * @throws Exception
-     */
-    public function write_order()
-    {
-        [$code, $confirm] = UtilService::getMore([
-            ['code', ''],
-            ['confirm', 0]
-        ], $this->request, true);
-        if (!$code) return $this->fail('Lack of write-off code');
-        StoreOrderModel::beginTrans();
-        $orderInfo = StoreOrderModel::merSet($this->merId)->where('verify_code', $code)->where('paid', 1)->field(['status', 'uid', 'order_id'])->where('refund_status', 0)->find();
-        if (!$orderInfo) return $this->fail('Write off order does not exist');
-        if ($orderInfo->status > 0) return $this->fail('Order written off');
-        if ($orderInfo->combination_id && $orderInfo->pink_id) {
-            $res = StorePink::where('id', $orderInfo->pink_id)->where('status', '<>', 2)->count();
-            if ($res) return $this->fail('Failed to write off the group order');
-        }
-        if ($confirm == 0) {
-            $orderInfo['nickname'] = User::where(['uid' => $orderInfo['uid']])->value('nickname');
-            return $this->success($orderInfo->toArray());
-        }
-        $orderInfo->status = 2;
-        if ($orderInfo->save()) {
-            StoreOrderModel::commitTrans();
-            return $this->success('Write off successfully');
-        } else {
-            StoreOrderModel::rollbackTrans();
-            return $this->fail('Write off failure');
-        }
-    }
-
-    /**
-     * 修改支付金额等
-     * @param $id
-     * @return mixed|Json|void
-     * @throws DataNotFoundException
-     * @throws DbException
-     * @throws ModelNotFoundException
-     */
-    public function edit($id)
-    {
-        if (!$id) return $this->fail('Data does not exist!');
-        $product = StoreOrderModel::merSet($this->merId)->where('id', $id)->find();
-        if (!$product) return $this->fail('Data does not exist!');
-        $f = [];
-        $f[] = Form::input('order_id', '订单编号', $product->getData('order_id'))->disabled(1);
-        $f[] = Form::number('total_price', '商品总价', $product->getData('total_price'))->min(0);
-        $f[] = Form::number('total_postage', '原始邮费', $product->getData('total_postage'))->min(0);
-        $f[] = Form::number('pay_price', '实际支付金额', $product->getData('pay_price'))->min(0);
-        $f[] = Form::number('pay_postage', '实际支付邮费', $product->getData('pay_postage'));
-        $f[] = Form::number('gain_integral', '赠送积分', $product->getData('gain_integral'));
-        return $this->makePostForm('修改订单', $f, Url::buildUrl('/order/update/' . $id), 'PUT');
-    }
-
-    /**
-     * 修改订单
-     * @param $id
-     * @return mixed
-     * @throws DataNotFoundException
-     * @throws DbException
-     * @throws ModelNotFoundException
-     * @throws Exception
-     */
-    public function update($id)
-    {
-        if (!$id) return $this->fail('Missing order ID');
-        $product = StoreOrderModel::merSet($this->merId)->where('id', $id)->find();
-        if (!$product) return $this->fail('Data does not exist!');
-        $data = UtilService::postMore([
-            ['order_id', ''],
-            ['total_price', 0],
-            ['total_postage', 0],
-            ['pay_price', 0],
-            ['pay_postage', 0],
-            ['gain_integral', 0],
-        ], $this->request);
-
-        $this->validate($data, StoreOrderValidate::class);
-
-        if ($data['total_price'] < 0) return $this->fail('Please enter the total price');
-        if ($data['pay_price'] < 0) return $this->fail('Please enter the actual payment amount');
-
-        StoreOrderModel::beginTrans();
-        $data['order_id'] = StoreOrderModel::changeOrderId($data['order_id']);
-        $res = StoreOrderModel::edit($data, $id);
-        $res = $res && StoreOrderStatus::status($id, 'order_edit', '修改商品总价为:' . $data['total_price'] . ' 实际支付金额' . $data['pay_price']);
-        if ($res) {
-            event('StoreProductOrderEditAfter', [$data, $id]);
-            StoreOrderModel::commitTrans();
-            return $this->success('Modified success');
-        } else {
-            StoreOrderModel::rollbackTrans();
-            return $this->fail('Modification failed');
-        }
-    }
-
-    /**
-     * 获取快递公司
-     * @return mixed
-     */
-    public function express()
-    {
-        $list = Express::where('is_show', 1)->order('sort desc')->column('name', 'id');
-        $data = [];
-        foreach ($list as $key => $value) {
-            $data[] = ['id' => $key, 'value' => $value];
-        }
-        return $this->success($data);
-    }
-
-    /**
-     * 批量删除用户已经删除的订单
-     * @return mixed
-     * @throws Exception
-     */
-    public function del_orders()
-    {
-        [$ids] = UtilService::postMore([
-            ['ids', []],
-        ], $this->request, true);
-        if (!count($ids)) return $this->fail('请选择需要删除的订单');
-        if (StoreOrderModel::merSet($this->merId)->where('is_del', 0)->whereIn('id', $ids)->count())
-            return $this->fail('您选择的的订单存在用户未删除的订单');
-        if (StoreOrderModel::merSet($this->merId)->whereIn('id', $ids)->update(['is_system_del' => 1]))
-            return $this->success('SUCCESS');
-        else
-            return $this->fail('ERROR');
-    }
-
-    //批量设置标签
-    public function setLevel()
-    {
-        $data = UtilService::postMore([
-            ['ids', []],
-            ['level', '']
-        ], $this->request);
-        if (!count($data['ids'])) return $this->fail('请选择需要设置的订单');
-        if (StoreOrderModel::merSet($this->merId)->whereIn('id', $data['ids'])->update(['level' => $data['level']]))
-            return $this->success('SUCCESS');
-        else
-            return $this->fail('ERROR');
-    }
-
-    /**
-     * 删除订单
-     * @param $id
-     * @return mixed
-     * @throws DataNotFoundException
-     * @throws DbException
-     * @throws ModelNotFoundException
-     */
-    public function del($id)
-    {
-        if (!$id || !($orderInfo = StoreOrderModel::merSet($this->merId)->where('id', $id)->find()))
-            return $this->fail('订单不存在');
-        if (!$orderInfo->is_del)
-            return $this->fail('订单用户未删除无法删除');
-        $orderInfo->is_system_del = 1;
-        if ($orderInfo->save())
-            return $this->success('SUCCESS');
-        else
-            return $this->fail('ERROR');
-    }
-
-    /**
-     * 订单发送货
-     * @param int $id 订单id
-     * @return mixed
-     * @throws Exception
-     */
-    public function update_delivery($id)
-    {
-        if (!$id) return $this->fail('订单不存在');
-        $product = StoreOrderModel::merSet($this->merId)->where('id', $id)->find();
-        if (!$product) return $this->fail('订单不存在');
-        $data = UtilService::postMore([
-            ['type', 1],
-            ['delivery_name', ''],
-            ['delivery_id', ''],
-            ['sh_delivery_name', ''],
-            ['sh_delivery_id', ''],
-        ], $this->request);
-        StoreOrderModel::beginTrans();
-        $type = (int)$data['type'];
-        unset($data['type']);
-        switch ($type) {
-            case 1:
-                //发货
-                $data['delivery_type'] = 'express';
-                if (!$data['delivery_name']) return $this->fail('请选择快递公司');
-                if (!$data['delivery_id']) return $this->fail('请输入快递单号');
-                $data['status'] = 1;
-                StoreOrderModel::edit($data, $id);
-                event('StoreProductOrderDeliveryGoodsAfter', [$data, $id]);
-                StoreOrderStatus::setStatus($id, 'delivery_goods', '已发货 快递公司:' . $data['delivery_name'] . ' 快递单号:' . $data['delivery_id']);
-                break;
-            case 2:
-                $data['delivery_type'] = 'send';
-                $data['delivery_name'] = $data['sh_delivery_name'];
-                $data['delivery_id'] = $data['sh_delivery_id'];
-                unset($data['sh_delivery_name'], $data['sh_delivery_id']);
-                if (!$data['delivery_name']) return $this->fail('请输入送货人姓名');
-                if (!$data['delivery_id']) return $this->fail('请输入送货人电话号码');
-                if (!preg_match("/^1[3456789]{1}\d{9}$/", $data['delivery_id'])) return $this->fail('请输入正确的送货人电话号码');
-                $data['status'] = 1;
-                StoreOrderModel::edit($data, $id);
-                event('StoreProductOrderDeliveryAfter', [$data, $id]);
-                StoreOrderStatus::setStatus($id, 'delivery', '已配送 发货人:' . $data['delivery_name'] . ' 发货人电话:' . $data['delivery_id']);
-                break;
-            case 3:
-                $data['delivery_type'] = 'fictitious';
-                $data['status'] = 1;
-                unset($data['sh_delivery_name'], $data['sh_delivery_id'], $data['delivery_name'], $data['delivery_id']);
-                StoreOrderModel::edit($data, $id);
-                event('StoreProductOrderDeliveryAfter', [$data, $id]);
-                StoreOrderStatus::setStatus($id, 'delivery_fictitious', '已虚拟发货');
-                break;
-            default:
-                return $this->fail('暂时不支持其他发货类型');
-                break;
-        }
-        //短信发送
-        event('ShortMssageSend', [StoreOrderModel::where('id', $id)->value('order_id'), 'Deliver']);
-        StoreOrderModel::commitTrans();
-        return $this->success('SUCCESS');
-    }
-
-
-    /**
-     * 确认收货
-     * @param int $id 订单id
-     * @return mixed
-     * @throws Exception
-     */
-    public function take_delivery($id)
-    {
-        if (!$id) return $this->fail('缺少参数');
-        $order = StoreOrderModel::merSet($this->merId)->where('id', $id)->find();
-        if (!$order) return $this->fail('订单不存在');
-        if ($order['status'] == 2)
-            return $this->fail('不能重复收货!');
-        if ($order['paid'] == 1 && $order['status'] == 1)
-            $data['status'] = 2;
-        else if ($order['pay_type'] == 'offline')
-            $data['status'] = 2;
-        else
-            return $this->fail('请先发货或者送货!');
-        StoreOrderModel::beginTrans();
-        if (!StoreOrderModel::edit($data, $id)) {
-            StoreOrderModel::rollbackTrans();
-            return $this->fail('收货失败,请稍候再试!');
-        } else {
-            OrderRepository::storeProductOrderTakeDeliveryAdmin($order);
-            StoreOrderStatus::setStatus($id, 'take_delivery', '已收货');
-            StoreOrderModel::commitTrans();
-            //发送短信
-            event('ShortMssageSend', [$order['order_id'], 'Receiving']);
-            return $this->success('收货成功');
-        }
-    }
-
-    /**
-     * 退款表单生成
-     * @param int $id 订单id
-     * @return mixed
-     * @throws DataNotFoundException
-     * @throws DbException
-     * @throws FormBuilderException
-     * @throws ModelNotFoundException
-     */
-    public function refund($id)
-    {
-        if (!$id) return $this->fail('Data does not exist!');
-        $order = StoreOrderModel::merSet($this->merId)->where('id', $id)->find();
-        if (!$order) return $this->fail('未查到订单');
-        if (!$order['paid']) return $this->fail('未支付无法退款');
-        if ($order['pay_price'] <= $order['refund_price']) return $this->fail('订单已退款');
-        $f[] = Form::input('order_id', '退款单号', $order->getData('order_id'))->disabled(1);
-        $f[] = Form::number('refund_price', '退款金额', $order->getData('pay_price'))->precision(2)->min(0.01)->required('请输入退款金额');
-        $f[] = Form::radio('type', '状态', 1)->options([['label' => '直接退款', 'value' => 1], ['label' => '退款后,返回原状态', 'value' => 2]]);
-        return $this->makePostForm('退款处理', $f, Url::buildUrl('/order/refund/' . $id), 'PUT');
-    }
-
-    /**
-     * 订单退款
-     * @param int $id 订单id
-     * @return mixed
-     * @throws DataNotFoundException
-     * @throws ModelNotFoundException
-     * @throws DbException
-     * @throws Exception
-     */
-    public function update_refund($id)
-    {
-        $data = UtilService::postMore([['refund_price', 0], ['type', 1]], $this->request);
-        if (!$id) return $this->fail('Data does not exist!');
-        $order = StoreOrderModel::merSet($this->merId)->where('id', $id)->find();
-        if (!$order) return $this->fail('未查到订单');
-        if ($order['pay_price'] == $order['refund_price']) return $this->fail('已退完支付金额!不能再退款了');
-        if (!$data['refund_price']) return $this->fail('请输入退款金额');
-        $refund_price = $data['refund_price'];
-        $data['refund_price'] = bcadd($data['refund_price'], $order['refund_price'], 2);
-        $bj = bccomp((float)$order['pay_price'], (float)$data['refund_price'], 2);
-        if ($bj < 0) return $this->fail('退款金额大于支付金额,请修改退款金额');
-
-        if ($data['type'] == 1)
-            $data['refund_status'] = 2;
-        else if ($data['type'] == 2)
-            $data['refund_status'] = 0;
-        $type = $data['type'];
-        unset($data['type']);
-        $refund_data['pay_price'] = $order['pay_price'];
-        $refund_data['refund_price'] = $refund_price;
-        //退款处理
-        StoreOrderModel::beginTrans();
-        $res = true;
-        switch ($order['pay_type']) {
-            case 'weixin':
-                if ($order['is_channel'] == 1)
-                    MiniProgramService::payOrderRefund($order['order_id'], $refund_data, $this->merId);//小程序
-                else
-                    WechatService::payOrderRefund($order['order_id'], $refund_data);//公众号
-                break;
-            case 'yue':
-                $usermoney = User::where('uid', $order['uid'])->value('now_money');
-                $res = User::bcInc($order['uid'], 'now_money', $refund_price, 'uid') &&
-                    UserBill::income(
-                        '商品退款',
-                        $order['uid'],
-                        'now_money',
-                        'pay_product_refund',
-                        $refund_price, $order['id'],
-                        bcadd($usermoney, $refund_price, 2),
-                        '订单退款到余额' . floatval($refund_price) . '元',
-                        1,
-                        $this->merId
-                    );
-                OrderRepository::storeOrderYueRefund($order, $refund_data);
-                break;
-        }
-        if (!$res) return $this->fail('余额退款失败');
-        //修改订单退款状态
-        $res = true;
-        if (StoreOrderModel::edit($data, $id)) {
-            $data['type'] = $type;
-            if ($data['type'] == 1) $res = StorePink::setRefundPink($id);
-            if (!$res) return $this->fail('拼团修改失败');
-            OrderRepository::storeProductOrderRefundY($data, $id);
-            StoreOrderStatus::setStatus($id, 'refund_price', '退款给用户' . $refund_price . '元');
-            //退佣金
-            $brokerage_list = UserBill::where('category', 'now_money')
-                ->where('type', 'brokerage')
-                ->where('link_id', $id)
-                ->where('pm', 1)
-                ->select();
-
-            if ($brokerage_list) {
-                $brokerage_list = $brokerage_list->toArray();
-                foreach ($brokerage_list as $item) {
-                    $usermoney = User::where('uid', $item['uid'])->value('brokerage_price');
-                    if ($item['number'] > $usermoney)
-                        $item['number'] = $usermoney;
-                    User::bcDec($item['uid'], 'brokerage_price', $item['number'], 'uid');
-                    UserBill::expend('退款退佣金', $item['uid'], 'now_money', 'brokerage', $item['number'], $id, bcsub($usermoney, $item['number'], 2), '订单退款扣除佣金' . floatval($item['number']) . '元', 1, $this->merId);
-                }
-            }
-            //退款扣除用户积分
-            $bill_integral = UserBill::where('category', 'integral')
-                ->where('type', 'gain')
-                ->where('link_id', $id)
-                ->where('pm', 1)
-                ->find();
-            if ($bill_integral) {
-                $bill_integral = $bill_integral->toArray();
-                //用户积分
-                $user_integral = User::where('uid', $bill_integral['uid'])->value('integral');
-                if ($bill_integral['number'] > $user_integral)
-                    $bill_integral['number'] = $user_integral;
-                User::bcDec($bill_integral['uid'], 'integral', $bill_integral['number'], 'uid');
-                UserBill::expend('退款扣除积分', $bill_integral['uid'], 'integral', 'gain', $bill_integral['number'], $id, bcsub($user_integral, $bill_integral['number'], 2), '订单退款扣除积分' . floatval($bill_integral['number']) . '积分', 1, $this->merId);
-            }
-            StoreOrderModel::commitTrans();
-            return $this->success('退款成功');
-        } else {
-            StoreOrderModel::rollbackTrans();
-            StoreOrderStatus::setStatus($id, 'refund_price', '退款给用户' . $refund_price . '元失败');
-            return $this->fail('退款失败');
-        }
-    }
-
-    /**
-     * 订单详情
-     * @param int $id 订单id
-     * @return mixed
-     * @throws DataNotFoundException
-     * @throws DbException
-     * @throws ModelNotFoundException
-     */
-    public function order_info($id)
-    {
-        if (!$id || !($orderInfo = StoreOrderModel::merSet($this->merId)->where('id', $id)->find()))
-            return $this->fail('订单不存在');
-        $userInfo = User::merSet($this->merId)->where('uid', $orderInfo['uid'])->find();
-        if (!$userInfo) return $this->fail('用户信息不存在');
-        $userInfo = $userInfo->hidden(['pwd', 'add_ip', 'last_ip', 'login_type']);
-        $userInfo['spread_name'] = '';
-        if ($userInfo['spread_uid'])
-            $userInfo['spread_name'] = User::where('uid', $userInfo['spread_uid'])->value('nickname');
-        $orderInfo = StoreOrderModel::tidyOrder($orderInfo->toArray(), false, false, $this->merId);
-        if ($orderInfo['store_id'] && $orderInfo['shipping_type'] == 2)
-            $orderInfo['_store_name'] = SystemStore::where('id', $orderInfo['store_id'])->value('name');
-        else
-            $orderInfo['_store_name'] = '';
-        $userInfo = $userInfo->toArray();
-        return $this->success(compact('orderInfo', 'userInfo'));
-    }
-
-    /**
-     * 查询物流信息
-     * @param int $id 订单id
-     * @return mixed
-     * @throws DataNotFoundException
-     * @throws DbException
-     * @throws ModelNotFoundException
-     */
-    public function get_express($id)
-    {
-        if (!$id || !($orderInfo = StoreOrderModel::merSet($this->merId)->where('id', $id)->find()))
-            return $this->fail('订单不存在');
-        if ($orderInfo['delivery_type'] != 'express' || !$orderInfo['delivery_id'])
-            return $this->fail('该订单不存在快递单号');
-
-        $cacheName = $orderInfo['order_id'] . $orderInfo['delivery_id'];
-        if (!$result = CacheService::get($cacheName, null)) {
-            $result = ExpressService::query($orderInfo['delivery_id']);
-            if (is_array($result) &&
-                isset($result['result']) &&
-                isset($result['result']['deliverystatus']) &&
-                $result['result']['deliverystatus'] >= 3)
-                $cacheTime = 0;
-            else
-                $cacheTime = 1800;
-            CacheService::set($cacheName, $result, $cacheTime);
-        }
-        $data['delivery_name'] = $orderInfo['delivery_name'];
-        $data['delivery_id'] = $orderInfo['delivery_id'];
-        $data['result'] = $result['result']['list'] ?? [];
-        return $this->success($data);
-    }
-
-
-    /**
-     * 获取修改配送信息表单结构
-     * @param int $id 订单id
-     * @return mixed
-     * @throws DataNotFoundException
-     * @throws DbException
-     * @throws ModelNotFoundException
-     */
-    public function distribution($id)
-    {
-        if (!$id || !($orderInfo = StoreOrderModel::merSet($this->merId)->where('id', $id)->find()))
-            return $this->fail('订单不存在');
-
-        $f[] = Form::input('order_id', '订单号', $orderInfo->getData('order_id'))->disabled(1);
-        switch ($orderInfo['delivery_type']) {
-            case 'send':
-                $f[] = Form::input('delivery_name', '送货人姓名', $orderInfo->getData('delivery_name'))->required('请输入送货人姓名');
-                $f[] = Form::input('delivery_id', '送货人电话', $orderInfo->getData('delivery_id'))->required('请输入送货人电话');
-                break;
-            case 'express':
-                $f[] = Form::select('delivery_name', '快递公司', $orderInfo->getData('delivery_name'))->setOptions(function () {
-                    $list = Express::where('is_show', 1)->column('name', 'id');
-                    $menus = [];
-                    foreach ($list as $k => $v) {
-                        $menus[] = ['value' => $v, 'label' => $v];
-                    }
-                    return $menus;
-                })->required('请选择快递公司');
-                $f[] = Form::input('delivery_id', '快递单号', $orderInfo->getData('delivery_id'))->required('请填写快递单号');
-                break;
-        }
-        return $this->makePostForm('配送信息', $f, Url::buildUrl('/order/distribution/' . $id), 'PUT');
-    }
-
-    /**
-     * 修改配送信息
-     * @param int $id 订单id
-     * @return mixed
-     * @throws Exception
-     */
-    public function update_distribution($id)
-    {
-        $data = UtilService::postMore([['delivery_name', ''], ['delivery_id', '']], $this->request);
-        if (!$id) return $this->fail('Data does not exist!');
-        $order = StoreOrderModel::merSet($this->merId)->where('id', $id)->find();
-        if (!$order) return $this->fail('数据不存在!');
-        switch ($order['delivery_type']) {
-            case 'send':
-                if (!$data['delivery_name']) return $this->fail('请输入送货人姓名');
-                if (!$data['delivery_id']) return $this->fail('请输入送货人电话号码');
-                if (!preg_match("/^1[3456789]{1}\d{9}$/", $data['delivery_id'])) return $this->fail('请输入正确的送货人电话号码');
-                break;
-            case 'express':
-                if (!$data['delivery_name']) return $this->fail('请选择快递公司');
-                if (!$data['delivery_id']) return $this->fail('请输入快递单号');
-                break;
-            default:
-                return $this->fail('未发货,请先发货再修改配送信息');
-                break;
-        }
-        StoreOrderModel::edit($data, $id);
-        event('StoreProductOrderDistributionAfter', [$data, $id]);
-        StoreOrderStatus::setStatus($id, 'distribution', '修改发货信息为' . $data['delivery_name'] . '号' . $data['delivery_id']);
-        return $this->success('Modified success');
-    }
-
-    /**
-     * 不退款表单结构
-     * @param $id
-     * @return mixed
-     * @throws DataNotFoundException
-     * @throws DbException
-     * @throws ModelNotFoundException
-     */
-    public function no_refund($id)
-    {
-        if (!$id) return $this->fail('Data does not exist!');
-        $order = StoreOrderModel::merSet($this->merId)->where('id', $id)->find();
-        if (!$order) return $this->fail('Data does not exist!');
-        $f[] = Form::input('order_id', '不退款单号', $order->getData('order_id'))->disabled(1);
-        $f[] = Form::input('refund_reason', '不退款原因')->type('textarea')->required('请填写不退款原因');
-        return $this->makePostForm('不退款原因', $f, Url::buildUrl('order/no_refund/' . $id)->suffix(false), 'PUT');
-    }
-
-    /**
-     * 订单不退款
-     * @param $id
-     * @return mixed
-     * @throws DataNotFoundException
-     * @throws DbException
-     * @throws ModelNotFoundException
-     * @throws Exception
-     */
-    public function update_un_refund($id)
-    {
-        if (!$id || !($orderInfo = StoreOrderModel::merSet($this->merId)->where('id', $id)->find()))
-            return $this->fail('订单不存在');
-        [$refund_reason] = UtilService::postMore([['refund_reason', '']], $this->request, true);
-        if (!$refund_reason) return $this->fail('请输入不退款原因');
-        StoreOrderModel::edit(['refund_reason' => $refund_reason, 'refund_status' => 0], $id);
-        event('StoreProductOrderRefundNAfter', [$refund_reason, $id]);
-        StoreOrderStatus::setStatus($id, 'refund_n', '不退款原因:' . $refund_reason);
-        return $this->success('Modified success');
-    }
-
-    /**
-     * 线下支付
-     * @param int $id 订单id
-     * @return mixed
-     */
-    public function pay_offline($id)
-    {
-        if (!$id) return $this->fail('缺少参数');
-        $res = StoreOrderModel::updateOffline($id, $this->merId);
-        if ($res) {
-            event('StoreProductOrderOffline', [$id]);
-            StoreOrderStatus::setStatus($id, 'offline', '线下付款');
-            return $this->success('Modified success');
-        } else {
-            return $this->fail(StoreOrderModel::getErrorInfo('Modification failed'));
-        }
-    }
-
-    /**
-     * 退积分表单获取
-     * @param $id
-     * @return mixed
-     * @throws DataNotFoundException
-     * @throws DbException
-     * @throws ModelNotFoundException
-     */
-    public function refund_integral($id)
-    {
-        if (!$id || !($orderInfo = StoreOrderModel::merSet($this->merId)->where('id', $id)->find()))
-            return $this->fail('订单不存在');
-        if ($orderInfo->use_integral < 0 || $orderInfo->use_integral == $orderInfo->back_integral)
-            return $this->fail('积分已退或者积分为零无法再退');
-        if (!$orderInfo->paid)
-            return $this->fail('未支付无法退积分');
-        $f[] = Form::input('order_id', '退款单号', $orderInfo->getData('order_id'))->disabled(1);
-        $f[] = Form::number('use_integral', '使用的积分', (float)$orderInfo->getData('use_integral'))->min(0)->disabled(1);
-        $f[] = Form::number('use_integrals', '已退积分', (float)$orderInfo->getData('back_integral'))->min(0)->disabled(1);
-        $f[] = Form::number('back_integral', '可退积分', (float)bcsub($orderInfo->getData('use_integral'), $orderInfo->getData('use_integral')))->min(0)->required('请输入可退积分');
-        return $this->makePostForm('退积分', $f, Url::buildUrl('/order/refund_integral/' . $id), 'PUT');
-    }
-
-    /**
-     * 退积分保存
-     * @param $id
-     * @return mixed
-     * @throws DataNotFoundException
-     * @throws DbException
-     * @throws ModelNotFoundException
-     * @throws Exception
-     */
-    public function update_refund_integral($id)
-    {
-        [$back_integral] = UtilService::postMore([['back_integral', 0]], $this->request, true);
-        if (!$id || !($orderInfo = StoreOrderModel::merSet($this->merId)->where('id', $id)->find()))
-            return $this->fail('订单不存在');
-        if ($back_integral <= 0)
-            return $this->fail('请输入积分');
-        if ($orderInfo['use_integral'] == $orderInfo['back_integral'])
-            return $this->fail('已退完积分!不能再积分了');
-
-        $data['back_integral'] = bcadd($back_integral, $orderInfo['back_integral'], 2);
-        $bj = bccomp((float)$orderInfo['use_integral'], (float)$data['back_integral'], 2);
-        if ($bj < 0) return $this->fail('退积分大于支付积分,请修改退积分');
-        //积分退款处理
-        StoreOrderModel::beginTrans();
-        $integral = User::where('uid', $orderInfo['uid'])->value('integral');
-        $res1 = User::bcInc($orderInfo['uid'], 'integral', $back_integral, 'uid');
-        $res2 = UserBill::income('商品退积分', $orderInfo['uid'], 'integral', 'pay_product_integral_back', $back_integral, $orderInfo['id'], bcadd($integral, $back_integral, 2), '订单退积分' . floatval($back_integral) . '积分到用户积分', 1, $this->merId);
-        event('StoreOrderIntegralBack', [$orderInfo, $back_integral]);
-        OrderRepository::storeOrderIntegralBack($orderInfo, $back_integral);
-        if ($res1 && $res2) {
-            StoreOrderModel::edit($data, $id);
-            StoreOrderStatus::setStatus($id, 'integral_back', '商品退积分:' . $data['back_integral']);
-            StoreOrderModel::commitTrans();
-            return $this->success('退积分成功');
-        } else {
-            StoreOrderModel::rollbackTrans();
-            return $this->fail('退积分失败');
-        }
-    }
-
-    /**
-     * 修改备注
-     * @param $id
-     * @return mixed
-     * @throws Exception
-     */
-    public function remark($id)
-    {
-        $data = UtilService::postMore([['remark', '']], $this->request);
-        if (!$data['remark'])
-            return $this->fail('请输入要备注的内容');
-        if (!$id)
-            return $this->fail('缺少参数');
-        if (!StoreOrderModel::merSet($this->merId)->where('id', $id)->find()) {
-            return $this->fail('找不到订单');
-        }
-        $res = $this->model_save($id, $data);
-        if ($res) {
-            return $this->success('备注成功');
-        } else
-            return $this->fail($this->getErrorInfo());
-    }
-
-    /**
-     * 获取订单状态列表并分页
-     * @param $id
-     * @return mixed
-     * @throws Exception
-     */
-    public function status($id)
-    {
-        if (!$id) return $this->fail('缺少参数');
-        if (!StoreOrderModel::merSet($this->merId)->where('id', $id)->find()) {
-            return $this->fail('找不到订单');
-        }
-        [$page, $limit] = UtilService::getMore([['page', 1], ['limit', 10]], $this->request, true);
-        return $this->success(StoreOrderStatus::getOrderList($id, $page, $limit));
-    }
-
-    /**
-     * 获取商品下的门店
-     */
-
-}

+ 87 - 0
app/adminapi/controller/v1/page/Page.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace app\adminapi\controller\v1\page;
+
+use app\adminapi\controller\AuthController;
+use app\models\page\PageModel;
+use crmeb\services\{UtilService as Util};
+use think\Request;
+
+class Page extends AuthController
+{
+    /**
+     * 显示资源列表
+     *
+     * @return \think\Response
+     */
+    public function index()
+    {
+        $where = Util::getMore([
+            ['page', 1],
+            ['limit', 10]
+        ], $this->request);
+        $list = PageModel::systemPage($where);
+        return $this->success($list);
+    }
+
+    /**
+     * 保存新建的资源
+     *
+     * @param \think\Request $request
+     * @return \think\Response
+     */
+    public function save(Request $request)
+    {
+        $data = Util::postMore([
+            ['id', 0],
+            ['title', ''],
+            ['unique', ''],
+            ['content', '']
+        ]);
+        $data['add_time'] = time();
+        if ($data['id']) {
+            $id = $data['id'];
+            unset($data['id']);
+            $res = PageModel::edit($data, $id, 'id');
+            if($res)
+                return $this->success('修改成功!', ['id' => $id]);
+            else
+                return $this->fail('修改失败!');
+        } else {
+            $res = PageModel::create($data);
+            return $this->success('添加成功!', ['id' => $res->id]);
+        }
+    }
+
+    /**
+     * 显示指定的资源
+     *
+     * @param int $id
+     * @return \think\Response
+     */
+    public function read($id)
+    {
+        $info = PageModel::getOne($id);
+        return $this->success(compact('info'));
+    }
+
+    /**
+     * 删除指定资源
+     *
+     * @param int $id
+     * @return \think\Response
+     */
+    public function delete($id)
+    {
+        if (!$id) return $this->fail('数据不存在');
+        $res = PageModel::get($id);
+        if (!$res) return $this->fail('数据不存在!');
+        if ($res['is_del']) return $this->fail('已删除!');
+        $data['is_del'] = 1;
+        if (PageModel::edit($data, $id))
+            return $this->success('删除成功!');
+        else
+            return $this->fail('删除失败,请稍候再试!');
+    }
+
+}

+ 0 - 1
app/adminapi/controller/v1/product/.WeDrive

@@ -1 +0,0 @@
-/Users/huangjianfeng/WeDrive/六牛科技/源码/CRMEB_PRO_v1.0.0(9)/app/adminapi/controller/v1/product

+ 0 - 928
app/adminapi/controller/v1/product/CopyTaobao.php

@@ -1,928 +0,0 @@
-<?php
-/**
- * Project: 快速复制 淘宝、天猫、1688、京东 商品到CRMEB系统
- * Author: 有一片天 <810806442@qq.com>  微信:szktor
- * Date: 2019-04-25
- */
-
-namespace app\adminapi\controller\v1\product;
-
-use app\adminapi\controller\AuthController;
-use app\models\store\{StoreProduct as ProductModel,
-    StoreDescription,
-    StoreProductAttr,
-    StoreProductAttrValue,
-    StoreProductCate};
-use crmeb\services\{HttpService, UploadService, UtilService};
-use think\exception\PDOException;
-use app\models\system\SystemAttachment;
-use app\models\system\SystemAttachmentCategory;
-
-
-
-/**
- * 商品管理
- * Class StoreProduct
- * @package app\admin\controller\store
- */
-class CopyTaobao extends AuthController
-{
-
-//    use CurdControllerTrait;
-
-    protected $bindModel = ProductModel::class;
-    //错误信息
-    protected $errorInfo = true;
-    //商品默认字段
-    protected $productInfo = [
-        'cate_id' => '',
-        'store_name' => '',
-        'store_info' => '',
-        'unit_name' => '件',
-        'price' => 0,
-        'keyword' => '',
-        'ficti' => 0,
-        'ot_price' => 0,
-        'give_integral' => 0,
-        'postage' => 0,
-        'cost' => 0,
-        'image' => '',
-        'slider_image' => '',
-        'add_time' => 0,
-        'stock' => 0,
-        'description' => '',
-        'soure_link' => '',
-        'temp_id' => 0
-    ];
-    //抓取网站主域名
-    protected $grabName = [
-        'taobao',
-        '1688',
-        'tmall',
-        'jd'
-    ];
-    //远程下载附件图片分类名称
-    protected $AttachmentCategoryName = '远程下载';
-
-    //cookie 采集前请配置自己的 cookie,获取方式浏览器登录平台,F12或查看元素 network->headers 查看Request Headers 复制cookie 到下面变量中
-    protected $webcookie = [
-        //淘宝
-        'taobao' => 'cookie: miid=8289590761042824660; thw=cn; cna=bpdDExs9KGgCAXuLszWnEXxS; hng=CN%7Czh-CN%7CCNY%7C156; tracknick=taobaorongyao; _cc_=WqG3DMC9EA%3D%3D; tg=0; enc=WQPStocTopRI3wEBOPpj8VUDkqSw4Ph81ASG9053SgG8xBMzaOuq6yMe8KD4xPBlNfQST7%2Ffsk9M9GDtGmn6iQ%3D%3D; t=4bab065740d964a05ad111f5057078d4; cookie2=1965ea371faf24b163093f31af4120c2; _tb_token_=5d3380e119d6e; v=0; mt=ci%3D-1_1; _m_h5_tk=61bf01c61d46a64c98209a7e50e9e1df_1572349453522; _m_h5_tk_enc=9d9adfcbd7af7e2274c9b331dc9bae9b; l=dBgc_jG4vxuski7DBOCgCuI8aj7TIIRAguPRwN0viOCKUxT9CgCDAJt5v8PWVNKO7t1nNetzvui3udLHRntW6KTK6MK9zd9snxf..; isg=BJWVXJ3FZGyiWUENfGCuywlwpJePOkncAk8hmRc6WoxbbrVg3-Jadf0uODL97mFc',
-        //阿里巴巴 1688
-        'alibaba' => '',
-        //天猫 可以和淘宝一样
-        'tmall' => 'cookie: miid=8289590761042824660; thw=cn; cna=bpdDExs9KGgCAXuLszWnEXxS; hng=CN%7Czh-CN%7CCNY%7C156; tracknick=taobaorongyao; _cc_=WqG3DMC9EA%3D%3D; tg=0; enc=WQPStocTopRI3wEBOPpj8VUDkqSw4Ph81ASG9053SgG8xBMzaOuq6yMe8KD4xPBlNfQST7%2Ffsk9M9GDtGmn6iQ%3D%3D; t=4bab065740d964a05ad111f5057078d4; cookie2=1965ea371faf24b163093f31af4120c2; _tb_token_=5d3380e119d6e; v=0; mt=ci%3D-1_1; _m_h5_tk=61bf01c61d46a64c98209a7e50e9e1df_1572349453522; _m_h5_tk_enc=9d9adfcbd7af7e2274c9b331dc9bae9b; l=dBgc_jG4vxuski7DBOCgCuI8aj7TIIRAguPRwN0viOCKUxT9CgCDAJt5v8PWVNKO7t1nNetzvui3udLHRntW6KTK6MK9zd9snxf..; isg=BJWVXJ3FZGyiWUENfGCuywlwpJePOkncAk8hmRc6WoxbbrVg3-Jadf0uODL97mFc',
-        //京东 可不用配置
-        'jd' => ''
-    ];
-
-    //请求平台名称 taobao alibaba tmall jd
-    protected $webnname = 'taobao';
-
-    /*
-     * 设置错误信息
-     * @param string $msg 错误信息
-     * */
-    public function setErrorInfo($msg = '')
-    {
-        $this->errorInfo = $msg;
-        return false;
-    }
-
-    /*
-     * 设置字符串字符集
-     * @param string $str 需要设置字符集的字符串
-     * @return string
-     * */
-    public function Utf8String($str)
-    {
-        $encode = mb_detect_encoding($str, array("ASCII", 'UTF-8', 'UTF-32BE', "GB2312", "GBK", 'BIG5'));
-        if (strtoupper($encode) != 'UTF-8') $str = mb_convert_encoding($str, 'utf-8', $encode);
-        return $str;
-    }
-
-    /**
-     * 获取资源,并解析出对应的商品参数
-     * @return json
-     */
-    public function get_request_contents()
-    {
-        list($link) = UtilService::postMore([
-            ['link', '']
-        ], $this->request, true);
-        $url = $this->checkurl($link);
-        if ($url === false) return $this->fail($this->errorInfo);
-        $this->errorInfo = true;
-        $html = $this->curl_Get($url, 60);
-        if (!$html) return $this->fail('商品HTML信息获取失败');
-        $html = $this->Utf8String($html);
-        preg_match('/<title>([^<>]*)<\/title>/', $html, $title);
-        //商品标题
-        $this->productInfo['store_name'] = isset($title['1']) ? str_replace(['-淘宝网', '-tmall.com天猫', ' - 阿里巴巴', ' ', '-', '【图片价格品牌报价】京东', '京东', '【行情报价价格评测】'], '', trim($title['1'])) : '';
-        $this->productInfo['store_info'] = $this->productInfo['store_name'];
-        try {
-            //获取url信息
-            $pathinfo = pathinfo($url);
-            if (!isset($pathinfo['dirname'])) return $this->fail('解析URL失败');
-            //提取域名
-            $parse_url = parse_url($pathinfo['dirname']);
-            if (!isset($parse_url['host'])) return $this->fail('获取域名失败');
-            //获取第一次.出现的位置
-            $strLeng = strpos($parse_url['host'], '.') + 1;
-            //截取域名中的真实域名不带.com后的
-            $funsuffix = substr($parse_url['host'], $strLeng, strrpos($parse_url['host'], '.') - $strLeng);
-            if (!in_array($funsuffix, $this->grabName)) return $this->fail('您输入的地址不在复制范围内!');
-            //设拼接设置商品函数
-            $funName = "setProductInfo" . ucfirst($funsuffix);
-            //执行方法
-            if (method_exists($this, $funName))
-                $this->$funName($html);
-            else
-                return $this->fail('设置商品函数不存在');
-            if (!$this->productInfo['slider_image']) return $this->fail('未能获取到商品信息,请确保商品信息有效!');
-            return $this->success(['info' => $this->productInfo]);
-        } catch (\Exception $e) {
-            return $this->fail('系统错误', ['line' => $e->getLine(), 'meass' => $e->getMessage()]);
-        }
-    }
-
-    /*
-     * 淘宝设置商品
-     * @param string $html 网页内容
-     * */
-    public function setProductInfoTaobao($html)
-    {
-        $this->webnname = 'taobao';
-        //获取轮播图
-        $images = $this->getTaobaoImg($html);
-        $images = array_merge(is_array($images) ? $images : []);
-        $this->productInfo['slider_image'] = isset($images['gaoqing']) ? $images['gaoqing'] : (array)$images;
-        $this->productInfo['slider_image'] = array_slice($this->productInfo['slider_image'], 0, 5);
-        //获取商品详情请求链接
-        $link = $this->getTaobaoDesc($html);
-        //获取请求内容
-        $desc_json = HttpService::getRequest($link);
-        //转换字符集
-        $desc_json = $this->Utf8String($desc_json);
-        //截取掉多余字符
-        $this->productInfo['test'] = $desc_json;
-        $desc_json = str_replace('var desc=\'', '', $desc_json);
-        $desc_json = str_replace(["\n", "\t", "\r"], '', $desc_json);
-        $content = substr($desc_json, 0, -2);
-        $this->productInfo['description'] = $content;
-        //获取详情图
-        $description_images = $this->decodedesc($this->productInfo['description']);
-        $this->productInfo['description_images'] = is_array($description_images) ? $description_images : [];
-        $this->productInfo['image'] = is_array($this->productInfo['slider_image']) && isset($this->productInfo['slider_image'][0]) ? $this->productInfo['slider_image'][0] : '';
-    }
-
-    /*
-     * 天猫设置商品
-     * @param string $html 网页内容
-     * */
-    public function setProductInfoTmall($html)
-    {
-        $this->webnname = 'tmall';
-        //获取轮播图
-        $images = $this->getTianMaoImg($html);
-        $images = array_merge(is_array($images) ? $images : []);
-        $this->productInfo['slider_image'] = $images;
-        $this->productInfo['slider_image'] = array_slice($this->productInfo['slider_image'], 0, 5);
-        $this->productInfo['image'] = is_array($this->productInfo['slider_image']) && isset($this->productInfo['slider_image'][0]) ? $this->productInfo['slider_image'][0] : '';
-        //获取商品详情请求链接
-        $link = $this->getTianMaoDesc($html);
-        //获取请求内容
-        $desc_json = HttpService::getRequest($link);
-        //转换字符集
-        $desc_json = $this->Utf8String($desc_json);
-        //截取掉多余字符
-        $desc_json = str_replace('var desc=\'', '', $desc_json);
-        $desc_json = str_replace(["\n", "\t", "\r"], '', $desc_json);
-        $content = substr($desc_json, 0, -2);
-        $this->productInfo['description'] = $content;
-        //获取详情图
-        $description_images = $this->decodedesc($this->productInfo['description']);
-        $this->productInfo['description_images'] = is_array($description_images) ? $description_images : [];
-    }
-
-    /*
-     * 1688设置商品
-     * @param string $html 网页内容
-     * */
-    public function setProductInfo1688($html)
-    {
-        $this->webnname = 'alibaba';
-        //获取轮播图
-        $images = $this->get1688Img($html);
-        if (isset($images['gaoqing'])) {
-            $images['gaoqing'] = array_merge($images['gaoqing']);
-            $this->productInfo['slider_image'] = $images['gaoqing'];
-        } else
-            $this->productInfo['slider_image'] = $images;
-        if (!is_array($this->productInfo['slider_image'])) {
-            $this->productInfo['slider_image'] = [];
-        }
-        $this->productInfo['slider_image'] = array_slice($this->productInfo['slider_image'], 0, 5);
-        $this->productInfo['image'] = is_array($this->productInfo['slider_image']) && isset($this->productInfo['slider_image'][0]) ? $this->productInfo['slider_image'][0] : '';
-        //获取商品详情请求链接
-        $link = $this->get1688Desc($html);
-        //获取请求内容
-        $desc_json = HttpService::getRequest($link);
-        //转换字符集
-        $desc_json = $this->Utf8String($desc_json);
-        $this->productInfo['test'] = $desc_json;
-        //截取掉多余字符
-        $desc_json = str_replace('var offer_details=', '', $desc_json);
-        $desc_json = str_replace(["\n", "\t", "\r"], '', $desc_json);
-        $desc_json = substr($desc_json, 0, -1);
-        $descArray = json_decode($desc_json, true);
-        if (!isset($descArray['content'])) $descArray['content'] = '';
-        $this->productInfo['description'] = $descArray['content'];
-        //获取详情图
-        $description_images = $this->decodedesc($this->productInfo['description']);
-        $this->productInfo['description_images'] = is_array($description_images) ? $description_images : [];
-    }
-
-    /*
-     * JD设置商品
-     * @param string $html 网页内容
-     * */
-    public function setProductInfoJd($html)
-    {
-        $this->webnname = 'jd';
-        //获取商品详情请求链接
-        $desc_url = $this->getJdDesc($html);
-        //获取请求内容
-        $desc_json = HttpService::getRequest($desc_url);
-        //转换字符集
-        $desc_json = $this->Utf8String($desc_json);
-        //截取掉多余字符
-        if (substr($desc_json, 0, 8) == 'showdesc') $desc_json = str_replace('showdesc', '', $desc_json);
-        $desc_json = str_replace('data-lazyload=', 'src=', $desc_json);
-        $descArray = json_decode($desc_json, true);
-        if (!$descArray) $descArray = ['content' => ''];
-        //获取轮播图
-        $images = $this->getJdImg($html);
-        $images = array_merge(is_array($images) ? $images : []);
-        $this->productInfo['slider_image'] = $images;
-        $this->productInfo['image'] = is_array($this->productInfo['slider_image']) ? ($this->productInfo['slider_image'][0] ?? '') : '';
-        $this->productInfo['description'] = $descArray['content'];
-        //获取详情图
-        $description_images = $this->decodedesc($descArray['content']);
-        $this->productInfo['description_images'] = is_array($description_images) ? $description_images : [];
-    }
-
-    /*
-    * 检查淘宝,天猫,1688的商品链接
-    * @return string
-    */
-    public function checkurl($link)
-    {
-        $link = strtolower(htmlspecialchars_decode($link));
-        if (!$link) return $this->setErrorInfo('请输入链接地址');
-        if (substr($link, 0, 4) != 'http') return $this->setErrorInfo('链接地址必须以http开头');
-        $arrLine = explode('?', $link);
-        if (!count($arrLine)) return $this->setErrorInfo('链接地址有误(ERR:1001)');
-        if (!isset($arrLine[1])) {
-            if (strpos($link, '1688') !== false && strpos($link, 'offer') !== false) return trim($arrLine[0]);
-            else if (strpos($link, 'item.jd') !== false) return trim($arrLine[0]);
-            else return $this->setErrorInfo('链接地址有误(ERR:1002)');
-        }
-        if (strpos($link, '1688') !== false && strpos($link, 'offer') !== false) return trim($arrLine[0]);
-        if (strpos($link, 'item.jd') !== false) return trim($arrLine[0]);
-        $arrLineValue = explode('&', $arrLine[1]);
-        if (!is_array($arrLineValue)) return $this->setErrorInfo('链接地址有误(ERR:1003)');
-        if (!strpos(trim($arrLine[0]), 'item.htm')) $this->setErrorInfo('链接地址有误(ERR:1004)');
-        //链接参数
-        $lastStr = '';
-        foreach ($arrLineValue as $k => $v) {
-            if (substr(strtolower($v), 0, 3) == 'id=') {
-                $lastStr = trim($v);
-                break;
-            }
-        }
-        if (!$lastStr) return $this->setErrorInfo('链接地址有误(ERR:1005)');
-        return trim($arrLine[0]) . '?' . $lastStr;
-    }
-
-    /*
-     * 保存图片保存商品信息
-     * */
-    public function save_product()
-    {
-        $data = UtilService::postMore([
-            ['cate_id', ''],
-            ['store_name', ''],
-            ['store_info', ''],
-            ['keyword', ''],
-            ['unit_name', ''],
-            ['image', ''],
-            ['slider_image', []],
-//            ['price', ''],
-//            ['ot_price', ''],
-            ['give_integral', ''],
-            ['postage', ''],
-//            ['sales', ''],
-            ['ficti', ''],
-//            ['stock', ''],
-//            ['cost', ''],
-            ['description_images', []],
-            ['description', ''],
-            ['is_show', 0],
-            ['soure_link', ''],
-            ['temp_id', 0],
-            ['spec_type', 0],
-            ['items', []],
-            ['attrs', []]
-        ]);
-        $data['mer_id'] = $this->merId ?: '';
-        $detail = $data['items'];
-        unset($data['items']);
-        $attrs = $data['attrs'];
-        unset($data['attrs']);
-        if (!$data['cate_id']) return $this->fail('请选择分类!');
-        if (!$data['store_name']) return $this->fail('请填写商品名称');
-        if (!$data['unit_name']) return $this->fail('请填写商品单位');
-        if (!$data['image']) return $this->fail('商品主图暂无,无法保存商品,您可选择其他链接进行复制商品');
-        if (!$data['temp_id']) return $this->fail('请选择运费模板');
-        //查询附件分类
-        $AttachmentCategory = SystemAttachmentCategory::where('name', $this->AttachmentCategoryName)->find();
-        //不存在则创建
-        if (!$AttachmentCategory) $AttachmentCategory = SystemAttachmentCategory::create(['pid' => '0', 'name' => $this->AttachmentCategoryName, 'enname' => '']);
-        //生成附件目录
-        try {
-            if (make_path('attach', 3, true) === '')
-                return $this->fail('无法创建文件夹,请检查您的上传目录权限:' . app()->getRootPath() . 'public' . DS . 'uploads' . DS . 'attach' . DS);
-
-        } catch (\Exception $e) {
-            return $this->fail($e->getMessage() . '或无法创建文件夹,请检查您的上传目录权限:' . app()->getRootPath() . 'public' . DS . 'uploads' . DS . 'attach' . DS);
-        }
-        ini_set("max_execution_time", 600);
-        //开始图片下载处理
-        ProductModel::beginTrans();
-        try {
-            //放入主图
-            $images = [
-                ['w' => 305, 'h' => 305, 'line' => $data['image'], 'valuename' => 'image']
-            ];
-            //放入轮播图
-            foreach ($data['slider_image'] as $item) {
-                $value = ['w' => 640, 'h' => 640, 'line' => $item, 'valuename' => 'slider_image', 'isTwoArray' => true];
-                array_push($images, $value);
-            }
-            //执行下载
-            $res = $this->uploadImage($images, false, 0, $AttachmentCategory['id']);
-            if (!is_array($res)) return $this->fail($this->errorInfo ? $this->errorInfo : '保存图片失败');
-            if (isset($res['image'])) $data['image'] = $res['image'];
-            if (isset($res['slider_image'])) $data['slider_image'] = $res['slider_image'];
-            $data['slider_image'] = count($data['slider_image']) ? json_encode($data['slider_image']) : '';
-            //替换并下载详情里面的图片默认下载全部图片
-            $data['description'] = preg_replace('#<style>.*?</style>#is', '', $data['description']);
-            $data['description'] = $this->uploadImage($data['description_images'], $data['description'], 1, $AttachmentCategory['id']);
-            unset($data['description_images']);
-            $description = $data['description'];
-            unset($data['description']);
-            $data['add_time'] = time();
-            $cate_id = $data['cate_id'];
-            $data['cate_id'] = implode(',',$data['cate_id']);
-            //商品存在
-            if ($productInfo = ProductModel::where('soure_link', $data['soure_link'])->find()) {
-                $productInfo->slider_image = $data['slider_image'];
-                $productInfo->image = $data['image'];
-                $productInfo->store_name = $data['store_name'];
-                StoreDescription::saveDescription($description, $productInfo->id);
-                $productInfo->save();
-                ProductModel::commitTrans();
-                return $this->success('商品存在,信息已被更新成功');
-            } else {
-                //不存在时新增
-                if ($productId = ProductModel::insertGetId($data)) {
-                    $cateList = [];
-                    foreach ($cate_id as $cid) {
-                        $cateList [] = ['product_id' => $productId, 'cate_id' => $cid, 'add_time' => time()];
-                    }
-                    StoreProductCate::insertAll($cateList);
-                    $attr = [
-                        [
-                            'value' => '规格',
-                            'detailValue' => '',
-                            'attrHidden' => '',
-                            'detail' => ['默认']
-                        ]
-                    ];
-                    $detail[0]['value1'] = '规格';
-                    $detail[0]['detail'] = ['规格' => '默认'];
-                    $detail[0]['price'] = $attrs[0]['price'];
-                    $detail[0]['stock'] = $attrs[0]['stock'];
-                    $detail[0]['cost'] = $attrs[0]['cost'];
-                    $detail[0]['pic'] = $attrs[0]['pic'];
-                    $detail[0]['ot_price'] = $attrs[0]['price'];
-                    $attr_res = StoreProductAttr::createProductAttr($attr, $detail, $productId);
-                    if ($attr_res) {
-                        StoreDescription::saveDescription($description, $productId);
-                        ProductModel::commitTrans();
-                        return $this->success('生成商品成功');
-                    } else {
-                        ProductModel::rollbackTrans();
-                        return $this->fail(StoreProductAttr::getErrorInfo('生成商品失败'));
-                    }
-                } else {
-                    ProductModel::rollbackTrans();
-                    return $this->fail('生成商品失败');
-                }
-            }
-        } catch (\PDOException $e) {
-            ProductModel::rollbackTrans();
-            return $this->fail('插入数据库错误', ['line' => $e->getLine(), 'messag' => $e->getMessage()]);
-        } catch (\Exception $e) {
-            ProductModel::rollbackTrans();
-            return $this->fail('系统错误', ['line' => $e->getLine(), 'messag' => $e->getMessage(), 'file' => $e->getFile()]);
-        }
-    }
-
-    /*
-     * 上传图片处理
-     * @param array $image 图片路径
-     * @param int $uploadType 上传方式 0=远程下载
-     * */
-    public function uploadImage(array $images = [], $html = '', $uploadType = 0, $AttachmentCategoryId = 0)
-    {
-        $uploadImage = [];
-        $siteUrl = sys_config('site_url');
-        switch ($uploadType) {
-            case 0:
-                foreach ($images as $item) {
-                    //下载图片文件
-                    if ($item['w'] && $item['h'])
-                        $uploadValue = $this->downloadImage($item['line'], '', 0, 30, $item['w'], $item['h']);
-                    else
-                        $uploadValue = $this->downloadImage($item['line']);
-                    //下载成功更新数据库
-                    if (is_array($uploadValue)) {
-                        //TODO 拼接图片地址
-                        if ($uploadValue['image_type'] == 1) $imagePath = $siteUrl . $uploadValue['path'];
-                        else $imagePath = $uploadValue['path'];
-                        //写入数据库
-                        if (!$uploadValue['is_exists'] && $AttachmentCategoryId) SystemAttachment::attachmentAdd($uploadValue['name'], $uploadValue['size'], $uploadValue['mime'], $imagePath, $imagePath, $AttachmentCategoryId, $uploadValue['image_type'], time(), 1);
-                        //组装数组
-                        if (isset($item['isTwoArray']) && $item['isTwoArray'])
-                            $uploadImage[$item['valuename']][] = $imagePath;
-                        else
-                            $uploadImage[$item['valuename']] = $imagePath;
-                    }
-                }
-                break;
-            case 1:
-                preg_match_all('#<img.*?src="([^"]*)"[^>]*>#i', $html, $match);
-                if (isset($match[1])) {
-                    foreach ($match[1] as $item) {
-                        if (is_int(strpos($item, 'http')))
-                            $arcurl = $item;
-                        else
-                            $arcurl = 'http://' . ltrim($item, '\//');
-                        $uploadValue = $this->downloadImage($arcurl);
-                        //下载成功更新数据库
-                        if (is_array($uploadValue)) {
-                            //TODO 拼接图片地址
-                            if ($uploadValue['image_type'] == 1) $imagePath = $siteUrl . $uploadValue['path'];
-                            else $imagePath = $uploadValue['path'];
-                            //写入数据库
-                            if (!$uploadValue['is_exists'] && $AttachmentCategoryId) SystemAttachment::attachmentAdd($uploadValue['name'], $uploadValue['size'], $uploadValue['mime'], $imagePath, $imagePath, $AttachmentCategoryId, $uploadValue['image_type'], time(), 1);
-                            //替换图片
-                            $html = str_replace($item, $imagePath, $html);
-                        } else {
-                            //替换掉没有下载下来的图片
-                            $html = preg_replace('#<img.*?src="' . $item . '"*>#i', '', $html);
-                        }
-                    }
-                }
-                return $html;
-                break;
-            default:
-                return $this->setErrorInfo('上传方式错误');
-                break;
-        }
-        return $uploadImage;
-    }
-
-    //提取商品描述中的所有图片
-    public function decodedesc($desc = '')
-    {
-        $desc = trim($desc);
-        if (!$desc) return '';
-        preg_match_all('/<img[^>]*?src="([^"]*?)"[^>]*?>/i', $desc, $match);
-        if (!isset($match[1]) || count($match[1]) <= 0) {
-            preg_match_all('/:url(([^"]*?));/i', $desc, $match);
-            if (!isset($match[1]) || count($match[1]) <= 0) return $desc;
-        } else {
-            preg_match_all('/:url(([^"]*?));/i', $desc, $newmatch);
-            if (isset($newmatch[1]) && count($newmatch[1]) > 0) $match[1] = array_merge($match[1], $newmatch[1]);
-        }
-        $match[1] = array_unique($match[1]); //去掉重复
-        foreach ($match[1] as $k => &$v) {
-            $_tmp_img = str_replace([')', '(', ';'], '', $v);
-            $_tmp_img = strpos($_tmp_img, 'http') ? $_tmp_img : 'http:' . $_tmp_img;
-            if (strpos($v, '?')) {
-                $_tarr = explode('?', $v);
-                $_tmp_img = trim($_tarr[0]);
-            }
-            $_urls = str_replace(['\'', '"'], '', $_tmp_img);
-            if ($this->_img_exists($_urls)) $v = $_urls;
-        }
-        return $match[1];
-    }
-
-    //获取京东商品组图
-    public function getJdImg($html = '')
-    {
-        //获取图片服务器网址
-        preg_match('/<img(.*?)id="spec-img"(.*?)data-origin=\"(.*?)\"[^>]*>/', $html, $img);
-        if (!isset($img[3])) return '';
-        $info = parse_url(trim($img[3]));
-        if (!$info['host']) return '';
-        if (!$info['path']) return '';
-        $_tmparr = explode('/', trim($info['path']));
-        $url = 'http://' . $info['host'] . '/' . $_tmparr[1] . '/' . str_replace(['jfs', ' '], '', trim($_tmparr[2]));
-        preg_match('/imageList:(.*?)"],/is', $html, $img);
-        if (!isset($img[1])) {
-            return '';
-        }
-        $_arr = explode(',', $img[1]);
-        foreach ($_arr as $k => &$v) {
-            $_str = $url . str_replace(['"', '[', ']', ' '], '', trim($v));
-            if (strpos($_str, '?')) {
-                $_tarr = explode('?', $_str);
-                $_str = trim($_tarr[0]);
-            }
-            if ($this->_img_exists($_str)) {
-                $v = $_str;
-            } else {
-                unset($_arr[$k]);
-            }
-        }
-        return array_unique($_arr);
-    }
-
-    //获取京东商品描述
-    public function getJdDesc($html = '')
-    {
-        preg_match('/,(.*?)desc:([^<>]*)\',/i', $html, $descarr);
-        if (!isset($descarr[1]) && !isset($descarr[2])) return '';
-        $tmpArr = explode(',', $descarr[2]);
-        if (count($tmpArr) > 0) {
-            $descarr[2] = trim($tmpArr[0]);
-        }
-        $replace_arr = ['\'', '\',', ' ', ',', '/*', '*/'];
-        if (isset($descarr[2])) {
-            $d_url = str_replace($replace_arr, '', $descarr[2]);
-            return $this->formatDescUrl(strpos($d_url, 'http') ? $d_url : 'http:' . $d_url);
-        }
-        $d_url = str_replace($replace_arr, '', $descarr[1]);
-        $d_url = $this->formatDescUrl($d_url);
-        $d_url = rtrim(rtrim($d_url, "?"), "&");
-        return substr($d_url, 0, 4) == 'http' ? $d_url : 'http:' . $d_url;
-    }
-
-    //处理下京东商品描述网址
-    public function formatDescUrl($url = '')
-    {
-        if (!$url) return '';
-        $url = substr($url, 0, 4) == 'http' ? $url : 'http:' . $url;
-        if (!strpos($url, '&')) {
-            $_arr = explode('?', $url);
-            if (!is_array($_arr) || count($_arr) <= 0) return $url;
-            return trim($_arr[0]);
-        } else {
-            $_arr = explode('&', $url);
-        }
-        if (!is_array($_arr) || count($_arr) <= 0) return $url;
-        unset($_arr[count($_arr) - 1]);
-        $new_url = '';
-        foreach ($_arr as $k => $v) {
-            $new_url .= $v . '&';
-        }
-        return !$new_url ? $url : $new_url;
-    }
-
-    //获取1688商品组图
-    public function get1688Img($html = '')
-    {
-        preg_match('/<ul class=\"nav nav-tabs fd-clr\">(.*?)<\/ul>/is', $html, $img);
-        if (!isset($img[0])) {
-            return '';
-        }
-        preg_match_all('/preview":"(.*?)\"\}\'>/is', $img[0], $arrb);
-        if (!isset($arrb[1]) || count($arrb[1]) <= 0) {
-            return '';
-        }
-        $thumb = [];
-        $gaoqing = [];
-        $res = ['thumb' => '', 'gaoqing' => ''];  //缩略图片和高清图片
-        foreach ($arrb[1] as $k => $v) {
-            $_str = str_replace(['","original":"'], '*', $v);
-            $_arr = explode('*', $_str);
-            if (is_array($_arr) && isset($_arr[0]) && isset($_arr[1])) {
-                if (strpos($_arr[0], '?')) {
-                    $_tarr = explode('?', $_arr[0]);
-                    $_arr[0] = trim($_tarr[0]);
-                }
-                if (strpos($_arr[1], '?')) {
-                    $_tarr = explode('?', $_arr[1]);
-                    $_arr[1] = trim($_tarr[0]);
-                }
-                if ($this->_img_exists($_arr[0])) $thumb[] = trim($_arr[0]);
-                if ($this->_img_exists($_arr[1])) $gaoqing[] = trim($_arr[1]);
-            }
-        }
-        $res = ['thumb' => array_unique($thumb), 'gaoqing' => array_unique($gaoqing)];  //缩略图片和高清图片
-        return $res;
-    }
-
-    //获取1688商品描述
-    public function get1688Desc($html = '')
-    {
-        preg_match('/data-tfs-url="([^<>]*)data-enable="true"/', $html, $descarr);
-        if (!isset($descarr[1])) return '';
-        return str_replace(['"', ' '], '', $descarr[1]);
-    }
-
-    //获取天猫商品组图
-    public function getTianMaoImg($html = '')
-    {
-        $pic_size = '430';
-        preg_match('/<img[^>]*id="J_ImgBooth"[^r]*rc=\"([^"]*)\"[^>]*>/', $html, $img);
-        if (isset($img[1])) {
-            $_arr = explode('x', $img[1]);
-            $filename = $_arr[count($_arr) - 1];
-            $pic_size = intval(substr($filename, 0, 3));
-        }
-        preg_match('|<ul id="J_UlThumb" class="tb-thumb tm-clear">(.*)</ul>|isU', $html, $match);
-        preg_match_all('/<img src="(.*?)" \//', $match[1], $images);
-        if (!isset($images[1])) return '';
-        foreach ($images[1] as $k => &$v) {
-            $tmp_v = trim($v);
-            $_arr = explode('x', $tmp_v);
-            $_fname = $_arr[count($_arr) - 1];
-            $_size = intval(substr($_fname, 0, 3));
-            if (strpos($tmp_v, '://')) {
-                $_arr = explode(':', $tmp_v);
-                $r_url = trim($_arr[1]);
-            } else {
-                $r_url = $tmp_v;
-            }
-            $str = str_replace($_size, $pic_size, $r_url);
-            if (strpos($str, '?')) {
-                $_tarr = explode('?', $str);
-                $str = trim($_tarr[0]);
-            }
-            $_i_url = strpos($str, 'http') ? $str : 'http:' . $str;
-            if ($this->_img_exists($_i_url)) {
-                $v = $_i_url;
-            } else {
-                unset($images[1][$k]);
-            }
-        }
-        return array_unique($images[1]);
-    }
-
-    //获取天猫商品描述
-    public function getTianMaoDesc($html = '')
-    {
-        preg_match('/descUrl":"([^<>]*)","httpsDescUrl":"/', $html, $descarr);
-        if (!isset($descarr[1])) {
-            preg_match('/httpsDescUrl":"([^<>]*)","fetchDcUrl/', $html, $descarr);
-            if (!isset($descarr[1])) return '';
-        }
-        return strpos($descarr[1], 'http') ? $descarr[1] : 'http:' . $descarr[1];
-    }
-
-    //获取淘宝商品组图
-    public function getTaobaoImg($html = '')
-    {
-        preg_match('/auctionImages([^<>]*)"]/', $html, $imgarr);
-        if (!isset($imgarr[1])) return '';
-        $arr = explode(',', $imgarr[1]);
-        foreach ($arr as $k => &$v) {
-            $str = trim($v);
-            $str = str_replace(['"', ' ', '', ':['], '', $str);
-            if (strpos($str, '?')) {
-                $_tarr = explode('?', $str);
-                $str = trim($_tarr[0]);
-            }
-            $_i_url = strpos($str, 'http') ? $str : 'http:' . $str;
-            if ($this->_img_exists($_i_url)) {
-                $v = $_i_url;
-            } else {
-                unset($arr[$k]);
-            }
-        }
-        return array_unique($arr);
-    }
-
-    //获取淘宝商品描述
-    public function getTaobaoDesc($html = '')
-    {
-        preg_match('/descUrl([^<>]*)counterApi/', $html, $descarr);
-        if (!isset($descarr[1])) return '';
-        $arr = explode(':', $descarr[1]);
-        $url = [];
-        foreach ($arr as $k => $v) {
-            if (strpos($v, '//')) {
-                $str = str_replace(['\'', ',', ' ', '?', ':'], '', $v);
-                $url[] = trim($str);
-            }
-        }
-        if ($url) {
-            return strpos($url[0], 'http') ? $url[0] : 'http:' . $url[0];
-        } else {
-            return '';
-        }
-    }
-
-    /**
-     * GET 请求
-     * @param string $url
-     */
-    public function curl_Get($url = '', $time_out = 25)
-    {
-        if (!$url) return '';
-        $ch = curl_init();
-        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查  
-        if (stripos($url, "https://") !== FALSE) {
-            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);  // 从证书中检查SSL加密算法是否存在
-        }
-        $headers = ['user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36'];
-        if ($this->webnname) {
-            $headers[] = $this->webcookie["$this->webnname"];
-        }
-
-        curl_setopt($ch, CURLOPT_URL, $url);
-        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
-        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
-        curl_setopt($ch, CURLOPT_TIMEOUT, $time_out);
-        $response = curl_exec($ch);
-        if ($error = curl_error($ch)) {
-            return false;
-        }
-        curl_close($ch);
-//        return mb_convert_encoding($response, 'utf-8', 'GB2312');
-        return $response;
-    }
-
-    //检测远程文件是否存在
-    public function _img_exists($url = '')
-    {
-        ini_set("max_execution_time", 0);
-        $str = @file_get_contents($url, 0, null, 0, 1);
-        if (strlen($str) <= 0) return false;
-        if ($str)
-            return true;
-        else
-            return false;
-    }
-
-    //TODO 下载图片
-    public function downloadImage($url = '', $name = '', $type = 0, $timeout = 30, $w = 0, $h = 0)
-    {
-        if (!strlen(trim($url))) return '';
-        if (!strlen(trim($name))) {
-            //TODO 获取要下载的文件名称
-            $downloadImageInfo = $this->getImageExtname($url);
-            $name = $downloadImageInfo['file_name'];
-            if (!strlen(trim($name))) return '';
-        }
-        //TODO 获取远程文件所采用的方法
-        if ($type) {
-            $ch = curl_init();
-            curl_setopt($ch, CURLOPT_URL, $url);
-            curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
-            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
-            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //TODO 跳过证书检查
-            if (stripos($url, "https://") !== FALSE) curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);  //TODO 从证书中检查SSL加密算法是否存在
-            curl_setopt($ch, CURLOPT_HTTPHEADER, array('user-agent:' . $_SERVER['HTTP_USER_AGENT']));
-            if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);//TODO 是否采集301、302之后的页面
-            $content = curl_exec($ch);
-            curl_close($ch);
-        } else {
-            try {
-                ob_start();
-                readfile($url);
-                $content = ob_get_contents();
-                ob_end_clean();
-            } catch (\Exception $e) {
-                return $e->getMessage();
-            }
-        }
-        $size = strlen(trim($content));
-        if (!$content || $size <= 2) return '图片流获取失败';
-        $date_dir = date('Y') . DS . date('m') . DS . date('d');
-        $upload_type = sys_config('upload_type', 1);
-        $upload = UploadService::init();
-        if ($upload->to('attach/' . $date_dir)->stream($content, $name) === false) {
-            return $upload->getError();
-        }
-        $imageInfo = $upload->getUploadInfo();
-        $date['path'] = $imageInfo['dir'];
-        $date['name'] = $imageInfo['name'];
-        $date['size'] = $imageInfo['size'];
-        $date['mime'] = $imageInfo['type'];
-        $date['image_type'] = $upload_type;
-        $date['is_exists'] = false;
-        return $date;
-    }
-
-    //获取即将要下载的图片扩展名
-    public function getImageExtname($url = '', $ex = 'jpg')
-    {
-        $_empty = ['file_name' => '', 'ext_name' => $ex];
-        if (!$url) return $_empty;
-        if (strpos($url, '?')) {
-            $_tarr = explode('?', $url);
-            $url = trim($_tarr[0]);
-        }
-        $arr = explode('.', $url);
-        if (!is_array($arr) || count($arr) <= 1) return $_empty;
-        $ext_name = trim($arr[count($arr) - 1]);
-        $ext_name = !$ext_name ? $ex : $ext_name;
-        return ['file_name' => md5($url) . '.' . $ext_name, 'ext_name' => $ext_name];
-    }
-
-    /*
-      $filepath = 绝对路径,末尾有斜杠 /
-      $name = 图片文件名
-      $maxwidth 定义生成图片的最大宽度(单位:像素)
-      $maxheight 生成图片的最大高度(单位:像素)
-      $filetype 最终生成的图片类型(.jpg/.png/.gif)
-    */
-    public function resizeImage($filepath = '', $name = '', $maxwidth = 0, $maxheight = 0)
-    {
-        $pic_file = $filepath . $name; //图片文件
-        $img_info = getimagesize($pic_file); //索引 2 是图像类型的标记:1 = GIF,2 = JPG,3 = PNG,4 = SWF,5 = PSD,
-        if ($img_info[2] == 1) {
-            $im = imagecreatefromgif($pic_file); //打开图片
-            $filetype = '.gif';
-        } elseif ($img_info[2] == 2) {
-            $im = imagecreatefromjpeg($pic_file); //打开图片
-            $filetype = '.jpg';
-        } elseif ($img_info[2] == 3) {
-            $im = imagecreatefrompng($pic_file); //打开图片
-            $filetype = '.png';
-        } else {
-            return ['path' => $filepath, 'file' => $name, 'mime' => ''];
-        }
-        $file_name = md5('_tmp_' . microtime() . '_' . rand(0, 10)) . $filetype;
-        $pic_width = imagesx($im);
-        $pic_height = imagesy($im);
-        $resizewidth_tag = false;
-        $resizeheight_tag = false;
-        if (($maxwidth && $pic_width > $maxwidth) || ($maxheight && $pic_height > $maxheight)) {
-            if ($maxwidth && $pic_width > $maxwidth) {
-                $widthratio = $maxwidth / $pic_width;
-                $resizewidth_tag = true;
-            }
-            if ($maxheight && $pic_height > $maxheight) {
-                $heightratio = $maxheight / $pic_height;
-                $resizeheight_tag = true;
-            }
-            if ($resizewidth_tag && $resizeheight_tag) {
-                if ($widthratio < $heightratio)
-                    $ratio = $widthratio;
-                else
-                    $ratio = $heightratio;
-            }
-            if ($resizewidth_tag && !$resizeheight_tag)
-                $ratio = $widthratio;
-            if ($resizeheight_tag && !$resizewidth_tag)
-                $ratio = $heightratio;
-            $newwidth = $pic_width * $ratio;
-            $newheight = $pic_height * $ratio;
-            if (function_exists("imagecopyresampled")) {
-                $newim = imagecreatetruecolor($newwidth, $newheight);
-                imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $pic_width, $pic_height);
-            } else {
-                $newim = imagecreate($newwidth, $newheight);
-                imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $pic_width, $pic_height);
-            }
-            if ($filetype == '.png') {
-                imagepng($newim, $filepath . $file_name);
-            } else if ($filetype == '.gif') {
-                imagegif($newim, $filepath . $file_name);
-            } else {
-                imagejpeg($newim, $filepath . $file_name);
-            }
-            imagedestroy($newim);
-        } else {
-            if ($filetype == '.png') {
-                imagepng($im, $filepath . $file_name);
-            } else if ($filetype == '.gif') {
-                imagegif($im, $filepath . $file_name);
-            } else {
-                imagejpeg($im, $filepath . $file_name);
-            }
-            imagedestroy($im);
-        }
-        @unlink($pic_file);
-        return ['path' => $filepath, 'file' => $file_name, 'mime' => $img_info['mime']];
-    }
-}

+ 0 - 220
app/adminapi/controller/v1/product/StoreCategory.php

@@ -1,220 +0,0 @@
-<?php
-
-namespace app\adminapi\controller\v1\product;
-
-use app\adminapi\controller\AuthController;
-use app\models\article\ArticleCategory;
-use crmeb\services\FormBuilder as Form;
-use crmeb\services\UtilService as Util;
-use think\Request;
-use app\models\store\StoreCategory as CategoryModel;
-use think\facade\Route as Url;
-
-/**
- * 商品分类控制器
- * Class StoreCategory
- * @package app\admin\controller\system
- */
-class StoreCategory extends AuthController
-{
-
-    /**
-     * 显示资源列表
-     *
-     * @return \think\Response
-     */
-    public function index()
-    {
-        $where = Util::getMore([
-            ['page', 1],
-            ['limit', 20],
-            ['is_show', ''],
-            ['pid', ''],
-            ['cate_name', ''],
-            ['type', 0]
-        ]);
-        if($this->merId){
-            $where['mer_id'] = $this->merId;
-        }
-        if ($where['type']) {
-            $data1 = CategoryModel::getCategoryList();
-            $list = ArticleCategory::tidyTree($data1);
-        } else {
-            $list = CategoryModel::CategoryList($where);
-            if ($where['pid']=='' || $where['cate_name']==''){
-//                $list['list'] = ArticleCategory::tidyTree($list['list']);
-                $list['list'] = array_slice(ArticleCategory::tidyTree($list['list']), ((int)$where['page'] - 1) * $where['limit'], $where['limit']);
-            }
-
-        }
-        return $this->success($list);
-    }
-
-    /**
-     * 树形列表
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     */
-    public function tree_list($type)
-    {
-        $mer_id = $this->merId ?: '';
-        $list = CategoryModel::getTierList(null, $type, $mer_id);
-        return $this->success($list);
-    }
-
-    /**
-     * 修改状态
-     * @param string $is_show
-     * @param string $id
-     */
-    public function set_show($is_show = '', $id = '')
-    {
-        ($is_show == '' || $id == '') && $this->fail('缺少参数');
-        $mer_id = $this->merId ?: '';
-        if (CategoryModel::setCategoryShow($id, (int)$is_show, $mer_id)) {
-            return $this->success($is_show == 1 ? '显示成功' : '隐藏成功');
-        } else {
-            return $this->fail(CategoryModel::getErrorInfo($is_show == 1 ? '显示失败' : '隐藏失败'));
-        }
-    }
-
-    /**
-     * 快速编辑
-     * @param string $field
-     * @param string $id
-     * @param string $value
-     */
-    public function set_category($id)
-    {
-        $data = Util::postMore([
-            ['field', 'cate_name'],
-            ['value', '']
-        ]);
-        $data['field'] == '' || $id == '' || $data['value'] == '' && $this->fail('缺少参数');
-        if (CategoryModel::where('id', $id)->update([$data['field'] => $data['value']]))
-            return $this->success('保存成功');
-        else
-            return $this->fail('保存失败');
-    }
-
-    /**
-     * 显示创建资源表单页.
-     *
-     * @return \think\Response
-     */
-    public function create()
-    {
-        $field = [
-            Form::select('pid', '父级')->setOptions(function () {
-                $mer_id = $this->merId ?: '';
-                $list = CategoryModel::getTierList(null, 0, $mer_id);
-                $menus = [['value' => 0, 'label' => '顶级菜单']];
-                foreach ($list as $menu) {
-                    $menus[] = ['value' => $menu['id'], 'label' => $menu['html'] . $menu['cate_name']];
-                }
-                return $menus;
-            })->filterable(1),
-            Form::input('cate_name', '分类名称'),
-            Form::frameImageOne('pic', '分类图标(180*180)', Url::buildUrl('admin/widget.images/index', array('fodder' => 'pic')))->icon('ios-add')->width('60%')->height('435px'),
-            Form::number('sort', '排序')->value(0),
-            Form::radio('is_show', '状态', 1)->options([['label' => '显示', 'value' => 1], ['label' => '隐藏', 'value' => 0]])
-        ];
-        return $this->makePostForm('添加分类', $field, Url::buildUrl('/product/category'), 'POST');
-    }
-
-    /**
-     * 保存新建的资源
-     *
-     * @param \think\Request $request
-     * @return \think\Response
-     */
-    public function save(Request $request)
-    {
-        $data = Util::postMore([
-            'pid',
-            'cate_name',
-            ['pic', []],
-            'sort',
-            ['is_show', 0]
-        ], $request);
-        $data['mer_id'] = $this->merId ?: 0;
-        if ($data['pid'] == '') return $this->fail('请选择父类');
-        if (!$data['cate_name']) return $this->fail('请输入分类名称');
-        if (count($data['pic']) < 1) return $this->fail('请上传分类图标');
-        if ($data['sort'] < 0) $data['sort'] = 0;
-        $data['pic'] = $data['pic'][0];
-        $data['add_time'] = time();
-        CategoryModel::create($data);
-        return $this->success('添加分类成功!');
-    }
-
-    /**
-     * 显示编辑资源表单页.
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function edit($id)
-    {
-        $c = CategoryModel::get($id);
-        if (!$c) return $this->fail('数据不存在!');
-        $field = [
-            Form::select('pid', '父级', (string)$c->getData('pid'))->setOptions(function () use ($id) {
-                $mer_id = $this->merId ?: '';
-                $list = CategoryModel::getTierList(CategoryModel::where('id', '<>', $id), 0, $mer_id);
-//                $list = (Util::sortListTier(CategoryModel::where('id','<>',$id)->select()->toArray(),'顶级','pid','cate_name'));
-                $menus = [['value' => 0, 'label' => '顶级菜单']];
-                foreach ($list as $menu) {
-                    $menus[] = ['value' => $menu['id'], 'label' => $menu['html'] . $menu['cate_name']];
-                }
-                return $menus;
-            })->filterable(1),
-            Form::input('cate_name', '分类名称', $c->getData('cate_name')),
-            Form::frameImageOne('pic', '分类图标', Url::buildUrl('admin/widget.images/index', array('fodder' => 'pic')), $c->getData('pic'))->icon('ios-add')->width('60%')->height('435px'),
-            Form::number('sort', '排序', $c->getData('sort')),
-            Form::radio('is_show', '状态', $c->getData('is_show'))->options([['label' => '显示', 'value' => 1], ['label' => '隐藏', 'value' => 0]])
-        ];
-        return $this->makePostForm('编辑分类', $field, Url::buildUrl('/product/category/' . $id), 'PUT');
-    }
-
-    /**
-     * 保存更新的资源
-     *
-     * @param \think\Request $request
-     * @param int $id
-     * @return \think\Response
-     */
-    public function update(Request $request, $id)
-    {
-        $data = Util::postMore([
-            'pid',
-            'cate_name',
-            ['pic', []],
-            'sort',
-            ['is_show', 0]
-        ], $request);
-        if ($data['pid'] == '') return $this->fail('请选择父类');
-        if (!$data['cate_name']) return $this->fail('请输入分类名称');
-        if (count($data['pic']) < 1) return $this->fail('请上传分类图标');
-        if ($data['sort'] < 0) $data['sort'] = 0;
-        $data['pic'] = $data['pic'][0];
-        CategoryModel::edit($data, $id);
-        return $this->success('修改成功!');
-    }
-
-    /**
-     * 删除指定资源
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function delete($id)
-    {
-        if (!CategoryModel::delCategory($id))
-            return $this->fail(CategoryModel::getErrorInfo('删除失败,请稍候再试!'));
-        else
-            return $this->success('删除成功!');
-    }
-}

+ 0 - 701
app/adminapi/controller/v1/product/StoreProduct.php

@@ -1,701 +0,0 @@
-<?php
-
-namespace app\adminapi\controller\v1\product;
-
-use app\adminapi\controller\AuthController;
-use app\models\store\{
-    StoreBargain,
-    StoreCombination,
-    StoreProductAttrValue,
-    StoreProductCate,
-    StoreProductAttr,
-    StoreProductAttrResult,
-    StoreProductRelation,
-    StoreDescription,
-    StoreProduct as ProductModel,
-    StoreCategory,
-    StoreSeckill,
-    StoreGiftCode
-};
-use app\models\routine\RoutineCode;
-use app\models\system\ShippingTemplates;
-use app\models\system\SystemProductStore;
-use app\models\system\SystemStore;
-use crmeb\services\UploadService;
-use crmeb\traits\CurdControllerTrait;
-use crmeb\services\UtilService as Util;
-
-/**
- * 商品管理
- * Class StoreProduct
- * @package app\admin\controller\store
- */
-class StoreProduct extends AuthController
-{
-
-    use CurdControllerTrait;
-
-    protected $bindModel = ProductModel::class;
-
-    /**
-     * 显示资源列表头部
-     *
-     * @return \think\Response
-     */
-    public function type_header()
-    {
-        $mer_id = $this->merId ?: '';
-        //出售中商品
-        $onsale = ProductModel::merSet($this->merId)->where('is_del', 0)->where('is_show', 1)->count();
-        //待上架商品
-        $forsale = ProductModel::merSet($this->merId)->where('is_del', 0)->where('is_show', 0)->count();
-        //仓库中商品
-        $warehouse = ProductModel::merSet($this->merId)->where('is_del', 0)->count();
-        //已经售馨产品
-        $outofstock = ProductModel::getModelObject(['type' => 4, 'mer_id' => $mer_id])->count();
-        //警戒库存
-        $policeforce = ProductModel::getModelObject(['type' => 5, 'mer_id' => $mer_id])->count();
-        //回收站
-        $recycle = ProductModel::where('mer_id', $mer_id)->where('is_del', 1)->count();
-        //新人专享商品
-        $newExclusive = ProductModel::where('mer_id', $mer_id)->where('is_del', 0)->where('is_one', 1)->count();
-        $list = [
-            ['type' => 1, 'name' => '出售中商品', 'count' => $onsale],
-            ['type' => 2, 'name' => '仓库中商品', 'count' => $forsale],
-//            ['type' => 3, 'name' => '仓库中商品', 'count' => $warehouse],
-            ['type' => 4, 'name' => '已经售馨商品', 'count' => $outofstock],
-            ['type' => 5, 'name' => '警戒库存', 'count' => $policeforce],
-            ['type' => 6, 'name' => '商品回收站', 'count' => $recycle],
-            ['type' => 7, 'name' => '新人专享商品', 'count' => $newExclusive],
-        ];
-        return $this->success(compact('list'));
-    }
-
-    /**
-     * 显示资源列表
-     * @return mixed
-     */
-    public function index()
-    {
-        $where = Util::getMore([
-            ['page', 1],
-            ['limit', 20],
-            ['store_name', ''],
-            ['cate_id', ''],
-            ['excel', 0],
-            ['type', 1]
-        ]);
-        if($this->merId){
-            $where['mer_id'] = $this->merId;
-        }
-        return $this->success(ProductModel::ProductList($where));
-    }
-
-    /**
-     * 修改状态
-     * @param string $is_show
-     * @param string $id
-     * @return mixed
-     */
-    public function set_show($is_show = '', $id = '')
-    {
-        ($is_show == '' || $id == '') && $this->fail('缺少参数');
-        if (ProductModel::be(['id' => $id, 'is_del' => 1])) return $this->fail('商品已删除,不能上架');
-        $res = ProductModel::where(['id' => $id])->update(['is_show' => (int)$is_show]);
-        if ($res) {
-            return $this->success($is_show == 1 ? '上架成功' : '下架成功');
-        } else {
-            return $this->fail($is_show == 1 ? '上架失败' : '下架失败');
-        }
-    }
-
-    /**
-     * 快速编辑
-     * @param string $field
-     * @param string $id
-     * @param string $value
-     * @return mixed
-     */
-    public function set_product($id = '')
-    {
-        $data = Util::postMore([
-            ['field', ''],
-            ['value', '']
-        ]);
-        $data['field'] == '' || $id == '' || $data['value'] == '' && $this->fail('缺少参数');
-        if (ProductModel::where(['id' => $id])->update([$data['field'] => $data['value']]))
-            return $this->success('保存成功');
-        else
-            return $this->fail('保存失败');
-    }
-
-    /**
-     * 设置批量商品上架
-     * @return mixed
-     */
-    public function product_show()
-    {
-        $post = Util::postMore([
-            ['ids', []]
-        ]);
-        if (empty($post['ids'])) {
-            return $this->fail('请选择需要上架的商品');
-        } else {
-            $res = ProductModel::where('id', 'in', $post['ids'])->update(['is_show' => 1]);
-            if ($res !== false)
-                return $this->success('上架成功');
-            else
-                return $this->fail('上架失败');
-        }
-    }
-
-    /**
-     * 获取规则属性模板
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function get_rule()
-    {
-        return $this->success(\app\models\store\StoreProductRule::merSet($this->merId)->field(['rule_name', 'rule_value'])->select()->each(function ($item) {
-            $item['rule_value'] = json_decode($item['rule_value'], true);
-        })->toArray());
-    }
-
-    /**
-     * 获取商品详细信息
-     * @param int $id
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function get_product_info($id = 0)
-    {
-        $mer_id = $this->merId ?: '';
-        $list = StoreCategory::getTierList(null, 1, $mer_id);
-        $menus = [];
-        foreach ($list as $menu) {
-            $menus[] = ['value' => $menu['id'], 'label' => $menu['html'] . $menu['cate_name'], 'disabled' => $menu['pid'] == 0 ? 0 : 1];//,'disabled'=>$menu['pid']== 0];
-        }
-        $data['tempList'] = ShippingTemplates::order('sort', 'desc')->field(['id', 'name'])->select()->toArray();
-        $data['cateList'] = $menus;
-        $data['storeList'] = SystemStore::where('mer_id', $mer_id)->where('is_del', 0)->where('is_show', 1)->select()->toArray();
-        $data['productInfo'] = [];
-        if ($id) {
-            $productInfo = ProductModel::get($id);
-            if (!$productInfo) {
-                return $this->fail('修改的商品不存在');
-            }
-            $productInfo['cate_id'] = explode(',', $productInfo['cate_id']);
-            $productInfo['give_integral'] = floatval($productInfo['give_integral']);
-            $productInfo['description'] = StoreDescription::getDescription($id);
-            $productInfo['slider_image'] = is_string($productInfo['slider_image']) ? json_decode($productInfo['slider_image'], true) : [];
-            $productInfo['store_id'] = SystemProductStore::where('product_id', $id)->column('store_id');
-            if ($productInfo['spec_type'] == 1) {
-                $result = StoreProductAttrResult::getResult($id);
-                foreach ($result['value'] as $k => $v) {
-                    $num = 1;
-                    foreach ($v['detail'] as $dv) {
-                        $result['value'][$k]['value' . $num] = $dv;
-                        $num++;
-                    }
-                }
-                $productInfo['items'] = $result['attr'];
-                $productInfo['attrs'] = $result['value'];
-                $productInfo['attr'] = ['pic' => '', 'price' => 0, 'cost' => 0, 'ot_price' => 0, 'stock' => 0, 'bar_code' => '', 'weight' => 0, 'volume' => 0, 'brokerage' => 0, 'brokerage_two' => 0];
-            } else {
-                $result = StoreProductAttrValue::where('product_id', $id)->where('type', 0)->find();
-                $productInfo['items'] = [];
-                $productInfo['attrs'] = [];
-                $productInfo['attr'] = [
-                    'pic' => $result['image'] ?? '',
-                    'price' => $result['price'] ? floatval($result['price']) : 0,
-                    'cost' => $result['cost'] ? floatval($result['cost']) : 0,
-                    'ot_price' => $result['ot_price'] ? floatval($result['ot_price']) : 0,
-                    'stock' => $result['stock'] ? floatval($result['stock']) : 0,
-                    'bar_code' => $result['bar_code'] ?? '',
-                    'weight' => $result['weight'] ? floatval($result['weight']) : 0,
-                    'volume' => $result['volume'] ? floatval($result['volume']) : 0,
-                    'brokerage' => $result['brokerage'] ? floatval($result['brokerage']) : 0,
-                    'brokerage_two' => $result['brokerage_two'] ? floatval($result['brokerage_two']) : 0
-                ];
-            }
-            if ($productInfo['activity']) {
-                $activity = explode(',', $productInfo['activity']);
-                foreach ($activity as $k => $v) {
-                    if ($v == 1) {
-                        $activity[$k] = '秒杀';
-                    } elseif ($v == 2) {
-                        $activity[$k] = '砍价';
-                    } elseif ($v == 3) {
-                        $activity[$k] = '拼团';
-                    }
-                }
-                $productInfo['activity'] = $activity;
-            } else {
-                $productInfo['activity'] = ['秒杀', '砍价', '拼团'];
-            }
-            $data['productInfo'] = $productInfo;
-        }
-        return $this->success($data);
-    }
-
-    /**
-     * 保存新建或编辑
-     * @param $id
-     * @return mixed
-     * @throws \Exception
-     */
-    public function save($id)
-    {
-        $data = Util::postMore([
-            ['cate_id', []],
-            'store_name',
-            'store_info',
-            'keyword',
-            ['unit_name', '件'],
-            ['image', []],
-            ['slider_image', []],
-            ['postage', 0],
-            ['is_sub', 0],
-            ['sort', 0],
-            ['sales', 0],
-            ['ficti', 100],
-            ['give_integral', 0],
-            ['is_show', 0],
-            ['temp_id', 0],
-            ['is_hot', 0],
-            ['is_benefit', 0],
-            ['is_best', 0],
-            ['is_new', 0],
-            ['is_one', 0],
-            ['is_ban', 0],
-            ['mer_use', 0],
-            ['is_postage', 0],
-            ['is_good', 0],
-            ['description', ''],
-            ['spec_type', 0],
-            ['video_link', ''],
-            ['items', []],
-            ['attrs', []],
-            ['activity', []],
-            ['is_alone', 0],
-            ['delivery', ''],
-            ['store_id', []],
-        ]);
-        $data['mer_id'] = $this->merId ?: '';
-        foreach ($data['activity'] as $k => $v) {
-            if ($v == '秒杀') {
-                $data['activity'][$k] = 1;
-            } elseif ($v == '砍价') {
-                $data['activity'][$k] = 2;
-            } else {
-                $data['activity'][$k] = 3;
-            }
-        }
-        $data['activity'] = implode(',', $data['activity']);
-        $detail = $data['attrs'];
-        $data['price'] = min(array_column($detail, 'price'));
-        $data['ot_price'] = min(array_column($detail, 'ot_price'));
-        $data['cost'] = min(array_column($detail, 'cost'));
-        $attr = $data['items'];
-        unset($data['items'], $data['video'], $data['attrs']);
-        if (count($data['cate_id']) < 1) return $this->fail('请选择商品分类');
-        $cate_id = $data['cate_id'];
-        $data['cate_id'] = implode(',', $data['cate_id']);
-        if (!$data['store_name']) return $this->fail('请输入商品名称');
-        if (count($data['image']) < 1) return $this->fail('请上传商品图片');
-        if (count($data['slider_image']) < 1) return $this->fail('请上传商品轮播图');
-        $data['image'] = $data['image'][0];
-        $data['slider_image'] = json_encode($data['slider_image']);
-        $data['stock'] = array_sum(array_column($detail, 'stock'));
-        ProductModel::beginTrans();
-        foreach ($detail as &$item) {
-            if (($item['brokerage'] + $item['brokerage_two']) > $item['price']) {
-                return $this->fail('一二级返佣相加不能大于商品售价');
-            }
-        }
-        if ($id) {
-            unset($data['sales']);
-            ProductModel::edit($data, $id);
-            $description = $data['description'];
-            unset($data['description']);
-            StoreDescription::saveDescription($description, $id);
-            StoreProductCate::where('product_id', $id)->delete();
-            $cateData = [];
-            foreach ($cate_id as $cid) {
-                $cateData[] = ['product_id' => $id, 'cate_id' => $cid, 'add_time' => time()];
-            }
-            StoreProductCate::insertAll($cateData);
-            SystemProductStore::saveProductStore($data['store_id'], $id);
-            if ($data['spec_type'] == 0) {
-                $attr = [
-                    [
-                        'value' => '规格',
-                        'detailValue' => '',
-                        'attrHidden' => '',
-                        'detail' => ['默认']
-                    ]
-                ];
-                $detail[0]['value1'] = '规格';
-                $detail[0]['detail'] = ['规格' => '默认'];
-            }
-
-            $attr_res = StoreProductAttr::createProductAttr($attr, $detail, $id);
-            if ($attr_res) {
-                ProductModel::commitTrans();
-                return $this->success('修改成功!');
-            } else {
-                ProductModel::rollbackTrans();
-                return $this->fail(StoreProductAttr::getErrorInfo());
-            }
-        } else {
-            $data['add_time'] = time();
-            $data['code_path'] = '';
-            $res = ProductModel::create($data);
-            $description = $data['description'];
-            StoreDescription::saveDescription($description, $res['id']);
-            $cateData = [];
-            foreach ($cate_id as $cid) {
-                $cateData[] = ['product_id' => $res['id'], 'cate_id' => $cid, 'add_time' => time()];
-            }
-            StoreProductCate::insertAll($cateData);
-            SystemProductStore::saveProductStore($data['store_id'], $res['id']);
-            if ($data['spec_type'] == 0) {
-                $attr = [
-                    [
-                        'value' => '规格',
-                        'detailValue' => '',
-                        'attrHidden' => '',
-                        'detail' => ['默认']
-                    ]
-                ];
-                $detail[0]['value1'] = '规格';
-                $detail[0]['detail'] = ['规格' => '默认'];
-            }
-            $attr_res = StoreProductAttr::createProductAttr($attr, $detail, $res['id']);
-            if ($attr_res) {
-                ProductModel::commitTrans();
-                return $this->success('添加商品成功!');
-            } else {
-                ProductModel::rollbackTrans();
-                return $this->fail(StoreProductAttr::getErrorInfo());
-            }
-        }
-    }
-
-    /**
-     * 删除指定资源
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function delete($id)
-    {
-        if (!$id) return $this->fail('数据不存在');
-        if (!ProductModel::be(['id' => $id])) return $this->fail('商品数据不存在');
-        if (ProductModel::be(['id' => $id, 'is_del' => 1])) {
-            $data['is_del'] = 0;
-            if (!ProductModel::edit($data, $id))
-                return $this->fail(ProductModel::getErrorInfo('恢复失败,请稍候再试!'));
-            else
-                return $this->success('成功恢复商品!');
-        } else {
-            $data['is_del'] = 1;
-            $data['is_show'] = 0;
-            if (!ProductModel::edit($data, $id))
-                return $this->fail(ProductModel::getErrorInfo('删除失败,请稍候再试!'));
-            else
-                return $this->success('成功移到回收站!');
-        }
-    }
-
-    /**
-     * 生成属性
-     * @param int $id
-     */
-    public function is_format_attr($id)
-    {
-        $data = Util::postMore([
-            ['attrs', []],
-            ['items', []]
-        ]);
-        $attr = $data['attrs'];
-        $value = attr_format($attr)[1];
-        $valueNew = [];
-        $count = 0;
-        foreach ($value as $key => $item) {
-            $detail = $item['detail'];
-            sort($item['detail'], SORT_STRING);
-            $suk = implode(',', $item['detail']);
-            if ($id) {
-                $sukValue = StoreProductAttrValue::where('product_id', $id)->where('type', 0)->where('suk', $suk)->column('bar_code,cost,price,ot_price,stock,image as pic,weight,volume,brokerage,brokerage_two', 'suk');
-                if (!count($sukValue)) {
-                    $sukValue[$suk]['pic'] = '';
-                    $sukValue[$suk]['price'] = 0;
-                    $sukValue[$suk]['cost'] = 0;
-                    $sukValue[$suk]['ot_price'] = 0;
-                    $sukValue[$suk]['stock'] = 0;
-                    $sukValue[$suk]['bar_code'] = '';
-                    $sukValue[$suk]['weight'] = 0;
-                    $sukValue[$suk]['volume'] = 0;
-                    $sukValue[$suk]['brokerage'] = 0;
-                    $sukValue[$suk]['brokerage_two'] = 0;
-                }
-            } else {
-                $sukValue[$suk]['pic'] = '';
-                $sukValue[$suk]['price'] = 0;
-                $sukValue[$suk]['cost'] = 0;
-                $sukValue[$suk]['ot_price'] = 0;
-                $sukValue[$suk]['stock'] = 0;
-                $sukValue[$suk]['bar_code'] = '';
-                $sukValue[$suk]['weight'] = 0;
-                $sukValue[$suk]['volume'] = 0;
-                $sukValue[$suk]['brokerage'] = 0;
-                $sukValue[$suk]['brokerage_two'] = 0;
-            }
-            foreach (array_keys($detail) as $k => $title) {
-                $header[$k]['title'] = $title;
-                $header[$k]['align'] = 'center';
-                $header[$k]['minWidth'] = 120;
-            }
-            foreach (array_values($detail) as $k => $v) {
-                $valueNew[$count]['value' . ($k + 1)] = $v;
-                $header[$k]['key'] = 'value' . ($k + 1);
-            }
-            $valueNew[$count]['detail'] = $detail;
-            $valueNew[$count]['pic'] = $sukValue[$suk]['pic'] ?? '';
-            $valueNew[$count]['price'] = $sukValue[$suk]['price'] ? floatval($sukValue[$suk]['price']) : 0;
-            $valueNew[$count]['cost'] = $sukValue[$suk]['cost'] ? floatval($sukValue[$suk]['cost']) : 0;
-            $valueNew[$count]['ot_price'] = isset($sukValue[$suk]['ot_price']) ? floatval($sukValue[$suk]['ot_price']) : 0;
-            $valueNew[$count]['stock'] = $sukValue[$suk]['stock'] ? intval($sukValue[$suk]['stock']) : 0;
-            $valueNew[$count]['bar_code'] = $sukValue[$suk]['bar_code'] ?? '';
-            $valueNew[$count]['weight'] = $sukValue[$suk]['weight'] ? floatval($sukValue[$suk]['weight']) : 0;
-            $valueNew[$count]['volume'] = $sukValue[$suk]['volume'] ? floatval($sukValue[$suk]['volume']) : 0;
-            $valueNew[$count]['brokerage'] = $sukValue[$suk]['brokerage'] ? floatval($sukValue[$suk]['brokerage']) : 0;
-            $valueNew[$count]['brokerage_two'] = $sukValue[$suk]['brokerage_two'] ? floatval($sukValue[$suk]['brokerage_two']) : 0;
-            $count++;
-        }
-        $header[] = ['title' => '图片', 'slot' => 'pic', 'align' => 'center', 'minWidth' => 80];
-        $header[] = ['title' => '售价', 'slot' => 'price', 'align' => 'center', 'minWidth' => 95];
-        $header[] = ['title' => '成本价', 'slot' => 'cost', 'align' => 'center', 'minWidth' => 95];
-        $header[] = ['title' => '原价', 'slot' => 'ot_price', 'align' => 'center', 'minWidth' => 95];
-        $header[] = ['title' => '库存', 'slot' => 'stock', 'align' => 'center', 'minWidth' => 95];
-        $header[] = ['title' => '商品编号', 'slot' => 'bar_code', 'align' => 'center', 'minWidth' => 120];
-        $header[] = ['title' => '重量(KG)', 'slot' => 'weight', 'align' => 'center', 'minWidth' => 95];
-        $header[] = ['title' => '体积(m³)', 'slot' => 'volume', 'align' => 'center', 'minWidth' => 95];
-        $header[] = ['title' => '操作', 'slot' => 'action', 'align' => 'center', 'minWidth' => 70];
-        $info = ['attr' => $attr, 'value' => $valueNew, 'header' => $header];
-        return $this->success(compact('info'));
-    }
-
-    public function set_attr($id)
-    {
-        if (!$id) return $this->fail('商品不存在!');
-        list($attr, $detail) = Util::postMore([
-            ['items', []],
-            ['attrs', []]
-        ], null, true);
-        $res = StoreProductAttr::createProductAttr($attr, $detail, $id);
-        if ($res)
-            return $this->success('编辑属性成功!');
-        else
-            return $this->fail(StoreProductAttr::getErrorInfo());
-    }
-
-    public function clear_attr($id)
-    {
-        if (!$id) return $this->fail('商品不存在!');
-        if (false !== StoreProductAttr::clearProductAttr($id) && false !== StoreProductAttrResult::clearResult($id))
-            return $this->success('清空商品属性成功!');
-        else
-            return $this->fail(StoreProductAttr::getErrorInfo('清空商品属性失败!'));
-    }
-
-    /**
-     * 点赞
-     * @param $id
-     * @return mixed|\think\response\Json|void
-     */
-    public function collect($id)
-    {
-        if (!$id) return $this->fail('数据不存在');
-        $product = ProductModel::get($id);
-        if (!$product) return $this->fail('数据不存在!');
-        $this->assign(StoreProductRelation::getCollect($id));
-        return $this->fetch();
-    }
-
-    /**
-     * 收藏
-     * @param $id
-     * @return mixed|\think\response\Json|void
-     */
-    public function like($id)
-    {
-        if (!$id) return $this->fail('数据不存在');
-        $product = ProductModel::get($id);
-        if (!$product) return $this->fail('数据不存在!');
-        $this->assign(StoreProductRelation::getLike($id));
-        return $this->fetch();
-    }
-
-    /**
-     * 修改商品价格
-     */
-    public function edit_product_price()
-    {
-        $data = Util::postMore([
-            ['id', 0],
-            ['price', 0],
-        ]);
-        if (!$data['id']) return $this->fail('参数错误');
-        $res = ProductModel::edit(['price' => $data['price']], $data['id']);
-        if ($res) return $this->success('修改成功');
-        else return $this->fail('修改失败');
-    }
-
-    /**
-     * 修改商品库存
-     *
-     */
-    public function edit_product_stock()
-    {
-        $data = Util::postMore([
-            ['id', 0],
-            ['stock', 0],
-        ]);
-        if (!$data['id']) return $this->fail('参数错误');
-        $res = ProductModel::edit(['stock' => $data['stock']], $data['id']);
-        if ($res) return $this->success('修改成功');
-        else return $this->fail('修改失败');
-    }
-
-    /**
-     * 获取选择的商品列表
-     * @return mixed
-     */
-    public function search_list()
-    {
-        $where = Util::getMore([
-            ['page', 1],
-            ['limit', 20],
-            ['cate_id', 0],
-            ['store_name', '']
-        ]);
-        if($this->merId){
-            $where['mer_id'] = $this->merId;
-        }
-        $list = ProductModel::getList($where);
-        return $this->success($list);
-    }
-
-    /**
-     * 获取某个商品规格
-     * @return mixed
-     */
-    public function get_attrs()
-    {
-        list($id, $type) = Util::getMore([
-            ['id', 0],
-            ['type', 0],
-        ], $this->request, true);
-        return $this->success(ProductModel::getAttrs($id, $type));
-    }
-
-    /**
-     * 商品添加修改获取运费模板
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function get_template()
-    {
-        return $this->success(ShippingTemplates::merSet($this->merId)->order('sort desc,id desc')->field(['id', 'name'])->select()->toArray());
-    }
-
-    public function getTempKeys()
-    {
-        $upload = UploadService::init();
-        return $this->success($upload->getTempKeys());
-    }
-
-    /**
-     * 检测商品是否开活动
-     * @param $id
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function check_activity($id)
-    {
-        if ($id != 0) {
-            $res1 = StoreSeckill::where('product_id', $id)->where('is_del', 0)->find();
-            $res2 = StoreBargain::where('product_id', $id)->where('is_del', 0)->find();
-            $res3 = StoreCombination::where('product_id', $id)->where('is_del', 0)->find();
-            if ($res1 || $res2 || $res3) {
-                return $this->success('该商品有活动开启,无法删除属性');
-            } else {
-                return $this->fail();
-            }
-        } else {
-            return $this->fail();
-        }
-    }
-
-    /**
-     * 生成礼品唯一二维码
-     */
-    public function gift_code($id)
-    {
-        $mer_id = 11;
-        if (!$id || !($storeInfo = ProductModel::getValidOneProduct($id, 'id', $mer_id))) return app('json')->fail('礼品不存在或已下架');
-        $siteUrl = sys_config('site_url', '', $mer_id);
-        $code = makeOrderNo();
-        $codeData = 'id=' . $id;
-        $codeData .= '&code='. $code;
-        $name = $id . '_' . $code . '_product.jpg';
-        $res = RoutineCode::getPageCode('pages/subs/goods_details/index', $codeData, 280, $mer_id);
-        if (!$res) return app('json')->fail('二维码生成失败');
-        $uploadType = (int)sys_config('upload_type', 1, $mer_id);
-        $upload = UploadService::init(null, $mer_id);
-        $res = $upload->to('routine/product')->validate()->stream($res, $name);
-        if ($res === false) {
-            return app('json')->fail($upload->getError());
-        }
-        $imageInfo = $upload->getUploadInfo();
-        $imageInfo['image_type'] = $uploadType;
-        $url = $imageInfo['dir'];
-        if ($imageInfo['image_type'] == 1) $url = $siteUrl . $url;
-        $data['code'] = $code;
-        $data['is_use'] = 0;
-        $data['mer_id'] = $mer_id;
-        $result = StoreGiftCode::create($data);
-        if($result){
-            return app('json')->successful(['code' => $url]);
-        }
-        return app('json')->fail('二维码保存失败');
-    }
-
-    public function product_code($id)
-    {
-        $mer_id = 11;
-        $siteUrl = sys_config('site_url', '', $mer_id);
-        $codeData = 'id=' . $id;
-        $name = $id . '_product.jpg';
-        $res = RoutineCode::getPageCode('pages/subs/goods_details/index', $codeData, 280, $mer_id);
-        if(!$res) return app('json')->fail('二维码生成失败');
-        $uploadType = (int)sys_config('upload_type', 1, $mer_id);
-        $upload = UploadService::init(null, $mer_id);
-        $res = $upload->to('routine/product')->validate()->stream($res, $name);
-        if ($res === false) {
-            return app('json')->fail($upload->getError());
-        }
-        $imageInfo = $upload->getUploadInfo();
-        $imageInfo['image_type'] = $uploadType;
-        $url = $imageInfo['dir'];
-        if ($imageInfo['image_type'] == 1) $url = $siteUrl . $url;
-        return app('json')->successful(['code' => $url]);
-    }
-}

+ 0 - 124
app/adminapi/controller/v1/product/StoreProductReply.php

@@ -1,124 +0,0 @@
-<?php
-
-namespace app\adminapi\controller\v1\product;
-
-use app\adminapi\controller\AuthController;
-use crmeb\services\FormBuilder as Form;
-use crmeb\services\UtilService;
-use crmeb\traits\CurdControllerTrait;
-use crmeb\services\UtilService as Util;
-use app\models\store\StoreProductReply as ProductReplyModel;
-use think\facade\Route as Url;
-
-/**
- * 评论管理 控制器
- * Class StoreProductReply
- * @package app\admin\controller\store
- */
-class StoreProductReply extends AuthController
-{
-
-    use CurdControllerTrait;
-
-    /**
-     * 显示资源列表
-     *
-     * @return \think\Response
-     */
-    public function index()
-    {
-        $where = UtilService::getMore([
-            ['page', 1],
-            ['limit', 20],
-            ['is_reply', ''],
-            ['store_name', ''],
-            ['account', ''],
-            ['data', ''],
-            ['product_id', 0]
-        ]);
-        $where['mer_id'] = $this->merId ?: '';
-        $list = ProductReplyModel::sysPage($where);
-        return $this->success($list);
-    }
-
-    /**
-     * 删除
-     * @param $id
-     * @return \think\response\Json|void
-     */
-    public function delete($id)
-    {
-        if (!$id) return $this->fail('数据不存在');
-        $data['is_del'] = 1;
-        if (!ProductReplyModel::edit($data, $id))
-            return $this->fail(ProductReplyModel::getErrorInfo('删除失败,请稍候再试!'));
-        else
-            return $this->success('删除成功!');
-    }
-
-    /**
-     * 回复评论
-     */
-    public function set_reply($id)
-    {
-        $data = Util::postMore([
-            'content',
-        ]);
-        if ($data['content'] == '') return $this->fail('请输入回复内容');
-        $save['merchant_reply_content'] = $data['content'];
-        $save['merchant_reply_time'] = time();
-        $save['is_reply'] = 1;
-        $res = ProductReplyModel::edit($save, $id);
-        if (!$res)
-            return $this->fail(ProductReplyModel::getErrorInfo('回复失败,请稍候再试!'));
-        else
-            return $this->success('回复成功!');
-    }
-
-    /**
-     * 添加虚拟评论表单
-     * @return mixed
-     */
-    public function fictitious_reply()
-    {
-        $field = [
-            Form::frameImageOne('image', '商品', Url::buildUrl('admin/store.StoreProduct/index', array('fodder' => 'image')))->icon('ios-add')->width('60%')->height('536px')->setProps(['srcKey' => 'image']),
-            Form::hidden('product_id', ''),
-            Form::input('nickname', '用户名称')->col(Form::col(24)),
-            Form::input('comment', '评价文字')->type('textarea'),
-            Form::number('product_score', '商品分数')->col(8)->value(5)->min(1)->max(5),
-            Form::number('service_score', '服务分数')->col(8)->value(5)->min(1)->max(5),
-            Form::frameImageOne('avatar', '用户头像', Url::buildUrl('admin/widget.images/index', array('fodder' => 'avatar')))->icon('ios-add')->width('50%')->height('396px'),
-            Form::frameImages('pics', '评价图片', Url::buildUrl('admin/widget.images/index', array('fodder' => 'pics', 'type' => 'many')))->maxLength(5)->icon('ios-add')->width('50%')->height('396px')->spin(0)->setProps(['srcKey' => 'att_dir']),
-        ];
-        return $this->makePostForm('添加虚拟评论', $field, Url::buildUrl('/product/reply/save_fictitious_reply'), 'POST');
-    }
-
-    /**
-     * 添加虚拟评论
-     * @return mixed
-     */
-    public function save_fictitious_reply()
-    {
-        $data = Util::postMore([
-            ['image', ''],
-            ['nickname', ''],
-            ['avatar', ''],
-            ['comment', ''],
-            ['pics', []],
-            ['product_score', 0],
-            ['service_score', 0],
-        ]);
-        $this->validate(['image' => $data['image'], 'nickname' => $data['nickname'], 'avatar' => $data['avatar'], 'comment' => $data['comment'], 'product_score' => $data['product_score'], 'service_score' => $data['service_score']], \app\adminapi\validates\product\StoreProductReplyValidate::class, 'save');
-        $data['product_id'] = $data['image']['product_id'];
-        $data['uid'] = 0;
-        $data['oid'] = 0;
-        $data['unique'] = uniqid();
-        $data['reply_type'] = 'product';
-        $data['add_time'] = time();
-        $data['pics'] = json_encode(array_column($data['pics'],'att_dir'));
-        unset($data['image']);
-        ProductReplyModel::create($data);
-        return $this->success('添加成功!');
-    }
-}

+ 0 - 95
app/adminapi/controller/v1/product/StoreProductRule.php

@@ -1,95 +0,0 @@
-<?php
-
-namespace app\adminapi\controller\v1\product;
-
-use app\adminapi\controller\AuthController;
-use app\models\store\StoreProductRule as ProductRuleModel;
-use crmeb\services\UtilService;
-use think\Request;
-
-/**
- * 规则管理
- * Class StoreProductRule
- * @package app\adminapi\controller\v1\product
- */
-class StoreProductRule extends AuthController
-{
-    /**
-     * 显示资源列表
-     *
-     * @return \think\Response
-     */
-    public function index()
-    {
-        $where = UtilService::getMore([
-            ['page', 1],
-            ['limit', 15],
-            ['rule_name','']
-        ]);
-        if($this->merId){
-            $where['mer_id'] = $this->merId;
-        }
-        $list = ProductRuleModel::sysPage($where);
-        return $this->success($list);
-    }
-
-    /**
-     * 保存新建的资源
-     *
-     * @param \think\Request $request
-     * @return \think\Response
-     */
-    public function save(Request $request,$id)
-    {
-        $data = UtilService::postMore([
-            ['rule_name',''],
-            ['spec',[]]
-        ]);
-        $data['mer_id'] = $this->merId ?: '';
-        if ($data['rule_name'] == '') return $this->fail('请输入规则名称');
-        if (!$data['spec']) return $this->fail('缺少规则值');
-        $data['rule_value'] = json_encode($data['spec']);
-        unset($data['spec']);
-        if ($id){
-            $rule = ProductRuleModel::get($id);
-            if (!$rule) return $this->fail('数据不存在');
-            ProductRuleModel::edit($data, $id);
-            return $this->success('编辑成功!');
-        }else{
-            ProductRuleModel::create($data);
-            return $this->success('规则添加成功!');
-        }
-    }
-
-    /**
-     * 显示指定的资源
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function read($id)
-    {
-        $info = ProductRuleModel::sysInfo($id);
-        return $this->success($info);
-    }
-
-    /**
-     * 删除指定资源
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function delete()
-    {
-        $data = UtilService::postMore([
-            ['ids','']
-        ]);
-        if ($data['ids']=='') return $this->fail('请至少选择一条数据');
-        $ids = strval($data['ids']);
-        $res = ProductRuleModel::whereIn('id',$ids)->delete();
-        if (!$res)
-            return $this->fail(ProductRuleModel::getErrorInfo('删除失败,请稍候再试!'));
-        else
-            return $this->success('删除成功!');
-    }
-}

+ 0 - 144
app/adminapi/controller/v1/section/Section.php

@@ -1,144 +0,0 @@
-<?php
-
-namespace app\adminapi\controller\v1\section;
-
-use app\adminapi\controller\AuthController;
-use app\models\section\SectionModel;
-use think\Request;
-use think\facade\Route as Url;
-use crmeb\services\{
-    FormBuilder as Form, UtilService as Util
-};
-
-/**
- * 部门管理
- */
-class Section extends AuthController
-{
-    /**
-     * 显示资源列表
-     */
-    public function index()
-    {
-        $where = Util::getMore([
-            ['page', 1],
-            ['limit', 15],
-            ['status', ''],
-            ['title', ''],
-        ], $this->request);
-        $list = SectionModel::systemPage($where);
-        return $this->success($list);
-    }
-
-    /**
-     * 显示创建资源表单页.
-     *
-     * @return \think\Response
-     */
-    public function create()
-    {
-        $f = array();
-        $f[] = Form::input('title', '部门名称');
-        $f[] = Form::input('intr', '部门简介')->type('textarea');
-        $f[] = Form::frameImageOne('slider_image', '部门图片', Url::buildUrl('admin/widget.images/index', array('fodder' => 'slider_image')))->icon('ios-add')->width('60%')->height('435px');
-        $f[] = Form::number('sort', '排序', 0);
-        $f[] = Form::radio('status', '状态', 1)->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
-        return $this->makePostForm('添加部门', $f, Url::buildUrl('/section/section'), 'POST');
-    }
-
-    /**
-     * 保存新建的资源
-     *
-     * @param \think\Request $request
-     * @return \think\Response
-     */
-    public function save(Request $request)
-    {
-        $data = Util::postMore([
-            'title',
-            'intr',
-            ['image', []],
-            ['sort', 0],
-            'status',]);
-        if (!$data['title']) return $this->fail('请输入部门名称');
-        if (count($data['image']) != 1) return $this->fail('请选择部门图片,并且只能上传一张');
-        if ($data['sort'] < 0) return $this->fail('排序不能是负数');
-        $data['add_time'] = time();
-        $data['image'] = $data['image'][0];
-        $res = SectionModel::create($data);
-        return $this->success('添加部门成功!');
-    }
-
-    /**
-     * 显示编辑资源表单页.
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function edit($id)
-    {
-        if (!$id) return $this->fail('参数错误');
-        $section = SectionModel::get($id)->getData();
-        if (!$section) return $this->fail('数据不存在!');
-        $f = array();
-        $f[] = Form::input('title', '部门名称', $section['title']);
-        $f[] = Form::input('intr', '部门简介', $section['intr'])->type('textarea');
-        $f[] = Form::frameImageOne('slider_image', '部门图片', Url::buildUrl('admin/widget.images/index', array('fodder' => 'slider_image')), $section['image'])->icon('ios-add')->width('60%')->height('435px');
-        $f[] = Form::number('sort', '排序', $section['sort']);
-        $f[] = Form::radio('status', '状态', $section['status'])->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
-        return $this->makePostForm('编辑部门', $f, Url::buildUrl('/section/section/' . $id), 'PUT');
-    }
-
-    /**
-     * 保存更新的资源
-     *
-     * @param \think\Request $request
-     * @param int $id
-     * @return \think\Response
-     */
-    public function update(Request $request, $id)
-    {
-        $data = Util::postMore([
-            'title',
-            'intr',
-            ['image', []],
-            ['sort', 0],
-            'status',]);
-        if (!$data['title']) return $this->fail('请输入分类名称');
-        if (count($data['image']) != 1) return $this->fail('请选择分类图片,并且只能上传一张');
-        if ($data['sort'] < 0) return $this->fail('排序不能是负数');
-        $data['image'] = $data['image'][0];
-        if (!SectionModel::get($id)) return $this->fail('编辑的记录不存在!');
-        SectionModel::edit($data, $id);
-        return $this->success('修改成功!');
-    }
-
-    /**
-     * 删除指定资源
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function delete($id)
-    {
-        $res = SectionModel::edit(['is_del' => 1], $id, 'id');
-        if (!$res)
-            return $this->fail(SectionModel::getErrorInfo('删除失败,请稍候再试!'));
-        else
-            return $this->success('删除成功!');
-    }
-
-    /**
-     * 修改状态
-     * @param $id
-     * @param $status
-     * @return mixed
-     */
-    public function set_status($id, $status)
-    {
-        if ($status == '' || $id == 0) return $this->fail('参数错误');
-        SectionModel::where(['id' => $id])->update(['status' => $status]);
-        return $this->success($status == 0 ? '隐藏成功' : '显示成功');
-    }
-
-}

+ 16 - 0
app/adminapi/route/article.php

@@ -0,0 +1,16 @@
+<?php
+
+use think\facade\Route;
+
+/**
+ * 文章管理 相关路由
+ */
+Route::group('article', function () {
+    //文章资源路由
+    Route::resource('article', 'v1.article.Article')->name('ArticleResource');
+
+})->middleware([
+    \app\http\middleware\AllowOriginMiddleware::class,
+    \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
+    \app\adminapi\middleware\AdminCkeckRole::class
+]);

+ 0 - 26
app/adminapi/route/cms.php

@@ -1,26 +0,0 @@
-<?php
-
-use think\facade\Route;
-
-/**
- * 文章管理 相关路由
- */
-Route::group('cms', function () {
-    //文章资源路由
-    Route::resource('cms', 'v1.cms.Article')->name('ArticleResource');
-    //分类列表
-    Route::get('cms/merchant_index/:id', 'v1.cms.Article/merchantIndex')->name('MerchantIndex');
-    //关联商品
-    Route::put('cms/relation/:id', 'v1.cms.Article/relation')->name('Relation');
-    //取消关联
-    Route::put('cms/unrelation/:id', 'v1.cms.Article/unrelation')->name('UnRelation');
-    //文章分类资源路由
-    Route::resource('category', 'v1.cms.ArticleCategory')->name('ArticleCategoryResource');
-    //修改状态
-    Route::put('category/set_status/:id/:status', 'v1.cms.ArticleCategory/set_status')->name('CategoryStatus');
-
-})->middleware([
-    \app\http\middleware\AllowOriginMiddleware::class,
-    \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
-    \app\adminapi\middleware\AdminCkeckRole::class
-]);

+ 18 - 0
app/adminapi/route/course.php

@@ -0,0 +1,18 @@
+<?php
+
+use think\facade\Route;
+
+/**
+ * 课程管理 相关路由
+ */
+Route::group('course', function () {
+    //机构资源路由
+    Route::resource('organ', 'v1.course.Organ')->name('OrganResource');
+    //课程资源路由
+    Route::resource('course', 'v1.course.Course')->name('CourseResource');
+
+})->middleware([
+    \app\http\middleware\AllowOriginMiddleware::class,
+    \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
+    \app\adminapi\middleware\AdminCkeckRole::class
+]);

+ 16 - 0
app/adminapi/route/open.php

@@ -0,0 +1,16 @@
+<?php
+
+use think\facade\Route;
+
+/**
+ * 小程序授权第三方平台 相关路由
+ */
+Route::group('open', function () {
+    Route::get('auth_url/:type', 'v1.merchant.Open/createAuthUrl')->name('createAuthUrl');//生成小程序授权地址
+    Route::post('get/:info_type', 'v1.merchant.Open/getInfoForFront')->name('getInfoForFront');//获取信息
+    Route::post('redirect/:mer_id', 'v1.merchant.Open/wxAuthRedirect');//接收授权码
+})->middleware([
+    \app\http\middleware\AllowOriginMiddleware::class,
+    \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
+    \app\adminapi\middleware\AdminCkeckRole::class
+]);

+ 0 - 64
app/adminapi/route/order.php

@@ -1,64 +0,0 @@
-<?php
-
-use think\facade\Route;
-
-/**
- * 订单路由
- */
-Route::group('order', function () {
-    //订单列表
-    Route::get('list', 'v1.order.StoreOrder/lst')->name('StoreOrderList');
-    //订单数据
-    Route::get('chart', 'v1.order.StoreOrder/chart')->name('StoreOrderChart');
-    //订单核销
-    Route::post('write', 'v1.order.StoreOrder/write_order')->name('writeOrder');
-    //获取订单编辑表格
-    Route::get('edit/:id', 'v1.order.StoreOrder/edit')->name('StoreOrderEdit');
-    //修改订单
-    Route::put('update/:id', 'v1.order.StoreOrder/update')->name('StoreOrderUpdate');
-    //确认收货
-    Route::put('take/:id', 'v1.order.StoreOrder/take_delivery')->name('StoreOrderTakeDelivery');
-    //发送货
-    Route::put('delivery/:id', 'v1.order.StoreOrder/update_delivery')->name('StoreOrderUpdateDelivery');
-    //订单退款表格
-    Route::get('refund/:id', 'v1.order.StoreOrder/refund')->name('StoreOrderRefund');
-    //订单退款
-    Route::put('refund/:id', 'v1.order.StoreOrder/update_refund')->name('StoreOrderUpdateRefund');
-    //获取物流信息
-    Route::get('express/:id', 'v1.order.StoreOrder/get_express')->name('StoreOrderUpdateExpress');
-    //获取物流公司
-    Route::get('express_list', 'v1.order.StoreOrder/express')->name('StoreOrdeRexpressList');
-    //订单详情
-    Route::get('info/:id', 'v1.order.StoreOrder/order_info')->name('StoreOrderorInfo');
-    //获取配送信息表格
-    Route::get('distribution/:id', 'v1.order.StoreOrder/distribution')->name('StoreOrderorDistribution');
-    //修改配送信息
-    Route::put('distribution/:id', 'v1.order.StoreOrder/update_distribution')->name('StoreOrderorUpdateDistribution');
-    //获取不退款表格
-    Route::get('no_refund/:id', 'v1.order.StoreOrder/no_refund')->name('StoreOrderorNoRefund');
-    //修改不退款理由
-    Route::put('no_refund/:id', 'v1.order.StoreOrder/update_un_refund')->name('StoreOrderorUpdateNoRefund');
-    //线下支付
-    Route::post('pay_offline/:id', 'v1.order.StoreOrder/pay_offline')->name('StoreOrderorPayOffline');
-    //获取退积分表格
-    Route::get('refund_integral/:id', 'v1.order.StoreOrder/refund_integral')->name('StoreOrderorRefundIntegral');
-    //修改退积分
-    Route::put('refund_integral/:id', 'v1.order.StoreOrder/update_refund_integral')->name('StoreOrderorUpdateRefundIntegral');
-    //修改备注信息
-    Route::put('remark/:id', 'v1.order.StoreOrder/remark')->name('StoreOrderorRemark');
-    //获取订单状态
-    Route::get('status/:id', 'v1.order.StoreOrder/status')->name('StoreOrderorStatus');
-    //删除订单单个
-    Route::delete('del/:id', 'v1.order.StoreOrder/del')->name('StoreOrderorDel');
-    //批量删除订单
-    Route::post('dels', 'v1.order.StoreOrder/del_orders')->name('StoreOrderorDels');
-    //批量设置标签
-    Route::post('setLevel', 'v1.order.StoreOrder/setLevel')->name('StoreOrderorLevel');
-    //获取商品对应门店
-    Route::get('product/store', 'v1.order.StoreOrder/product_store')->name('StoreProductStore');
-
-})->middleware([
-    \app\http\middleware\AllowOriginMiddleware::class,
-    \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
-    \app\adminapi\middleware\AdminCkeckRole::class
-]);

+ 16 - 0
app/adminapi/route/page.php

@@ -0,0 +1,16 @@
+<?php
+
+use think\facade\Route;
+
+/**
+ * 单页管理 相关路由
+ */
+Route::group('page', function () {
+    //文章资源路由
+    Route::resource('page', 'v1.page.Page')->name('PageResource');
+
+})->middleware([
+    \app\http\middleware\AllowOriginMiddleware::class,
+    \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
+    \app\adminapi\middleware\AdminCkeckRole::class
+]);

+ 0 - 84
app/adminapi/route/product.php

@@ -1,84 +0,0 @@
-<?php
-
-use think\facade\Route;
-
-Route::group('product', function () {
-
-    Route::get('category', 'v1.product.StoreCategory/index');
-    //商品树形列表
-    Route::get('category/tree/:type', 'v1.product.StoreCategory/tree_list');
-    //商品分类新增表单
-    Route::get('category/create', 'v1.product.StoreCategory/create');
-    //商品分类新增
-    Route::post('category', 'v1.product.StoreCategory/save');
-    //商品分类编辑表单
-    Route::get('category/:id/edit', 'v1.product.StoreCategory/edit');
-    //商品分类编辑
-    Route::put('category/:id', 'v1.product.StoreCategory/update');
-    //删除商品分类
-    Route::delete('category/:id', 'v1.product.StoreCategory/delete');
-    //商品分类修改状态
-    Route::put('category/set_show/:id/:is_show', 'v1.product.StoreCategory/set_show');
-    //商品分类快捷编辑
-    Route::put('category/set_category/:id', 'v1.product.StoreCategory/set_category');
-    //商品列表
-    Route::get('product', 'v1.product.StoreProduct/index');
-    //获取所有商品列表
-    Route::get('product/list', 'v1.product.StoreProduct/search_list');
-    //获取商品规格
-    Route::get('product/attrs/:id/:type', 'v1.product.StoreProduct/get_attrs');
-    //商品列表头
-    Route::get('product/type_header', 'v1.product.StoreProduct/type_header');
-    //商品详情
-    Route::get('product/:id', 'v1.product.StoreProduct/get_product_info');
-    //加入回收站
-    Route::delete('product/:id', 'v1.product.StoreProduct/delete');
-    //保存新建或保存
-    Route::post('product/:id', 'v1.product.StoreProduct/save');
-    //修改商品状态
-    Route::put('product/set_show/:id/:is_show', 'v1.product.StoreProduct/set_show');
-    //商品快速编辑
-    Route::put('product/set_product/:id', 'v1.product.StoreProduct/set_product');
-    //设置批量商品上架
-    Route::put('product/product_show', 'v1.product.StoreProduct/product_show');
-    //规则列表
-    Route::get('product/rule', 'v1.product.StoreProductRule/index');
-    //规则 保存新建或编辑
-    Route::post('product/rule/:id', 'v1.product.StoreProductRule/save');
-    //规则详情
-    Route::get('product/rule/:id', 'v1.product.StoreProductRule/read');
-    //删除属性规则
-    Route::delete('product/rule/delete', 'v1.product.StoreProductRule/delete');
-    //生成属性
-    Route::post('generate_attr/:id', 'v1.product.StoreProduct/is_format_attr');
-    //评论列表
-    Route::get('reply', 'v1.product.StoreProductReply/index');
-    //回复评论
-    Route::put('reply/set_reply/:id', 'v1.product.StoreProductReply/set_reply');
-    //删除评论
-    Route::delete('reply/:id', 'v1.product.StoreProductReply/delete');
-    //获取商品数据
-    Route::post('crawl', 'v1.product.CopyTaobao/get_request_contents');
-    //保存商品数据
-    Route::post('crawl/save', 'v1.product.CopyTaobao/save_product');
-    //调起虚拟评论表单
-    Route::get('reply/fictitious_reply', 'v1.product.StoreProductReply/fictitious_reply');
-    //保存虚拟评论
-    Route::post('reply/save_fictitious_reply', 'v1.product.StoreProductReply/save_fictitious_reply');
-    //获取规则属性模板
-    Route::get('product/get_rule', 'v1.product.StoreProduct/get_rule');
-    //获取运费模板
-    Route::get('product/get_template', 'v1.product.StoreProduct/get_template');
-    //上传视频密钥接口
-    Route::get('product/get_temp_keys', 'v1.product.StoreProduct/getTempKeys');
-    //检测是否有活动开启
-    Route::get('product/check_activity/:id', 'v1.product.StoreProduct/check_activity');
-    //生成礼品唯一二维码
-    Route::get('product/code/:id', 'v1.product.StoreProduct/gift_code');
-    //生成商品二维码
-    Route::get('product/product_code/:id', 'v1.product.StoreProduct/product_code');
-})->middleware([
-    \app\http\middleware\AllowOriginMiddleware::class,
-    \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
-    \app\adminapi\middleware\AdminCkeckRole::class
-]);

+ 0 - 18
app/adminapi/route/section.php

@@ -1,18 +0,0 @@
-<?php
-
-use think\facade\Route;
-
-/**
- * 部门管理 相关路由
- */
-Route::group('section', function () {
-    //部门资源路由
-    Route::resource('section', 'v1.section.Section')->name('SectionResource');
-    //修改状态
-    Route::put('section/set_status/:id/:status', 'v1.section.Section/set_status')->name('SectionStatus');
-
-})->middleware([
-    \app\http\middleware\AllowOriginMiddleware::class,
-    \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
-    \app\adminapi\middleware\AdminCkeckRole::class
-]);

+ 50 - 0
app/adminapi/route/third.php

@@ -0,0 +1,50 @@
+<?php
+
+use think\facade\Route;
+
+/**
+ * 第三方平台代小程序实现业务 相关路由
+ */
+Route::group('third', function () {
+    //快速创建小程序(不一定用)
+    Route::post('miniprogram/create', 'v1.merchant.Third/createMiniProgram')->name('createMiniProgram');//快速创建小程序
+
+    //基础信息设置
+    Route::post('code/modify_domain/:mer_id', 'v1.merchant.Third/modifyDomain')->name('modifyDomain');//设置服务器域名
+
+    //代码模板库设置
+    Route::get('template/draft_list', 'v1.merchant.Third/getTemplateDraftList')->name('getTemplateDraftList');//获取代码草稿列表
+    Route::get('template/list', 'v1.merchant.Third/getTemplateList')->name('getTemplateList');//获取代码模板列表
+    Route::post('template/add/:draft_id', 'v1.merchant.Third/addToTemplate')->name('addToTemplate');//将草稿添加到代码模板库
+    Route::post('template/del/:template_id', 'v1.merchant.Third/deleteTemplate')->name('deleteTemplate');//删除指定代码模板
+
+    //代码管理
+    Route::post('code/commit/:mer_id/:template_id', 'v1.merchant.Third/commitCode')->name('commitCode');//上传小程序代码
+    Route::get('code/list/:mer_id', 'v1.merchant.Third/getPageList')->name('getPageList');//获取已上传的代码的页面列表
+    Route::get('code/qrcode/:mer_id', 'v1.merchant.Third/getQrCode')->name('getQrCode');//获取体验版二维码
+    Route::post('code/audit/:mer_id', 'v1.merchant.Third/submitAudit')->name('submitAudit');//提交审核
+    Route::post('code/audit/media/:mer_id', 'v1.merchant.Third/addAuditMedia')->name('addAuditMedia');//提交审核素材
+    Route::get('code/audit_list', 'v1.merchant.Third/getAuditList')->name('getAuditList');//获取审核列表
+    Route::post('code/audit_status/:mer_id/:auditid', 'v1.merchant.Third/getAuditStatus')->name('getAuditStatus');//查询指定发布审核单的审核状态
+    Route::post('code/undo/:mer_id', 'v1.merchant.Third/undoAudit')->name('undoAudit');//小程序审核撤回
+    Route::get('code/audit_last_status/:mer_id', 'v1.merchant.Third/getLatestAuditStatus')->name('getLatestAuditStatus');//查询最新一次审核单的审核状态
+    Route::post('code/release/:mer_id', 'v1.merchant.Third/release')->name('release');//发布已通过审核的小程序
+    Route::post('code/revert/:mer_id', 'v1.merchant.Third/revertCodeRelease')->name('revertCodeRelease');//版本回退
+    Route::post('code/gray_release/:mer_id/:gray', 'v1.merchant.Third/grayRelease')->name('grayRelease');//分阶段发布
+    Route::post('code/gray_release/revert/:mer_id/', 'v1.merchant.Third/revertGrayRelease')->name('revertGrayRelease');//分阶段发布
+    Route::get('code/gray_release/plan/:mer_id', 'v1.merchant.Third/getGrayReleasePlan')->name('getGrayReleasePlan');//查询当前分阶段发布详情
+    Route::post('code/visit_status/:mer_id/:action', 'v1.merchant.Third/changeVisitStatus')->name('changeVisitStatus');//修改小程序线上代码的可见状态(仅供第三方代小程序调用)
+    Route::get('code/support_version/:mer_id', 'v1.merchant.Third/getWeAppSupportVersion')->name('getWeAppSupportVersion');//查询当前设置的最低基础库版本及各版本用户占比
+    Route::post('code/support_version/:mer_id', 'v1.merchant.Third/setWeAppSupportVersion')->name('setWeAppSupportVersion');//设置最低基础库版本
+    Route::get('code/query_quota/:mer_id', 'v1.merchant.Third/queryQuota')->name('queryQuota');//询服务商的当月提审限额(quota)和加急次数
+    Route::post('code/speed_up_audit/:mer_id/:auditid', 'v1.merchant.Third/speedUpAudit')->name('speedUpAudit');//加急审核申请
+    Route::get('code/cate/:mer_id', 'v1.merchant.Third/getCategory')->name('getCategory');//获取审核时可填写的类目信息
+
+    //体验者管理
+    Route::post('tester/add/:mer_id', 'v1.merchant.Third/bindTester')->name('bindTester');//绑定体验者
+    Route::post('tester/del/:mer_id', 'v1.merchant.Third/unbindTester')->name('unbindTester');//解绑体验者
+})->middleware([
+    \app\http\middleware\AllowOriginMiddleware::class,
+    \app\adminapi\middleware\AdminAuthTokenMiddleware::class,
+    \app\adminapi\middleware\AdminCkeckRole::class
+]);

+ 0 - 15
app/badmin/route/route.php

@@ -1,15 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | ThinkPHP [ WE CAN DO IT JUST THINK ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
-// +----------------------------------------------------------------------
-// | Author: liu21st <liu21st@gmail.com>
-// +----------------------------------------------------------------------
-use think\facade\Route;
-
-Route::miss(function () {
-    return view(app()->getRootPath() . 'public' . DS . 'badmin/index.html');
-});

+ 0 - 61
app/badminapi/BadminApiExceptionHandle.php

@@ -1,61 +0,0 @@
-<?php
-
-
-namespace app\badminapi;
-
-
-use crmeb\exceptions\AdminException;
-use crmeb\exceptions\AuthException;
-use crmeb\exceptions\UtilException;
-use think\db\exception\DbException;
-use think\exception\Handle;
-use think\exception\ValidateException;
-use think\facade\Env;
-use think\Response;
-use Throwable;
-
-class BadminApiExceptionHandle extends Handle
-{
-
-    /**
-     * 记录异常信息(包括日志或者其它方式记录)
-     *
-     * @access public
-     * @param Throwable $exception
-     * @return void
-     */
-    public function report(Throwable $exception): void
-    {
-        // 使用内置的方式记录异常日志
-        parent::report($exception);
-    }
-
-    /**
-     * Render an exception into an HTTP response.
-     *
-     * @access public
-     * @param \think\Request $request
-     * @param Throwable $e
-     * @return Response
-     */
-    public function render($request, Throwable $e): Response
-    {
-        $massageData = Env::get('app_debug', false) ? [
-            'file' => $e->getFile(),
-            'line' => $e->getLine(),
-            'trace' => $e->getTrace(),
-            'previous' => $e->getPrevious(),
-        ] : [];
-        // 添加自定义异常处理机制
-        if ($e instanceof DbException) {
-            return app('json')->fail('数据获取失败', $massageData);
-        } elseif ($e instanceof AuthException || $e instanceof ValidateException || $e instanceof UtilException) {
-            return app('json')->make($e->getCode() ?: 400, $e->getMessage());
-        } elseif ($e instanceof AdminException) {
-            return app('json')->fail($e->getMessage(), $massageData);
-        } else {
-            return app('json')->code(200)->make(400, $e->getMessage(), $massageData);
-        }
-    }
-
-}

+ 0 - 70
app/badminapi/README.md

@@ -1,70 +0,0 @@
-飞博多商户总管理系统
-===============
-
-> 运行环境要求PHP7.1 ~ 7.3。
-
-## API接口
-###1.数据库部分
-    1.商户信息
-        门店名称,
-        门店图标 -- 上传门头
-        营业执照号 
-        电话
-        地址
-        行业   --- 添加行业分类表
-        营业时间
-        店内设施 ---tag[逗号隔开]
-        账号号码
-        版本类型    -- 普通版本  专业版本(预留)
-        到期时间   --- 2020 01 12到期
-    小程序表 [对应商户信息] 
-                 授权码
-                 appid
-                 小程序名称
-                 小程序头像
-                 小程序码
-                 介绍
-                 主体信息
-                 服务类目
-                 商户类型
-                 微信支付商户号 ---- 可以后台设置
-                 微信支付商户秘钥 
-                 商户p12证书
-                 正式版二维码
-                 体验版二维码
-    体验者
-                微信号
-    (上述具体看小程序接口)               
-    2.员工管理,可以添加商户员工账号(查看cms系统--添加一个sid【商户ID】)
-    3.行业分类 --- 二级分类
-    4.店铺装修
-            店铺名称
-            店铺code(后期上传小程序对于模板目录)
-            创建时间
-            试用版号  1.普通版本  2 专业版本
-            是否禁用  1.使用  -1 禁用
-            排序
-    5.业绩统计商户表
-         商户ID
-         本日注册量---(用户注册量)
-         本日访问量---(用户进入小程序[注册用户])
-         本日订单量
-         本日订单总额
-         报表生成日期
-    6.业绩总表
-        本日注册量---(用户注册量)
-        本日访问量---(用户进入小程序[注册用户])
-        本日订单量
-        本日订单总额
-        报表生成日期
- 上面新建立的数据,根据我们大概要求进行更加明细添加
-  
-###2.后台栏目
-     1.控制台---预留(门店排行榜,前top10排行榜等等)//接口完成
-     2.系统设置   --- 包含添加管理人员。管理权限总后台先不要。//是否把原来放在admin里的挪过来
-     3.商户管理//接口完成
-     4.行业分类//接口完成
-     5.店铺装修//增删改查完成
-     6.营销管理 ---- 每个门店
-     7.功能插件 ---- (暂时不添加,我们后期讨论开发)
-     

+ 0 - 7
app/badminapi/common.php

@@ -1,7 +0,0 @@
-<?php
-
-if (!function_exists('void_fuc')) {
-    function void_fuc()
-    {
-    }
-}

+ 0 - 1
app/badminapi/config/.WeDrive

@@ -1 +0,0 @@
-/Users/huangjianfeng/WeDrive/六牛科技/源码/CRMEB_PRO_v1.0.0(9)/app/badminapi/config

+ 0 - 25
app/badminapi/config/route.php

@@ -1,25 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | ThinkPHP [ WE CAN DO IT JUST THINK ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
-// +----------------------------------------------------------------------
-// | Author: liu21st <liu21st@gmail.com>
-// +----------------------------------------------------------------------
-
-// +----------------------------------------------------------------------
-// | 应用设置
-// +----------------------------------------------------------------------
-
-return [
-    // 是否强制使用路由
-    'url_route_must'        => true,
-    // 合并路由规则
-    'route_rule_merge'      => true,
-    // 路由是否完全匹配
-    'route_complete_match'  => true,
-    // 是否自动转换URL中的控制器和操作名
-    'url_convert'           => false,
-];

+ 0 - 54
app/badminapi/controller/AuthController.php

@@ -1,54 +0,0 @@
-<?php
-
-namespace app\badminapi\controller;
-
-
-use crmeb\basic\BaseController;
-
-/**
- * 基类 所有控制器继承的类
- * Class AuthController
- * @package app\adminapi\controller
- */
-class AuthController extends BaseController
-{
-    /**
-     * 当前登陆管理员信息
-     * @var
-     */
-    protected $adminInfo;
-
-    /**
-     * 当前登陆管理员ID
-     * @var
-     */
-    protected $adminId;
-
-    /**
-     * 当前管理员权限
-     * @var array
-     */
-    protected $auth = [];
-
-    /**
-     * 模型类名
-     * @var null
-     */
-    protected $bindModel = null;
-
-    /**
-     * 初始化
-     */
-    protected function initialize()
-    {
-        parent::initialize();
-
-        $this->adminId = $this->request->adminId();
-        $this->adminInfo = $this->request->adminInfo();
-
-        $this->auth = $this->request->adminInfo['rule'] ?? [];
-
-        event('BAdminVisit', [$this->adminInfo, 'system']);
-    }
-
-}

+ 0 - 22
app/badminapi/controller/Common.php

@@ -1,22 +0,0 @@
-<?php
-
-namespace app\badminapi\controller;
-
-use app\models\store\StoreOrder;
-use app\models\store\StoreProduct;
-use app\models\store\StoreProductAttrValue;
-use app\models\user\User;
-use crmeb\repositories\NoticeRepositories;
-
-/**
- * 公共接口基类 主要存放公共接口
- * Class Common
- * @package app\adminapi\controller
- */
-class Common extends AuthController
-{
-    public function homeStatics()
-    {
-
-    }
-}

+ 0 - 103
app/badminapi/controller/Login.php

@@ -1,103 +0,0 @@
-<?php
-
-namespace app\badminapi\controller;
-
-
-use app\models\system\SystemBadmin;
-use app\models\system\SystemMenus;
-use crmeb\basic\BaseController;
-use crmeb\services\GroupDataService;
-use crmeb\services\UtilService;
-use crmeb\utils\Captcha;
-use Psr\SimpleCache\InvalidArgumentException;
-use think\db\exception\DataNotFoundException;
-use think\facade\Cache;
-use think\Response;
-
-/**
- * 后台登陆
- * Class Login
- * @package app\adminapi\controller
- */
-class Login extends BaseController
-{
-
-    /**
-     * 验证码
-     * @return $this|Response
-     */
-    public function captcha()
-    {
-        return (new Captcha())->create();
-    }
-
-    /**
-     * 登陆
-     * @return mixed
-     * @throws InvalidArgumentException
-     * @throws DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function login()
-    {
-        [$account, $pwd, $imgcode] = UtilService::postMore([
-            'account', 'pwd', ['imgcode', '']
-        ], $this->request, true);
-
-        if (!(new Captcha)->check($imgcode)) {
-            return app('json')->fail('验证码错误,请重新输入');
-        }
-
-        $this->validate(['account' => $account, 'pwd' => $pwd], \app\badminapi\validates\SystemBAdminValidata::class, 'get');
-
-        $error = Cache::get('badmin_login_error') ?: ['num' => 0, 'time' => time()];
-        $error['num'] = 0;
-        if ($error['num'] >= 5 && $error['time'] > strtotime('- 5 minutes'))
-            return $this->fail('错误次数过多,请稍候再试!');
-        $adminInfo = SystemBAdmin::login($account, $pwd);
-        if ($adminInfo) {
-            $token = SystemBAdmin::createToken($adminInfo, 'badmin');
-            if ($token === false) {
-                return app('json')->fail(SystemBadmin::getErrorInfo());
-            }
-            Cache::set('badmin_login_error', null);
-            //获取用户菜单
-//            $menusModel = new SystemMenus();
-//            $menus = $menusModel->getRoute($adminInfo->roles, $adminInfo['level']);
-//            $unique_auth = $menusModel->getUniqueAuth($adminInfo->roles, $adminInfo['level']);
-            return app('json')->success([
-                'token' => $token['token'],
-                'expires_time' => $token['params']['exp'],
-//                'menus' => $menus,
-//                'unique_auth' => $unique_auth,
-                'user_info' => [
-                    'id' => $adminInfo->getData('id'),
-                    'account' => $adminInfo->getData('account'),
-                    'head_pic' => $adminInfo->getData('head_pic'),
-                ],
-                'logo' => sys_config('site_logo'),
-                'logo_square' => sys_config('site_logo_square'),
-//                'version' => get_crmeb_version()
-            ]);
-        } else {
-            $error['num'] += 1;
-            $error['time'] = time();
-            Cache::set('badmin_login_error', $error);
-            return app('json')->fail(SystemBadmin::getErrorInfo('用户名错误,请重新输入'));
-        }
-    }
-
-    /**
-     * 获取后台登录页轮播图以及LOGO
-     * @return mixed
-     */
-    public function info()
-    {
-        $data['slide'] = GroupDataService::getData('admin_login_slide', 0, false, $this->merId) ?? [];
-        $data['logo_square'] = sys_config('site_logo_square');//透明
-        $data['logo_rectangle'] = sys_config('site_logo');//方形
-        $data['login_logo'] = sys_config('login_logo');//登陆
-        return app('json')->success($data);
-    }
-}

+ 0 - 903
app/badminapi/controller/Report.php

@@ -1,903 +0,0 @@
-<?php
-
-namespace app\badminapi\controller;
-
-
-use app\models\merchant\Merchant;
-use app\models\store\StoreOrder;
-use app\models\store\StoreProduct;
-use app\models\store\StoreProductAttrValue;
-use app\models\system\MerchantDailyReport;
-use app\models\system\SystemDailyReport;
-use app\models\user\User;
-use crmeb\basic\BaseModel;
-use crmeb\services\UtilService;
-use crmeb\traits\ModelTrait;
-use Exception;
-use think\db\exception\DbException;
-
-/**
- * 报表控制器
- * Class Report
- * @package app\adminapi\controller
- */
-class Report extends AuthController
-{
-
-    public function initialize()
-    {
-        parent::initialize(); // TODO: Change the autogenerated stub
-    }
-
-    use ModelTrait;
-
-    /**
-     * 手动生成昨日报表
-     * @return mixed
-     */
-    public function createYesterdayReport()
-    {
-        try {
-            MerchantDailyReport::recordYesterdayReport();
-            SystemDailyReport::recordYesterdayReport();
-            BaseModel::commitTrans();
-            return app('json')->success('生成成功');
-        } catch (DbException $e) {
-            BaseModel::rollbackTrans();
-            return app('json')->fail($e->getMessage());
-        }
-    }
-
-    /**
-     * 系统报表
-     * @return mixed
-     * @throws Exception
-     */
-    public function systemReportList()
-    {
-        list($page, $limit) = UtilService::getMore([['page', 1], ['limit', 10]], $this->request, true);
-        //今日系统报表
-        $today = [
-            'today_reg' => User::whereDay('add_time', 'today')->count(),
-            'today_visit' => User::whereDay('last_time', 'today')->count(),
-            'today_order' => StoreOrder::whereDay('add_time', 'today')->count(),
-            'today_order_money' => StoreOrder::where('paid', 1)
-                ->where('is_del', 0)
-                ->where('refund_status', 0)
-                ->whereDay('pay_time', 'today')
-                ->sum('pay_price')
-        ];
-        $pass_list = SystemDailyReport::order('report_date', 'desc')->page($page, $limit)->select();
-        if (count($pass_list) > 0) {
-            $pass_list->toArray();
-        } else {
-            $pass_list = [];
-        }
-        return app('json')->success('ok', compact('today', 'pass_list'));
-    }
-
-    /**
-     * 商户报表
-     * @return mixed
-     * @throws Exception
-     */
-    public function merchantReportList()
-    {
-        list($page, $limit, $mer_id, $date) = UtilService::getMore([
-            ['page', 1],
-            ['limit', 10],
-            ['mer_id', ''],
-            ['date', '']
-        ], $this->request, true);
-        if ($mer_id) {
-            if (!Merchant::be($mer_id)) {
-                return app('json')->fail('无此商户');
-            }
-            //今日系统报表
-            $today = [
-                'today_reg' => User::merSet($mer_id)->whereDay('add_time', 'today')->count(),
-                'today_visit' => User::merSet($mer_id)->whereDay('last_time', 'today')->count(),
-                'today_order' => StoreOrder::merSet($mer_id)->whereDay('add_time', 'today')->count(),
-                'today_order_money' => StoreOrder::where('mer_id', $mer_id)
-                    ->where('paid', 1)
-                    ->where('is_del', 0)
-                    ->where('refund_status', 0)
-                    ->whereDay('pay_time', 'today')
-                    ->sum('pay_price')
-            ];
-        }
-        $model = MerchantDailyReport::order('report_date', 'desc');
-        if ($mer_id) {
-            $model->where('mer_id', $mer_id);
-        }
-        if ($date) {
-            list($startTime, $endTime) = explode('-', $date);
-            $model = $model->where('report_date', '>=', $startTime);
-            $model = $model->where('report_date', '<=', $endTime);
-        }
-        $pass_list = $model->page($page, $limit)->select();
-        if (count($pass_list) > 0) {
-            $pass_list->toArray();
-        } else {
-            $pass_list = [];
-        }
-        return app('json')->success('ok', isset($today) ? compact('today', 'pass_list') : ['pass_list' => $pass_list]);
-    }
-
-    /**
-     * 商户排行
-     * @param $type
-     * @param $sort
-     * @return mixed
-     * @throws Exception
-     */
-    public function merchantRank($type, $sort)
-    {
-        if (!in_array(strtolower($type), ['sum_reg', 'sum_visit', 'sum_order', 'sum_order_money'])) {
-            return app('json')->fail('查询的排行键值有误');
-        }
-        if (!in_array(strtolower($sort), ['desc', 'asc'])) {
-            return app('json')->fail('查询的排行方式有误');
-        }
-        list($page, $limit) = UtilService::getMore([['page', 1], ['limit', 10]], $this->request, true);
-        $report = MerchantDailyReport::alias('r')->group('mer_id')
-            ->field('r.mer_id, m.name, m.logo, SUM(r.today_reg) as sum_reg,SUM(r.today_visit) as sum_visit,SUM(r.today_order) as sum_order,SUM(r.today_order_money) as sum_order_money')
-            ->join('merchant m', 'r.mer_id = m.id')
-            ->order(strtolower($type), strtolower($sort))
-            ->page($page, $limit)->select();
-        foreach($report as $key => $value) {
-            $value['id'] = $key + 1;
-        }
-        return app('json')->success('ok', $report ? $report->toArray() : []);
-    }
-
-    /**
-     * 首页头部统计数据
-     * @return mixed
-     */
-    public function homeStatics($mer_id)
-    {
-        //TODO 销售额
-        //今日销售额
-        $today_sales = StoreOrder::merSet($mer_id)
-            ->where('paid', 1)
-            ->where('is_del', 0)
-            ->where('refund_status', 0)
-            ->whereDay('pay_time')
-            ->sum('pay_price');
-        //昨日销售额
-        $yesterday_sales = StoreOrder::merSet($mer_id)
-            ->where('paid', 1)
-            ->where('is_del', 0)
-            ->where('refund_status', 0)
-            ->whereDay('pay_time', 'yesterday')
-            ->sum('pay_price');
-        //日同比
-        $sales_today_ratio = $this->growth($today_sales, $yesterday_sales);
-        //周销售额
-        //本周
-        $this_week_sales = StoreOrder::merSet($mer_id)
-            ->where('paid', 1)
-            ->where('is_del', 0)
-            ->where('refund_status', 0)
-            ->whereWeek('pay_time')
-            ->sum('pay_price');
-        //上周
-        $last_week_sales = StoreOrder::merSet($mer_id)
-            ->where('paid', 1)
-            ->where('is_del', 0)
-            ->where('refund_status', 0)
-            ->whereWeek('pay_time', 'last week')
-            ->sum('pay_price');
-        //周同比
-        $sales_week_ratio = $this->growth($this_week_sales, $last_week_sales);
-        //总销售额
-        $total_sales = StoreOrder::merSet($mer_id)
-            ->where('paid', 1)
-            ->where('is_del', 0)
-            ->where('refund_status', 0)
-            ->sum('pay_price');
-        $sales = [
-            'today' => $today_sales,
-            'yesterday' => $yesterday_sales,
-            'today_ratio' => $sales_today_ratio,
-            'week' => $this_week_sales,
-            'last_week' => $last_week_sales,
-            'week_ratio' => $sales_week_ratio,
-            'total' => $total_sales . '元',
-            'date' => '昨日'
-        ];
-        //TODO:用户访问量
-        //今日访问量
-        $today_visits = User::merSet($mer_id)->WhereDay('last_time')->count();
-        //昨日访问量
-        $yesterday_visits = User::merSet($mer_id)->whereDay('last_time', 'yesterday')->count();
-        //日同比
-        $visits_today_ratio = $this->growth($today_visits, $yesterday_visits);
-        //本周访问量
-        $this_week_visits = User::merSet($mer_id)->WhereWeek('last_time')->count();
-        //上周访问量
-        $last_week_visits = User::merSet($mer_id)->WhereWeek('last_time', 'last week')->count();
-        //周同比
-        $visits_week_ratio = $this->growth($this_week_visits, $last_week_visits);
-        //总访问量
-        $total_visits = User::merSet($mer_id)->count();
-        $visits = [
-            'today' => $today_visits,
-            'yesterday' => $yesterday_visits,
-            'today_ratio' => $visits_today_ratio,
-            'week' => $this_week_visits,
-            'last_week' => $last_week_visits,
-            'week_ratio' => $visits_week_ratio,
-            'total' => $total_visits . 'Pv',
-            'date' => '昨日'
-        ];
-        //TODO 订单量
-        //今日订单量
-        $today_order = StoreOrder::merSet($mer_id)->whereDay('add_time')->count();
-        //昨日订单量
-        $yesterday_order = StoreOrder::merSet($mer_id)->whereDay('add_time', 'yesterday')->count();
-        //订单日同比
-        $order_today_ratio = $this->growth($today_order, $yesterday_order);
-        //本周订单量
-        $this_week_order = StoreOrder::merSet($mer_id)->whereWeek('add_time')->count();
-        //上周订单量
-        $last_week_order = StoreOrder::merSet($mer_id)->whereWeek('add_time', 'last week')->count();
-        //订单周同比
-        $order_week_ratio = $this->growth($this_week_order, $last_week_order);
-        //总订单量
-        $total_order = StoreOrder::merSet($mer_id)->where('is_system_del', 0)->count();
-        $order = [
-            'today' => $today_order,
-            'yesterday' => $yesterday_order,
-            'today_ratio' => $order_today_ratio,
-            'week' => $this_week_order,
-            'last_week' => $last_week_order,
-            'week_ratio' => $order_week_ratio,
-            'total' => $total_order . '单',
-            'date' => '昨日'
-        ];
-        //TODO 用户
-        //今日新增用户
-        $today_user = User::merSet($mer_id)->whereDay('add_time')->count();
-        //昨日新增用户
-        $yesterday_user = User::merSet($mer_id)->whereDay('add_time', 'yesterday')->count();
-        //新增用户日同比
-        $user_today_ratio = $this->growth($today_user, $yesterday_user);
-        //本周新增用户
-        $this_week_user = User::merSet($mer_id)->whereWeek('add_time')->count();
-        //上周新增用户
-        $last_week_user = User::merSet($mer_id)->whereWeek('add_time', 'last week')->count();
-        //新增用户周同比
-        $user_week_ratio = $this->growth($this_week_user, $last_week_user);
-        //所有用户
-        $total_user = User::merSet($mer_id)->count();
-        $user = [
-            'today' => $today_user,
-            'yesterday' => $yesterday_user,
-            'today_ratio' => $user_today_ratio,
-            'week' => $this_week_user,
-            'last_week' => $last_week_user,
-            'week_ratio' => $user_week_ratio,
-            'total' => $total_user . '人',
-            'date' => '昨日'
-        ];
-        // $qrcode = MerchantMiniprogram::vaildWhere()->where('mer_id', $this->merId)->field('test_qrcode_url,qrcode_url')->find();
-        $info = array_values(compact('sales', 'visits', 'order', 'user'));
-        $info[0]['title'] = '销售额';
-        $info[1]['title'] = '用户访问量';
-        $info[2]['title'] = '订单量';
-        $info[3]['title'] = '新增用户';
-        $info[0]['total_name'] = '总销售额';
-        $info[1]['total_name'] = '总访问量';
-        $info[2]['total_name'] = '总订单量';
-        $info[3]['total_name'] = '总用户';
-        return $this->success(compact('info'));
-    }
-
-    //增长率
-    public function growth($left, $right)
-    {
-        if ($right)
-            $ratio = bcmul(bcdiv(bcsub($left, $right, 2), $right, 4), 100, 2);
-        else {
-            if ($left)
-                $ratio = 100;
-            else
-                $ratio = 0;
-        }
-        return $ratio;
-    }
-
-    /**
-     * 订单图表
-     */
-    public function orderChart($mer_id)
-    {
-        $cycle = $this->request->param('cycle') ?: 'thirtyday';//默认30天
-        $datalist = [];
-        switch ($cycle) {
-            case 'thirtyday':
-                $datebefor = date('Y-m-d', strtotime('-30 day'));
-                $dateafter = date('Y-m-d');
-                //上期
-                $pre_datebefor = date('Y-m-d', strtotime('-60 day'));
-                $pre_dateafter = date('Y-m-d', strtotime('-30 day'));
-                for ($i = -30; $i < 0; $i++) {
-                    $datalist[date('m-d', strtotime($i . ' day'))] = date('m-d', strtotime($i . ' day'));
-                }
-                $order_list = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$datebefor, $dateafter])
-                    ->field("FROM_UNIXTIME(add_time,'%m-%d') as day,count(*) as count,sum(pay_price) as price")
-                    ->group("FROM_UNIXTIME(add_time, '%Y%m%d')")
-                    ->order('add_time asc')
-                    ->select()->toArray();
-                if (empty($order_list)) return app('json')->success();
-                foreach ($order_list as $k => &$v) {
-                    $order_list[$v['day']] = $v;
-                }
-                $cycle_list = [];
-                foreach ($datalist as $dk => $dd) {
-                    if (!empty($order_list[$dd])) {
-                        $cycle_list[$dd] = $order_list[$dd];
-                    } else {
-                        $cycle_list[$dd] = ['count' => 0, 'day' => $dd, 'price' => ''];
-                    }
-                }
-                $chartdata = [];
-                $data = [];//临时
-                $chartdata['yAxis']['maxnum'] = 0;//最大值数量
-                $chartdata['yAxis']['maxprice'] = 0;//最大值金额
-                foreach ($cycle_list as $k => $v) {
-                    $data['day'][] = $v['day'];
-                    $data['count'][] = $v['count'];
-                    $data['price'][] = round($v['price'], 2);
-                    if ($chartdata['yAxis']['maxnum'] < $v['count'])
-                        $chartdata['yAxis']['maxnum'] = $v['count'];//日最大订单数
-                    if ($chartdata['yAxis']['maxprice'] < $v['price'])
-                        $chartdata['yAxis']['maxprice'] = $v['price'];//日最大金额
-                }
-                $chartdata['legend'] = ['订单金额', '订单数'];//分类
-                $chartdata['xAxis'] = $data['day'];//X轴值
-                //,'itemStyle'=>$series
-//                $series = ['normal' => ['label' => ['show' => true, 'position' => 'top']]];
-                $series1 = ['normal' => ['color' => [
-                    'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
-                    'colorStops' => [
-                        [
-                            'offset' => 0,
-                            'color' => '#69cdff'
-                        ],
-                        [
-                            'offset' => 0.5,
-                            'color' => '#3eb3f7'
-                        ],
-                        [
-                            'offset' => 1,
-                            'color' => '#1495eb'
-                        ]
-                    ]
-                ]]
-                ];
-                $series2 = ['normal' => ['color' => [
-                    'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
-                    'colorStops' => [
-                        [
-                            'offset' => 0,
-                            'color' => '#6fdeab'
-                        ],
-                        [
-                            'offset' => 0.5,
-                            'color' => '#44d693'
-                        ],
-                        [
-                            'offset' => 1,
-                            'color' => '#2cc981'
-                        ]
-                    ]
-                ]]
-                ];
-                $chartdata['series'][] = ['name' => $chartdata['legend'][0], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['price']];//分类1值
-                $chartdata['series'][] = ['name' => $chartdata['legend'][1], 'type' => 'bar', 'itemStyle' => $series2, 'data' => $data['count']];//分类2值
-                //统计总数上期
-                $pre_total = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$pre_datebefor, $pre_dateafter])
-                    ->field("count(*) as count,sum(pay_price) as price")
-                    ->find();
-                if ($pre_total) {
-                    $chartdata['pre_cycle']['count'] = [
-                        'data' => $pre_total['count'] ?: 0
-                    ];
-                    $chartdata['pre_cycle']['price'] = [
-                        'data' => $pre_total['price'] ?: 0
-                    ];
-                }
-                //统计总数
-                $total = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$datebefor, $dateafter])
-                    ->field("count(*) as count,sum(pay_price) as price")
-                    ->find();
-                if ($total) {
-                    $cha_count = intval($pre_total['count']) - intval($total['count']);
-                    $pre_total['count'] = $pre_total['count'] == 0 ? 1 : $pre_total['count'];
-                    $chartdata['cycle']['count'] = [
-                        'data' => $total['count'] ?: 0,
-                        'percent' => round((abs($cha_count) / intval($pre_total['count']) * 100), 2),
-                        'is_plus' => $cha_count > 0 ? -1 : ($cha_count == 0 ? 0 : 1)
-                    ];
-                    $cha_price = round($pre_total['price'], 2) - round($total['price'], 2);
-                    $pre_total['price'] = $pre_total['price'] == 0 ? 1 : $pre_total['price'];
-                    $chartdata['cycle']['price'] = [
-                        'data' => $total['price'] ?: 0,
-                        'percent' => round(abs($cha_price) / $pre_total['price'] * 100, 2),
-                        'is_plus' => $cha_price > 0 ? -1 : ($cha_price == 0 ? 0 : 1)
-                    ];
-                }
-                return $this->success($chartdata);
-                break;
-            case 'week':
-                $weekarray = array(['周日'], ['周一'], ['周二'], ['周三'], ['周四'], ['周五'], ['周六']);
-                $datebefor = date('Y-m-d', strtotime('-1 week Monday'));
-                $dateafter = date('Y-m-d', strtotime('-1 week Sunday'));
-                $order_list = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$datebefor, $dateafter])
-                    ->field("FROM_UNIXTIME(add_time,'%w') as day,count(*) as count,sum(pay_price) as price")
-                    ->group("FROM_UNIXTIME(add_time, '%Y%m%e')")
-                    ->order('add_time asc')
-                    ->select()->toArray();
-                //数据查询重新处理
-                $new_order_list = [];
-                foreach ($order_list as $k => $v) {
-                    $new_order_list[$v['day']] = $v;
-                }
-                $now_datebefor = date('Y-m-d', (time() - ((date('w') == 0 ? 7 : date('w')) - 1) * 24 * 3600));
-                $now_dateafter = date('Y-m-d', strtotime("+1 day"));
-                $now_order_list = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$now_datebefor, $now_dateafter])
-                    ->field("FROM_UNIXTIME(add_time,'%w') as day,count(*) as count,sum(pay_price) as price")
-                    ->group("FROM_UNIXTIME(add_time, '%Y%m%e')")
-                    ->order('add_time asc')
-                    ->select()->toArray();
-                //数据查询重新处理 key 变为当前值
-                $new_now_order_list = [];
-                foreach ($now_order_list as $k => $v) {
-                    $new_now_order_list[$v['day']] = $v;
-                }
-                foreach ($weekarray as $dk => $dd) {
-                    if (!empty($new_order_list[$dk])) {
-                        $weekarray[$dk]['pre'] = $new_order_list[$dk];
-                    } else {
-                        $weekarray[$dk]['pre'] = ['count' => 0, 'day' => $weekarray[$dk][0], 'price' => '0'];
-                    }
-                    if (!empty($new_now_order_list[$dk])) {
-                        $weekarray[$dk]['now'] = $new_now_order_list[$dk];
-                    } else {
-                        $weekarray[$dk]['now'] = ['count' => 0, 'day' => $weekarray[$dk][0], 'price' => '0'];
-                    }
-                }
-                $chartdata = [];
-                $data = [];//临时
-                $chartdata['yAxis']['maxnum'] = 0;//最大值数量
-                $chartdata['yAxis']['maxprice'] = 0;//最大值金额
-                foreach ($weekarray as $k => $v) {
-                    $data['day'][] = $v[0];
-                    $data['pre']['count'][] = $v['pre']['count'];
-                    $data['pre']['price'][] = round($v['pre']['price'], 2);
-                    $data['now']['count'][] = $v['now']['count'];
-                    $data['now']['price'][] = round($v['now']['price'], 2);
-                    if ($chartdata['yAxis']['maxnum'] < $v['pre']['count'] || $chartdata['yAxis']['maxnum'] < $v['now']['count']) {
-                        $chartdata['yAxis']['maxnum'] = $v['pre']['count'] > $v['now']['count'] ? $v['pre']['count'] : $v['now']['count'];//日最大订单数
-                    }
-                    if ($chartdata['yAxis']['maxprice'] < $v['pre']['price'] || $chartdata['yAxis']['maxprice'] < $v['now']['price']) {
-                        $chartdata['yAxis']['maxprice'] = $v['pre']['price'] > $v['now']['price'] ? $v['pre']['price'] : $v['now']['price'];//日最大金额
-                    }
-                }
-                $chartdata['legend'] = ['上周金额', '本周金额', '上周订单数', '本周订单数'];//分类
-                $chartdata['xAxis'] = $data['day'];//X轴值
-                //,'itemStyle'=>$series
-//                $series = ['normal' => ['label' => ['show' => true, 'position' => 'top']]];
-                $series1 = ['normal' => ['color' => [
-                    'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
-                    'colorStops' => [
-                        [
-                            'offset' => 0,
-                            'color' => '#69cdff'
-                        ],
-                        [
-                            'offset' => 0.5,
-                            'color' => '#3eb3f7'
-                        ],
-                        [
-                            'offset' => 1,
-                            'color' => '#1495eb'
-                        ]
-                    ]
-                ]]
-                ];
-                $series2 = ['normal' => ['color' => [
-                    'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
-                    'colorStops' => [
-                        [
-                            'offset' => 0,
-                            'color' => '#6fdeab'
-                        ],
-                        [
-                            'offset' => 0.5,
-                            'color' => '#44d693'
-                        ],
-                        [
-                            'offset' => 1,
-                            'color' => '#2cc981'
-                        ]
-                    ]
-                ]]
-                ];
-                $chartdata['series'][] = ['name' => $chartdata['legend'][0], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['pre']['price']];//分类1值
-                $chartdata['series'][] = ['name' => $chartdata['legend'][1], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['now']['price']];//分类1值
-                $chartdata['series'][] = ['name' => $chartdata['legend'][2], 'type' => 'line', 'itemStyle' => $series2, 'data' => $data['pre']['count']];//分类2值
-                $chartdata['series'][] = ['name' => $chartdata['legend'][3], 'type' => 'line', 'itemStyle' => $series2, 'data' => $data['now']['count']];//分类2值
-
-                //统计总数上期
-                $pre_total = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$datebefor, $dateafter])
-                    ->field("count(*) as count,sum(pay_price) as price")
-                    ->find();
-                if ($pre_total) {
-                    $chartdata['pre_cycle']['count'] = [
-                        'data' => $pre_total['count'] ?: 0
-                    ];
-                    $chartdata['pre_cycle']['price'] = [
-                        'data' => $pre_total['price'] ?: 0
-                    ];
-                }
-                //统计总数
-                $total = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$now_datebefor, $now_dateafter])
-                    ->field("count(*) as count,sum(pay_price) as price")
-                    ->find();
-                if ($total) {
-                    $cha_count = intval($pre_total['count']) - intval($total['count']);
-                    $pre_total['count'] = $pre_total['count'] == 0 ? 1 : $pre_total['count'];
-                    $chartdata['cycle']['count'] = [
-                        'data' => $total['count'] ?: 0,
-                        'percent' => round((abs($cha_count) / intval($pre_total['count']) * 100), 2),
-                        'is_plus' => $cha_count > 0 ? -1 : ($cha_count == 0 ? 0 : 1)
-                    ];
-                    $cha_price = round($pre_total['price'], 2) - round($total['price'], 2);
-                    $pre_total['price'] = $pre_total['price'] == 0 ? 1 : $pre_total['price'];
-                    $chartdata['cycle']['price'] = [
-                        'data' => $total['price'] ?: 0,
-                        'percent' => round(abs($cha_price) / $pre_total['price'] * 100, 2),
-                        'is_plus' => $cha_price > 0 ? -1 : ($cha_price == 0 ? 0 : 1)
-                    ];
-                }
-                return $this->success($chartdata);
-                break;
-            case 'month':
-                $weekarray = array('01' => ['1'], '02' => ['2'], '03' => ['3'], '04' => ['4'], '05' => ['5'], '06' => ['6'], '07' => ['7'], '08' => ['8'], '09' => ['9'], '10' => ['10'], '11' => ['11'], '12' => ['12'], '13' => ['13'], '14' => ['14'], '15' => ['15'], '16' => ['16'], '17' => ['17'], '18' => ['18'], '19' => ['19'], '20' => ['20'], '21' => ['21'], '22' => ['22'], '23' => ['23'], '24' => ['24'], '25' => ['25'], '26' => ['26'], '27' => ['27'], '28' => ['28'], '29' => ['29'], '30' => ['30'], '31' => ['31']);
-
-                $datebefor = date('Y-m-01', strtotime('-1 month'));
-                $dateafter = date('Y-m-d', strtotime(date('Y-m-01')));
-                $order_list = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$datebefor, $dateafter])
-                    ->field("FROM_UNIXTIME(add_time,'%d') as day,count(*) as count,sum(pay_price) as price")
-                    ->group("FROM_UNIXTIME(add_time, '%Y%m%e')")
-                    ->order('add_time asc')
-                    ->select()->toArray();
-                //数据查询重新处理
-                $new_order_list = [];
-                foreach ($order_list as $k => $v) {
-                    $new_order_list[$v['day']] = $v;
-                }
-                $now_datebefor = date('Y-m-01');
-                $now_dateafter = date('Y-m-d', strtotime("+1 day"));
-                $now_order_list = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$now_datebefor, $now_dateafter])
-                    ->field("FROM_UNIXTIME(add_time,'%d') as day,count(*) as count,sum(pay_price) as price")
-                    ->group("FROM_UNIXTIME(add_time, '%Y%m%e')")
-                    ->order('add_time asc')
-                    ->select()->toArray();
-                //数据查询重新处理 key 变为当前值
-                $new_now_order_list = [];
-                foreach ($now_order_list as $k => $v) {
-                    $new_now_order_list[$v['day']] = $v;
-                }
-                foreach ($weekarray as $dk => $dd) {
-                    if (!empty($new_order_list[$dk])) {
-                        $weekarray[$dk]['pre'] = $new_order_list[$dk];
-                    } else {
-                        $weekarray[$dk]['pre'] = ['count' => 0, 'day' => $weekarray[$dk][0], 'price' => '0'];
-                    }
-                    if (!empty($new_now_order_list[$dk])) {
-                        $weekarray[$dk]['now'] = $new_now_order_list[$dk];
-                    } else {
-                        $weekarray[$dk]['now'] = ['count' => 0, 'day' => $weekarray[$dk][0], 'price' => '0'];
-                    }
-                }
-                $chartdata = [];
-                $data = [];//临时
-                $chartdata['yAxis']['maxnum'] = 0;//最大值数量
-                $chartdata['yAxis']['maxprice'] = 0;//最大值金额
-                foreach ($weekarray as $k => $v) {
-                    $data['day'][] = $v[0];
-                    $data['pre']['count'][] = $v['pre']['count'];
-                    $data['pre']['price'][] = round($v['pre']['price'], 2);
-                    $data['now']['count'][] = $v['now']['count'];
-                    $data['now']['price'][] = round($v['now']['price'], 2);
-                    if ($chartdata['yAxis']['maxnum'] < $v['pre']['count'] || $chartdata['yAxis']['maxnum'] < $v['now']['count']) {
-                        $chartdata['yAxis']['maxnum'] = $v['pre']['count'] > $v['now']['count'] ? $v['pre']['count'] : $v['now']['count'];//日最大订单数
-                    }
-                    if ($chartdata['yAxis']['maxprice'] < $v['pre']['price'] || $chartdata['yAxis']['maxprice'] < $v['now']['price']) {
-                        $chartdata['yAxis']['maxprice'] = $v['pre']['price'] > $v['now']['price'] ? $v['pre']['price'] : $v['now']['price'];//日最大金额
-                    }
-
-                }
-                $chartdata['legend'] = ['上月金额', '本月金额', '上月订单数', '本月订单数'];//分类
-                $chartdata['xAxis'] = $data['day'];//X轴值
-                //,'itemStyle'=>$series
-//                $series = ['normal' => ['label' => ['show' => true, 'position' => 'top']]];
-                $series1 = ['normal' => ['color' => [
-                    'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
-                    'colorStops' => [
-                        [
-                            'offset' => 0,
-                            'color' => '#69cdff'
-                        ],
-                        [
-                            'offset' => 0.5,
-                            'color' => '#3eb3f7'
-                        ],
-                        [
-                            'offset' => 1,
-                            'color' => '#1495eb'
-                        ]
-                    ]
-                ]]
-                ];
-                $series2 = ['normal' => ['color' => [
-                    'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
-                    'colorStops' => [
-                        [
-                            'offset' => 0,
-                            'color' => '#6fdeab'
-                        ],
-                        [
-                            'offset' => 0.5,
-                            'color' => '#44d693'
-                        ],
-                        [
-                            'offset' => 1,
-                            'color' => '#2cc981'
-                        ]
-                    ]
-                ]]
-                ];
-                $chartdata['series'][] = ['name' => $chartdata['legend'][0], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['pre']['price']];//分类1值
-                $chartdata['series'][] = ['name' => $chartdata['legend'][1], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['now']['price']];//分类1值
-                $chartdata['series'][] = ['name' => $chartdata['legend'][2], 'type' => 'line', 'itemStyle' => $series2, 'data' => $data['pre']['count']];//分类2值
-                $chartdata['series'][] = ['name' => $chartdata['legend'][3], 'type' => 'line', 'itemStyle' => $series2, 'data' => $data['now']['count']];//分类2值
-
-                //统计总数上期
-                $pre_total = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$datebefor, $dateafter])
-                    ->field("count(*) as count,sum(pay_price) as price")
-                    ->find();
-                if ($pre_total) {
-                    $chartdata['pre_cycle']['count'] = [
-                        'data' => $pre_total['count'] ?: 0
-                    ];
-                    $chartdata['pre_cycle']['price'] = [
-                        'data' => $pre_total['price'] ?: 0
-                    ];
-                }
-                //统计总数
-                $total = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$now_datebefor, $now_dateafter])
-                    ->field("count(*) as count,sum(pay_price) as price")
-                    ->find();
-                if ($total) {
-                    $cha_count = intval($pre_total['count']) - intval($total['count']);
-                    $pre_total['count'] = $pre_total['count'] == 0 ? 1 : $pre_total['count'];
-                    $chartdata['cycle']['count'] = [
-                        'data' => $total['count'] ?: 0,
-                        'percent' => round((abs($cha_count) / intval($pre_total['count']) * 100), 2),
-                        'is_plus' => $cha_count > 0 ? -1 : ($cha_count == 0 ? 0 : 1)
-                    ];
-                    $cha_price = round($pre_total['price'], 2) - round($total['price'], 2);
-                    $pre_total['price'] = $pre_total['price'] == 0 ? 1 : $pre_total['price'];
-                    $chartdata['cycle']['price'] = [
-                        'data' => $total['price'] ?: 0,
-                        'percent' => round(abs($cha_price) / $pre_total['price'] * 100, 2),
-                        'is_plus' => $cha_price > 0 ? -1 : ($cha_price == 0 ? 0 : 1)
-                    ];
-                }
-                return $this->success($chartdata);
-                break;
-            case 'year':
-                $weekarray = array('01' => ['一月'], '02' => ['二月'], '03' => ['三月'], '04' => ['四月'], '05' => ['五月'], '06' => ['六月'], '07' => ['七月'], '08' => ['八月'], '09' => ['九月'], '10' => ['十月'], '11' => ['十一月'], '12' => ['十二月']);
-                $datebefor = date('Y-01-01', strtotime('-1 year'));
-                $dateafter = date('Y-12-31', strtotime('-1 year'));
-                $order_list = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$datebefor, $dateafter])
-                    ->field("FROM_UNIXTIME(add_time,'%m') as day,count(*) as count,sum(pay_price) as price")
-                    ->group("FROM_UNIXTIME(add_time, '%Y%m')")
-                    ->order('add_time asc')
-                    ->select()->toArray();
-                //数据查询重新处理
-                $new_order_list = [];
-                foreach ($order_list as $k => $v) {
-                    $new_order_list[$v['day']] = $v;
-                }
-                $now_datebefor = date('Y-01-01');
-                $now_dateafter = date('Y-m-d');
-                $now_order_list = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$now_datebefor, $now_dateafter])
-                    ->field("FROM_UNIXTIME(add_time,'%m') as day,count(*) as count,sum(pay_price) as price")
-                    ->group("FROM_UNIXTIME(add_time, '%Y%m')")
-                    ->order('add_time asc')
-                    ->select()->toArray();
-                //数据查询重新处理 key 变为当前值
-                $new_now_order_list = [];
-                foreach ($now_order_list as $k => $v) {
-                    $new_now_order_list[$v['day']] = $v;
-                }
-                foreach ($weekarray as $dk => $dd) {
-                    if (!empty($new_order_list[$dk])) {
-                        $weekarray[$dk]['pre'] = $new_order_list[$dk];
-                    } else {
-                        $weekarray[$dk]['pre'] = ['count' => 0, 'day' => $weekarray[$dk][0], 'price' => '0'];
-                    }
-                    if (!empty($new_now_order_list[$dk])) {
-                        $weekarray[$dk]['now'] = $new_now_order_list[$dk];
-                    } else {
-                        $weekarray[$dk]['now'] = ['count' => 0, 'day' => $weekarray[$dk][0], 'price' => '0'];
-                    }
-                }
-                $chartdata = [];
-                $data = [];//临时
-                $chartdata['yAxis']['maxnum'] = 0;//最大值数量
-                $chartdata['yAxis']['maxprice'] = 0;//最大值金额
-                foreach ($weekarray as $k => $v) {
-                    $data['day'][] = $v[0];
-                    $data['pre']['count'][] = $v['pre']['count'];
-                    $data['pre']['price'][] = round($v['pre']['price'], 2);
-                    $data['now']['count'][] = $v['now']['count'];
-                    $data['now']['price'][] = round($v['now']['price'], 2);
-                    if ($chartdata['yAxis']['maxnum'] < $v['pre']['count'] || $chartdata['yAxis']['maxnum'] < $v['now']['count']) {
-                        $chartdata['yAxis']['maxnum'] = $v['pre']['count'] > $v['now']['count'] ? $v['pre']['count'] : $v['now']['count'];//日最大订单数
-                    }
-                    if ($chartdata['yAxis']['maxprice'] < $v['pre']['price'] || $chartdata['yAxis']['maxprice'] < $v['now']['price']) {
-                        $chartdata['yAxis']['maxprice'] = $v['pre']['price'] > $v['now']['price'] ? $v['pre']['price'] : $v['now']['price'];//日最大金额
-                    }
-                }
-                $chartdata['legend'] = ['去年金额', '今年金额', '去年订单数', '今年订单数'];//分类
-                $chartdata['xAxis'] = $data['day'];//X轴值
-                //,'itemStyle'=>$series
-//                $series = ['normal' => ['label' => ['show' => true, 'position' => 'top']]];
-                $series1 = ['normal' => ['color' => [
-                    'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
-                    'colorStops' => [
-                        [
-                            'offset' => 0,
-                            'color' => '#69cdff'
-                        ],
-                        [
-                            'offset' => 0.5,
-                            'color' => '#3eb3f7'
-                        ],
-                        [
-                            'offset' => 1,
-                            'color' => '#1495eb'
-                        ]
-                    ]
-                ]]
-                ];
-                $series2 = ['normal' => ['color' => [
-                    'x' => 0, 'y' => 0, 'x2' => 0, 'y2' => 1,
-                    'colorStops' => [
-                        [
-                            'offset' => 0,
-                            'color' => '#6fdeab'
-                        ],
-                        [
-                            'offset' => 0.5,
-                            'color' => '#44d693'
-                        ],
-                        [
-                            'offset' => 1,
-                            'color' => '#2cc981'
-                        ]
-                    ]
-                ]]
-                ];
-                $chartdata['series'][] = ['name' => $chartdata['legend'][0], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['pre']['price']];//分类1值
-                $chartdata['series'][] = ['name' => $chartdata['legend'][1], 'type' => 'bar', 'itemStyle' => $series1, 'data' => $data['now']['price']];//分类1值
-                $chartdata['series'][] = ['name' => $chartdata['legend'][2], 'type' => 'line', 'itemStyle' => $series2, 'data' => $data['pre']['count']];//分类2值
-                $chartdata['series'][] = ['name' => $chartdata['legend'][3], 'type' => 'line', 'itemStyle' => $series2, 'data' => $data['now']['count']];//分类2值
-
-                //统计总数上期
-                $pre_total = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$datebefor, $dateafter])
-                    ->field("count(*) as count,sum(pay_price) as price")
-                    ->find();
-                if ($pre_total) {
-                    $chartdata['pre_cycle']['count'] = [
-                        'data' => $pre_total['count'] ?: 0
-                    ];
-                    $chartdata['pre_cycle']['price'] = [
-                        'data' => $pre_total['price'] ?: 0
-                    ];
-                }
-                //统计总数
-                $total = StoreOrder::merSet($mer_id)->where('add_time', 'between time', [$now_datebefor, $now_dateafter])
-                    ->field("count(*) as count,sum(pay_price) as price")
-                    ->find();
-                if ($total) {
-                    $cha_count = intval($pre_total['count']) - intval($total['count']);
-                    $pre_total['count'] = $pre_total['count'] == 0 ? 1 : $pre_total['count'];
-                    $chartdata['cycle']['count'] = [
-                        'data' => $total['count'] ?: 0,
-                        'percent' => round((abs($cha_count) / intval($pre_total['count']) * 100), 2),
-                        'is_plus' => $cha_count > 0 ? -1 : ($cha_count == 0 ? 0 : 1)
-                    ];
-                    $cha_price = round($pre_total['price'], 2) - round($total['price'], 2);
-                    $pre_total['price'] = $pre_total['price'] == 0 ? 1 : $pre_total['price'];
-                    $chartdata['cycle']['price'] = [
-                        'data' => $total['price'] ?: 0,
-                        'percent' => round(abs($cha_price) / $pre_total['price'] * 100, 2),
-                        'is_plus' => $cha_price > 0 ? -1 : ($cha_price == 0 ? 0 : 1)
-                    ];
-                }
-                return $this->success($chartdata);
-                break;
-            default:
-                break;
-        }
-    }
-
-    /**
-     * 用户图表
-     */
-    public function userChart($mer_id)
-    {
-        $starday = date('Y-m-d', strtotime('-30 day'));
-        $yesterday = date('Y-m-d');
-
-        $user_list = User::merSet($mer_id)->where('add_time', 'between time', [$starday, $yesterday])
-            ->field("FROM_UNIXTIME(add_time,'%m-%e') as day,count(*) as count")
-            ->group("FROM_UNIXTIME(add_time, '%Y%m%e')")
-            ->order('add_time asc')
-            ->select()->toArray();
-        $chartdata = [];
-        $data = [];
-        $chartdata['legend'] = ['用户数'];//分类
-        $chartdata['yAxis']['maxnum'] = 0;//最大值数量
-        $chartdata['xAxis'] = [date('m-d')];//X轴值
-        $chartdata['series'] = [0];//分类1值
-        if (!empty($user_list)) {
-            foreach ($user_list as $k => $v) {
-                $data['day'][] = $v['day'];
-                $data['count'][] = $v['count'];
-                if ($chartdata['yAxis']['maxnum'] < $v['count'])
-                    $chartdata['yAxis']['maxnum'] = $v['count'];
-            }
-            $chartdata['xAxis'] = $data['day'];//X轴值
-            $chartdata['series'] = $data['count'];//分类1值
-        }
-        $chartdata['bing_xdata'] = ['未消费用户', '消费一次用户', '留存客户', '回流客户'];
-        $color = ['#5cadff', '#b37feb', '#19be6b', '#ff9900'];
-        $pay[0] = User::merSet($mer_id)->where('pay_count', 0)->count();
-        $pay[1] = User::merSet($mer_id)->where('pay_count', 1)->count();
-        $pay[2] = User::merSet($mer_id)->where('pay_count', '>', 0)->where('pay_count', '<', 4)->count();
-        $pay[3] = User::merSet($mer_id)->where('pay_count', '>', 4)->count();
-        foreach ($pay as $key => $item) {
-            $bing_data[] = ['name' => $chartdata['bing_xdata'][$key], 'value' => $pay[$key], 'itemStyle' => ['color' => $color[$key]]];
-        }
-        $chartdata['bing_data'] = $bing_data;
-        return $this->success($chartdata);
-    }
-
-    /**
-     * 交易额排行
-     * @return mixed
-     */
-    public function purchaseRanking($mer_id)
-    {
-        $dlist = StoreProductAttrValue::alias('v')
-            ->where('p.mer_id', $mer_id)
-            ->join('store_product p', 'v.product_id=p.id')
-            ->field('v.product_id,p.store_name,sum(v.sales * v.price) as val')->group('v.product_id')->order('val', 'desc')->limit(20)->select()->toArray();
-        $slist = StoreProduct::merSet($mer_id)->field('id as product_id,store_name,sales * price as val')->where('is_del', 0)->order('val', 'desc')->limit(20)->select()->toArray();
-        $data = array_merge($dlist, $slist);
-        $last_names = array_column($data, 'val');
-        array_multisort($last_names, SORT_DESC, $data);
-        $list = array_splice($data, 0, 20);
-        return $this->success(compact('list'));
-    }
-}

+ 0 - 155
app/badminapi/controller/Template.php

@@ -1,155 +0,0 @@
-<?php
-
-namespace app\badminapi\controller;
-
-
-use app\models\system\StoreTemplate;
-use crmeb\basic\BaseModel;
-use crmeb\services\UtilService;
-use think\db\exception\DataNotFoundException;
-use think\db\exception\DbException;
-use think\db\exception\ModelNotFoundException;
-use think\Exception;
-use think\Response;
-
-/**
- * 店铺模板类
- * Class Template
- * @package app\adminapi\controller
- */
-class Template extends AuthController
-{
-    public function initialize()
-    {
-        parent::initialize(); // TODO: Change the autogenerated stub
-    }
-
-    /**
-     * 获取模板列表
-     * @return mixed
-     * @throws DbException
-     * @throws DataNotFoundException
-     * @throws ModelNotFoundException
-     */
-    public function get_list()
-    {
-        $search = UtilService::getMore([
-            ['name', ''],
-            ['page', 1],
-            ['limit', 10],
-            ['use_version', ''],
-            ['is_ban', ''],
-        ], $this->request, false);
-        $list = StoreTemplate::getList($search);
-        return $this->success($list);
-    }
-
-    /**
-     * 修改状态
-     * @param string $id
-     * @param string $is_ban
-     * @return Response
-     */
-    public function set_ban($id = '')
-    {
-        $is_ban = $this->request->post('is_ban', 1);
-        if (!in_array($is_ban, [1, -1])) {
-            $this->fail('参数错误');
-        }
-        ($is_ban == '' || $id == '') && $this->fail('缺少参数');
-        if (StoreTemplate::setTemplateBan($id, (int)$is_ban)) {
-            return $this->success($is_ban == 1 ? '启用成功' : '禁用成功');
-        } else {
-            return $this->fail(StoreTemplate::getErrorInfo($is_ban == 1 ? '启用失败' : '禁用失败'));
-        }
-    }
-
-    /**
-     * 快速编辑
-     * @param string $id
-     * @return Response
-     * @throws \Exception
-     */
-    public function set_template($id)
-    {
-        $data = UtilService::postMore([
-            ['field', 'name', '', '', 'empty_check', '缺少参数'],
-            ['value', '', '', '', 'empty_check', '缺少参数']
-        ]);
-        if (!$id) return $this->fail('缺少参数');
-        if (StoreTemplate::where('id', $id)->update([$data['field'] => $data['value']]))
-            return $this->success('保存成功');
-        else
-            return $this->fail('保存失败');
-    }
-
-    /**
-     * 新增/修改模板
-     * @param int $id
-     * @return mixed
-     * @throws DbException
-     */
-    public function add_template($id = 0)
-    {
-        $data = UtilService::postMore([
-            ['name', '', '', '', 'empty_check', '请输入模板名'],
-            ['code', '', '', '', 'empty_check', '请上传模板'],
-            ['use_version', 1],
-            ['is_ban', 1],
-            ['sort', 0],
-        ]);
-        if ($id) {
-            if (!StoreTemplate::vaildWhere()->where('id', $id)->find()) {
-                return $this->fail('所选模板不存在');
-            }
-        }
-        BaseModel::beginTrans();
-        try {
-            if ($id) {
-                $res = StoreTemplate::edit($data, $id);
-            } else {
-                $data['add_time'] = time();
-                $res = StoreTemplate::create($data);
-            }
-            if ($res) {
-                BaseModel::commitTrans();
-                return $this->success('操作成功');
-            } else {
-                BaseModel::rollbackTrans();
-                return $this->fail('操作失败');
-            }
-        } catch (Exception $e) {
-            BaseModel::rollbackTrans();
-            return $this->fail($e->getMessage());
-        } catch (DbException $e) {
-            BaseModel::rollbackTrans();
-            return $this->fail($e->getMessage());
-        }
-    }
-
-    /**
-     * 获取指定资源
-     *
-     * @param int $id
-     * @return Response
-     */
-    public function get_template($id)
-    {
-        return $this->success('ok', StoreTemplate::get($id) ? StoreTemplate::get($id)->toArray() : []);
-    }
-
-
-    /**
-     * 删除指定资源
-     *
-     * @param int $id
-     * @return Response
-     */
-    public function delete($id)
-    {
-        if (!StoreTemplate::delTemplate($id))
-            return $this->fail(StoreTemplate::getErrorInfo('删除失败,请稍候再试!'));
-        else
-            return $this->success('删除成功!');
-    }
-}

+ 0 - 55
app/badminapi/controller/Test.php

@@ -1,55 +0,0 @@
-<?php
-
-namespace app\badminapi\controller;
-
-
-use app\lib\wx_encode\WXBizMsgCrypt;
-use app\badminapi\controller\merchant\Open;
-use app\models\merchant\MerchantCodeAudit;
-use app\models\system\MerchantDailyReport;
-use app\models\system\SystemDailyReport;
-use app\Request;
-use crmeb\basic\BaseModel;
-use crmeb\services\CacheService;
-use crmeb\services\UtilService;
-use think\db\exception\DbException;
-use think\Exception;
-use think\facade\App;
-
-class Test
-{
-
-    public function index(Request $request)
-    {
-        BaseModel::beginTrans();
-        try {
-            $res = ['auditid' => 425384030, 'errcode' => 0];
-            if (isset($res['errcode']) && $res['errcode'] == 0) {
-                $ret = MerchantCodeAudit::create(['mer_id' => 1, 'auditid' => $res['auditid'], 'commit_time' => time()]);
-                if ($ret) {
-                    BaseModel::commitTrans();
-                    return app('json')->success('提交审核完成');
-                } else {
-                    BaseModel::rollbackTrans();
-                    return app('json')->success(MerchantCodeAudit::getErrorInfo('审核记录失败,请手动记录'), ['auditid' => $res['auditid']]);
-                }
-            } else {
-                BaseModel::rollbackTrans();
-                return app('json')->fail($res['errmsg'] ?? $res['msg'] ?? '请求错误');
-            }
-        } catch (Exception $e) {
-            BaseModel::rollbackTrans();
-            return app('json')->fail($e->getMessage(), ['file' => $e->getFile(), 'line' => $e->getLine()]);
-        } catch (DbException $e) {
-            BaseModel::rollbackTrans();
-            return app('json')->fail($e->getMessage(), ['file' => $e->getFile(), 'line' => $e->getLine()]);
-        }
-    }
-
-    public function wxCallback()
-    {
-        $appid = '';
-        $res = new Open(new App(),true)->wxCallback($appid);
-        dump($res);
-    }
-}

+ 0 - 148
app/badminapi/controller/file/SystemAttachment.php

@@ -1,148 +0,0 @@
-<?php
-
-namespace app\badminapi\controller\file;
-
-use app\badminapi\controller\AuthController;
-use think\facade\Route as Url;
-use crmeb\services\{
-    UtilService as Util, FormBuilder as Form
-};
-use app\models\system\{
-    SystemAttachment as SystemAttachmentModel, SystemAttachmentCategory as Category
-};
-use think\Request;
-use crmeb\services\UploadService;
-
-/**
- * 图片管理类
- * Class SystemAttachment
- * @package app\badminapi\controller\v1\file
- */
-class SystemAttachment extends AuthController
-{
-
-    /**
-     * 显示资源列表
-     *
-     * @return \think\Response
-     */
-    public function index()
-    {
-        $where = Util::getMore([
-            ['page', 1],
-            ['limit', 18],
-            ['pid', 0]
-        ]);
-        return $this->success(SystemAttachmentModel::getImageList($where));
-    }
-
-    /**
-     * 删除指定资源
-     *
-     * @param string $ids
-     * @return \think\Response
-     */
-    public function delete()
-    {
-        $request = app('request');
-        $ids = $request->post('ids');
-        $ids = explode(',', $ids);
-        if (empty($ids))
-            return $this->fail('请选择要删除的图片');
-        foreach ($ids as $v) {
-            self::deleteImg($v);
-        }
-        return $this->success('删除成功');
-    }
-
-    /**
-     * 图片管理上传图片
-     * @return \think\response\Json
-     */
-    public function upload($upload_type = 0)
-    {
-        [$pid, $file] = Util::postMore([
-            ['pid', 0],
-            ['file', 'file']
-        ], $this->request, true);
-        if ($upload_type == 0) {
-            $upload_type = sys_config('upload_type', 1);
-        }
-        try {
-            $path = make_path('attach', 2, true);
-            $upload = UploadService::init($upload_type);
-            $res = $upload->to($path)->validate()->move($file);
-            if ($res === false) {
-                return $this->fail($upload->getError());
-            } else {
-                $fileInfo = $upload->getUploadInfo();
-                if ($fileInfo) {
-                    SystemAttachmentModel::attachmentAdd($fileInfo['name'], $fileInfo['size'], $fileInfo['type'], $fileInfo['dir'], $fileInfo['thumb_path'], $pid, $upload_type, $fileInfo['time']);
-                }
-                return $this->success('上传成功', ['src' => $res->filePath]);
-            }
-        } catch (\Exception $e) {
-            return $this->fail($e->getMessage());
-        }
-    }
-
-    /**删除图片和数据记录
-     * @param $att_id
-     */
-    public function deleteImg($att_id)
-    {
-        $attinfo = SystemAttachmentModel::get($att_id);
-        if ($attinfo) {
-            try {
-                $upload = UploadService::init($attinfo['image_type']);
-                if ($attinfo['image_type'] == 1) {
-                    if (strpos($attinfo['att_dir'], '/') == 0) {
-                        $attinfo['att_dir'] = substr($attinfo['att_dir'], 1);
-                    }
-                    $upload->delete($attinfo['att_dir']);
-                } else {
-                    $upload->delete($attinfo['name']);
-                }
-            } catch (\Throwable $e) {
-            }
-            SystemAttachmentModel::where('att_id', $att_id)->delete();
-        }
-    }
-
-    /**
-     * 移动图片分类显示
-     */
-    public function move($images)
-    {
-        $formbuider = [];
-        $formbuider[] = Form::hidden('images', $images);
-        $formbuider[] = Form::select('pid', '选择分类')->setOptions(function () {
-            $list = Category::getCateList();
-            $options = [['value' => 0, 'label' => '所有分类']];
-            foreach ($list as $id => $cateName) {
-                $options[] = ['label' => $cateName['html'] . $cateName['name'], 'value' => $cateName['id']];
-            }
-            return $options;
-        })->filterable(1);
-        return $this->makePostForm('编辑分类', $formbuider, Url::buildUrl('/file/do_move'), 'PUT');
-    }
-
-    /**
-     * 移动图片分类操作
-     */
-    public function moveImageCate()
-    {
-        $data = Util::postMore([
-            'pid',
-            'images'
-        ]);
-        if ($data['images'] == '') return $this->fail('请选择图片');
-        if (!$data['pid']) return $this->fail('请选择分类');
-        $res = SystemAttachmentModel::where('att_id', 'in', $data['images'])->update(['pid' => $data['pid']]);
-        if ($res)
-            return $this->success('移动成功');
-        else
-            return $this->fail('移动失败!');
-    }
-
-}

+ 0 - 131
app/badminapi/controller/file/SystemAttachmentCategory.php

@@ -1,131 +0,0 @@
-<?php
-
-namespace app\badminapi\controller\file;
-
-use app\badminapi\controller\AuthController;
-use think\Request;
-use think\facade\Route as Url;
-use crmeb\services\{UtilService as Util,FormBuilder as Form};
-use app\models\system\{SystemAttachment as SystemAttachmentModel,SystemAttachmentCategory as Category};
-
-/**
- * 图片分类管理类
- * Class SystemAttachmentCategory
- * @package app\badminapi\controller\v1\file
- */
-class SystemAttachmentCategory extends AuthController
-{
-    /**
-     * 显示资源列表
-     *
-     * @return \think\Response
-     */
-    public function index($name='')
-    {
-        return $this->success(Category::getAll($name));
-    }
-
-    /**
-     * 显示创建资源表单页.
-     *
-     * @return \think\Response
-     */
-    public function create()
-    {
-        $id=$this->request->param('id');
-        $id=$id ?? 0;
-        $formbuider = [];
-        $formbuider[] = Form::select('pid','上级分类',(string)$id)->setOptions(function (){
-            $list = Category::getCateList(0);
-            $options =  [['value'=>0,'label'=>'所有分类']];
-            foreach ($list as $id=>$cateName){
-                $options[] = ['label'=>$cateName['html'].$cateName['name'],'value'=>$cateName['id']];
-            }
-            return $options;
-        })->filterable(1);
-        $formbuider[] = Form::input('name','分类名称');
-        return $this->makePostForm('添加分类', $formbuider, Url::buildUrl('/file/category'), 'POST');
-    }
-
-    /**
-     * 保存新建的资源
-     *
-     * @param  \think\Request  $request
-     * @return \think\Response
-     */
-    public function save(Request $request)
-    {
-        $request = app('request');
-        $post = $request->post();
-        $data['pid'] = $post['pid'];
-        $data['name'] = $post['name'];
-        if(empty($post['name'] ))
-            return $this->fail('分类名称不能为空!');
-        $res = Category::create($data);
-        if($res)
-            return $this->success('添加成功');
-        else
-            return $this->fail('添加失败!');
-    }
-
-    /**
-     * 显示编辑资源表单页.
-     *
-     * @param  int  $id
-     * @return \think\Response
-     */
-    public function edit($id)
-    {
-        $Category = Category::get($id);
-        if(!$Category) return $this->fail('数据不存在!');
-        $formbuider = [];
-        $formbuider[] = Form::hidden('id',$id);
-        $formbuider[] = Form::select('pid','上级分类',(string)$Category->getData('pid'))->setOptions(function ()use($id){
-            $list = Category::getCateList();
-            $options =  [['value'=>0,'label'=>'所有分类']];
-            foreach ($list as $id=>$cateName){
-                $options[] = ['label'=>$cateName['html'].$cateName['name'],'value'=>$cateName['id']];
-            }
-            return $options;
-        })->filterable(1);
-        $formbuider[] = Form::input('name','分类名称',$Category->getData('name'));
-        return $this->makePostForm('编辑分类', $formbuider, Url::buildUrl('/file/category/'.$id), 'PUT');
-    }
-
-    /**
-     * 保存更新的资源
-     *
-     * @param  \think\Request  $request
-     * @param  int  $id
-     * @return \think\Response
-     */
-    public function update(Request $request, $id)
-    {
-        $data = Util::postMore([
-            'pid',
-            'name'
-        ]);
-        if($data['pid'] == '') return $this->fail('请选择父类');
-        if(!$data['name']) return $this->fail('请输入分类名称');
-        Category::edit($data,$id);
-        return $this->success('分类编辑成功!');
-    }
-
-    /**
-     * 删除指定资源
-     *
-     * @param  int  $id
-     * @return \think\Response
-     */
-    public function delete($id)
-    {
-        $chdcount = Category::where('pid',$id)->count();
-        if($chdcount) return $this->fail('有子栏目不能删除');
-        $chdcount = SystemAttachmentModel::where('pid',$id)->count();
-        if($chdcount) return $this->fail('栏目内有图片不能删除');
-        if(Category::del($id))
-            return $this->success('删除成功!');
-        else
-            return $this->fail('删除失败');
-    }
-}

+ 0 - 228
app/badminapi/controller/merchant/Industry.php

@@ -1,228 +0,0 @@
-<?php
-
-
-namespace app\badminapi\controller\merchant;
-
-
-use app\badminapi\controller\AuthController;
-use app\models\article\ArticleCategory;
-use app\models\merchant\Industry as IndustryModel;
-use crmeb\services\FormBuilder as Form;
-use crmeb\basic\BaseModel;
-use crmeb\services\UtilService;
-use think\db\exception\DataNotFoundException;
-use think\db\exception\DbException;
-use think\db\exception\ModelNotFoundException;
-use think\facade\Route as Url;
-use think\Exception;
-use think\Response;
-
-class Industry extends AuthController
-{
-    public function initialize()
-    {
-        parent::initialize(); // TODO: Change the autogenerated stub
-    }
-
-    /**
-     * 获取行业列表
-     * @return mixed
-     * @throws DbException
-     * @throws DataNotFoundException
-     * @throws ModelNotFoundException
-     */
-    public function get_list()
-    {
-        $search = UtilService::getMore([
-            ['name', ''],
-            ['pid', ''],
-            ['is_show', ''],
-            ['page', 1],
-            ['limit', 10],
-            ['type', 0]
-        ], $this->request, false);
-        if ($search['type']) {
-            $list = IndustryModel::getList();
-            $list['list'] = ArticleCategory::tidyTree($list['list']);
-        } else {
-            $list = IndustryModel::getList($search);
-            $list['list'] = array_slice(ArticleCategory::tidyTree($list['list']), ((int)$search['page'] - 1) * $search['limit'], $search['limit']);
-        }
-        return $this->success($list);
-    }
-
-    /**
-     * 树形列表
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\ModelNotFoundException
-     * @throws \think\exception\DbException
-     */
-    public function tree_list($type)
-    {
-        $list = IndustryModel::getTierList(null, $type);
-        return $this->success($list);
-    }
-
-    /**
-     * 修改状态
-     * @param string $is_show
-     * @param string $id
-     * @return Response
-     */
-    public function set_show($id = '', $is_show = '')
-    {
-        ($is_show == '' || $id == '') && $this->fail('缺少参数');
-        if (IndustryModel::setIndustryShow($id, (int)$is_show)) {
-            return $this->success($is_show == 1 ? '显示成功' : '隐藏成功');
-        } else {
-            return $this->fail(IndustryModel::getErrorInfo($is_show == 1 ? '显示失败' : '隐藏失败'));
-        }
-    }
-
-    /**
-     * 显示创建资源表单页.
-     *
-     * @return \think\Response
-     */
-    public function create()
-    {
-        $field = [
-            Form::select('pid', '父级')->setOptions(function () {
-                $list = IndustryModel::getTierList(null, 0);
-                $menus = [['value' => 0, 'label' => '顶级菜单']];
-                foreach ($list as $menu) {
-                    $menus[] = ['value' => $menu['id'], 'label' => $menu['html'] . $menu['name']];
-                }
-                return $menus;
-            })->filterable(1),
-            Form::input('name', '行业名称'),
-            Form::textarea('info', '详细描述'),
-            Form::number('sort', '排序')->value(0),
-            Form::radio('is_show', '状态', 1)->options([['label' => '显示', 'value' => 1], ['label' => '隐藏', 'value' => 0]])
-        ];
-        return $this->makePostForm('添加行业', $field, Url::buildUrl('/badminapi/industry/add/0'), 'POST');
-    }
-
-    /**
-     * 显示编辑资源表单页.
-     *
-     * @param int $id
-     * @return \think\Response
-     */
-    public function edit($id)
-    {
-        $c = IndustryModel::get($id);
-        if (!$c) return $this->fail('数据不存在!');
-        $field = [
-            Form::select('pid', '父级', (string)$c->getData('pid'))->setOptions(function () use ($id) {
-                $list = IndustryModel::getTierList(IndustryModel::where('id', '<>', $id), 0);
-                $menus = [['value' => 0, 'label' => '顶级菜单']];
-                foreach ($list as $menu) {
-                    $menus[] = ['value' => $menu['id'], 'label' => $menu['html'] . $menu['name']];
-                }
-                return $menus;
-            })->filterable(1),
-            Form::input('name', '行业名称', $c->getData('name')),
-            Form::textarea('info', '详细描述', $c->getData('info')),
-            Form::number('sort', '排序', $c->getData('sort')),
-            Form::radio('is_show', '状态', $c->getData('is_show'))->options([['label' => '显示', 'value' => 1], ['label' => '隐藏', 'value' => 0]])
-        ];
-        return $this->makePostForm('编辑行业', $field, Url::buildUrl('/badminapi/industry/add/' . $id), 'POST');
-    }
-
-    /**
-     * 快速编辑
-     * @param string $id
-     * @return Response
-     * @throws \Exception
-     */
-    public function set_industry($id)
-    {
-        $data = UtilService::postMore([
-            ['field', 'name', '', '', 'empty_check', '缺少参数'],
-            ['value', '', '', '', 'empty_check', '缺少参数']
-        ]);
-        if (!$id) return $this->fail('缺少参数');
-        if (IndustryModel::where('id', $id)->update([$data['field'] => $data['value'], 'update' => time()]))
-            return $this->success('保存成功');
-        else
-            return $this->fail('保存失败');
-    }
-
-    /**
-     * 新增/修改行业
-     * @param int $id
-     * @return mixed
-     * @throws DbException
-     */
-    public function add_industry($id = 0)
-    {
-        $data = UtilService::postMore([
-            ['name', '', '', '', 'empty_check', '请输入行业名'],
-            ['pid', 0],
-            ['info', ''],
-            ['is_show', 0],
-            ['sort', 0]
-        ]);
-        if ($id) {
-            if (!IndustryModel::vaildWhere()->where('id', $id)->find()) {
-                return $this->fail('所选行业不存在');
-            }
-        }
-        if ($data['pid'] != 0) {
-            if (!IndustryModel::vaildWhere()->where('id', $data['pid'])->find()) {
-                return $this->fail('上级行业不存在');
-            }
-        }
-        BaseModel::beginTrans();
-        try {
-            $data['update'] = time();
-            if ($id) {
-                $res = IndustryModel::edit($data, $id);
-            } else {
-                $data['add_time'] = time();
-                $res = IndustryModel::create($data);
-            }
-            if ($res) {
-                BaseModel::commitTrans();
-                return $this->success('操作成功');
-            } else {
-                BaseModel::rollbackTrans();
-                return $this->fail('操作失败');
-            }
-        } catch (Exception $e) {
-            BaseModel::rollbackTrans();
-            return $this->fail($e->getMessage());
-        } catch (DbException $e) {
-            BaseModel::rollbackTrans();
-            return $this->fail($e->getMessage());
-        }
-    }
-
-    /**
-     * 获取指定资源
-     *
-     * @param int $id
-     * @return Response
-     */
-    public function get_industry($id)
-    {
-        return $this->success('ok', IndustryModel::get($id) ? IndustryModel::get($id)->toArray() : []);
-    }
-
-
-    /**
-     * 删除指定资源
-     *
-     * @param int $id
-     * @return Response
-     */
-    public function delete($id)
-    {
-        if (!IndustryModel::delIndustry($id))
-            return $this->fail(IndustryModel::getErrorInfo('删除失败,请稍候再试!'));
-        else
-            return $this->success('删除成功!');
-    }
-}

+ 0 - 24
app/badminapi/event.php

@@ -1,24 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | ThinkPHP [ WE CAN DO IT JUST THINK ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
-// +----------------------------------------------------------------------
-// | Author: liu21st <liu21st@gmail.com>
-// +----------------------------------------------------------------------
-
-// 事件定义文件
-return [
-    'listen'    => [
-        'AppInit'  => [],
-        'HttpRun'  => [],
-        'HttpEnd'  => [],
-        'LogLevel' => [],
-        'LogWrite' => [],
-        'UserLogin'=>[
-             \crmeb\listeners\user\UserLogin::class
-        ]
-    ]
-];

+ 0 - 40
app/badminapi/middleware/BadminAuthTokenMiddleware.php

@@ -1,40 +0,0 @@
-<?php
-
-
-namespace app\badminapi\middleware;
-
-
-use app\Request;
-use crmeb\interfaces\MiddlewareInterface;
-use crmeb\repositories\BAdminRepository;
-use Psr\SimpleCache\InvalidArgumentException;
-use think\db\exception\DataNotFoundException;
-use think\db\exception\DbException;
-use think\db\exception\ModelNotFoundException;
-use think\facade\Config;
-
-class BadminAuthTokenMiddleware implements MiddlewareInterface
-{
-    public function handle(Request $request, \Closure $next)
-    {
-        $authInfo = null;
-        $token = trim(ltrim($request->header(Config::get('cookie.badmin_token_name', 'Badmin-Authori-zation')), 'Bearer'));
-
-
-        $adminInfo = BAdminRepository::adminParseToken($token);
-
-
-        Request::macro('isAdminLogin', function () use (&$adminInfo) {
-            return !is_null($adminInfo);
-        });
-        Request::macro('adminId', function () use (&$adminInfo) {
-            return $adminInfo['id'];
-        });
-
-        Request::macro('adminInfo', function () use (&$adminInfo) {
-            return $adminInfo;
-        });
-
-        return $next($request);
-    }
-}

+ 0 - 33
app/badminapi/middleware/BadminCkeckRole.php

@@ -1,33 +0,0 @@
-<?php
-
-
-namespace app\badminapi\middleware;
-
-use app\Request;
-use crmeb\exceptions\AuthException;
-use crmeb\interfaces\MiddlewareInterface;
-use app\models\system\SystemMenus;
-use app\models\system\SystemRole;
-use crmeb\repositories\AuthRepository;
-use crmeb\utils\ApiErrorCode;
-
-/**
- * 权限规则验证
- * Class AdminCkeckRole
- * @package app\http\middleware
- */
-class BadminCkeckRole implements MiddlewareInterface
-{
-
-    public function handle(Request $request, \Closure $next)
-    {
-//        if (!$request->adminId() || !$request->adminInfo())
-//            throw new AuthException(ApiErrorCode::ERR_ADMINID_VOID);
-//
-//        if ($request->adminInfo()['level']) {
-//            AuthRepository::verifiAuth($request);
-//        }
-
-        return $next($request);
-    }
-}

+ 0 - 17
app/badminapi/provider.php

@@ -1,17 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | ThinkPHP [ WE CAN DO IT JUST THINK ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
-// +----------------------------------------------------------------------
-// | Author: liu21st <liu21st@gmail.com>
-// +----------------------------------------------------------------------
-
-use app\Request;
-
-// 容器Provider定义文件
-return [
-    'think\exception\Handle' => \app\badminapi\BadminApiExceptionHandle::class,
-];

+ 0 - 26
app/badminapi/route/file.php

@@ -1,26 +0,0 @@
-<?php
-
-use think\facade\Route;
-
-/**
- * 附件相关路由
- */
-Route::group('file', function () {
-    //附件列表
-    Route::get('file', 'file.SystemAttachment/index');
-    //删除图片和数据记录
-    Route::post('file/delete', 'file.SystemAttachment/delete');
-    //移动图片分类表单
-    Route::get('file/move', 'file.SystemAttachment/move');
-    //移动图片分类
-    Route::put('file/do_move', 'file.SystemAttachment/moveImageCate');
-    //上传图片
-    Route::post('upload/[:upload_type]', 'file.SystemAttachment/upload');
-    //附件分类管理资源路由
-    Route::resource('category', 'file.SystemAttachmentCategory');
-
-})->middleware([
-    \app\http\middleware\AllowOriginMiddleware::class,
-    \app\badminapi\middleware\BadminAuthTokenMiddleware::class,
-    \app\badminapi\middleware\BadminCkeckRole::class,
-]);

+ 0 - 22
app/badminapi/route/industry.php

@@ -1,22 +0,0 @@
-<?php
-
-use think\facade\Route;
-
-/**
- * 行业 相关路由
- */
-Route::group('industry', function () {
-    Route::get('list', 'merchant.Industry/get_list')->name('get_list');//获取行业列表
-    Route::get('tree/:type', 'merchant.Industry/tree_list');//行业树形列表
-    Route::post('show/:id/:is_show', 'merchant.Industry/set_show')->name('set_show');//设置显示/隐藏
-    Route::post('set/:id', 'merchant.Industry/set_industry')->name('set_industry');//快速编辑某字段
-    Route::get('create', 'merchant.Industry/create')->name('create_industry');//新增表单
-    Route::get('edit/:id', 'merchant.Industry/edit')->name('edit_industry');//编辑表单
-    Route::post('add/:id', 'merchant.Industry/add_industry')->name('add_industry');//添加/编辑行业
-    Route::get('get/:id', 'merchant.Industry/get_industry')->name('get_industry');//获取行业
-    Route::delete('del/:id', 'merchant.Industry/delete')->name('delete');//删除行业
-})->middleware([
-    \app\http\middleware\AllowOriginMiddleware::class,
-    \app\badminapi\middleware\BadminAuthTokenMiddleware::class,
-    \app\badminapi\middleware\BadminCkeckRole::class
-]);

+ 0 - 19
app/badminapi/route/merchant.php

@@ -1,19 +0,0 @@
-<?php
-
-use think\facade\Route;
-
-/**
- * 商户 相关路由
- */
-Route::group('merchant', function () {
-	Route::post('register', 'merchant.Merchant/registerMerchant')->name('registerMerchant');//注册商户
-    Route::post('edit/:mer_id', 'merchant.Merchant/editMerchant')->name('editMerchant');//编辑商户
-    Route::get('list', 'merchant.Merchant/getMerchantList')->name('getMerchantList');//获取商户列表
-    Route::get('detail/:mer_id', 'merchant.Merchant/getMerchantDetail')->name('getMerchantDetail');//获取商户详情
-    Route::post('del/:mer_id', 'merchant.Merchant/delete')->name('deleteMerchantMiniprogram');//删除商户小程序绑定记录
-    Route::post('edit_pay/:mer_id', 'merchant.Merchant/editMerchantPay')->name('editMerchantPay');//编辑商户支付信息
-})->middleware([
-    \app\http\middleware\AllowOriginMiddleware::class,
-    \app\badminapi\middleware\BadminAuthTokenMiddleware::class,
-    \app\badminapi\middleware\BadminCkeckRole::class
-]);

+ 0 - 16
app/badminapi/route/open.php

@@ -1,16 +0,0 @@
-<?php
-
-use think\facade\Route;
-
-/**
- * 小程序授权第三方平台 相关路由
- */
-Route::group('open', function () {
-    Route::get('auth_url/:type', 'merchant.Open/createAuthUrl')->name('createAuthUrl');//生成小程序授权地址
-    Route::post('get/:info_type', 'merchant.Open/getInfoForFront')->name('getInfoForFront');//获取信息
-    Route::post('redirect/:mer_id', 'merchant.Open/wxAuthRedirect');//接收授权码
-})->middleware([
-    \app\http\middleware\AllowOriginMiddleware::class,
-    \app\badminapi\middleware\BadminAuthTokenMiddleware::class,
-    \app\badminapi\middleware\BadminCkeckRole::class
-]);

+ 0 - 21
app/badminapi/route/report.php

@@ -1,21 +0,0 @@
-<?php
-
-use think\facade\Route;
-
-/**
- * 报表 相关路由
- */
-Route::group('report', function () {
-    Route::post('hand_create', 'Report/createYesterdayReport')->name('createYesterdayReport');//手动生成昨日报表
-    Route::get('system_list', 'Report/systemReportList')->name('systemReportList');//系统报表
-    Route::get('merchant_list', 'Report/merchantReportList')->name('merchantReportList');//商户报表
-    Route::get('rank/:type/:sort', 'Report/merchantRank')->name('merchantRank');//商户排行
-    Route::get('header/:mer_id', 'Report/homeStatics')->name('homeStatics');//首页统计数据
-    Route::get('order/:mer_id', 'Report/orderChart')->name('orderChant');//首页订单图表
-    Route::get('user/:mer_id', 'Report/userChart')->name('userChant');//首页用户图表
-    Route::get('rank/:mer_id', 'Report/purchaseRanking')->name('purchaseRanking');//交易额排行
-})->middleware([
-    \app\http\middleware\AllowOriginMiddleware::class,
-    \app\badminapi\middleware\BadminAuthTokenMiddleware::class,
-    \app\badminapi\middleware\BadminCkeckRole::class
-]);

+ 0 - 39
app/badminapi/route/route.php

@@ -1,39 +0,0 @@
-<?php
-
-use think\facade\Route;
-use think\facade\Config;
-use think\Response;
-use app\http\middleware\AllowOriginMiddleware;
-
-/**
- * 无需授权的接口
- */
-Route::group(function () {
-    Route::post('login', 'Login/login')->name('BAdminLogin');//用户名密码登录
-    Route::get('login/info', 'Login/info');//后台登录页面数据
-    Route::get('captcha_pro', 'Login/captcha');//验证码
-    Route::any('open/ticket', 'merchant.Open/wxTicketCallback');//授权事件接收URL
-    Route::any('open/callback/:appid', 'merchant.Open/wxCallback');//消息与事件接收URL
-
-    Route::any('test', 'Test/index');//测试接口
-    Route::any('wxCallback', 'Test/wxCallback');//测试接口
-})->middleware(AllowOriginMiddleware::class);
-/**
- * 需授权的接口
- */
-Route::group(function () {
-
-})->middleware(AllowOriginMiddleware::class)
-    ->middleware(\app\badminapi\middleware\BadminAuthTokenMiddleware::class, false)
-    ->middleware(\app\badminapi\middleware\BadminCkeckRole::class, false);
-/**
- * miss 路由
- */
-Route::miss(function () {
-    if (app()->request->isOptions()) {
-        $header = Config::get('cookie.header');
-        $header['Access-Control-Allow-Origin'] = app()->request->header('origin');
-        return Response::create('ok')->code(200)->header($header);
-    } else
-        return Response::create()->code(404);
-});

+ 0 - 19
app/badminapi/route/template.php

@@ -1,19 +0,0 @@
-<?php
-
-use think\facade\Route;
-
-/**
- * 模板相关路由
- */
-Route::group('template', function () {
-    Route::get('list', 'Template/get_list')->name('get_list');//获取模板列表
-    Route::post('ban/:id', 'Template/set_ban')->name('set_ban');//设置启用/禁用
-    Route::post('set/:id', 'Template/set_template')->name('set_template');//快速编辑某字段
-    Route::post('add/:id', 'Template/add_template')->name('add_template');//添加/编辑模板
-    Route::get('get/:id', 'Template/get_template')->name('get_template');//获取模板
-    Route::post('del/:id', 'Template/delete')->name('delete');//删除模板
-})->middleware([
-    \app\http\middleware\AllowOriginMiddleware::class,
-    \app\badminapi\middleware\BadminAuthTokenMiddleware::class,
-    \app\badminapi\middleware\BadminCkeckRole::class
-]);

+ 0 - 50
app/badminapi/route/third.php

@@ -1,50 +0,0 @@
-<?php
-
-use think\facade\Route;
-
-/**
- * 第三方平台代小程序实现业务 相关路由
- */
-Route::group('third', function () {
-    //快速创建小程序(不一定用)
-    Route::post('miniprogram/create', 'merchant.Third/createMiniProgram')->name('createMiniProgram');//快速创建小程序
-
-    //基础信息设置
-    Route::post('code/modify_domain/:mer_id', 'merchant.Third/modifyDomain')->name('modifyDomain');//设置服务器域名
-
-    //代码模板库设置
-    Route::get('template/draft_list', 'merchant.Third/getTemplateDraftList')->name('getTemplateDraftList');//获取代码草稿列表
-    Route::get('template/list', 'merchant.Third/getTemplateList')->name('getTemplateList');//获取代码模板列表
-    Route::post('template/add/:draft_id', 'merchant.Third/addToTemplate')->name('addToTemplate');//将草稿添加到代码模板库
-    Route::post('template/del/:template_id', 'merchant.Third/deleteTemplate')->name('deleteTemplate');//删除指定代码模板
-
-    //代码管理
-    Route::post('code/commit/:mer_id/:template_id', 'merchant.Third/commitCode')->name('commitCode');//上传小程序代码
-    Route::get('code/list/:mer_id', 'merchant.Third/getPageList')->name('getPageList');//获取已上传的代码的页面列表
-    Route::get('code/qrcode/:mer_id', 'merchant.Third/getQrCode')->name('getQrCode');//获取体验版二维码
-    Route::post('code/audit/:mer_id', 'merchant.Third/submitAudit')->name('submitAudit');//提交审核
-    Route::post('code/audit/media/:mer_id', 'merchant.Third/addAuditMedia')->name('addAuditMedia');//提交审核素材
-    Route::get('code/audit_list', 'merchant.Third/getAuditList')->name('getAuditList');//获取审核列表
-    Route::post('code/audit_status/:mer_id/:auditid', 'merchant.Third/getAuditStatus')->name('getAuditStatus');//查询指定发布审核单的审核状态
-    Route::post('code/undo/:mer_id', 'merchant.Third/undoAudit')->name('undoAudit');//小程序审核撤回
-    Route::get('code/audit_last_status/:mer_id', 'merchant.Third/getLatestAuditStatus')->name('getLatestAuditStatus');//查询最新一次审核单的审核状态
-    Route::post('code/release/:mer_id', 'merchant.Third/release')->name('release');//发布已通过审核的小程序
-    Route::post('code/revert/:mer_id', 'merchant.Third/revertCodeRelease')->name('revertCodeRelease');//版本回退
-    Route::post('code/gray_release/:mer_id/:gray', 'merchant.Third/grayRelease')->name('grayRelease');//分阶段发布
-    Route::post('code/gray_release/revert/:mer_id/', 'merchant.Third/revertGrayRelease')->name('revertGrayRelease');//分阶段发布
-    Route::get('code/gray_release/plan/:mer_id', 'merchant.Third/getGrayReleasePlan')->name('getGrayReleasePlan');//查询当前分阶段发布详情
-    Route::post('code/visit_status/:mer_id/:action', 'merchant.Third/changeVisitStatus')->name('changeVisitStatus');//修改小程序线上代码的可见状态(仅供第三方代小程序调用)
-    Route::get('code/support_version/:mer_id', 'merchant.Third/getWeAppSupportVersion')->name('getWeAppSupportVersion');//查询当前设置的最低基础库版本及各版本用户占比
-    Route::post('code/support_version/:mer_id', 'merchant.Third/setWeAppSupportVersion')->name('setWeAppSupportVersion');//设置最低基础库版本
-    Route::get('code/query_quota/:mer_id', 'merchant.Third/queryQuota')->name('queryQuota');//询服务商的当月提审限额(quota)和加急次数
-    Route::post('code/speed_up_audit/:mer_id/:auditid', 'merchant.Third/speedUpAudit')->name('speedUpAudit');//加急审核申请
-    Route::get('code/cate/:mer_id', 'merchant.Third/getCategory')->name('getCategory');//获取审核时可填写的类目信息
-
-    //体验者管理
-    Route::post('tester/add/:mer_id', 'merchant.Third/bindTester')->name('bindTester');//绑定体验者
-    Route::post('tester/del/:mer_id', 'merchant.Third/unbindTester')->name('unbindTester');//解绑体验者
-})->middleware([
-    \app\http\middleware\AllowOriginMiddleware::class,
-    \app\badminapi\middleware\BadminAuthTokenMiddleware::class,
-    \app\badminapi\middleware\BadminCkeckRole::class
-]);

+ 0 - 44
app/badminapi/validates/SystemBAdminValidata.php

@@ -1,44 +0,0 @@
-<?php
-namespace app\badminapi\validates;
-
-use think\Validate;
-
-class SystemBAdminValidata extends Validate
-{
-    /**
-     * 定义验证规则
-     * 格式:'字段名'    =>    ['规则1','规则2'...]
-     *
-     * @var array
-     */
-    protected $rule = [
-        'account' => ['require', 'alphaDash'],
-        'conf_pwd' => 'require',
-        'pwd' => 'require',
-        'real_name' => 'require',
-        'roles' => ['require', 'array'],
-    ];
-
-    /**
-     * 定义错误信息
-     * 格式:'字段名.规则名'    =>    '错误信息'
-     *
-     * @var array
-     */
-    protected $message = [
-        'account.require' => '请填写管理员账号',
-        'account.alphaDash' => '管理员账号为应为和字母',
-        'conf_pwd.require' => '请输入确认密码',
-        'pwd.require' => '请输入密码',
-        'real_name.require' => '请输管理员姓名',
-        'roles.require' => '请选择管理员身份',
-        'roles.array' => '身份必须为数组',
-    ];
-
-    protected $scene = [
-        'get' => ['account', 'pwd'],
-        'update' => ['account', 'roles'],
-    ];
-
-
-}

+ 16 - 7
app/models/section/SectionModel.php → app/models/article/ArticleModel.php

@@ -1,14 +1,13 @@
 <?php
 <?php
 
 
-namespace app\models\section;
+namespace app\models\article;
 
 
-use think\facade\Db;
 use crmeb\traits\ModelTrait;
 use crmeb\traits\ModelTrait;
 use crmeb\basic\BaseModel;
 use crmeb\basic\BaseModel;
 
 
-class SectionModel extends BaseModel
+class ArticleModel extends BaseModel
 {
 {
-	/**
+    /**
      * 数据表主键
      * 数据表主键
      * @var string
      * @var string
      */
      */
@@ -18,7 +17,7 @@ class SectionModel extends BaseModel
      * 模型名称
      * 模型名称
      * @var string
      * @var string
      */
      */
-    protected $name = 'section';
+    protected $name = 'article';
 
 
     use ModelTrait;
     use ModelTrait;
 
 
@@ -26,12 +25,22 @@ class SectionModel extends BaseModel
     {
     {
         $model = new self;
         $model = new self;
         if (isset($where['title']) && $where['title'] !== '') $model = $model->where('title', 'LIKE', "%$where[title]%");
         if (isset($where['title']) && $where['title'] !== '') $model = $model->where('title', 'LIKE', "%$where[title]%");
-        if (isset($where['status']) && $where['status'] !== '') $model = $model->where('status', $where['status']);
         $model = $model->where('is_del', 0);
         $model = $model->where('is_del', 0);
         $model = $model->order('sort desc,id desc');
         $model = $model->order('sort desc,id desc');
         $count = $model->count();
         $count = $model->count();
-        $list = $model->page((int)$where['page'], (int)$where['limit'])->select()->toArray();
+        $list = $model->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
+            $item['_add_time'] = date('Y-m-d H:i:s', $item['add_time']);
+        })->toArray();
         return compact('count', 'list');
         return compact('count', 'list');
     }
     }
 
 
+    /**
+     * 详情
+     */
+    public static function getOne($id)
+    {
+        $info = self::where('is_del', 0)->find($id);
+        return $info;
+    }
+
 }
 }

+ 0 - 50
app/models/company/DesignerModel.php

@@ -1,50 +0,0 @@
-<?php
-
-namespace app\models\company;
-
-use think\facade\Db;
-use crmeb\traits\ModelTrait;
-use crmeb\basic\BaseModel;
-
-class DesignerModel extends BaseModel
-{
-	/**
-     * 数据表主键
-     * @var string
-     */
-    protected $pk = 'id';
-
-    /**
-     * 模型名称
-     * @var string
-     */
-    protected $name = 'designer';
-
-    use ModelTrait;
-
-    /**
-     * 新增或编辑设计师
-     */
-    public static function saveDesigner($indata, $cid)
-    {
-        $ids = array();
-        foreach($indata as $value){
-            if(!$value){
-                return $this->fail('请输入正确的案例');
-            }
-            if(!empty($value['id'])){
-                $ids[] = $value['id'];
-                self::edit($value, $value['id']);
-            }else{
-                $ids[] = self::insertGetId($value);
-            }
-        }
-        $data[] = ['id', 'not in', $ids];
-        $data[] = ['cid', '=', $cid];
-        $overs = self::where($data)->select();
-        foreach($overs as $over){
-            self::destroy($over['id']);
-        }
-    }
-
-}

+ 0 - 50
app/models/company/ExampleModel.php

@@ -1,50 +0,0 @@
-<?php
-
-namespace app\models\company;
-
-use think\facade\Db;
-use crmeb\traits\ModelTrait;
-use crmeb\basic\BaseModel;
-
-class ExampleModel extends BaseModel
-{
-	/**
-     * 数据表主键
-     * @var string
-     */
-    protected $pk = 'id';
-
-    /**
-     * 模型名称
-     * @var string
-     */
-    protected $name = 'example';
-
-    use ModelTrait;
-
-    /**
-     * 新增或编辑案例
-     */
-    public static function saveExample($indata, $cid)
-    {
-        $ids = array();
-        foreach($indata as $value){
-            if(!$value){
-                return $this->fail('请输入正确的案例');
-            }
-            if(!empty($value['id'])){
-                $ids[] = $value['id'];
-                self::edit($value, $value['id']);
-            }else{
-                $ids[] = self::insertGetId($value);
-            }
-        }
-        $data[] = ['id', 'not in', $ids];
-        $data[] = ['cid', '=', $cid];
-        $overs = self::where($data)->select();
-        foreach($overs as $over){
-            self::destroy($over['id']);
-        }
-    }
-
-}

+ 4 - 14
app/models/company/CompanyModel.php → app/models/course/CourseModel.php

@@ -1,12 +1,11 @@
 <?php
 <?php
 
 
-namespace app\models\company;
+namespace app\models\course;
 
 
-use think\facade\Db;
 use crmeb\traits\ModelTrait;
 use crmeb\traits\ModelTrait;
 use crmeb\basic\BaseModel;
 use crmeb\basic\BaseModel;
 
 
-class CompanyModel extends BaseModel
+class CourseModel extends BaseModel
 {
 {
 	/**
 	/**
      * 数据表主键
      * 数据表主键
@@ -18,21 +17,20 @@ class CompanyModel extends BaseModel
      * 模型名称
      * 模型名称
      * @var string
      * @var string
      */
      */
-    protected $name = 'company';
+    protected $name = 'course';
 
 
     use ModelTrait;
     use ModelTrait;
 
 
     public static function systemPage($where)
     public static function systemPage($where)
     {
     {
         $model = new self;
         $model = new self;
+        if (isset($where['area']) && $where['area'] !== '') $model = $model->where('area', $where['area']);
         if (isset($where['title']) && $where['title'] !== '') $model = $model->where('title', 'LIKE', "%$where[title]%");
         if (isset($where['title']) && $where['title'] !== '') $model = $model->where('title', 'LIKE', "%$where[title]%");
-        if (isset($where['sid']) && $where['sid'] !== '') $model = $model->where('sid', $where['sid']);
         $model = $model->where('is_del', 0);
         $model = $model->where('is_del', 0);
         $model = $model->order('sort desc,id desc');
         $model = $model->order('sort desc,id desc');
         $count = $model->count();
         $count = $model->count();
         $list = $model->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
         $list = $model->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
             $item['_add_time'] = date('Y-m-d H:i:s', $item['add_time']);
             $item['_add_time'] = date('Y-m-d H:i:s', $item['add_time']);
-            $item['slider_image'] = json_decode($item['slider_image'], true);
         })->toArray();
         })->toArray();
         return compact('count', 'list');
         return compact('count', 'list');
     }
     }
@@ -43,14 +41,6 @@ class CompanyModel extends BaseModel
     public static function getOne($id)
     public static function getOne($id)
     {
     {
         $info = self::where('is_del', 0)->find($id);
         $info = self::where('is_del', 0)->find($id);
-        if ($info) {
-            $info['example'] = ExampleModel::where(['cid' => $id])->order('sort desc, id asc')->select();
-            $info['designer'] = DesignerModel::where(['cid' => $id])->order('sort desc, id asc')->select();
-            if (isset($info['slider_image']) && $info['slider_image'])
-                $info['slider_image'] = json_decode($info['slider_image'], true);
-            else
-                $info['slider_image'] = [];
-        }
         return $info;
         return $info;
     }
     }
 
 

+ 44 - 0
app/models/course/OrganModel.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace app\models\course;
+
+use crmeb\traits\ModelTrait;
+use crmeb\basic\BaseModel;
+
+class OrganModel extends BaseModel
+{
+	/**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'organ';
+
+    use ModelTrait;
+
+    public static function systemPage($where)
+    {
+        $model = new self;
+        $model = $model->where('is_del', 0);
+        $count = $model->count();
+        $list = $model->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
+            $item['_add_time'] = date('Y-m-d H:i:s', $item['add_time']);
+        })->toArray();
+        return compact('count', 'list');
+    }
+
+    /**
+     * 详情
+     */
+    public static function getOne($id)
+    {
+        $info = self::where('is_del', 0)->find($id);
+        return $info;
+    }
+
+}

+ 44 - 0
app/models/page/PageModel.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace app\models\page;
+
+use crmeb\traits\ModelTrait;
+use crmeb\basic\BaseModel;
+
+class PageModel extends BaseModel
+{
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'page';
+
+    use ModelTrait;
+
+    public static function systemPage($where)
+    {
+        $model = new self;
+        $model = $model->where('is_del', 0);
+        $count = $model->count();
+        $list = $model->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
+            $item['_add_time'] = date('Y-m-d H:i:s', $item['add_time']);
+        })->toArray();
+        return compact('count', 'list');
+    }
+
+    /**
+     * 详情
+     */
+    public static function getOne($id)
+    {
+        $info = self::where('is_del', 0)->find($id);
+        return $info;
+    }
+
+}