dever 6 years ago
parent
commit
1a26458890

+ 12 - 0
code/database/info.php

@@ -163,6 +163,18 @@ return array
 			'list'		=> 'Dever::load("code/lib/manage.showUserInfo", "{create_uid}", "{uid}", "{ldate}")',
 		),
 
+		'order_id'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '付款订单id',
+            'default'   => '',
+            'desc'      => '付款订单id',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            //'list'        => true,
+            //'list'        => '"{order_id}" ? "{order_id}" : "{code}"',
+        ), 
+
 		'state'		=> array
 		(
 			'type' 		=> 'tinyint-1',

+ 5 - 2
code/lib/Core.php

@@ -6,13 +6,13 @@ use Dever;
 
 class Core
 {
-	public function createCode($product, $cate_id, $product_id, $seller_id, $product_num = 1, $create_uid = -1)
+	public function createCode($product, $cate_id, $product_id, $seller_id, $product_num = 1, $create_uid = -1, $order_id = false)
 	{
 		$code = Dever::rand(8, 0);
 		$data['code'] = $code;
 		$total = Dever::db('code/info')->total($data);
 		if ($total > 0) {
-			return $this->createCode($product, $cate_id, $product_id, $seller_id, $product_num, $create_uid);
+			return $this->createCode($product, $cate_id, $product_id, $seller_id, $product_num, $create_uid, $order_id);
 		}
 		
 		//$data['product'] = $product;
@@ -21,6 +21,9 @@ class Core
 		$data['seller_id'] = $seller_id;
 		$data['product_num'] = $product_num;
 		$data['type'] = 1;
+		if ($order_id) {
+			$data['order_id'] = $order_id;
+		}
 		if ($create_uid > 0) {
 			$data['create_uid'] = $create_uid;
 		}

+ 12 - 0
journal/database/buy_num.php

@@ -96,6 +96,18 @@ return array
             //'update'    => 'text',
         ),
 
+        'code'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '生成兑换码数量-直接填写购买当前本数所能得到的兑换码数,默认为1',
+            'default'   => '1',
+            'desc'      => '生成兑换码数量',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
         'reorder'       => array
         (
             'type'      => 'int-11',

+ 11 - 1
journal/lib/Pay.php

@@ -35,11 +35,21 @@ class Pay
                 if ($order['type'] == 3) {
                     # 购买兑换码
                     $product_num = 1;
+                    $code_num = 1;
                     if ($order['buy_id'] > 0) {
                         $buy = Dever::db('journal/buy_num')->one($order['buy_id']);
                         $product_num = $buy['num'];
+                        $code_num = $buy['code'];
+                    }
+                    
+                    if ($code_num > 1) {
+                        $product_num = intval($product_num/$code_num);
+                        for ($i = 0; $i < $code_num; $i++) {
+                            $update['code'] = Dever::load('code/lib/core')->createCode($order['cate_id'] . ',' . $order['product_id'], $order['cate_id'], $order['product_id'], $order['seller_id'], $product_num, $uid, $order['order_id']);
+                        }
+                    } else {
+                        $update['code'] = Dever::load('code/lib/core')->createCode($order['cate_id'] . ',' . $order['product_id'], $order['cate_id'], $order['product_id'], $order['seller_id'], $product_num, $uid, $order['order_id']);
                     }
-                    $update['code'] = Dever::load('code/lib/core')->createCode($order['cate_id'] . ',' . $order['product_id'], $order['cate_id'], $order['product_id'], $order['seller_id'], $product_num, $uid);
                 }
 
                 Dever::db('journal/order')->update($update);

+ 2 - 1
service/assets/mobile/pay.html

@@ -33,7 +33,7 @@
 <script type="text/javascript" src="js/global.js?v=0b04b240"></script><script type="text/javascript" src="js/pay.js?v=0b04b240"></script></body>
 
 </html>
-
+<script type="text/javascript" src="https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js"></script>
 <script>
 function pay(url)
 {
@@ -44,6 +44,7 @@ function pay(url)
 
 $(function()
 {
+    FastClick.attach(document.body);
     $('#open').click(function(){
         $('#layer').show();
     });

+ 4 - 1
service/src/Buy.php

@@ -168,7 +168,10 @@ class Buy extends Base
             }
             
             $config['code'] = '<p>兑换码:'.$order['code'].'</p>';
-            
+            $buy = Dever::db('journal/buy_num')->one($buy_id);
+            if ($buy && $buy['code'] > 1) {
+                $config['code'] = '<p><a href="'.$config['buy'].'">点此查看更多</a></p>';
+            }
         }
 
         return $config;