Commit fd7392dd authored by houyadong's avatar houyadong

富币-全民邀请

parent 54a5d63a
......@@ -1648,4 +1648,19 @@ function getSys(){
return'Other';
}
}
/**
* 格式化print_r
* @param mixed $data 数据
* @param bool $flag 是否需要die
* @return mixed
*/
function p($data, $flag = true)
{
echo '<pre>';
print_r($data);
echo '</pre>';
if ($flag) {
die;
}
}
?>
\ No newline at end of file
......@@ -380,25 +380,22 @@ class PkTopAction extends IdentityAction{
public function join(){
// $code_type = 35;
$code_type = 32;
$mfrom=I('mfrom',0);
$mfrom = I('mfrom',0);
//报名大赛
$mobile = I('mobile', '');
$smsCode = I('smsCode', '');
$referer =I('referer', '');
$inviterId =I('inviterId', '',intval);
$referer = I('referer', '');
$inviterId = I('inviterId', '',intval);
$targetUrl = I('targetUrl', '');
$targetUrl =I('targetUrl', '');
// var_dump($referer);exit;
//app外打开
if($mobile){
if (!$smsCode) {
if(!$smsCode) {
$this->ajaxReturn(['status' => 0, 'info' => '请输入手机验证码!']);
}
$param = ['mobile'=>$mobile,'code'=>$smsCode,'type'=>$code_type];
if(D('Sms')->checkCode($param)){
}else{
if(!D('Sms')->checkCode($param)){
$this->ajaxReturn(['status' => 0, 'info' => '对不起!手机验证码错误或已过期!']);
}
......@@ -410,22 +407,17 @@ class PkTopAction extends IdentityAction{
$ucData=$ucUser['data'];
}
}else{
$groupInfo=M('Group')->field('group_id,web_id,category,name,startTime,endTime')->where(array('group_id'=>$this->GID))->find();
$groupStatus=$this->getGroupStatus($groupInfo);
if ($groupStatus==3) {
$this->ajaxReturn(['status' => 0, 'info' => '大赛已经结束,不能报名!']);
}
if($mfrom==1||$mfrom==2){
if($mfrom==1||$mfrom==2){
$userId = I('userId', '',intval);
if($mfrom==1){
// $referer=$referer?$referer:'ios_banner';
$referer=$referer?$referer:(I('place')?I('place'):'ios_banner');
}
if($mfrom==2){
// $referer=$referer?$referer:'android_banner';
$referer=$referer?$referer:(I('place')?I('place'):'android_banner');
}
......@@ -591,7 +583,6 @@ class PkTopAction extends IdentityAction{
return ['status'=>0,'info'=>'登录成功','debug'=>$userId,'flag'=>1];
}
}
//加入炼股赛用户表
$exist=M('PktopUser')->where(array('user_id'=>$userId))->find();
if(empty($exist)){
......@@ -634,7 +625,11 @@ class PkTopAction extends IdentityAction{
D('User')->finishXunzhang($userId,$userName,$mobile,'cansai');
D('Sms')->send(['mobile'=>$mobile,'content' =>$bmContent,'type'=>46],true,true);
#富币任务-全民邀请参赛
if(cookie('aid')){
D('CofCoin')->addMoneyForQmShare($userId,cookie('aid'));
cookie('aid',null);
}
return ['status'=>1,'info'=>'参赛成功','debug'=>$userId];
}
......@@ -1035,24 +1030,13 @@ class PkTopAction extends IdentityAction{
}
//新首页
public function index() {
//首页的排行榜等切换
// if(!I('viewPage')){
// header('location:'.M_URL.'/Match/jiang');
// exit;
// }
public function index()
{
//邀请人id
if(I('aid')){
cookie('aid',I('aid'));
}
$userIdParam = I('user_id', '', intval);
// $isapp = I('isapp');
// if ($isapp) {
// $userId = substr($isapp, strpos($isapp, '=') + 1);
// if ($userId) {
// $userIdParam = $userId;
// }
// }
$key = I('key', '');
$key2 = I('key2', '');
......@@ -1072,14 +1056,11 @@ class PkTopAction extends IdentityAction{
$userId = $userIdParam;
}
}
//echo $userId;exit;
//app从过来可能没有userName
if ($userId && $this->user['userName'] == '') {
$this->setUcLogin($userId);
}
// $gid = $this->GID;
$groupId =$this->GID;
$groupId = $this->GID;
$groupInfo = M('Group')->field('group_id,web_id,category,name,startTime,endTime,member_quantity')->where(['group_id' => $groupId])->find();
$groupStatus = $this->getGroupStatus($groupInfo);
......
<?php
/**
* 富币体系
*/
class CofCoinModel extends Model
{
public $autoCheckFields = false;
/** @var int 邀请好友全民炼股参赛成功 */
const TYPE_INVITA_QM = 26;
/**
* 被邀请参加全民后奖励富币
* @param $user_id int 被邀请人用户id
* @param $share_user_id int 邀请人用户id
* @return bool
*/
public function addMoneyForQmShare($user_id,$share_user_id)
{
if(!$user_id || !$share_user_id){
return false;
}
$type_info = M('CoinType')->where(['type_id'=>26])->find();
if(empty($type_info)){
return false;
}
#邀请人的数据
$share_user_info = uc_get_user(['userId' => $share_user_id,'type'=>3]);
if($share_user_info['data']['user_id'] !== $share_user_id){
return false;
}
$share_user_info = $share_user_info['data'];
$my_coin = M('CoinUser')->where(['user_id' => $share_user_info['user_id']])->getField('coin');
if ($my_coin === null) {
M('CoinUser')->add(['user_id' => $share_user_info['user_id'], 'coin' => 0, 'add_time' => time()]);
}
#富币明细表
M('CoinDetail')->add([
'title' => $type_info['type_name'],
'user_id' => $share_user_info['user_id'],
'user_name' => $share_user_info['user_name'],
'mobile' => $share_user_info['mobile'],
'coin_change' => $type_info['coin'],
'add_time' => time(),
'type_id' => self::TYPE_INVITA_QM,
'other_id' => $user_id,
]);
#富币用户表
M('CoinUser')->where(['user_id' => $share_user_info['user_id']])->setInc('coin', $type_info['coin']);
return true;
}
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment