dever il y a 3 ans
Parent
commit
2a23244c4b

+ 25 - 4
app/shop/database/coupon.php

@@ -1,5 +1,7 @@
 <?php
 
+$shop_id = Dever::input('search_option_shop_id');
+
 $coupon = function()
 {
     $array = array();
@@ -19,6 +21,7 @@ return array
     # 显示给用户看的名称
     'lang' => '优惠券设置',
     'menu' => false,
+    'check' => 'shop_id,coupon_id',
     # 数据结构
     'struct' => array
     (
@@ -87,8 +90,7 @@ return array
             'desc'      => '发放数量',
             'match'     => 'is_string',
             'update'    => 'text',
-            'list_name' => '当前库存',
-            'list'        => '{num}-{act_num}',
+            'list'        => true,
         ),
 
         'act_num'      => array
@@ -99,6 +101,8 @@ return array
             'desc'      => '已用数量',
             'match'     => 'is_string',
             //'update'    => 'text',
+            'list_name' => '剩余数量',
+            'list'      => '{num}-{act_num}',
         ),
 
         'state'     => array
@@ -125,12 +129,29 @@ return array
 
     'manage' => array
     (
-        
+        'button' => array
+        (
+            '分享领取优惠券活动设置' => array('fast', 1, 'coupon_act_1&where_id='.$shop_id.'&search_option_shop_id='.$shop_id),
+        ),
     ),
 
     'request' => array
     (
-        # 更新售出量
+        'getData' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'shop_id' => 'yes',
+                'coupon_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('id' => 'desc'),
+            'col' => '*,num-act_num as total',
+        ),
+
+        # 更新使用量
         'updateNum' => array
         (
             'type' => 'update',

+ 95 - 0
app/shop/database/coupon_act_1.php

@@ -0,0 +1,95 @@
+<?php
+
+$shop_id = Dever::input('search_option_shop_id');
+
+$coupon = function() use($shop_id)
+{
+    $array = array();
+    $info = Dever::load('shop/lib/coupon')->getAll($shop_id);
+    
+    if($info)
+    {
+        $array += $info;
+    }
+    return $array;
+};
+
+return array
+(
+    # 表名
+    'name' => 'coupon_act_1',
+    # 显示给用户看的名称
+    'lang' => '活动优惠券设置',
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '所属门店',
+            'default'   => '',
+            'desc'      => '所属门店',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => $shop_id,
+            'list'      => 'Dever::load("shop/info-find#name", {shop_id})',
+        ),
+
+        'shop_coupon_id'      => array
+        (
+            'type'      => 'varchar-500',
+            'name'      => '勾选参与活动可发放的优惠券',
+            'default'   => '',
+            'desc'      => '勾选参与活动可发放的优惠券',
+            'match'     => 'is_string',
+            'update'    => 'checkbox',
+            'option'    => $coupon,
+            'list'		=> 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
+    (
+        
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 31 - 39
app/shop/database/info.php

@@ -13,10 +13,16 @@ $type = array
     2 => '平台店',
 );
 
+$act = array
+(
+    1 => '分享领取优惠券活动',
+    2 => '推广员营销活动',
+);
+
 $yes = array
 (
-    1 => '是',
-    2 => '否',
+    1 => '可用',
+    2 => '不可用',
 );
 
 $open = array
@@ -40,6 +46,7 @@ return array
     'lang' => '门店列表',
     # 后台菜单排序
     'order' => 99,
+    'act' => $act,
 
     'end' => array
     (
@@ -406,62 +413,46 @@ return array
             'place'     => '660*660',
         ),
 
-        /*
         'hr4'       => array
         (
-            'name'      => '优惠券设置',
+            'name'      => '其他设置',
             'class'     => '',//本项必须填写
             'attr'      => '',
         ),
 
-        'coupon_city'        => array
-        (
-            'type'      => 'tinyint-1',
-            'name'      => '是否参数同城活动',
-            'default'   => '1',
-            'desc'      => '是否参数同城活动',
-            'match'     => 'is_numeric',
-            'update'    => 'radio',
-            'option'    => $yes,
-            //'search'    => 'select',
-        ),
-
-        'coupon_share'        => array
+        'type'        => array
         (
-            'type'      => 'tinyint-1',
-            'name'      => '是否参与分享活动',
+            'type'      => 'int-11',
+            'name'      => '门店类型-自营为平台店,当没有找到加盟店时,将自动获取平台店',
             'default'   => '1',
-            'desc'      => '是否参与分享活动',
+            'desc'      => '门店类型',
             'match'     => 'is_numeric',
             'update'    => 'radio',
-            'option'    => $yes,
-            //'search'    => 'select',
+            'option'    => $type,
+            'search'    => 'select',
+            'list'      => true,
         ),
 
-        'coupon_tg'        => array
+        'coupon_city'        => array
         (
-            'type'      => 'tinyint-1',
-            'name'      => '是否参与推广员活动',
-            'default'   => '1',
-            'desc'      => '是否参与推广员活动',
+            'type'      => 'int-11',
+            'name'      => '优惠券是否同城可用',
+            'default'   => '2',
+            'desc'      => '优惠券是否同城可用',
             'match'     => 'is_numeric',
             'update'    => 'radio',
             'option'    => $yes,
-            //'search'    => 'select',
         ),
-        */
 
-        'type'        => array
+        'act'        => array
         (
-            'type'      => 'int-11',
-            'name'      => '门店类型-自营为平台店,当没有找到加盟店时,将自动获取平台店',
-            'default'   => '1',
-            'desc'      => '门店类型',
+            'type'      => 'varchar-500',
+            'name'      => '参与活动',
+            'default'   => '',
+            'desc'      => '参与活动',
             'match'     => 'is_numeric',
-            'update'    => 'radio',
-            'option'    => $type,
-            'search'    => 'select',
-            'list'      => true,
+            'update'    => 'checkbox',
+            'option'    => $act,
         ),
 
         'status'        => array
@@ -506,13 +497,14 @@ return array
         (
             'delete' => '删除',
 
-
             'br11' => array('<br /><br />'),
 
             'add12' => array('分配工厂', '"info&where_id={id}&col=factory&oper_save_jump=info&oper_table=info&oper_parent=info"'),
 
             'add13' => array('分配仓库', '"info&where_id={id}&col=store&oper_save_jump=info&oper_table=info&oper_parent=info"'),
 
+            'fast' => array('设置活动', '"info&where_id={id}&col=coupon_city,act&oper_save_jump=info&oper_table=info&oper_parent=info"'),
+
             'br1' => array('<br /><br />'),
 
             'add1' => array('批量设置商品', '"info&where_id={id}&col=goods&oper_save_jump=info&oper_table=info&oper_parent=info"'),

+ 23 - 0
app/shop/lib/Coupon.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace Shop\Lib;
+
+use Dever;
+
+class Coupon
+{
+    public function getAll($shop_id)
+    {
+        $data = Dever::db('shop/coupon')->getData(array('shop_id' => $shop_id));
+
+        if ($data) {
+        	foreach ($data as $k => $v) {
+        		$info = Dever::db('goods/coupon')->one($v['coupon_id']);
+
+        		$data[$k]['name'] = $info['name'];
+        	}
+        }
+
+        return $data;
+    }
+}