Browse Source

Add UserChannel, Changelog, TODO

joe 3 years ago
parent
commit
5c2b67772d

+ 26 - 1
CHANGELOG

@@ -78,4 +78,29 @@ VALUES('leader_robot_earn_max', 'text', 'number', 25, '', NULL, NULL, 100, NULL,
 
 2022-08-18
 
-ALTER TABLE twong.eb_system_attachment CHANGE att_id id int(10) auto_increment NOT NULL;
+ALTER TABLE twong.eb_system_attachment CHANGE att_id id int(10) auto_increment NOT NULL;
+
+2022-09-30
+
+CREATE TABLE `eb_user_streaks` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `uid` int(11) NOT NULL,
+  `flag` int(2) NOT NULL DEFAULT 0 COMMENT '0 连赢 1 连输',
+  `link_id` varchar(32) NOT NULL COMMENT '订单号',
+  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
+  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
+  PRIMARY KEY (`id`),
+  KEY `idx_user_streaks_uid_flag` (`uid`,`flag`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
+
+CREATE TABLE `eb_dict_channels` (
+  `id` int(11) NOT NULL AUTO_INCREMENT,
+  `name` varchar(255) NOT NULL COMMENT '名称',
+  `code` varchar(16) NOT NULL COMMENT '渠道代码',
+  `desc` varchar(1024) NOT NULL DEFAULT '' COMMENT '渠道说明',
+  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
+  `updated_at` timestamp NULL DEFAULT NULL ON UPDATE current_timestamp(),
+  PRIMARY KEY (`id`),
+  KEY `idx_channels_code` (`code`),
+  KEY `idx_channels_name` (`name`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

+ 9 - 0
TODO

@@ -0,0 +1,9 @@
+1. 支持连输几次,连赢几次的奖励和补贴,记录相应的订单信息
+2. 支持大会员系统
+3. 支持分享商品并形成销售后的提成
+4. 小程序端的绑定手机号
+5. 小程序端微信通知
+6. 排行榜做到首页
+7. 首页登录
+8. 首页滚动消息优化
+9. 小程序端依赖升级

+ 7 - 6
app/admin/common.php

@@ -40,7 +40,7 @@ if (!function_exists('attr_format')) {
                                 //替代变量4
                                 $rep4['detail'][$rep3[0]] = isset($rep3[1]) ? $rep3[1] : '';
                             }
-                            if($count == count($rep4['detail']))
+                            if ($count == count($rep4['detail']))
                                 $res[] = $rep4;
                         }
                     }
@@ -68,7 +68,7 @@ if (!function_exists('get_month')) {
      * @param int $ceil
      * @return array
      */
-    function get_month($time = '', $ceil = 0)
+    function get_month($time = '', $ceil = 0): array
     {
         if (empty($time)) {
             $firstday = date("Y-m-01", time());
@@ -123,11 +123,11 @@ if (!function_exists('get_this_class_methods')) {
         $arrayall = get_class_methods($class);
         if ($parent_class = get_parent_class($class)) {
             $arrayparent = get_class_methods($parent_class);
-            $arraynow = array_diff($arrayall, $arrayparent);//去除父级的
+            $arraynow = array_diff($arrayall, $arrayparent); //去除父级的
         } else {
             $arraynow = $arrayall;
         }
-        return array_diff($arraynow, $unarray);//去除无用的
+        return array_diff($arraynow, $unarray); //去除无用的
     }
 }
 
@@ -149,7 +149,8 @@ if (!function_exists('verify_domain')) {
 }
 
 if (!function_exists('getFileHeaders')) {
-    function getFileHeaders(string $url, $isData = true) {
+    function getFileHeaders(string $url, $isData = true)
+    {
         stream_context_set_default(['ssl' => ['verify_peer' => false, 'verify_peer_name' => false]]);
         $header['size'] = 0;
         $header['type'] = 'image/jpeg';
@@ -189,4 +190,4 @@ if (!function_exists('getUrlImgInfo')) {
             'time' => time(),
         ];
     }
-}
+}

+ 105 - 0
app/admin/controller/user/UserChannel.php

@@ -0,0 +1,105 @@
+<?php
+
+namespace app\admin\controller\user;
+
+use app\admin\controller\AuthController;
+use app\admin\model\user\UserChannel as ChannelModel;
+use crmeb\services\JsonService;
+use crmeb\services\UtilService;
+use crmeb\services\FormBuilder as Form;
+use think\facade\Route as Url;
+
+/**
+ * Class UserGroup
+ * @package app\admin\controller\user
+ */
+class UserChannel extends AuthController
+{
+    /**
+     * 会员分组页面
+     * @return string
+     */
+    public function index()
+    {
+        return $this->fetch();
+    }
+
+    /**
+     * 分组列表
+     */
+    public function channelList()
+    {
+        $where = UtilService::getMore([
+            ['page', 1],
+            ['limit', 20],
+        ]);
+        return JsonService::successlayui(ChannelModel::getList($where));
+    }
+
+    /**
+     * 添加/修改分组页面
+     * @param int $id
+     * @return string
+     */
+    public function addChannel($id = 0)
+    {
+        $group = ChannelModel::get($id);
+        $f = [];
+        if (!$group) {
+            $f[] = Form::input('name', '渠道名称', '')->col(30);
+            $f[] = Form::input('code', '渠道代码', '')->col(30);
+            $f[] = Form::textarea('desc', '说明', '')->col(512)->rows(10);
+        } else {
+            $f[] = Form::input('name', '渠道名称', $group->getData('name'))->col(30);
+            $f[] = Form::input('code', '渠道代码', $group->getData('code'))->col(30);
+            $f[] = Form::textarea('desc', '说明', $group->getData('desc'))->col(512)->rows(10);
+        }
+        $form = Form::make_post_form('会员渠道', $f, Url::buildUrl('saveChannel', ['id' => $id]));
+        $this->assign(compact('form'));
+        return $this->fetch('public/form-builder');
+    }
+
+    /**
+     * 添加/修改
+     * @param int $id
+     */
+    public function saveChannel($id = 0)
+    {
+        $data = UtilService::postMore([
+            ['name', ''],
+            ['code', ''],
+            ['desc', ''],
+        ]);
+        if ($id) {
+            if (ChannelModel::where('id', $id)->update($data)) {
+                return JsonService::success('修改成功');
+            } else {
+                return JsonService::fail('修改失败或者您没有修改什么!');
+            }
+        } else {
+            if ($res = ChannelModel::create($data)) {
+                return JsonService::success('保存成功', ['id' => $res->id]);
+            } else {
+                return JsonService::fail('保存失败!');
+            }
+        }
+    }
+
+    /**
+     * 删除
+     * @param $id
+     * @throws \Exception
+     */
+    public function delete($id)
+    {
+        if (!$id) return $this->failed('数据不存在');
+        if (!ChannelModel::be(['id' => $id])) {
+            return $this->failed('渠道数据不存在');
+        }
+        if (!ChannelModel::where('id', $id)->delete()) {
+            return JsonService::fail(ChannelModel::getErrorInfo('删除失败,请稍候再试!'));
+        } else {
+            return JsonService::successful('删除渠道成功!');
+        }
+    }
+}

+ 39 - 0
app/admin/model/user/UserChannel.php

@@ -0,0 +1,39 @@
+<?php
+
+namespace app\admin\model\user;
+
+use crmeb\basic\BaseModel;
+use crmeb\traits\ModelTrait;
+
+/**
+ * Class UserChannel
+ * @package app\admin\model\user
+ */
+class UserChannel extends BaseModel
+{
+    /**
+     * 数据表主键
+     * @var string
+     */
+    protected $pk = 'id';
+
+    /**
+     * 模型名称
+     * @var string
+     */
+    protected $name = 'dict_channels';
+
+    use ModelTrait;
+
+    /**
+     * @param $where
+     * @return array
+     */
+    public static function getList($where)
+    {
+
+        $data = self::page((int)$where['page'], (int)$where['limit'])->select();
+        $count = $data->count();
+        return compact('count', 'data');
+    }
+}

+ 109 - 0
app/admin/view/user/user_channel/index.php

@@ -0,0 +1,109 @@
+{extend name="public/container"}
+{block name="head_top"}
+
+{/block}
+{block name="content"}
+<div class="layui-fluid" style="background: #fff;margin-top: -10px;">
+    <div class="layui-row layui-col-space15">
+        <div class="layui-col-md12">
+            <div class="layui-card">
+                <div class="layui-card-body">
+                    <div class="layui-btn-container">
+                        <button class="layui-btn layui-btn-sm" onclick="$eb.createModalFrame(this.innerText,'{:Url('addChannel')}',{h:480,w:720})">
+                            添加渠道
+                        </button>
+                    </div>
+                    <table class="layui-hide" id="List" lay-filter="List"></table>
+
+                    <script type="text/html" id="act">
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='edit'>
+                            编辑
+                        </button>
+                        <button type="button" class="layui-btn layui-btn-xs layui-btn-normal" lay-event='del'>
+                            删除
+                        </button>
+                    </script>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+<script src="{__ADMIN_PATH}js/layuiList.js"></script>
+{/block}
+{block name="script"}
+<script>
+    layList.tableList('List', "{:Url('channelList')}", function() {
+        return [{
+                field: 'id',
+                title: 'ID',
+                sort: true,
+                event: 'id',
+                width: '20%'
+            },
+            {
+                field: 'name',
+                title: '渠道名称',
+                width: '30%'
+            },
+            {
+                field: 'code',
+                title: '渠道代码',
+                width: '30%'
+            },
+            {
+                field: 'right',
+                title: '操作',
+                align: 'center',
+                toolbar: '#act',
+                width: '20%'
+            },
+        ];
+    });
+    //点击事件绑定
+    layList.tool(function(event, data, obj) {
+        switch (event) {
+            case 'del':
+                var url = layList.U({
+                    c: 'user.user_channel',
+                    a: 'delete',
+                    q: {
+                        id: data.id
+                    }
+                });
+                var code = {
+                    title: "操作提示",
+                    text: "确定删除该渠道?",
+                    type: 'info',
+                    confirm: '是的,删除'
+                };
+                $eb.$swal('delete', function() {
+                    $eb.axios.get(url).then(function(res) {
+                        if (res.status == 200 && res.data.code == 200) {
+                            $eb.$swal('success', res.data.msg);
+                            obj.del();
+                            location.reload();
+                        } else
+                            return Promise.reject(res.data.msg || '删除失败')
+                    }).catch(function(err) {
+                        $eb.$swal('error', err);
+                    });
+                }, code)
+                break;
+            case 'open_image':
+                $eb.openImage(data.image);
+                break;
+            case 'edit':
+                $eb.createModalFrame(data.name + '-编辑', layList.U({
+                    a: 'addChannel',
+                    q: {
+                        id: data.id
+                    }
+                }), {
+                    h: 480,
+                    w: 720
+                });
+                break;
+        }
+    })
+</script>
+{/block}