dever 6 years ago
parent
commit
9bc01b6828

+ 5 - 5
act/database/invite.php

@@ -5,9 +5,9 @@ $table = Dever::config('base')->type;
 return array
 (
 	# 表名
-	'name' => 'score',
+	'name' => 'invite',
 	# 显示给用户看的名称
-	'lang' => '积分排行榜',
+	'lang' => '邀请排行榜',
 	# 是否显示在后台菜单
 	'order' => 1,
 	'menu' => false,
@@ -44,14 +44,14 @@ return array
 		'type' 		=> array
 		(
 			'type' 		=> 'tinyint-1',
-			'name' 		=> '订阅类别',
+			'name' 		=> '邀请类型',
 			'default' 	=> '',
-			'desc' 		=> '订阅类别',
+			'desc' 		=> '邀请类型',
 			'match' 	=> 'option',
 			'update'	=> 'select',
 			//'search'	=> 'select',
 			'option' 	=> $table,
-			//'list'		=> true,
+			'list'		=> true,
 		),
 		
 		'data_id' 		=> array

+ 10 - 0
act/database/score.php

@@ -68,6 +68,16 @@ return array
 			'list'		=> 'Dever::load("act/lib/manage.load", "{type}", {data_id})',
 		),
 
+		'user_log_id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '用户积分日志id',
+			'default' 	=> '',
+			'desc' 		=> '用户积分日志id',
+			'update'	=> 'text',
+			'match' 	=> 'option',
+		),
+
 		'score' 		=> array
 		(
 			'type' 		=> 'varchar-80',

+ 18 - 0
act/database/share_reflux.php

@@ -2,6 +2,12 @@
 
 $table = Dever::config('base')->type;
 
+$type = array
+(
+    1 => '新用户',
+    2 => '老用户',
+    3 => '未知',
+);
 return array
 (
     # 表名
@@ -83,6 +89,18 @@ return array
             'list'      => '{uid} > 0 ? Dever::load("passport/user-one#username", {uid}) : "匿名用户"',
         ),
 
+        'user_type'      => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '是否新用户',
+            'default'   => '3',
+            'desc'      => '是否新用户',
+            'match'     => 'option',
+            'option'    => $type,
+            'list'      => true,
+            'search'    => 'select',
+        ),
+
         'gid'       => array
         (
             'type'      => 'varchar-80',

+ 2 - 11
act/lib/Invite.php

@@ -24,27 +24,18 @@ class Invite
         return $data;
     }
 
-    public function submit($uid, $id, $source = 1, $type = 4)
+    public function submit($source_uid, $uid, $id, $type = 4)
     {
+        $where['source_uid'] = $source_uid;
         $where['uid'] = $uid;
         $where['data_id'] = $id;
         $where['type'] = $type;
         $table = 'act/invite';
         $info = Dever::db($table)->one($where);
         if (!$info) {
-            $where['source'] = $source;
             Dever::db($table)->insert($where);
         }
 
-        # 更新订阅数
-        $where = array();
-        $where['data_id'] = $id;
-        $where['type'] = $type;
-        $where['state'] = 1;
-        $total = Dever::db($table)->total($where);
-        $table = Dever::config('base')->type_table[$type];
-        Dever::db($table)->update(array('where_id' => $id, 'num_ding' => $total));
-
         return true;
     }
 }

+ 38 - 18
act/lib/Score.php

@@ -39,26 +39,46 @@ class Score
         return $data;
     }
 
-    public function submit($uid, $id, $source = 1, $type = 4)
+    public function submit()
     {
-        $where['uid'] = $uid;
-        $where['data_id'] = $id;
-        $where['type'] = $type;
-        $table = 'act/score';
-        $info = Dever::db($table)->one($where);
-        if (!$info) {
-            $where['source'] = $source;
-            Dever::db($table)->insert($where);
-        }
+        $user_log_id = Dever::input('user_log_id');
+        $type = Dever::input('type', 4);
+        $id = Dever::input('id');
+        $method = Dever::input('method');
 
-        # 更新订阅数
-        $where = array();
-        $where['data_id'] = $id;
-        $where['type'] = $type;
-        $where['state'] = 1;
-        $total = Dever::db($table)->total($where);
-        $table = Dever::config('base')->type_table[$type];
-        Dever::db($table)->update(array('where_id' => $id, 'num_ding' => $total));
+        $user_log = Dever::db('score/user_log')->one($user_log_id);
+
+        if ($user_log) {
+            if ($method == 'share') {
+                # 活动结束后,无法增加当前小刊积分
+                if ($type == 4) {
+                    $journal = Dever::db('journal/active')->one(array('info_id' => $id, 'state' => 1));
+                    if (!$journal) {
+                        return;
+                    }
+                    if ($journal && $journal['status'] == 2) {
+                        return;
+                    }
+                    if ($journal && time() > $journal['end']) {
+                        return;
+                    }
+                }
+            }
+            $where['user_log_id'] = $user_log_id;
+            $where['uid'] = $user_log['uid'];
+            $where['data_id'] = $id;
+            $where['type'] = $type;
+            $table = 'act/score';
+            $info = Dever::db($table)->one($where);
+            if (!$info) {
+                $where['score'] = $user_log['num'];
+                Dever::db($table)->insert($where);
+            } else {
+                $where['where_id'] = $info['id'];
+                $where['score'] = $info['score'] + $user_log['num'];
+                Dever::db($table)->update($where);
+            }
+        }
 
         return true;
     }

+ 44 - 20
act/lib/Share.php

