dever 5 anni fa
parent
commit
c35dac4300

+ 4 - 2
app/collection/database/info.php

@@ -552,6 +552,8 @@ $config = array
 
             'list2' => array('门票', '"buy&search_option_info_id={id}&oper_table=info"' , '{audit} == 1 && {buy} == 1'),
 
+            'list3' => array('项目', '"object&search_option_info_id={id}&oper_table=info"' , '{audit} == 1 && {buy} == 1'),
+
             'br3' => array('<br />'),
 
             'list3' => array('章节', '"page&search_option_info_id={id}&oper_table=info"' , '{audit} == 1'),
@@ -633,7 +635,7 @@ $config = array
         ),
 
         # 更新购买量
-        'addDing' => array
+        'addBuy' => array
         (
             'type' => 'update',
             'where' => array
@@ -642,7 +644,7 @@ $config = array
             ),
             'set' => array
             (
-                'num_up' => array('1', '+='),
+                'num_buy' => array('1', '+='),
             ),
         ),
 

+ 173 - 0
app/collection/database/object.php

@@ -0,0 +1,173 @@
+<?php
+
+# 定义几个常用的选项
+$status = array
+(
+    1 => '在线',
+    2 => '下线',
+);
+
+return array
+(
+    # 表名
+    'name' => 'object',
+    # 显示给用户看的名称
+    'lang' => '购买项目设置',
+    'order' => 100,
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            //'list'        => true,
+        ),
+
+        'info_id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '合集',
+            'default'   => '',
+            'desc'      => '合集',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_info_id')
+        ),
+
+        'name'      => array
+        (
+            'type'      => 'varchar-80',
+            'name'      => '项目名称',
+            'default'   => '',
+            'desc'      => '项目名称',
+            'match'     => 'option',
+            'update'    => 'text',
+            //'search'    => 'fulltext',
+            'list'      => true,
+        ),
+
+        'info'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '项目介绍',
+            'default'   => '',
+            'desc'      => '项目介绍',
+            'match'     => 'option',
+            'update'    => 'textarea',
+            //'search'    => 'fulltext',
+            //'list'      => true,
+        ),
+
+        'avatar'		=> array
+		(
+			'type' 		=> 'varchar-150',
+			'name' 		=> '项目图片-图片尺寸150*150px或等比尺寸,上传大小不能超过2M,支持JPG、PNG、GIF格式,建议上传JPG格式',
+			'default' 	=> '',
+			'desc' 		=> '项目图片',
+			'match' 	=> 'is_string',
+			'update'	=> 'image',
+			'key' 		=> '1',
+			'place'		=> '150',
+		),
+
+		'num_buy'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买数',
+            'default'   => '0',
+            'desc'      => '请填写购买数',
+            'match'     => 'option',
+            'search'    => 'order',
+            'show'      => 'buy=1',
+            'list'      => 'Dever::load("collection/lib/manage.objectNum?id={id}")',
+            'list_name' => '统计数字',
+        ),
+
+        'num_ratio_buy'     => array
+        (
+            'type'      => 'varchar-20',
+            'name'      => '购买系数-用以增加总购买量,系数不能小于等于0,支持两位小数,总购买量=(用户当前购买数+购买基数)*购买系数。',
+            'default'   => '1',
+            'desc'      => '手动增加购买系数',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'show'      => 'buy=1',
+        ),
+
+        'num_add_buy'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '购买基数',
+            'default'   => '0',
+            'desc'      => '手动增加阅读数',
+            'match'     => 'option',
+            'update'    => 'text',
+            'show'      => 'buy=1',
+        ),
+
+        'reorder'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '排序(数值越大越靠前)',
+            'default'   => '1',
+            'desc'      => '请输入排序',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'order',
+            'list_name' => '排序',
+            'list'      => true,
+            'order'     => 'desc',
+            'edit'      => 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
+    (
+       'getAll' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'info_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => '*',
+        ),
+    ),
+);

+ 14 - 2
app/collection/lib/Core.php

@@ -16,7 +16,19 @@ class Core
     protected $parent_page_id;
     protected $page_id;
     protected $key = 'dreamland1985';
-    protected $source = 1;//来源1是h5、2安卓、3ios、4微信小程序
+    /*
+    # 定义全局的系统类型
+    'system_source' => array
+    (
+        1 => 'H5',
+        2 => '安卓',
+        3 => 'ios',
+        4 => 'pc',
+        5 => '微信小程序',
+        6 => '微信公众号',
+    ),
+    */
+    protected $system_source = 1;
 
     public function __construct()
     {
@@ -26,7 +38,7 @@ class Core
         $this->uid = 1;
         $this->user = $this->getUser($this->uid, $this->id);
         $this->user['id'] = $this->uid;
-        $this->source = Dever::input('source');
+        $this->system_source = Dever::input('system_source', 1);
     }
 
     protected function getUser($uid, $collection_id)

+ 29 - 13
app/collection/lib/Manage.php

@@ -26,31 +26,47 @@ class Manage
         $data = Dever::db('collection/info')->one($id);
         $data = Dever::load('collection/api')->ding($data);
 
-        $num_buy = $data['num_buy'];
-        $num_add_buy = $data['num_add_buy'];
-        $num_ratio_buy = $data['num_ratio_buy'];
-
-        $num_view = $data['num_view'];
-        $num_add_view = $data['num_add_view'];
-
-        $buy_num = $data['buy_num'];
-
-        //$html = '订阅本数:('.$buy_num.'+'.$num_add_buy.')*'.$num_ratio_buy.'='.$num_buy.'<br />阅读数:'.$num_view.'+'.$num_add_view.'<br />评论数:'.$num_comment.'<br />';
-
         $cate = Dever::db('collection/cate')->one($data['cate_id']);
         $html = '《' . $cate['name'] . '》<br />';
 
         if ($data['buy'] == 1) {
+
+            $num_buy = $data['num_buy'];
+            $num_add_buy = $data['num_add_buy'];
+            $num_ratio_buy = $data['num_ratio_buy'];
+            $num_buy_total = $data['num_buy_total'];
+
             $html .= '<font style="color:red">收费</font><br />';
-            $html .= '购买数:('.$buy_num.'+'.$num_add_buy.')*'.$num_ratio_buy.'='.$num_buy;
+            $html .= '购买数:('.$num_buy.'+'.$num_add_buy.')*'.$num_ratio_buy.'='.$num_buy_total;
         } else {
+
+            $num_view = $data['num_view'];
+            $num_add_view = $data['num_add_view'];
+            $num_view_total = $num_view + $num_add_view;
+
             $html .= '<font style="color:blue">免费</font><br />';
-            $html .= '阅读数:'.$num_view.'+'.$num_add_view.'='.($num_view+$num_add_view);
+            $html .= '阅读数:'.$num_view.'+'.$num_add_view.'='.$num_view_total;
         }
         
         return $html;
     }
 
