dever 3 rokov pred
rodič
commit
edb83e131f

+ 16 - 2
app/card/database/info.php

@@ -128,6 +128,20 @@ return array
             'edit'      => true,
         ),
 
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序-数值越大越靠前',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'  => 'text',
+            'search'    => 'order',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => true,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -153,9 +167,9 @@ return array
     (
     	'list_button' => array
         (
-            'fast' => array('生成卡号', '"add&where_id=1&search_option_info_id={id}"', '{status} == 1'),
+            //'fast' => array('生成卡号', '"add&where_id=1&search_option_info_id={id}"', '{status} == 1'),
 
-            'list1' => array('卡号列表', '"code&search_option_info_id={id}&oper_table=info"'),
+            //'list1' => array('卡号列表', '"code&search_option_info_id={id}&oper_table=info"'),
         ),
     ),
 

+ 74 - 58
app/card/database/code.php → app/card/database/order.php

@@ -1,23 +1,22 @@
 <?php
 $status = array
 (
-    1 => '已生成',
-    2 => '未兑换',
-    3 => '已使用',
+    1 => '待支付',
+    2 => '待发货',
+    3 => '待收货',
     4 => '已完成',
-    5 => '已过期',
+    5 => '已取消',
 );
 
 return array
 (
     # 表名
-    'name' => 'code',
+    'name' => 'order',
     # 显示给用户看的名称
-    'lang' => '礼品卡卡号',
+    'lang' => '礼品卡订单',
     'status' => $status,
     # 后台菜单排序
-    'order' => 99,
-    'menu'  => false,
+    'order' => 100,
     # 数据结构
     'struct' => array
     (
@@ -33,91 +32,108 @@ return array
             'order'     => 'desc',
         ),
         
-        'info_id'        => array
+        'uid'       => array
         (
             'type'      => 'int-11',
-            'name'      => '礼品卡',
-            'default'   => '',
-            'desc'      => '礼品卡',
+            'name'      => '购买人名称',
+            'default'   => '0',
+            'desc'      => '请选择用户',
             'match'     => 'is_numeric',
-            'update'    => 'hidden',
-            'value'     => Dever::input('search_option_info_id'),
-            'list'      => 'Dever::load("card/info-find#name", "{info_id}")',
+            'update'    => 'text',
+            //'search'  => 'select',
+            'search'    => array
+            (
+                'api' => 'passport/user-one',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+            'list'      => 'Dever::load("shop/lib/manage.user", {id})',
         ),
 
-        'card'      => array
+        'mobile'        => array
         (
-            'type'      => 'varchar-32',
-            'name'      => '卡号',
+            'type'      => 'varchar-300',
+            'name'      => '下单手机号',
             'default'   => '',
-            'desc'      => '卡号',
-            'match'     => 'is_string',
-            'update'    => 'text',
+            'desc'      => '手机号',
+            'match'     => 'option',
             'search'    => 'fulltext',
-            'list'        => true,
+            /*
+            'search'    => array
+            (
+                'api' => 'passport/user-select',//接口地址,最好是获取多条数据的地址
+                'col' => 'mobile',//要查询的字段
+                'result' => 'id',//返回的字段
+                'search' => 'uid',//本表的字段,默认为当前的字段
+            ),
+            */
         ),
 
-        'status'      => array
+        'shop_id'      => array
         (
             'type'      => 'int-11',
-            'name'      => '使用状态',
-            'default'   => '1',
-            'desc'      => '使用状态',
+            'name'      => '兑换门店',
+            'default'   => '',
+            'desc'      => '兑换门店',
             'match'     => 'is_numeric',
-            'option'    => $status,
-            'search'    => 'select',
-            'update'    => 'select',
-            'list'      => true,
-            //'mul'       => array(1 => '恢复使用', 4 => '已作废'),
         ),
 
-        'uid'       => array
+        'address_id'      => array
         (
             'type'      => 'int-11',
-            'name'      => '用户信息',
-            'default'   => '0',
-            'desc'      => '用户信息',
+            'name'      => '送货地址',
+            'default'   => '',
+            'desc'      => '送货地址',
             'match'     => 'is_numeric',
-            'list_name' => '兑换信息',
-            //'list'      => 'Dever::load("goods/lib/manage.showUserInfo", "{id}")',
+            //'list'      => 'Dever::load("passport/address-find#address", {address_id})';
         ),
 
-        'shop_id'      => array
+        'order_num'      => array
         (
-            'type'      => 'int-11',
-            'name'      => '兑换门店',
+            'type'      => 'varchar-100',
+            'name'      => '订单号',
             'default'   => '',
-            'desc'      => '兑换门店',
-            'match'     => 'is_numeric',
+            'desc'      => '订单号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'      => true,
         ),
 
-        'order_id'      => array
+        'price'      => array
         (
-            'type'      => 'int-11',
-            'name'      => '订单表id',
-            'default'   => '',
-            'desc'      => '订单表id',
-            'match'     => 'is_numeric',
+            'type'      => 'varchar-50',
+            'name'      => '支付金额',
+            'default'   => '0',
+            'desc'      => '支付金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'        => true,
         ),
 
-        'ddate'     => array
+        'num'        => array
         (
             'type'      => 'int-11',
-            'name'      => '兑换时间',
-            'match'     => 'option',
+            'name'      => '购买数量',
             'default'   => '',
-            'desc'      => '',
-            //'search'  => 'date',
+            'desc'      => '购买数量',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            //'list'        => true,
         ),
 
-        'edate'     => array
+        'status'      => array
         (
             'type'      => 'int-11',
-            'name'      => '失效时间',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '状态',
             'match'     => 'is_numeric',
-            'default'   => '',
-            'desc'      => '',
-            'list'      => 'date("Y-m-d H:i:s", {edate})',
+            'option'    => $status,
+            'search'    => 'select',
+            'update'    => 'select',
+            'list'      => true,
+            //'mul'       => array(1 => '恢复使用', 4 => '已作废'),
         ),
 
         'state'     => array

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

@@ -0,0 +1,166 @@
+<?php
+
+$status = array
+(
+    1 => '正常',
+    2 => '申请退款中',
+    3 => '已取消',
+);
+
+return array
+(
+    # 表名
+    'name' => 'order_card',
+    # 显示给用户看的名称
+    'lang' => '礼品卡子订单',
+    'menu' => false,
+    'status' => $status,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'order_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '订单表id',
+            'default'   => '',
+            'desc'      => '订单表id',
+            'match'     => 'is_numeric',
+        ),
+
+        'card_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '礼品卡名称',
+            'default'   => '',
+            'desc'      => '礼品卡名称',
+            'match'     => 'is_numeric',
+            'list'      => 'Dever::load("card/info-find#name", {card_id})',
+        ),
+
+        'price'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '单价',
+            'default'   => '',
+            'desc'      => '单价',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'        => true,
+        ),
+
+        'num'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买数量',
+            'default'   => '',
+            'desc'      => '购买数量',
+            'match'     => 'is_numeric',
+            'search'    => 'select',
+            'list'        => true,
+        ),
+
+        '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,
+            'search'    => 'date',
+            'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'insert' => false,
+        'delete' => false,
+        //'page_list' => 'sell_order_goods',
+    ),
+
+    'request' => array
+    (
+        # 获取单条数据
+        'getIds' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'uid' => 'yes',
+                'shop_id' => 'yes',
+                'order_id' => 'yes',
+                'status' => 1,
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*|id',
+        ),
+
+        # 获取多条数据
+        'getDataByIds' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'ids' => array('yes-id', 'in'),
+                'uid' => 'yes',
+                'shop_id' => 'yes',
+                'order_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*',
+        ),
+
+        # 获取多条数据
+        'getTotal' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'order_id' => 'yes',
+                'status' => array('yes', 'in'),
+                'state' => 1,
+            ),
+            'type' => 'count',
+            'col' => '*',
+        ),
+    ),
+);

