dever 3 년 전
부모
커밋
8bd0480b9d

+ 68 - 0
app/card/database/add.php

@@ -0,0 +1,68 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'add',
+    # 显示给用户看的名称
+    'lang' => '新增礼品卡',
+    'order' => 1,
+    'menu' => false,
+    'end' => array
+    (
+        'update' => 'card/lib/manage.createCard',
+        'insert' => 'card/lib/manage.createCard',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '系统ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'value'     => Dever::input('where_id'),
+        ),
+
+        'info_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '礼品卡',
+            'default'   => '',
+            'desc'      => '礼品卡',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id'),
+            'list'      => 'Dever::load("card/info-find#name", "{info_id}")',
+        ),
+        
+        'num'       => array
+        (
+            'type'      => 'varchar-32',
+            'name'      => '生成数量',
+            'default'   => '',
+            'desc'      => '请输入生成数量',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'value'     => '',
+        ),
+
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '录入时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+        ),
+    ),
+
+    'manage' => array
+    (
+        # 后台管理不要列表页
+        'list' => 'update',
+    ),
+);

+ 175 - 0
app/card/database/code.php

@@ -0,0 +1,175 @@
+<?php
+$status = array
+(
+    1 => '已生成',
+    2 => '未兑换',
+    3 => '已使用',
+    4 => '已完成',
+    5 => '已过期',
+);
+
+return array
+(
+    # 表名
+    'name' => 'code',
+    # 显示给用户看的名称
+    'lang' => '礼品卡卡号',
+    'status' => $status,
+    # 后台菜单排序
+    'order' => 99,
+    'menu'  => false,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+        
+        'info_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '礼品卡',
+            'default'   => '',
+            'desc'      => '礼品卡',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id'),
+            'list'      => 'Dever::load("card/info-find#name", "{info_id}")',
+        ),
+
+        'card'      => array
+        (
+            'type'      => 'varchar-32',
+            'name'      => '卡号',
+            'default'   => '',
+            'desc'      => '卡号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'        => true,
+        ),
+
+        'status'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '使用状态',
+            'default'   => '1',
+            'desc'      => '使用状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'update'    => 'select',
+            'list'      => true,
+            //'mul'       => array(1 => '恢复使用', 4 => '已作废'),
+        ),
+
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户信息',
+            'default'   => '0',
+            'desc'      => '用户信息',
+            'match'     => 'is_numeric',
+            'list_name' => '兑换信息',
+            //'list'      => 'Dever::load("goods/lib/manage.showUserInfo", "{id}")',
+        ),
+
+        'shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '兑换门店',
+            'default'   => '',
+            'desc'      => '兑换门店',
+            'match'     => 'is_numeric',
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单表id',
+            'default'   => '',
+            'desc'      => '订单表id',
+            'match'     => 'is_numeric',
+        ),
+
+        'ddate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '兑换时间',
+            'match'     => 'option',
+            'default'   => '',
+            'desc'      => '',
+            //'search'  => 'date',
+        ),
+
+        'edate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '失效时间',
+            'match'     => 'is_numeric',
+            'default'   => '',
+            'desc'      => '',
+            'list'      => 'date("Y-m-d H:i:s", {edate})',
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '生成时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'excel' => true,
+        'delete' => false,
+        'edit' => false,
+        'insert' => false,
+       // 'mul' => '{type} == 1 || {type} == 4',
+
+        'list_button' => array
+        (
+            //'oper' => array('作废', 'goods/lib/manage.drop?id={id}', '{type} == 1'),
+
+            //'oper2' => array('恢复使用', 'goods/lib/manage.recovery?id={id}', '{type} == 4'),
+        ),
+    ),
+
+    # 索引
+    'index' => array
+    (
+        # 索引名 => 索引id
+        1 => array
+        (
+            'card' => 'card'
+        ),
+        'version' => 1,
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 166 - 0
app/card/database/info.php

@@ -0,0 +1,166 @@
+<?php
+$status = Dever::config('base')->status;
+$type = array
+(
+    1 => '永久有效',
+    2 => '固定天数',
+);
+
+$card_type = array
+(
+    1 => '全数字',
+    2 => '全小写',
+    3 => '全大写',
+    4 => '大小写组合',
+    5 => '数字+大小写组合',
+);
+
+return array
+(
+    # 表名
+    'name' => 'info',
+    # 显示给用户看的名称
+    'lang' => '礼品卡配置',
+    # 后台菜单排序
+    'order' => 99,
+    # 数据结构
+    'struct' => array
+    (
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+        ),
+        
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '礼品卡名称',
+            'default'   => '',
+            'desc'      => '请输入礼品卡名称',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'value'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '面值',
+            'default'   => '100',
+            'desc'      => '面值',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'type'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '礼品卡类型',
+            'default'   => '1',
+            'desc'      => '礼品卡类型',
+            'match'     => 'is_numeric',
+            'update'    => 'radio',
+            'option'    => $type,
+            'control'   => 'type',
+        ),
+
+        'day'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '有效天数',
+            'default'   => '7',
+            'desc'      => '有效天数',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'show'      => 'type=2',
+        ),
+
+        'card_type'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '卡号生成规则',
+            'default'   => '3',
+            'desc'      => '卡号生成规则',
+            'match'     => 'is_numeric',
+            'update'    => 'select',
+            'option'    => $card_type,
+        ),
+
+        'card_prefix'        => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '卡号前缀-前缀不占用卡号长度的位数,如卡号长度填写14,卡号前缀为Q,则生成卡号前缀+14位随机数',
+            'default'   => '',
+            'desc'      => '卡号前缀',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+
+        'card_len'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '卡号长度',
+            'default'   => '14',
+            'desc'      => '卡号长度',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
+            'match'     => 'is_numeric',
+            //'update'  => 'select',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+            'edit'      => true,
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '录入时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            'insert'    => true,
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+    	'list_button' => array
+        (
+            'fast' => array('生成卡号', '"add&where_id=1&search_option_info_id={id}"', '{status} == 1'),
+
+            'list1' => array('卡号列表', '"code&search_option_info_id={id}&oper_table=info"'),
+        ),
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 8 - 0
app/card/index.php