+    # 获取数据
+    public function objectNum($id)
+    {
+        $data = Dever::db('collection/object')->one($id);
+        $data = Dever::load('collection/api')->ding($data);
+
+        $num_buy = $data['num_buy'];
+        $num_add_buy = $data['num_add_buy'];
+        $num_ratio_buy = $data['num_ratio_buy'];
+        $num_buy_total = $data['num_buy_total'];
+
+        $html = '购买数:('.$num_buy.'+'.$num_add_buy.')*'.$num_ratio_buy.'='.$num_buy_total;
+        
+        return $html;
+    }
+
 	private function search($table = 'content/article')
 	{
 		$keyword = Dever::input('keyword');

+ 2 - 10
app/collection/src/Api.php

@@ -375,17 +375,9 @@ class Api extends Core
 
     public function ding($data)
     {
+        $data['num_buy_total'] = $data['num_buy'];
         if (isset($data['num_add_buy']) && isset($data['num_ratio_buy'])) {
-
-            if ($data['buy'] == 1) {
-                $data['num_up'] = 0;
-            } else {
-                $data['num_up'] = 0;
-            }
-
-            $data['num_buy'] = $data['num_buy'] + $data['num_up'];
-            $data['buy_num'] = $data['num_buy'];
-            $data['num_buy'] = round(($data['num_buy']+$data['num_add_buy'])*$data['num_ratio_buy']);
+            $data['num_buy_total'] = round(($data['num_buy_total']+$data['num_add_buy'])*$data['num_ratio_buy']);
         }
 
         return $data;

+ 47 - 79
app/user/database/ticket_order.php

@@ -1,18 +1,6 @@
 <?php
-
-$type = array
-(
-    1 => '购买兑换码',
-);
-
 # 系统
-$system = array
-(
-    1 => '小程序',
-    2 => 'H5',
-    3 => 'ios',
-    4 => '安卓',
-);
+$system_source = Dever::config('base')->system_source;
 
 $status = Dever::config('base', 'pay')->pay['status'];
 
@@ -80,9 +68,48 @@ return array
             'update'    => 'text',
             'search'    => 'fulltext',
             //'list'        => true,
-            'list'        => 'Dever::load("user/lib/ticket.getOrderId", "{order_id}", {id})',
+            'list'        => 'Dever::load("user/lib/ticket.getOrderIdAndId", "{order_id}", {id})',
         ), 
 
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户名',
+            'default'   => '',
+            'desc'      => '用户id',
+            'match'     => 'is_numeric',
+            'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+            'update'    => 'text',
+        ),
+
+        'parent_uid'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '邀请人',
+            'default'   => '',
+            'desc'      => '邀请人',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'system_source'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '所属平台',
+            'default'   => '1',
+            'desc'      => '所属平台',
+            'match'     => 'is_numeric',
+            'option'    => $system_source,
+            'update'    => 'radio',
+            'search'    => 'select',
+            'list'      => true,
+        ),
+
         # 仅用于搜索
         'cate_info_search'        => array
         (
@@ -120,12 +147,12 @@ return array
             //'list'        => true,
         ),
 
-        'star_id'        => array
+        'object_id'        => array
         (
             'type'      => 'int-11',
-            'name'      => '人物',
+            'name'      => '项目',
             'default'   => '',
-            'desc'      => '人物',
+            'desc'      => '项目',
             'match'     => 'is_numeric',
             'update'    => 'select',
             //'search'    => 'select',
@@ -169,59 +196,6 @@ return array
             'list'      => 'Dever::load("user/lib/manage.showOrderUser", "{id}")',
         ),
 
-        'uid'       => array
-        (
-            'type'      => 'int-11',
-            'name'      => '用户名',
-            'default'   => '',
-            'desc'      => '用户id',
-            'match'     => 'is_numeric',
-            'search'    => array
-            (
-                'api' => 'passport/user-all',
-                'col' => 'username',
-                'result' => 'id',
-            ),
-            'update'    => 'text',
-        ),
-
-        'source_uid'        => array
-        (
-            'type'      => 'int-11',
-            'name'      => '邀请人',
-            'default'   => '',
-            'desc'      => '邀请人',
-            'match'     => 'is_numeric',
-            'update'    => 'text',
-        ),
-
-        'type'      => array
-        (
-            'type'      => 'int-11',
-            'name'      => '支付方式',
-            'default'   => '1',
-            'desc'      => '支付方式',
-            'match'     => 'is_numeric',
-            'option'    => $type,
-            'search'    => 'select',
-            'update'    => 'radio',
-            //'list'        => true,
-            'control'   => 'type',
-        ),
-
-        'system'      => array
-        (
-            'type'      => 'int-11',
-            'name'      => '系统',
-            'default'   => '1',
-            'desc'      => '系统',
-            'match'     => 'is_numeric',
-            'option'    => $system,
-            'search'    => 'select',
-            'update'    => 'radio',
-            'list'        => true,
-        ),
-
         'cash'      => array
         (
             'type'      => 'varchar-50',
@@ -230,8 +204,7 @@ return array
             'desc'      => '支付金额',
             'match'     => 'option',
             'update'    => 'text',
-            //'list'        => true,
-            'show'      => 'type=1',
+            'list'        => true,
         ),
 
         'status'        => array
