rabin 1 tahun lalu
induk
melakukan
6b659d925a

+ 1 - 1
src/bao/connect/table/manage/connect_api.php

@@ -1,5 +1,5 @@
 <?php
-$connect_id = Dever::input('search')['connect_id'] ?? 0;
+$connect_id = Dever::input('set')['connect_id'] ?? 0;
 return array
 (
     'source' => 'connect/api',

+ 36 - 0
src/dai/channel/lib/Manage.php

@@ -8,4 +8,40 @@ class Manage extends Auth
     {
         return Dever::db('info', 'channel')->select(array('status' => 1));
     }
+
+    # 上传卡密
+    public function uploadCard($data)
+    {
+        if ($data['channel_id'] && $data['goods'] && $data['file']) {
+            $goods = explode(',', $data['goods']);
+            $file = Dever::load('view', 'upload')->local($data['file']);
+            $excel = Dever::load('import', 'excel')->act($file);
+            if ($excel) {
+                foreach ($excel as $k => $v) {
+                    if ($k > 1) {
+                        $update = array();
+                        $update['number'] = $v['A'];
+                        $info = Dever::db('card', 'channel')->find($update);
+                        if ($info) {
+                            Dever::error('卡号:' . $update['number'] . '已存在');
+                        }
+                        $update['pwd'] = $v['B'];
+                        $value = $v['C'];
+                        $sku = Dever::db('info_sku', 'goods')->find(array('info_id' => $goods[1], 'value' => $value));
+                        if (!$sku) {
+                            continue;
+                        }
+                        $update['goods_id'] = $goods[1];
+                        $update['sku_id'] = $sku['id'];
+                        $update['channel_id'] = $data['channel_id'];
+                        $update['goods'] = $data['goods'];
+                        Dever::db('card', 'channel')->insert($update);
+                    }
+                }
+            }
+        } else {
+            Dever::error('请上传文件或者选择商品');
+        }
+        return $data;
+    }
 }

+ 12 - 0
src/dai/channel/table/info.php

@@ -11,6 +11,18 @@ return array
             'type'      => 'varchar(32)',
         ),
 
+        'type' => array
+        (
+            'name'      => '渠道类型',
+            'type'      => 'tinyint(1)',
+            'default'   => 1,
+            'value'     => array
+            (
+                1 => '接口',
+                2 => '卡密',
+            ),
+        ),
+
         'connect_id' => array
         (
             'name'      => '通信规则',

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

@@ -24,5 +24,21 @@ return array
             'icon'      => 'command-line',
             'sort'      => '1',
         ),
+        'card' => array
+        (
+            'parent'    => 'supplier',
+            'name'      => '卡密管理',
+            'icon'      => 'command-line',
+            'sort'      => '2',
+            'show'      => 3,
+        ),
+        'card_upload' => array
+        (
+            'parent'    => 'supplier',
+            'name'      => '上传卡密文件',
+            'icon'      => 'command-line',
+            'sort'      => '2',
+            'show'      => 3,
+        ),
     ),
 );

+ 37 - 2
src/dai/channel/table/manage/info.php

@@ -7,7 +7,8 @@ return array
         (
             'id',
             'name',
-            'connect_id',
+            'type',
+            //'connect_id',
             'host',
             'status' => array
             (
@@ -20,6 +21,14 @@ return array
         'data_button' => array
         (
             '编辑' => 'edit',
+            '卡密列表' => array('route', array
+            (
+                'path' => 'supplier/card',
+                'param' => array
+                (
+                    'set' => array('channel_id' => 'id', 'menu' => 'supplier/info', 'parent' => 'supplier/card'),
+                ),
+            ), 'ChatLineSquare', 'type=2'),
         ),
         'button' => array
         (
@@ -28,18 +37,24 @@ return array
         'search' => array
         (
             'name',
+            'type',
         ),
     ),
     'update' => array
     (
         'tab' => array
         (
-            '基本设置' => 'name,discount,connect_id,appkey,appsecret,host,channel/set',
+            '基本设置' => 'name,type,discount,connect_id,appkey,appsecret,host,channel/set',
             '商品设置' => 'channel/goods',
         ),
         'field'    => array
         (
             'name',
+            'type' => array
+            (
+                'type' => 'radio',
+                'control' => true,
+            ),
             'discount' => array
             (
                 'name' => '默认折扣',
@@ -60,5 +75,25 @@ return array
                 'where'  => array('channel_id' => 'id'),
             ),
         ),
+
+        'control' => array
+        (
+            'connect_id' => array
+            (
+                'type' => 1,
+            ),
+            'appkey' => array
+            (
+                'type' => 1,
+            ),
+            'appsecret' => array
+            (
+                'type' => 1,
+            ),
+            'channel/set' => array
+            (
+                'type' => 1,
+            ),
+        ),
     ),
 );

+ 3 - 2
src/dai/seller/lib/Manage.php

@@ -178,9 +178,9 @@ class Manage extends Auth
         $where['status'] = 10;
         $yes = $db->count($where);
         if ($total <= 0) {
-            $lv = '0%';
+            $lv = '0';
         } else {
-            $lv = round($yes/$total*100, 2) . '%';
+            $lv = round($yes/$total*100, 2);
         }
         $czongjine = $db->find($where, array('col' => 'sum(cash) as cash'));
         $szongjine = $db->find($where, array('col' => 'sum(price) as cash'));
@@ -211,6 +211,7 @@ class Manage extends Auth
                 'span' => '3',
                 'name' => '成功率',
                 'value' => $lv,
+                'suffix' => '%',
             ),
             array
             (

+ 29 - 6
src/yuan/goods/lib/Manage.php

@@ -37,12 +37,16 @@ class Manage extends Auth
     }
 
     # 获取商品
