| | |
| | | namespace app\api\logic; |
| | | |
| | | use app\common\logic\Basic as BasicLogic; |
| | | use think\console\output\descriptor\Console; |
| | | use think\Db; |
| | | class ActivityInfo extends BasicLogic |
| | | { |
| | | |
| | | |
| | | /** |
| | | * è·åæ´»å¨ä¿¡æ¯ |
| | | */ |
| | | public function getActInfo($actid,$userid) |
| | | { |
| | | $res=Db::query('SELECT * FROM t_activity_manage WHERE id=?',[$actid]); |
| | | $response=[ |
| | | 'actstatus'=>1, |
| | | 'joinstatus'=>0 |
| | | ]; |
| | | if(empty($res)){ |
| | | $response['actstatus']=0;//ä¸åå¨ |
| | | return $response; |
| | | } |
| | | if($res[0]['act_status']==0) |
| | | { |
| | | $response['actstatus']=-1;//å·²ç»æ |
| | | return $response; |
| | | } |
| | | if(time()<strtotime($res[0]['start_time'])) |
| | | { |
| | | $response['actstatus']= -2;//æªå¼å§ |
| | | return $response; |
| | | } |
| | | if(time()>strtotime($res[0]['end_time'])) |
| | | { |
| | | $response['actstatus']= -3;//å·²ç»æ |
| | | return $response; |
| | | } |
| | | //æ¯å¦å·²åå æ´»å¨ |
| | | $recruitid=$actid.'u'.$userid; |
| | | $canjia=Db::query('select id from t_recruit_act where id=?',[$recruitid]); |
| | | if(empty($canjia)) |
| | | { |
| | | $response['joinstatus']=0;//æªåå |
| | | } |
| | | else{ |
| | | $response['joinstatus']=1;//å·²åå |
| | | } |
| | | return $response; |
| | | } |
| | | |
| | | /** |
| | | * åå æ´»å¨ |
| | | * |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * è·åå·²éè¯·äººæ° |
| | | */ |
| | | public function getActRecruitCount($actid,$userid) |
| | | { |
| | | $recruitid=$actid.'u'.$userid; |
| | | $count=Db::query('select recruit_count from t_recruit_act where id=?',[$recruitid]); |
| | | if(empty($count)) |
| | | { |
| | | return 0; |
| | | } |
| | | return $count[0]['recruit_count']; |
| | | } |
| | | |
| | | /** |
| | | * è·åæå |
| | | */ |
| | | public function getRankingList($actid,$userid) |
| | | { |
| | | $rList=Db::query(' SELECT a.id,a.nickname,a.avatar,b.recruit_count from t_recruit_act b left join t_user a on a.id =b.user_id where b.act_id=? and b.recruit_count>0 order by b.recruit_count desc limit 7',[$actid]); |
| | | if(empty($rList)) |
| | | { |
| | | return []; |
| | | } |
| | | return $rList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * è®¡ç®æåæ´»å¨éé¢ |
| | | * |
| | | */ |
| | | public function run_countRecruitAct() |
| | | { |
| | | //å
æ¥è¯¢æåæ´»å¨ |
| | | $actList=Db::query('select * from t_activity_manage where count_status=0 and act_type=0 and act_status=1'); |
| | | if(empty($actList)) |
| | | { |
| | | return '没æç¬¦åçæ´»å¨'; |
| | | } |
| | | |
| | | foreach($actList as $act) |
| | | {//å¾ªç¯æ´»å¨ï¼è®¡ç®éé¢ |
| | | //ä¿®æ¹æ´»å¨è®¡ç®ç¶æ |
| | | $this->run_UpdateActCount($act['id'],1); |
| | | $actEndTime=strtotime($act['end_time']);//æ´»å¨ç»ææ¶é´ |
| | | //æ¥è¯¢ææå䏿´»å¨çä¼å |
| | | $cusList=Db::query('select * from t_recruit_act where act_id=? and settlement_status=0 and user_t=0',[$act['id']]); |
| | | if(empty($cusList)) |
| | | { |
| | | $this->run_UpdateActCount($act['id'],2); |
| | | continue; |
| | | } |
| | | foreach($cusList as $cus) |
| | | {//循ç¯å䏿´»å¨çä¼å |
| | | $yqCount=Db::query('select count(1) as count from t_user where invitation_id=? and invite_bind_time>=? and invite_bind_time<=?',[$cus['user_id'],$cus['create_time'],$actEndTime]); |
| | | if(empty($yqCount)) |
| | | { |
| | | continue; |
| | | } |
| | | //计ç®åºå¾éé¢ |
| | | $price=0; |
| | | // |
| | | // |
| | | // |
| | | |
| | | |
| | | |
| | | $tradeId=$act['id'].$cus['user_id']; |
| | | //æå
¥èæ¨å®¢ç订å |
| | | $tradeHas=Db::query('select id from t_jtk_union_order_commission where trade_parent_id=?',[$tradeId]); |
| | | if(!empty($tradeHas)) |
| | | {//å·²ç»æè®¢å |
| | | continue; |
| | | } |
| | | $tradeRes=Db::execute('insert into t_jtk_union_order_commission (trade_parent_id,trade_id,member_id,buy_member_id,is_own,alipay_total_price,pub_share_pre_fee,item_title,item_id,is_settle,tb_paid_time,create_time,update_time)values(?,?,?,?,1,?,?,?,?,?,?,?,?)',[$tradeId,$tradeId,$cus['user_id'],$cus['user_id'],$price,$price,$act['act_name'],$act['id'],0,time(),time(),time()]); |
| | | if($tradeRes==1) |
| | | {//ä¿®æ¹è®¡ç®ç¶æ |
| | | Db::execute('update t_recruit_act set settlement_status=?,settlement_time=? where id=?',[1,time(),$tradeId]); |
| | | } |
| | | } |
| | | $this->run_UpdateActCount($act['id'],2); |
| | | } |
| | | return 'æ§è¡-success'; |
| | | } |
| | | |
| | | public function run_UpdateActCount($actid,$countStatus) |
| | | { |
| | | if($countStatus==1) |
| | | { |
| | | Db::execute('update t_activity_manage set count_status=? where id=?',[$countStatus,$actid]); |
| | | } |
| | | else{ |
| | | Db::execute('update t_activity_manage set count_status=?,count_time=? where id=?',[$countStatus,time(),$actid]); |
| | | } |
| | | } |
| | | |
| | | } |