@@ -383,7 +356,7 @@ return array
 
         'button' => array
         (
-            //'导出订单' => array('location', 'journal/lib/manage.out'),
+            //'导出订单' => array('location', 'user/lib/manage.out'),
         ),
 
         'list_button' => array(
@@ -399,10 +372,8 @@ return array
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                'type' => 'yes',
                 'uid' => 'yes',
                 'status' => array('1', '!='),
-                'uid' => 'yes',
                 'state' => 1,
             ),
             'type' => 'all',
@@ -433,7 +404,6 @@ return array
                 'cdate' => array('yes', '>='),
                 'notice' => 'yes',
                 'note' => 'yes',
-                'type' => array('yes', 'in'),
                 'state' => 1,
             ),
             'type' => 'all',
@@ -448,7 +418,6 @@ return array
             'option' => array
             (
                 'status' => 'yes',
-                'type' => array('yes', 'in'),
                 'info_id' => 'yes',
                 'order_id' => 'yes',
                 'uid' => 'yes',
@@ -464,7 +433,6 @@ return array
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                'type' => 'yes',
                 'uid' => 'yes',
                 'status' => 'yes',
                 'cate_id' => 'yes',
@@ -507,7 +475,7 @@ return array
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                'star_id' => 'yes',
+                'object_id' => 'yes',
                 'info_id' => 'yes',
                 'state' => 1,
             ),

+ 51 - 90
app/user/database/ticket_order_temp.php

@@ -1,27 +1,8 @@
 <?php
-
-$type = array
-(
-    1 => '购买兑换码',
-);
-
 # 系统
-$system = array
-(
-    1 => '小程序',
-    2 => 'H5',
-    3 => 'ios',
-    4 => '安卓',
-);
+$system_source = Dever::config('base')->system_source;
 
-$status = array
-(
-    1 => '待支付',
-    2 => '已支付',
-    3 => '支付失败',
-    4 => '申请退款',
-    5 => '已退款',
-);
+$status = Dever::config('base', 'pay')->pay['status'];
 
 $info = function()
 {
@@ -54,7 +35,7 @@ return array
     # 表名
     'name' => 'ticket_order_temp',
     # 显示给用户看的名称
-    'lang' => '临时订单管理',
+    'lang' => '门票临时订单',
     'order' => 1,
     'menu' => false,
 
@@ -88,9 +69,48 @@ return array
             'update'    => 'text',
             'search'    => 'fulltext',
             //'list'        => true,
-            'list'        => 'Dever::load("user/lib/ticket.getOrderId", "{order_id}", {id})',
+            'list'        => 'Dever::load("user/lib/ticket.getOrderIdAndId", "{order_id}", {id})',
         ), 
 
+        'uid'       => array
+        (
+            'type'      => 'int-11',
+            'name'      => '用户名',
+            'default'   => '',
+            'desc'      => '用户id',
+            'match'     => 'is_numeric',
+            'search'    => array
+            (
+                'api' => 'passport/user-all',
+                'col' => 'username',
+                'result' => 'id',
+            ),
+            'update'    => 'text',
+        ),
+
+        'parent_uid'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => '邀请人',
+            'default'   => '',
+            'desc'      => '邀请人',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'system_source'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '所属平台',
+            'default'   => '1',
+            'desc'      => '所属平台',
+            'match'     => 'is_numeric',
+            'option'    => $system_source,
+            'update'    => 'radio',
+            'search'    => 'select',
+            'list'      => true,
+        ),
+
         # 仅用于搜索
         'cate_info_search'        => array
         (
@@ -128,12 +148,12 @@ return array
             //'list'        => true,
         ),
 
