dever 6 年之前
父节点
当前提交
7451393eec
共有 3 个文件被更改,包括 79 次插入6 次删除
  1. 1 1
      service/src/Base.php
  2. 54 5
      source/database/info.php
  3. 24 0
      source/lib/Manage.php

+ 1 - 1
service/src/Base.php

@@ -4,7 +4,7 @@ use Dever;
 
 class Base
 {
-    private $key = 'jmbuybuybuy';
+    public $key = 'jmbuybuybuy';
 
 	public function __construct()
     {

+ 54 - 5
source/database/info.php

@@ -14,6 +14,23 @@ $link = function()
 	return $array;
 };
 
+$cate = function()
+{
+	$array = array();
+	$info = Dever::db('journal/cate')->state();
+	if($info)
+	{
+		$array += $info;
+	}
+	return $array;
+};
+
+$type = array
+(
+	1 => '购买小刊',
+	2 => '购买小刊兑换码',
+);
+
 return array
 (
 	# 表名
@@ -21,6 +38,11 @@ return array
 	# 显示给用户看的名称
 	'lang' => '渠道管理',
 	'order' => 10,
+	'end' => array
+	(
+		'insert' => 'source/lib/manage.updateCode',
+		'update' => 'source/lib/manage.updateCode',
+	),
 	# 数据结构
 	'struct' => array
 	(
@@ -46,6 +68,32 @@ return array
 			'list'		=> true,
 		),
 
+		'cate_id'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '小刊分类',
+			'default' 	=> '1',
+			'desc' 		=> '小刊分类',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $cate,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '类型',
+			'default' 	=> '1',
+			'desc' 		=> '类型',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $type,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
+
 		'link_id'		=> array
 		(
 			'type' 		=> 'int-11',
@@ -61,13 +109,14 @@ return array
 
 		'code'		=> array
 		(
-			'type' 		=> 'varchar-200',
-			'name' 		=> '渠道二维码',
+			'type' 		=> 'varchar-500',
+			'name' 		=> '渠道链接',
 			'default' 	=> '',
-			'desc' 		=> '渠道二维码',
+			'desc' 		=> '渠道链接',
 			'match' 	=> 'option',
 			//'update'	=> 'textarea',
 			//'list'		=> 'Dever::load("source/lib/manage.show", "{id}")',
+			'list'		=> true,
 		),
 
 		'state'		=> array
@@ -102,8 +151,8 @@ return array
 
 	'manage' => array
 	(
-		'delete' => false,
-		'edit' => false,
+		//'delete' => false,
+		//'edit' => false,
 		# 列表
 		'list_buttons' => array
 		(

+ 24 - 0
source/lib/Manage.php

@@ -18,4 +18,28 @@ class Manage
 
 		return '';
 	}
+
+	public function updateCode($id, $name, $param)
+	{
+		$cate_id = Dever::param('cate_id', $param);
+		$type = Dever::param('type', $param);
+		$link_id = Dever::param('link_id', $param);
+		$link = Dever::db('source/link')->one($link_id);
+		if (!$link) {
+			$link['link'] = Dever::url('home', 'service');
+		}
+
+		$send['cate'] = $cate_id;
+    	$send['source'] = $id;
+        $send['type'] = $type;
+        $send['seller'] = 1;
+        $key = Dever::load('service/base')->key;
+        $param = array();
+        $param['p'] = Dever::encode(Dever::json_encode($send), $key);
+
+    	$param = http_build_query($param);
+    	$url = $link['link'] . '?' . $param;
+
+    	Dever::db('source/info')->update(array('where_id' => $id, 'code' => $url));
+	}
 }