Kaynağa Gözat

Merge branch 'master' of https://git.dashgame.com/gsgundam/garden_server

superbee315 5 yıl önce
ebeveyn
işleme
a62430f31b

+ 29 - 2
application/newhome/controller/Pay.php

@@ -51,14 +51,18 @@ class Pay extends Controller{
             return json(["errno"=>101, "msg"=>"签名不对"]);
         }
 
-        $iapInfo = Db::name('iap_config')->where(['item_id'=>$order_id])->find();
+        $arr = explode("|", $exinfo);
+	    $item_id = $arr[0];
+	    $user_id = $arr[1];
+
+        $iapInfo = Db::name('iap_config')->where(['item_id'=>$item_id])->find();
         if(empty($iapInfo)) return (json(['errno'=>1111, "msg"=>"商品ID错误"]));
 
         $user = Db::name('user')->where(['id'=>$role_id])->find();
         if(empty($user)) return (json(['errno'=>1111, 'msg'=>"用户ID错误"]));
 
         $arr = array();
-        $arr['user_id'] = $role_id;
+        $arr['user_id'] = $user_id;
         $arr['pay_id'] = $iapInfo['id'];
         $arr['out_trade_no'] = $order_id;
         $arr['cost'] = $pay_money;
@@ -68,6 +72,29 @@ class Pay extends Controller{
         return json(['errno'=>1, 'msg'=>""]);
     }
 
+    public function get_reward()
+    {
+        $data = decode($this->request->post());
+        $user_id = $data['user_id'];
+
+        $user_pay = Db::name('user_pay')->where(['user_id'=>$user_id])->order('id DESC')->find();
+        if(!$user_pay)
+        {
+            return json(['error'=>0]);
+        }
+
+        Db::name('user_pay')->update(["reward"=>1])->where(["id"=>$user_pay['id']]);
+
+        $pay_id = $user_pay['pay_id'];
+        $iap_info = Db::name('iap_config')->where(['id'=>$pay_id])->find();
+        if(!$iap_info)
+        {
+            return json(['error'=>0]);
+        }
+
+        return json(['error'=>0, "reward"=>$iap_info["reward"]]);
+    }
+
 
 	public function notify(){
 		echo 'success';

+ 32 - 0
application/newhome/controller/User.php

@@ -100,6 +100,38 @@ class User extends Controller {
 		return json(['l'=>$info, 'p'=>$res['praise']]);
 	}
 
+	//老用户找回账户
+    public function load_back(){
+        $data = decode($this->request->post());
+
+        $id = $data['u'];
+        $ext_id = $data['e'];
+
+        $res = $this->userModel->getUserByCode($id);
+        if(!empty($res['ext_id']))
+        {
+            return json(['error'=>1023]);
+        }
+
+        if(empty($res)) return json(['error'=>1023]);
+        $path = "load/".$res['id'].".txt";
+
+        if(!is_file($path)) $path = "load/".$res['short'].".txt";
+
+        if(!is_file($path))
+            return json(['error'=>1009]);
+
+        $file = fopen($path, "r") or die(json(['error'=>1009]));
+        $info = fread($file, filesize($path));
+        fclose($file);
+
+        //更新sdk账号id至新的账号
+        $this->userModel->update(["ext_id"=>""])->where(['ext_id'=>$ext_id]);
+        $this->userModel->update(["ext_id"=>$ext_id])->where(["id"=>$res['id']]);
+
+        return json(['l'=>$info, 'p'=>$res['praise']]);
+    }
+
     public function save(){
         $data = decode($this->request->post());
 

+ 28 - 2
application/user/model/User.php

@@ -111,7 +111,27 @@ class User extends Model{
     	
     	return $info;
 	}
-	
+
+	public function loginBySdk($ext_id){
+        $this->data['uid'] = "";
+        $info = $this->db()->field('id i, ext_id e, diamond d, mobile m, coin c, short o, praise p, buddy b, last_login t')->where(array("ext_id"=>$ext_id))->find();
+
+        if(empty($info)) {
+            $info['d'] = 0;
+            $info['c'] = 0;
+            $info['p'] = 0;
+            $info['b'] = 25;
+            $info['i'] = $this->createUserBySdk($ext_id);
+            $info['e'] = $ext_id;
+            $info['o'] = $this->data['short'];
+            $info['t'] = $this->data['last_login'];
+        }
+
+        $this->isUpdate(true)->save(['id'=>$info['i']]);
+
+        return $info;
+    }
+
 	/**
 	 * 随机出非个人的短码
 	 * @param int $id
@@ -184,7 +204,13 @@ class User extends Model{
 		$this->isUpdate(false)->save($data);
 		return $data['id'];
 	}
-	
+
+	public function createUserBySdk($ext_id){
+        $data = ['id'=>getId(), 'ext_id'=>$ext_id];
+        $this->isUpdate(false)->save($data);
+        return $data['id'];
+    }
+
 	/**
 	 * 查看生成排行榜
 	 */

+ 1 - 0
application/user/model/UserBuddy.php

@@ -22,6 +22,7 @@ class UserBuddy extends Model {
 		->field("u.id i, u.nickname n, u.praise p, u.robot r, last_login t")
 		->join("gd_user u", "u.id = b.buddy_id", "LEFT")
 		->where(['b.user_id'=>$user, 'b.status'=>$status])
+        ->limit(10)
 		->select();
 	}
 	

+ 1 - 0
application/user/model/UserComment.php

@@ -31,6 +31,7 @@ class UserComment extends Model{
 		->where(['c.user_id'=>[['eq', $user], ['eq', $comment], 'or']])
 		->where(['c.comment_id'=>[['eq', $user], ['eq', $comment], 'or']])
 		->where(["c.type"=>$type])
+		->where("c.user_id != c.comment_id")
 		->page($page, config('paginate.list_rows'))
 		->order("inputtime DESC")
 		->select();