-        'star_id'        => array
+        'object_id'        => array
         (
             'type'      => 'int-11',
-            'name'      => '人物',
+            'name'      => '项目',
             'default'   => '',
-            'desc'      => '人物',
+            'desc'      => '项目',
             'match'     => 'is_numeric',
             'update'    => 'select',
             //'search'    => 'select',
@@ -177,59 +197,6 @@ return array
             'list'      => 'Dever::load("user/lib/manage.showOrderUser", "{id}")',
         ),
 
-        'uid'       => array
-        (
-            'type'      => 'int-11',
-            'name'      => '用户名',
-            'default'   => '',
-            'desc'      => '用户id',
-            'match'     => 'is_numeric',
-            'search'    => array
-            (
-                'api' => 'passport/user-all',
-                'col' => 'username',
-                'result' => 'id',
-            ),
-            'update'    => 'text',
-        ),
-
-        'source_uid'        => array
-        (
-            'type'      => 'int-11',
-            'name'      => '邀请人',
-            'default'   => '',
-            'desc'      => '邀请人',
-            'match'     => 'is_numeric',
-            'update'    => 'text',
-        ),
-
-        'type'      => array
-        (
-            'type'      => 'int-11',
-            'name'      => '支付方式',
-            'default'   => '1',
-            'desc'      => '支付方式',
-            'match'     => 'is_numeric',
-            'option'    => $type,
-            'search'    => 'select',
-            'update'    => 'radio',
-            //'list'        => true,
-            'control'   => 'type',
-        ),
-
-        'system'      => array
-        (
-            'type'      => 'int-11',
-            'name'      => '系统',
-            'default'   => '1',
-            'desc'      => '系统',
-            'match'     => 'is_numeric',
-            'option'    => $system,
-            'search'    => 'select',
-            'update'    => 'radio',
-            'list'        => true,
-        ),
-
         'cash'      => array
         (
             'type'      => 'varchar-50',
@@ -238,8 +205,7 @@ return array
             'desc'      => '支付金额',
             'match'     => 'option',
             'update'    => 'text',
-            //'list'        => true,
-            'show'      => 'type=1',
+            'list'        => true,
         ),
 
         'status'        => array
@@ -252,8 +218,8 @@ return array
             'option'    => $status,
             'search'    => 'select',
             'update'    => 'radio',
-            'list'		=> true,
-            //'list'      => 'Dever::load("user/lib/manage.showOrderStatus", "{id}")',
+            'list'      => true,
+            'list'      => 'Dever::load("user/lib/manage.showOrderStatus", "{id}")',
             'control'   => 'status',
         ),
 
@@ -391,7 +357,7 @@ return array
 
         'button' => array
         (
-            //'导出订单' => array('location', 'journal/lib/manage.out'),
+            //'导出订单' => array('location', 'user/lib/manage.out'),
         ),
 
         'list_button' => array(
@@ -407,10 +373,8 @@ return array
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                'type' => 'yes',
                 'uid' => 'yes',
                 'status' => array('1', '!='),
-                'uid' => 'yes',
                 'state' => 1,
             ),
             'type' => 'all',
@@ -441,7 +405,6 @@ return array
                 'cdate' => array('yes', '>='),
                 'notice' => 'yes',
                 'note' => 'yes',
-                'type' => array('yes', 'in'),
                 'state' => 1,
             ),
             'type' => 'all',
