dever 7 years ago
parent
commit
8cf2e67300
4 changed files with 29 additions and 6 deletions
  1. 1 0
      main/lib/Wechat.php
  2. 1 1
      youzan/database/card.php
  3. 12 1
      youzan/database/card_list.php
  4. 15 4
      youzan/src/Card.php

+ 1 - 0
main/lib/Wechat.php

@@ -269,6 +269,7 @@ class Wechat
 	 */
 	public function curl($method, $param = array(), $alert = true)
 	{
+		//return array();
 		if (is_string($param)) {
 			$result = json_decode(Dever::curl($param), true);
 		} else {

+ 1 - 1
youzan/database/card.php

@@ -17,7 +17,7 @@ return array
 	# 表名
 	'name' => 'card',
 	# 显示给用户看的名称
-	'lang' => '优惠券管理',
+	'lang' => '生成优惠券',
 	'order' => 100,
 	'check' => 'key',
 	# 数据结构

+ 12 - 1
youzan/database/card_list.php

@@ -21,7 +21,7 @@ return array
 	# 表名
 	'name' => 'card_list',
 	# 显示给用户看的名称
-	'lang' => '单个优惠券列表',
+	'lang' => '生成优惠券列表',
 	'order' => 90,
 	# 数据结构
 	'struct' => array
@@ -59,6 +59,17 @@ return array
 			'list'		=> 'Dever::load("youzan/card-one#name", {card_id})',
 		),
 
+		'index'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '索引值',
+			'default' 	=> '1',
+			'desc' 		=> '索引值',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'text',
+			'list'		=> true,
+		),
+
 		'user'		=> array
 		(
 			'type' 		=> 'varchar-120',

+ 15 - 4
youzan/src/Card.php

@@ -116,7 +116,6 @@ class Card
 
 			$info['expire_notice'] = $info['expire_notice'] - 1;
 			$info['fixed_begin_term'] = 0;
-			//$info['fixed_term'] = 0;
 
 			if ($info['fixed_term']) {
 				$info['date_type'] = 2;
@@ -172,8 +171,11 @@ class Card
 			$this->total();
 		} else {
 			$info = Dever::db('youzan/card')->one($id);
-			//$data['response']['promocard']['group_id'] = 1;
-			//$data['response']['promocard']['fetch_url'] = rand(1,100);
+			/*
+			$data['response']['promocard']['group_id'] = 1;
+			$data['response']['promocard']['fetch_url'] = rand(1,100);
+			$data['response']['promocard']['total'] = 100;
+			*/
 			if ($info && isset($data['response']['promocard']['group_id'])) {
 				$update['card_id'] = $info['id'];
 				$update['project_id'] = $info['project_id'];
@@ -183,7 +185,16 @@ class Card
 				$update['code_url'] = $data['response']['promocard']['fetch_url'];
 				$update['cdate'] = time();
 				$update['result'] = json_encode($data);
-				Dever::db('youzan/card_list')->insert($update);
+				if (isset($data['response']['promocard']['total']) && $data['response']['promocard']['total'] > 0) {
+					$total = $data['response']['promocard']['total'];
+					for ($i = 1; $i <= $total; $i++) {
+						$update['index'] = $i;
+						Dever::db('youzan/card_list')->insert($update);
+					}
+				} else {
+					$update['index'] = 1;
+					Dever::db('youzan/card_list')->insert($update);
+				}
 			}
 		}
 	}