dever %!s(int64=5) %!d(string=hai) anos
pai
achega
b98cad3276
Modificáronse 4 ficheiros con 59 adicións e 152 borrados
  1. 1 30
      database/info.php
  2. 39 1
      database/order.php
  3. 0 98
      database/rebate.php
  4. 19 23
      lib/Pay.php

+ 1 - 30
database/info.php

@@ -26,24 +26,6 @@ $shop = function()
 	return $array;
 };
 
-$rebate = function()
-{
-	$array = array
-	(
-		'-1' => array
-		(
-			'id' => '-1',
-			'name' => '无佣金',
-		),
-	);
-	$info = Dever::db('goods/rebate')->state();
-	if($info)
-	{
-		$array += $info;
-	}
-	return $array;
-};
-
 $type = array
 (
 	1 => '自营',
@@ -145,17 +127,6 @@ $config = array
 			'option'	=> $mode,
 		),
 
-		'rebate_id'		=> array
-		(
-			'type' 		=> 'int-11',
-			'name' 		=> '佣金',
-			'default' 	=> '-1',
-			'desc' 		=> '佣金',
-			'match' 	=> 'is_numeric',
-			'update'	=> 'select',
-			'option'	=> $rebate,
-		),
-
 		'link'		=> array
 		(
 			'type' 		=> 'varchar-800',
@@ -422,7 +393,7 @@ $config = array
 		),
 	),
 
-# 索引
+	# 索引
 	'index' => array
 	(
 		1 => array

+ 39 - 1
database/order.php

@@ -22,10 +22,28 @@ $config = array
 			//'list'		=> true,
 		),
 
+		'parent_uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '邀请人',
+            'default'   => '0',
+            'desc'      => '请选择用户',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            //'search'  => 'select',
+            'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+            'list'      => '{parent_uid} > 0 ? Dever::load("passport/user-one#username", {parent_uid}) : "无邀请人"',
+        ),
+
 		'uid'       => array
         (
             'type'      => 'int-11',
-            'name'      => '用户名',
+            'name'      => '购买人',
             'default'   => '0',
             'desc'      => '请选择用户',
             'match'     => 'is_numeric',
@@ -40,6 +58,26 @@ $config = array
             'list'      => '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
         ),
 
+        'type' 		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '所属数据源',
+			'default' 	=> '',
+			'desc' 		=> '所属数据源',
+			'match' 	=> 'is_string',
+			'list'		=> true,
+		),
+		
+		'type_id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '数据源id',
+			'default' 	=> '',
+			'desc' 		=> '数据源id',
+			'match' 	=> 'is_numeric',
+			'list'		=> true,
+		),
+
 		'info_id'		=> array
 		(
 			'type' 		=> 'int-11',

+ 0 - 98
database/rebate.php

@@ -1,98 +0,0 @@
-<?php
-$type = array
-(
-    1 => '数值',
-    2 => '百分比',
-);
-return array
-(
-    # 表名
-    'name' => 'rebate',
-    # 显示给用户看的名称
-    'lang' => '佣金配置',
-    'order' => 1,
-
-    # 数据结构
-    'struct' => array
-    (
-        'id'        => array
-        (
-            'type'      => 'int-11',
-            'name'      => 'ID',
-            'default'   => '',
-            'desc'      => '',
-            'match'     => 'is_numeric',
-            'search'    => 'order',
-            //'list'        => true,
-        ),
-
-        'name'      => array
-        (
-            'type'      => 'varchar-800',
-            'name'      => '佣金标题',
-            'default'   => '',
-            'desc'      => '标题',
-            'match'     => 'is_string',
-            'update'    => 'text',
-            'search'    => 'fulltext',
-            'list'        => true,
-            //'edit'        => true,
-        ),
-
-        'type'      => array
-        (
-            'type'      => 'tinyint-1',
-            'name'      => '佣金类型',
-            'default'   => '1',
-            'desc'      => '佣金类型',
-            'match'     => 'option',
-            'update'    => 'radio',
-            'option'    => $type,
-            'list'      => true,
-            'search'    => 'select',
-        ),
-        
-        'price'     => array
-        (
-            'type'      => 'varchar-500',
-            'name'      => '佣金金额-如果是百分比类型,这里如果填的是10,那就是商品支付价格的10%,填写数字就是一级,支持多层层级设置,1:20,2:30 就是1级202级30',
-            'default'   => '',
-            'desc'      => '佣金金额',
-            'match'     => 'is_string',
-            'update'    => 'textarea',
-            'list'      => true,
-        ),
-
-        'state'     => array
-        (
-            'type'      => 'tinyint-1',
-            'name'      => '状态',
-            'default'   => '1',
-            'desc'      => '请选择状态',
-            'match'     => 'is_numeric',
-        ),
-        
-        'cdate'     => array
-        (
-            'type'      => 'int-11',
-            'name'      => '录入时间',
-            'match'     => array('is_numeric', DEVER_TIME),
-            'desc'      => '',
-            # 只有insert时才生效
-            'insert'    => true,
-            'list'      => 'date("Y-m-d H:i:s", {cdate})',
-        ),
-    ),
-
-    'manage' => array
-    (
-        //'delete' => false,
-        //'edit' => false,
-        //'insert' => false,
-    ),
-
-    'request' => array
-    (
-        
-    )
-);

+ 19 - 23
lib/Pay.php

@@ -9,7 +9,7 @@ use Dever;
 class Pay
 {
     # 发起支付
-	public function action($uid, $id, $sku, $num, $source)
+	public function action($parent_uid, $uid, $id, $sku, $num, $source, $type = false, $type_id = false)
     {
         if (!$uid) {
             Dever::alert('错误的用户信息');
@@ -43,6 +43,18 @@ class Pay
         	$account_id = 1;
         }
         
+        if ($parent_uid) {
+            $order_data['parent_uid'] = $parent_uid;
+        }
+
+        if ($type) {
+            $order_data['type'] = $type;
+        }
+
+        if ($type_id) {
+            $order_data['type_id'] = $type_id;
+        }
+        
         $order_data['uid'] = $uid;
         $order_data['status'] = 1;
         $order_data['info_id'] = $goods['id'];
@@ -129,16 +141,17 @@ class Pay
                 }
 
                 # 增加积分
-                Dever::score($order['uid'], 'buy_goods', '购买商品');
+                if ($order['parent_uid'] > 0) {
+                    $uid = $order['parent_uid'] . '_' . $order['uid']
+                } else {
+                    $uid = $order['uid'];
+                }
+                Dever::score($uid, 'buy_my_goods', '购买自营商品', false, false, false, $order['type'], $order['type_id']);
 
                 # 发消息
                 if (Dever::project('message')) {
                     Dever::load('message/lib/data')->push(-1, $order['uid'], '购买提醒', '购买成功', 11);
                 }
-
-                # 增加上级佣金
-                $cash = $order['cash'] * $order['num'];
-                $this->rebate($order['uid'], $order['info_id'], $cash);
             }
 
 
@@ -150,23 +163,6 @@ class Pay
         return 'ok';
     }
 
-    # 增加上级佣金
-    public function rebate($uid, $goods_id, $cash)
-    {
-        $goods = Dever::db('goods/info')->one($goods_id);
-        $rebate_id = $goods['rebate_id'];
-        if ($rebate_id > 0) {
-            $rebate = Dever::db('goods/rebate')->one($rebate_id);
-            if ($rebate) {
-                if ($rebate['type'] == 1) {
-                    
-                } else {
-                    
-                }
-            }
-        }
-    }
-
     # 生成订单号
     public function getOrderId()
     {