+ 33 - 4
app/card/lib/Manage.php

@@ -6,6 +6,35 @@ use Dever;
 
 class Manage
 {
+    /**
+     * 显示用户信息
+     *
+     * @return mixed
+     */
+    public function showUserInfo($id)
+    {
+        $info = Dever::db('card/order')->find($id);
+        $table = array();
+        if ($info && $info['status'] > 1 && $info['uid'] && $info['uid'] > 0) {
+            $user = Dever::load('passport/user-one', $info['uid']);
+            if ($user) {
+                $table['购买人'] = $user['username'] . '('.$user['mobile'].')';
+                $table['下单时间'] = date('Y-m-d H:i:s', $info['cdate']);
+                $table['支付时间'] = date('Y-m-d H:i:s', $info['pdate']);
+            }
+
+            if ($info['duid'] && $info['duid'] > 0) {
+                $user = Dever::load('passport/user-one', $info['duid']);
+                if ($user) {
+                    $table['领取人'] = $user['username'] . '('.$user['mobile'].')';
+                    $table['兑换时间'] = date('Y-m-d H:i:s', $info['ddate']);
+                }
+            }
+        }
+
+        return Dever::table($table);
+    }
+
     /**
      * 创建兑换码
      *
@@ -30,7 +59,7 @@ class Manage
         # 生成卡号
         $card = $info['card_prefix'] . Dever::rand($info['card_len'], $info['card_type'] - 1);
         $where['card'] = $card;
-        $state = Dever::db('card/code')->find($where);
+        $state = Dever::db('card/order')->find($where);
 
         if (!$state) {
             $where['card_id'] = $info['id'];
@@ -39,7 +68,7 @@ class Manage
             }
 
             $where['edate'] = time() + ($info['day']*86400);
-            Dever::db('card/code')->insert($where);
+            Dever::db('card/order')->insert($where);
         } else {
             $this->createCode($info);
         }
@@ -54,7 +83,7 @@ class Manage
     {
         $update['where_id'] = $id;
         $update['type'] = 4;
-        Dever::db('card/code')->update($update);
+        Dever::db('card/order')->update($update);
         return 'ok';
     }
 
@@ -62,7 +91,7 @@ class Manage
     {
         $update['where_id'] = $id;
         $update['type'] = 1;
-        Dever::db('card/code')->update($update);
+        Dever::db('card/order')->update($update);
         return 'ok';
     }
 }