@@ -456,7 +419,6 @@ return array
             'option' => array
             (
                 'status' => 'yes',
-                'type' => array('yes', 'in'),
                 'info_id' => 'yes',
                 'order_id' => 'yes',
                 'uid' => 'yes',
@@ -472,7 +434,6 @@ return array
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                'type' => 'yes',
                 'uid' => 'yes',
                 'status' => 'yes',
                 'cate_id' => 'yes',
@@ -515,7 +476,7 @@ return array
             # 匹配的正则或函数 选填项
             'option' => array
             (
-                'star_id' => 'yes',
+                'object_id' => 'yes',
                 'info_id' => 'yes',
                 'state' => 1,
             ),

+ 33 - 70
app/user/lib/Ticket.php

@@ -1,13 +1,13 @@
 <?php
 
-namespace Collection\Lib;
+namespace User\Lib;
 
 use Dever;
 
 class Ticket
 {
     # 发起支付
-    public function action($parent_uid, $uid, $buy_id, $source)
+    public function action($parent_uid, $uid, $buy_id, $object_id, $system_source)
     {
         if (!$uid) {
             Dever::alert('错误的用户信息');
@@ -25,75 +25,50 @@ class Ticket
         if (!$cate) {
             Dever::alert('购买失败');
         }
-
-        $user = Dever::db('passport/user')->one($uid);
-
-        if ($source == 'ios') {
-            $method = 'app';
-            $account_id = 3;
-        } elseif ($source == 'android') {
-            $method = 'app';
-            $account_id = 3;
-        } elseif ($source == 'applet') {
-            # 小程序支付
-            $method = 'applet';
-            $account_id = 2;
-        } else {
-            # 网页支付
-            $method = 'page';
-            $account_id = 1;
-        }
         
+        $order_data['uid'] = $uid;
+        $order_data['status'] = 1;
+        $order_data['cate_id'] = $cate['id'];
+        $order_data['info_id'] = $info['id'];
+        $order_data['buy_id'] = $buy['id'];
+        $order_data['buy_num'] = $buy['num'];
+        $order_data['name'] = Dever::load("collection/lib/buy.getName", $buy);
+        $order_data['cash'] = Dever::load("collection/lib/buy.getPrice", $buy);
+        
+        $order_data['system_source'] = $system_source;
+        $order_data['order_id'] = $this->getOrderId();
+
         if ($parent_uid) {
             $order_data['parent_uid'] = $parent_uid;
         }
-
-        if ($type) {
-            $order_data['type'] = $type;
+        if ($object_id) {
+            $order_data['object_id'] = $object_id;
         }
 
-        if ($type_id) {
-            $order_data['type_id'] = $type_id;
-        }
-        
-        $order_data['uid'] = $uid;
-        $order_data['status'] = 1;
-        $order_data['info_id'] = $goods['id'];
-        $order_data['sku_id'] = $sku;
-        $order_data['name'] = $goods['name'];
-        $order_data['cash'] = $goods['price'];
-        $order_data['num'] = $num;
-        $order_data['source'] = $source;
-        $order_data['order_id'] = $this->getOrderId();
-        $id = Dever::db('goods/order')->insert($order_data);
+        $id = Dever::db('user/ticket_order')->insert($order_data);
 
         if (!$id) {
             Dever::alert('支付失败');
         }
 
-        $refer = 'test';
-
-        //$param参数
         $param = array
         (
-            'account_id' => $account_id,
             'project_id' => 1,
+            'channel_id' => $cate['pay_channel'],
+            'system_source' => $system_source,
             'uid' => $uid,
-            'username' => $user['username'],
             'name' => $order_data['name'],
-            'cash' => $order_data['cash'] * $order_data['num'],
-            //'cash' => '0.01',
-            'openid' => isset($wechat['openid']) ? $wechat['openid'] : '',
-            'product_id' => $goods['id'],
+            'cash' => $order_data['cash'],
+            'product_id' => $info['id'],
             'order_id' => $order_data['order_id'],
-            'refer' => $refer
         );
 
-        if ($method == 'apple') {
-            $param['other'] = $receipt;
+        $receipt = Dever::input('receipt');
+        if ($receipt) {
+            $param['receipt'] = $receipt;
         }
 
-        $result['pay'] = Dever::load('pay/api.' . $method, $param);
+        $result['pay'] = Dever::load('pay/api.pay', $param);
 
         $result['order_id'] = $order_data['order_id'];
 
@@ -108,7 +83,7 @@ class Ticket
         if ($info) {
             return $info['key'];
         }
-        return 'goods_dever_2020';
+        return 'ticket_dever_2020';
     }
 
     # 支付成功回调 安全加密
@@ -125,21 +100,10 @@ class Ticket
         $status = $send['pay_status'];
         $msg = $send['pay_msg'];
 
-        $order = Dever::db('goods/order')->one(array('order_id' => $order_id));
+        $order = Dever::db('user/ticket_order')->one(array('order_id' => $order_id));
 
         if ($order && $order['status'] == 1) {
-
             if ($status == 2) {
-                # 减少库存 增加销量
-                $update['where_id'] = $order['info_id'];
-                $update['sell_num'] = $order['num'];
-                Dever::db('goods/info')->updateSell($update);
-
-                if ($order['sku_id'] > 0) {
-                    $update['where_id'] = $order['sku_id'];
-                    $update['sell_num'] = $order['num'];
-                    Dever::db('goods/info_sku')->updateSell($update);
-                }
 
                 # 增加积分
                 if ($order['parent_uid'] > 0) {
@@ -147,18 +111,17 @@ class Ticket
                 } else {
                     $uid = $order['uid'];
                 }
-                Dever::score($uid, 'buy_my_goods', '购买自营商品', false, false, false, $order['type'], $order['type_id']);
+                Dever::score($uid, 'buy_ticket', '购买门票', false, false, false, 'collection', $order['info_id']);
 
                 # 发消息
                 if (Dever::project('message')) {
-                    Dever::load('message/lib/data')->push(-1, $order['uid'], '购买提醒', '购买成功', 11);
+                    Dever::load('message/lib/data')->push(-1, $order['uid'], '购买提醒', '购买门票成功', 11);
                 }
             }
 
-
             $update['status'] = $status;
-            $update['where_id'] = $order['id'];
-            Dever::db('goods/order')->update($update);
+            $update['id'] = $order['id'];
+            Dever::db('user/ticket_order')->update($update);
         }
 
         return 'ok';
@@ -168,7 +131,7 @@ class Ticket
     public function getOrderId()
     {
         $where['order_id'] = $this->createOrderId();
-        $state = Dever::db('goods/order')->one($where);
+        $state = Dever::db('user/ticket_order')->one($where);
         if (!$state) {
             return $where['order_id'];
         } else {
@@ -193,7 +156,7 @@ class Ticket
         return $prefix . (strtotime(date('YmdHis', time()))) . substr(microtime(), 2, 6) . sprintf('%03d', rand(0, 999));
     }
 
-    public function getOrderId($order_id, $id)
+    public function getOrderIdAndId($order_id, $id)
     {
     	if ($order_id) {
     		return $order_id . '/' . $id;

+ 4 - 2
app/user/src/Pay.php

@@ -26,7 +26,7 @@ class Pay extends Core
             Dever::alert('请传入正确的产品ID');
         }
 
-        $pay = Dever::load('goods/lib/pay')->action($this->share_uid, $uid, $goods_id, $sku, $num, $address_id, $this->source, 'collection/info', $this->id);
+        $pay = Dever::load('goods/lib/pay')->action($this->share_uid, $uid, $goods_id, $sku, $num, $address_id, $this->system_source, 'collection/info', $this->id);
 
         //return $pay;
 
@@ -55,7 +55,9 @@ class Pay extends Core
             Dever::alert('请选择正确的门票');
         }
 
-        $pay = Dever::load('user/lib/ticket')->action($this->share_uid, $uid, $buy_id, $this->source);
+        $object_id = Dever::input('object_id');
+
+        $pay = Dever::load('user/lib/ticket')->action($this->share_uid, $uid, $buy_id, $object_id, $this->system_source);
         print_r($pay);die;
 
         //return $pay;