@@ -50,29 +50,53 @@ class Share
         $share = Dever::db('act/share')->one($where);
         if ($share) {
 
-            $user = Dever::load('passport/user')->one($uid);
-            if ($user && $type <= 4) {
-                $method = '';
-                $name = Dever::config('base')->type[$type];
-                if ($type == 1) {
-                    $method = 'article';
-                }
-                if ($type == 2) {
-                    $method = 'vod';
-                }
-                if ($type == 3) {
-                    $method = 'live';
-                }
-                if ($type == 4) {
-                    $method = 'journal';
+            $user = Dever::db('passport/user')->one($uid);
+
+            $where['user_type'] = 3;
+
+            //if ($user['temp'] == 2 || $user['bind'] == 1) {
+            if ($user) {
+                # 必须是已经绑定手机号或者授权用户才可以增加积分
+
+                # 新用户 增加邀请关系
+                if (Dever::project('invite')) {
+                    $parent = Dever::load('invite/api')->getParent($uid, $level = 1);
+                    if (!$parent) {
+                        # 新用户
+                        $where['user_type'] = 1;
+                        Dever::load('invite/api')->setRelation($uid, $source_uid);
+                    } else {
+                        # 老用户
+                        $where['user_type'] = 2;
+                        
+                    }
                 }
-                if ($user['temp'] == 2) {
-                    Dever::score($source_uid, 'share_'.$method.'_reflux', '邀请到用户');
-                } else {
-                    Dever::score($source_uid, 'share_'.$method.'_reflux', '邀请到用户');
+                if ($type <= 4) {
+                    $method = '';
+                    $name = Dever::config('base')->type[$type];
+                    if ($type == 1) {
+                        $method = 'article';
+                    }
+                    if ($type == 2) {
+                        $method = 'vod';
+                    }
+                    if ($type == 3) {
+                        $method = 'live';
+                    }
+                    if ($type == 4) {
+                        $method = 'journal';
+                    }
+
+                    # 增加积分
+                    if ($where['user_type'] == 1) {
+                        Dever::score($source_uid, 'share_'.$method.'_new_reflux', '通过'.$name.'邀请到新用户', 'act/lib/score.submit?method=share&type='.$type.'&id=' . $id);
+                        # 插入到邀请列表里
+                        Dever::load('act/lib/invite')->submit($source_uid, $uid, $id, $type);
+                    } elseif ($where['user_type'] == 2) {
+                        Dever::score($source_uid, 'share_'.$method.'_reflux', '通过'.$name.'邀请到老用户');
+                    }
                 }
             }
-            
 
             $where['share_id'] = $share['id'];
             $info = Dever::db('act/share_reflux')->one($where);

+ 12 - 1
content/lib/Article.php

@@ -38,7 +38,11 @@ class Article
                 foreach ($matches[3] as $k => $v) {
                     $content = str_replace($matches[0][$k], '{replace}'.count($replace).'{replace}', $content);
 
-                    $replace[] = array('type' => 5, 'content' => $v);
+                    if (strstr($v, '.mp4')) {
+                        $replace[] = array('type' => 6, 'content' => $v);
+                    } else {
+                        $replace[] = array('type' => 5, 'content' => $v);
+                    }
                 }
             }
         }
@@ -50,6 +54,13 @@ class Article
             
             if (!isset($matches[4][0])) {
                 preg_match_all('/<p(.*?)>([\s]+)<img(.*?)data-key="(.*?)" data-id="(.*?)" \/>([\s]+)<\/p>/', $data['content'], $matches);
+                $temp = array();
+                if (isset($matches[4][0]) && isset($matches[5][0])) {
+                    $temp = $matches;
+                    $matches[4] = $temp[5];
+                    $matches[5] = $temp[4];
+                    unset($temp);
+                }
             }
             
             if (isset($matches[4][0]) && isset($matches[5][0])) {

+ 48 - 4
doc/apidoc.php

@@ -418,7 +418,7 @@
  * @apiSuccess {String}   info.share_content 分享内容
  * @apiSuccess {String}   info.function 开启的功能,这是一个字符串,用逗号隔开的,1代表显示浏览量,2代表显示评论,3代表显示喜欢,如值为1,2,则显示浏览量、评论,不显示喜欢
  * @apiSuccess {String}   info.content 内容
- * @apiSuccess {String}   info.content_array 数组内容,请使用该字段循环,type为类型,请参考类型设置说明,content为内容,type为1时为图文内容,type为2时content为视频详情的字段,type为3时content为直播详情的字段,type为5时content为音频或者视频地址
+ * @apiSuccess {String}   info.content_array 数组内容,请使用该字段循环,type为类型,请参考类型设置说明,content为内容,type为1时为图文内容,type为2时content为视频详情的字段,type为3时content为直播详情的字段,type为5时content为音频、type为6时是视频地址,后续增加type=56时的封面图,暂时没有
  *
  * @apiSuccess {Object[]} comment 评论列表
  * @apiSuccess {String}   comment.id 
@@ -583,7 +583,7 @@
  * @apiParam {String} signature signature
  * @apiParam {Number} type type类型
  * @apiParam {Number} id 当前的数据id
- * @apiParam {String} desc 说明:这是分享的说明介绍,请不要传入该参数,底层页分享时,请把路径path设置为首页的path?scene=signature,type,id  signature:当前邀请者的signature | type:当前分享的类型 图文等 | id:当前分享的图文的id,小程序中请判断,如果首页有scene参数,请在正常请求首页数据之后,先发起分享回流接口的请求,然后根据scene参数中的type和id的值,跳转到type所对应的path的详情页即可。
+ * @apiParam {String} desc 说明:这是分享的说明介绍,请不要传入该参数,底层页分享时,请把路径path设置为首页的path?scene=signature,type,id  signature:当前邀请者的signature | type:当前分享的类型 图文等 | id:当前分享的图文的id,小程序中请判断,如果首页有scene参数,请在正常请求首页数据之后,将这几个数据保存到本地,(这里不要发起分享回流接口的请求,请在用户授权用户信息或者授权手机号之后再发起分享回流的接口请求,发起请求之后,请从本地删除这几个数据),然后根据scene参数中的type和id的值,跳转到type所对应的path的详情页即可。
  *
  * @apiSuccess {Number}  id 当前的数据id
  */
@@ -789,7 +789,7 @@
  * @apiParam {String} signature signature
  * @apiParam {String} journal_id 小刊id
  * @apiParam {String} buy_id 购买本数id
- * @apiParam {String} source_signature 分享人的signature,scene参数中的source_signature
+ * @apiParam {String} source_signature 分享人的signature,scene参数中的source_signature,用完请删除该参数。
 *
  * @apiSuccess {Object[]} pay 微信支付返回的数据
  * @apiSuccess {String}   pay.time 服务器时间戳
@@ -810,7 +810,7 @@
  * @apiParam {String} signature signature
  * @apiParam {String} journal_id 小刊id
  * @apiParam {String} code 兑换码
- * @apiParam {String} source_signature 分享人的signature,scene参数中的source_signature
+ * @apiParam {String} source_signature 分享人的signature,scene参数中的source_signature,用完请删除该参数。
  *
  * @apiSuccess {String}   order_id 兑换成功则返回订单id
  */
@@ -831,6 +831,50 @@
  * @apiSuccess {String}   product.name 小刊名称
  */
 
+/**
+ * @api {get} wonderful/main/?l=journal.score 小刊积分排行榜
+ * @apiVersion 1.0.0
+ * @apiName journal.score
+ * @apiGroup Journal
+ *
+ * @apiDescription 小刊积分排行榜
+ *
+ * @apiParam {String} signature signature
+ * @apiParam {Number} id 小刊id
+ *
+ * @apiSuccess {Object[]} info 小刊详情
+ * @apiSuccess {String}   info.id 小刊id
+ * @apiSuccess {String}   info.name 名称
+ *
+ * @apiSuccess {Object[]}   score 积分排行
+ * @apiSuccess {String}   score.uid 用户id
+ * @apiSuccess {String}   score.score 积分数
+ * @apiSuccess {String}   score.username 用户名
+ * @apiSuccess {String}   score.avatar 头像
+ */
+
+
+/**
+ * @api {get} wonderful/main/?l=journal.invite 小刊我的邀请排行榜
+ * @apiVersion 1.0.0
+ * @apiName journal.invite
+ * @apiGroup Journal
+ *
+ * @apiDescription 小刊邀请排行榜
+ *
+ * @apiParam {String} signature signature
+ * @apiParam {Number} id 小刊id
+ *
+ * @apiSuccess {Object[]} info 小刊详情
+ * @apiSuccess {String}   info.id 小刊id
+ * @apiSuccess {String}   info.name 名称
+ *
+ * @apiSuccess {Object[]}   invite 邀请排行
+ * @apiSuccess {String}   invite.uid 用户id
+ * @apiSuccess {String}   invite.username 用户名
+ * @apiSuccess {String}   invite.avatar 头像
+ */
+
 /**
  * @api {get} wonderful/main/?l=user.my 获取用户信息
  * @apiVersion 1.0.0

+ 2 - 0
journal/database/info.php

@@ -382,6 +382,8 @@ return array
 		'list_button' => array
 		(
 			'edit' => array('预览', Dever::url('main/preview.get?type=4')),
+			'list10' => array('积分排行', '"score&project=act&search_type=4&search_option_data_id={id}&oper_parent=info&oper_project=journal"'),
+			'list11' => array('邀请排行', '"invite&project=act&search_type=4&search_option_data_id={id}&oper_parent=info&oper_project=journal"'),
 			'br1' => array('<br />'),
 			'list' => array('内页管理', '"content&search_option_info_id={id}&oper_parent=info&page_type=1"' , '{audit} == 1'),
 			'br2' => array('<br />'),

+ 4 - 0
journal/lib/Pay.php

@@ -32,6 +32,10 @@ class Pay
 
                 # 订阅
                 Dever::load('act/lib/subscribe')->submit($uid, $product_id, 1);
+
+                Dever::score($uid, 'buy_journal', '购买小刊', 'act/lib/score.submit?method=pay&type=4&id=' . $product_id);
+
+
             } else {
                 Dever::db('journal/order')->update(array('where_id' => $order['id'], 'status' => 3));
             }

+ 2 - 25
main/lib/Core.php

@@ -12,7 +12,7 @@ class Core
     {
         # 获取用户信息
         if ($this->checkUser) {
-            $this->data['uid'] = Dever::load('passport/applet')->check();
+            //$this->data['uid'] = Dever::load('passport/applet')->check();
         } else {
             $this->data['uid'] = Dever::load('passport/applet')->check(false);
         }
@@ -95,30 +95,7 @@ class Core
 
     protected function getSourceUid($error = true)
     {
-        $source_signature = Dever::input('source_signature');
-
-        if (!$source_signature) {
-            if (!$error) {
-                return false;
-            }
-            Dever::alert('错误的来源uid');
-        }
-        $user = Dever::loginResult($source_signature, false);
-        if (!isset($user['uid'])) {
-            if (!$error) {
-                return false;
-            }
-            //Dever::alert('错误的来源uid');
-        }
-
-        //$source_uid = $user['uid'];
-        $source_uid = 1;
-
-        if ($this->data['uid'] == $source_uid) {
-            return false;
-        }
-
-        return $source_uid;
+        return Dever::load('invite/api')->getSourceUid($this->data['uid'], $error);
     }
 
     protected function log()

+ 9 - 28
main/src/Journal.php

@@ -89,6 +89,10 @@ class Journal extends Core
         $this->data['info'] = $this->info($this->data['info'], false);
         $this->button($this->data['info']);
 
+        if ($this->data['uid'] > 0) {
+            Dever::score($this->data['uid'], 'view_journal', '浏览小刊首页');
+        }
+
         return $this->data;
     }
 
@@ -224,7 +228,7 @@ class Journal extends Core
 
         $id = $this->check();
 
-        $this->data['invite'] = Dever::load('act/lib/invite')->getList($this->data['uid'], $id);
+        $this->data['invite'] = Dever::load('act/lib/invite')->getList($this->data['uid'], $id, 1);
 
         return $this->data;
     }
@@ -245,6 +249,10 @@ class Journal extends Core
             //Dever::alert('未订阅');
         }
 
+        if ($this->data['uid'] > 0) {
+            Dever::score($this->data['uid'], 'read_journal', '阅读小刊');
+        }
+
         # 获取最新10条内容
         $where = array();
         $where['info_id'] = $id;
@@ -317,33 +325,6 @@ class Journal extends Core
         return $id;
     }
 
-
-    # 海报
-    public function poster() 
-    {
-        $id = Dever::input('product_id');
-        $template = Dever::input('template', 'share');
-        $path = Dever::input('path', 'template/home/index');
-        $info = Dever::db('product/info')->one($id);
-        $scene = $this->data['uid'] . ',' . $id;
-
-        $send['project'] = Dever::input('project', 1);
-        $send['send'] = $scene;
-        $send['width'] = 152;
-        $send['path'] = $path;
-        $logo = Dever::load('wechat_applet/code.get', $send);
-
-        $model = array
-        (
-            //'pic' => Dever::local($info['pic']),
-            //'name' => $info['name'],
-            'logo' => Dever::local(str_replace('https', 'http', $logo)),
-        );
-        $template = $info['share'];
-        $img = Dever::load('poster/api')->get($scene, $template, $model);
-        return $img;
-    }
-
     # 购买
     public function buy_action()
     {

+ 52 - 5
main/src/User.php

@@ -9,19 +9,47 @@ class User extends Core
 {
     protected $checkUser = true;
 
+    public function del()
+    {
+        $uid = Dever::input('uid');
+        Dever::db('passport/user')->delete($uid);
+        $info = Dever::db('passport/wechat')->state(array('uid' => $uid));
+        if ($info) {
+            foreach ($info as $k => $v) {
+                Dever::db('passport/wechat')->delete($v['id']);
+            }
+        }
+
+        return 'ok';
+    }
+
     # 我的页面
     public function my()
     {
         # 获取用户信息
         $this->data['user'] = Dever::load('passport/api')->info($this->data['uid']);
         if ($this->data['user']) {
-            $level = Dever::db('passport/level')->one($this->data['user']['level']);
+            $level = Dever::db('score/user_level')->one(array('uid' => $this->data['uid']));
             if ($level) {
-                $this->data['user']['level'] = $level['name'];
+                $level_info = Dever::db('score/level')->one($level['level_id']);
+                $this->data['user']['level'] = $level_info['name'];
             } else {
                 $this->data['user']['level'] = '无';
             }
 
+            $score = Dever::db('score/user')->all(array('uid' => $this->data['uid']));
+            $score_num = 0;
+            if ($score) {
+                foreach ($score as $k => $v) {
+                    $score_info = Dever::db('score/config')->one($v['config_id']);
+                    if ($score_info && $score_info['type'] == 1) {
+                        $score_num = $v['score'];
+                        break;
+                    }
+                }
+            }
+            $this->data['user']['score'] = $score_num;
+
             # 查看当前用户的消息
             $this->data['user_msg'] = Dever::load('message/lib/data')->num($this->data['uid']);
         }
@@ -90,9 +118,28 @@ class User extends Core
             Dever::alert('错误的类型');
         }
 
-        Dever::load('act/lib/share')->submit($this->data['uid'], $id, $type);
-
-        return array('id' => $id, 'type' => $type);
+        $template = Dever::input('template', 'share');
+        $path = Dever::input('path', 'template/home/index');
+
+        $table = Dever::config('base')->type_table[$type];
+        $info = Dever::db($table)->one($id);
+        $scene = Dever::login($this->data['uid']) . ',' . $type . ',' . $id;
+
+        $send['project'] = Dever::input('project', 1);
+        $send['send'] = $scene;
+        $send['width'] = 152;
+        $send['path'] = $path;
+        $logo = Dever::load('wechat_applet/code.get', $send);
+
+        $model = array
+        (
+            'pic' => Dever::local($info['share_pic']),
+            'name' => $info['share_name'],
+            'logo' => Dever::local(str_replace('https', 'http', $logo)),
+        );
+        $template = $info['share'];
+        $img = Dever::load('poster/api.get', $scene, $template, $model);
+        return $img;
     }
 
     # 分享

+ 4 - 4
score/database/action_log.php

@@ -92,15 +92,15 @@ return array
 			'list'		=> true,
 		),
 
-		'content'		=> array
+		'callback'		=> array
 		(
 			'type' 		=> 'varchar-800',
-			'name' 		=> '行为描述',
+			'name' 		=> '行为回调方法',
 			'default' 	=> '',
-			'desc' 		=> '行为描述',
+			'desc' 		=> '行为回调方法',
 			'match' 	=> 'option',
 			'update'	=> 'textarea',
-			'list'		=> true,
+			//'list'		=> true,
 		),
 
 		'cdate'		=> array

+ 38 - 0
score/database/config.php

@@ -1,5 +1,11 @@
 <?php
 
+$type = array
+(
+	1 => '主积分',
+	2 => '普通积分',
+);
+
 return array
 (
 	# 表名
@@ -7,6 +13,11 @@ return array
 	# 显示给用户看的名称
 	'lang' => '积分名称设置',
 	'order' => 1,
+	'end' => array
+	(
+		'insert' => 'score/lib/manage.config',
+		'update' => 'score/lib/manage.config',
+	),
 	# 数据结构
 	'struct' => array
 	(
@@ -30,6 +41,19 @@ return array
 			'search'	=> 'fulltext',
 			'list'		=> true,
 		),
+
+		'type'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '是否主积分-只能有一个主积分,主积分将作为用户主要积分显示在用户信息中',
+			'default' 	=> '2',
+			'desc' 		=> '是否主积分',
+			'match' 	=> 'is_numeric',
+			'update'	=> 'select',
+			'option'	=> $type,
+			'search'	=> 'select',
+			'list'		=> true,
+		),
 		
 		'reorder'		=> array
 		(
@@ -73,4 +97,18 @@ return array
 			'list' => array('规则设置', '"rule&search_option_config_id={id}&oper_parent=config"'),
 		),
 	),
+
+	'request' => array
+	(
+		# 更新
+		'set' => array
+		(
+			'type' => 'update',
+			'set' => array
+			(
+				'type' => '2',
+			),
+		),
+	),
+	
 );

+ 19 - 5
score/lib/Core.php

@@ -11,7 +11,7 @@ class Core
 	 *
 	 * @return mixed
 	 */
-	public function log($uid, $action_key, $action_name, $content = '')
+	public function log($uid, $action_key, $action_name, $callback = '')
 	{
 		$action = Dever::db('score/action')->one(array('key' => $action_key));
 
@@ -21,7 +21,7 @@ class Core
 		}
 
 		if (isset($action['id'])) {
-			$log_id = Dever::db('score/action_log')->insert(array('uid' => $uid, 'action_id' => $action['id'], 'content' => $content));
+			$log_id = Dever::db('score/action_log')->insert(array('uid' => $uid, 'action_id' => $action['id'], 'callback' => $callback));
 
 			//Dever::deamon('lib/core.oper?log_id='.$log_id, 'score');
 			Dever::load('score/lib/core.oper?log_id='.$log_id);
@@ -51,6 +51,7 @@ class Core
 		$uid = $log['uid'];
 
 		$user = Dever::db('score/user')->one(array('uid' => $uid, 'config_id' => $info['config_id']));
+
 		if (!$user) {
 			$user = array();
 			$user['id'] = Dever::db('score/user')->insert(array('uid' => $uid, 'config_id' => $info['config_id'], 'score' => 0, 'no_score' => 0));
@@ -78,9 +79,17 @@ class Core
 		$insert['status'] = 1;
 		$insert['num'] = $num;
 		$insert['total'] = $update['score'];
-		Dever::db('score/user_log')->insert($insert);
+		$user_log_id = Dever::db('score/user_log')->insert($insert);
 
 		Dever::db('score/user')->update($update);
+
+		if ($log['callback']) {
+			if (strstr($log['callback'], '?')) {
+				Dever::load($log['callback'] . '&user_log_id=' . $user_log_id);
+			} else {
+				Dever::load($log['callback'], $user_log_id);
+			}
+		}
 	}
 
 	private function upper($uid, $info)
@@ -149,12 +158,17 @@ class Core
 	public function cron()
 	{
 		$where['score_type'] = 1;
-		$log = Dever::db('score/action_log')->state($where);
+		$log = Dever::db('score/action_log')->all($where);
 		if ($log) {
-			$this->operAction($log['id']);
+			foreach ($log as $k => $v) {
+				$this->operAction($v);
+			}
 		}
 	}
 
+	public function cron_api()
+	{}
+
 
 	/**
 	 * 根据积分算等级

+ 6 - 26
score/lib/Manage.php

@@ -28,37 +28,17 @@ class Manage
 	}
 
     /**
-	 * 创建兑换码
+	 * 设置主积分
 	 *
 	 * @return mixed
 	 */
-	public function create($id, $name, $param)
+	public function config($id, $name, $param)
 	{
-		$code = Dever::param('num', $param);
-		$product_id = Dever::param('product_id', $param);
+		$type = Dever::param('type', $param);
 
-		//$total = Dever::db('code/info')->total(array('product_id' => $product_id, 'type' => 1));
-		$total = 0;
-		if ($code > 0 && $code > $total) {
-			$num = $code - $total;
-
-			for ($i = 0; $i < $num; $i++) {
-				$this->createCode($product_id);
-			}
-		}
-	}
-
-	private function createCode($product_id)
-	{
-		$code = Dever::rand(8, 0);
-		$data['product_id'] = $product_id;
-		$data['code'] = $code;
-		$total = Dever::db('code/info')->total($data);
-		if ($total > 0) {
-			return $this->createCode($product_id, $id);
+		if ($type == 1) {
+			Dever::db('score/config')->set(array('type' => 2));
+			Dever::db('score/config')->update(array('where_id' => $id, 'type' => 1));
 		}
-		$data['type'] = 1;
-		Dever::db('code/info')->insert($data);
-		return $code;
 	}
 }