-    public function getGoods()
+    public function getGoods($cate_key = '')
     {
-        $cate = Dever::db('cate', 'goods')->select([]);
+        $where = array();
+        if ($cate_key) {
+            $where['key'] = $cate_key;
+        }
+        $cate = Dever::db('cate', 'goods')->select($where);
         $result = array();
         foreach ($cate as $k => $v) {
-            $goods = Dever::db('info', 'goods')->select(array('cate_id' => $v['id']));
+            $goods = Dever::db('info', 'goods')->select(array('cate_id' => $v['id'], 'status' => 1));
             if ($goods) {
                 $result[] = array
                 (
@@ -56,12 +60,16 @@ class Manage extends Auth
     }
 
     # 获取商品规格
-    public function getGoodsSku()
+    public function getGoodsSku($cate_key = '')
     {
-        $cate = Dever::db('cate', 'goods')->select([]);
+        $where = array();
+        if ($cate_key) {
+            $where['key'] = $cate_key;
+        }
+        $cate = Dever::db('cate', 'goods')->select($where);
         $result = array();
         foreach ($cate as $k => $v) {
-            $goods = Dever::db('info', 'goods')->select(array('cate_id' => $v['id']));
+            $goods = Dever::db('info', 'goods')->select(array('cate_id' => $v['id'], 'status' => 1));
             if ($goods) {
                 foreach ($goods as $k1 => $v1) {
                     $sku = Dever::db('info_sku', 'goods')->select(array('info_id' => $v1['id']));
@@ -110,4 +118,19 @@ class Manage extends Auth
         $cate = array_merge($cate, Dever::db('cate', 'goods')->select([]));
         return $cate;
     }
+
+    # 展示订单金额
+    public function showGoodsInfo($goods, $goods_id, $sku_id)
+    {
+        $goods = Dever::db('info', 'goods')->find($goods_id);
+        $sku = Dever::db('info_sku', 'goods')->find($sku_id);
+        $result = $goods['name'];
+        if ($sku['key'] != -1) {
+            $spec = Dever::db('info_spec_value', 'goods')->find(array('id' => array('in', $sku['key'])), array('col' => 'id,group_concat(value) as name', 'group' => 'info_id'));
+            if ($spec) {
+                $result .= '-' . $spec['name'];
+            }
+        }
+        return $result;
+    }
 }

+ 6 - 5
src/yuan/goods/table/cate.php

@@ -22,13 +22,14 @@ return array
     ),
     'default' => array
     (
-        'field' => 'name,`key`,rule',
+        'field' => 'name,`key`,rule,cdate',
         'value' => array
         (
-            '"话费","hf","/^1\d{10}$/"',
-            '"中石化","zsh","/^1\d{18}$/"',
-            '"中石油","zsy","/^(?:7|9)\d{15}$/"',
-            '"权益卡","qyk",""',
+            '"话费","hf","/^1\d{10}$/",' . DEVER_TIME,
+            '"中石化","zsh","/^1\d{18}$/",' . DEVER_TIME,
+            '"中石油","zsy","/^(?:7|9)\d{15}$/",' . DEVER_TIME,
+            '"权益卡","qyk","",' . DEVER_TIME,
+            '"卡密","km","",' . DEVER_TIME,
         ),
         'num' => 1,
     ),

+ 4 - 0
src/yuan/goods/table/manage/info.php

@@ -5,6 +5,10 @@ return array
     (
         'field'      => array
         (
+            'id' => array
+            (
+                'name' => '商品ID',
+            ),
             'name',
             'cate_id',
             'status' => array