rabin 1 yıl önce
ebeveyn
işleme
c8f838742d

+ 19 - 0
src/dai/channel/lib/Config.php

@@ -0,0 +1,19 @@
+<?php namespace Channel\Lib;
+use Dever;
+use Dever\Project;
+use Manage\Lib\Auth;
+class Config extends Auth
+{
+    public function getTree()
+    {
+        $data = Dever::db('config', 'channel')->select([]);
+        $result = array();
+        $result[] = array
+        (
+            'id' => 'root',
+            'name' => '全部配置',
+            'children' => $data,
+        );
+        return $result;
+    }
+}

+ 33 - 0
src/dai/channel/table/config.php

@@ -0,0 +1,33 @@
+<?php
+return array
+(
+    'name' => '基础配置',
+    'struct' => array
+    (
+        'name' => array
+        (
+            'name'      => '配置名称',
+            'type'      => 'varchar(32)',
+        ),
+        'email_user' => array
+        (
+            'name'      => '邮箱账号',
+            'type'      => 'varchar(200)',
+        ),
+        'email_pass' => array
+        (
+            'name'      => '邮箱密码',
+            'type'      => 'varchar(200)',
+        ),
+    ),
+
+    'default' => array
+    (
+        'field' => 'id,name',
+        'value' => array
+        (
+            '1,"卡密配置"',
+        ),
+        'num' => 1,
+    ),
+);

+ 54 - 0
src/dai/channel/table/manage/config.php

@@ -0,0 +1,54 @@
+<?php
+return array
+(
+    'list' => array
+    (
+        'field'      => array
+        (
+            'name',
+            'email_user',
+        ),
+        'data_button' => array
+        (
+            '编辑' => 'fastedit',
+        ),
+    ),
+    'update' => array
+    (
+        # 展示左侧分栏
+        'column' => array
+        (
+            'load' => 'channel/config',
+            'add' => '新增',
+            'key' => 'id',
+            'data' => 'channel/config.getTree',
+            'active' => 1,
+            'where' => 'id',
+        ),
+        'field'    => array
+        (
+            'name',
+            'email_user',
+            'email_pass' => array
+            (
+                'desc' => '输入将更新旧密码',
+                'type' => 'password',
+                # 更新时的值,始终是空的,有值才更新
+                'update' => '',
+                # 空值不允许入库
+                'empty'  => false,
+                'rules'     => array
+                (
+                    array
+                    (
+                        # 仅限新增时必填,值为add/edit,不填则所有有效
+                        'only' => 'add',
+                        'required' => true,
+                        'trigger' => 'blur',
+                        'message' => '请输入密码',
+                    ),
+                ),
+            ),
+        ),
+    ),
+);

+ 8 - 0
src/dai/channel/table/manage/core.php

@@ -40,5 +40,13 @@ return array
             'sort'      => '2',
             'show'      => 3,
         ),
+        'config' => array
+        (
+            'parent'    => 'supplier',
+            'name'      => '配置管理',
+            'icon'      => 'album-line',
+            'sort'      => '5',
+            'path'      => 'update',
+        ),
     ),
 );

+ 5 - 5
src/dai/seller/api/Manage.php

@@ -221,7 +221,7 @@ class Manage extends Auth
     # 发送邮件
     public function send($email, $username, $title, $content, $file = '')
     {
-        $config = Dever::config('setting')['email'];
+        $config = Dever::db('config', 'channel')->find(1);
 
         Dever::apply('PHPMailer', 'email', 'src');
         Dever::apply('Exception', 'email', 'src');
@@ -231,13 +231,13 @@ class Manage extends Auth
         $mail->isSMTP();
         //$mail->SMTPDebug = 2;
         $mail->CharSet = 'UTF-8';
-        $mail->Host = $config['smtp'];
+        $mail->Host = 'smtp.exmail.qq.com';
         $mail->Port = 465;
         $mail->SMTPSecure = 'ssl';
         $mail->SMTPAuth = true;
-        $mail->Username = $config['username'];
-        $mail->Password = $config['password'];
-        $mail->setFrom($config['from'][0], 'API充值系统');
+        $mail->Username = $config['email_user'];
+        $mail->Password = $config['email_pass'];
+        $mail->setFrom($config['email_user'], 'API充值系统');
         $mail->addAddress($email, $username);
         $mail->Subject = "=?utf-8?B?" . base64_encode($title) . "?=";
         $mail->Body = $content;