@@ -0,0 +1,8 @@
+<?php
+
+define('DEVER_APP_NAME', 'card');
+define('DEVER_APP_LANG', '礼品卡管理');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 90);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-gift');
+include(DEVER_APP_PATH . '../boot.php');

+ 68 - 0
app/card/lib/Manage.php

@@ -0,0 +1,68 @@
+<?php
+
+namespace Card\Lib;
+
+use Dever;
+
+class Manage
+{
+    /**
+     * 创建兑换码
+     *
+     * @return mixed
+     */
+    public function createCard($id, $name, $param)
+    {
+        $num = Dever::param('num', $param);
+        $info_id = Dever::param('info_id', $param);
+
+        $info = Dever::db('card/info')->find($info_id);
+
+        if ($info && $num > 0) {
+            for ($i = 0; $i< $num;$i++) {
+                $this->createCode($info);
+            }
+        }
+    }
+
+    private function createCode($info)
+    {
+        # 生成卡号
+        $card = $info['card_prefix'] . Dever::rand($info['card_len'], $info['card_type'] - 1);
+        $where['card'] = $card;
+        $state = Dever::db('card/code')->find($where);
+
+        if (!$state) {
+            $where['card_id'] = $info['id'];
+            if ($info['type'] == 1) {
+                $info['day'] = 3650;
+            }
+
+            $where['edate'] = time() + ($info['day']*86400);
+            Dever::db('card/code')->insert($where);
+        } else {
+            $this->createCode($info);
+        }
+    }
+
+    /**
+     * 作废
+     *
+     * @return mixed
+     */
+    public function drop_api($id)
+    {
+        $update['where_id'] = $id;
+        $update['type'] = 4;
+        Dever::db('card/code')->update($update);
+        return 'ok';
+    }
+
+    public function recovery_api($id)
+    {
+        $update['where_id'] = $id;
+        $update['type'] = 1;
+        Dever::db('card/code')->update($update);
+        return 'ok';
+    }
+}

+ 3 - 6
app/goods/database/add_card.php

@@ -1,8 +1,5 @@
 <?php
-$seller = function()
-{
-    return Dever::db('code/seller')->state();
-};
+
 return array
 (
     # 表名
@@ -32,9 +29,9 @@ return array
         'card_id'        => array
         (
             'type'      => 'int-11',
-            'name'      => '品卡',
+            'name'      => '品卡',
             'default'   => '',
-            'desc'      => '品卡',
+            'desc'      => '品卡',
             'match'     => 'is_numeric',
             'update'    => 'hidden',
             'value'     => Dever::input('search_option_card_id'),

+ 2 - 1
app/goods/database/card.php

@@ -28,9 +28,10 @@ return array
     # 表名
     'name' => 'card',
     # 显示给用户看的名称
-    'lang' => '品卡配置',
+    'lang' => '品卡配置',
     # 后台菜单排序
     'order' => 99,
+    'menu' => false,
     # 数据结构
     'struct' => array
     (

+ 1 - 1
app/goods/database/card_code.php

@@ -13,7 +13,7 @@ return array
     # 表名
     'name' => 'card_code',
     # 显示给用户看的名称
-    'lang' => '品卡卡密',
+    'lang' => '品卡卡密',
     'status' => $status,
     # 后台菜单排序
     'order' => 99,