123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- namespace app\clientweb\controller;
- use app\common\controller\ClientWeb;
- use app\common\library\Redis;
- use app\main\constants\ActivityConstants;
- use app\main\constants\ClientWebConstants;
- use app\main\service\AdminService;
- use app\main\service\ClientAppService;
- use app\main\service\UserService;
- use think\Config;
- use think\Cookie;
- use think\Request;
- use think\Url;
- use app\main\constants\PayConstants;
- use app\main\constants\UserConstants;
- class Activity extends ClientWeb
- {
- public function index()
- {
- $rid = intval($_GET['rid'] ?? 0);
- $aid = intval($_GET['id'] ?? 0);
- if (empty($aid)) {
- $this->error('活动不存在');
- }
- $is_range = 0;
- if ($this->isLogin) {
- UserService::instance()->setUserCache($this->userid);
- $user_id = UserService::instance()->getUserInfo()->id;
- $admin_id = UserService::instance()->getAdminId()->data;
- $channel_id = UserService::instance()->getUserInfo()->channel_id;
- } else {
- //拉取系统默认设置
- $user_id = $this->userid;
- $admin_id = $channel_id = Config::get('site.fake_channel_id');
- }
- if ($this->request->has('isrange') || $this->request->has('isRange')) {
- $is_range = 1;
- }
- if ($this->request->has('visitor')) {
- Cookie::set('visitor', $this->request->get('visitor'));
- }
- /**
- * 获取渠道商/代理商资料
- */
- $adminExtend = AdminService::instance()->getAdminExtendModel()->where(['admin_id' => $admin_id])->find();
- if (!$adminExtend) {
- $this->error('管理员信息获取失败');
- }
- $activityInfo = model('Activity')->where('id', $aid)->find();
- $isGiveAct = $activityInfo['type'] == ActivityConstants::ACTIVITY_TYPE_GIVE;
- $res = model('resource')->join('activity a', 'a.id=resource.activity_id')->where('a.id', $aid)
- ->field('a.starttime,a.endtime,a.status as astatus,a.name as aname,resource.*')->order('resource.weigh', 'desc')->find();
- if(!$res){
- $this->error('活动不存在');
- }
- if ($res['goods_id'] > 0) {
- $goodsInfo = model('Goods')->where('id', $res['goods_id'])->find();
- if ($goodsInfo) {
- $res['money'] = $goodsInfo['money'];
- }
- }
- $recent_url = getCurrentDomain($channel_id, '/index/user/recent');
- $this->assign('recent_url', $recent_url);
- if ($res['activity_id'] == 100) {
- if (UserService::instance()->getUserInfo()->is_pay == UserConstants::USER_IS_PAY_YES) {
- $is_range = 1;
- }
- }
- if($res['endtime'] < $this->time||empty($res['astatus'])){
- $this->assign('isend',1);
- }
- if($res['starttime'] > $this->time && !empty($res['astatus'])){
- $this->assign('needWait',1);
- $lastTime = $this->lastTime($res['starttime']);
- $this->assign('lastTime',$lastTime);
- }
- $arr = [];
- array_push($arr,"\r\n");
- array_push($arr,"\r");
- array_push($arr,"\n");
- $pay_url = '';
- $res['warning'] = str_replace($arr,"<br/>",$res['warning']);
- $to_url = ClientAppService::instance()->parseAppUrl('book', []);
- $payment_method = empty($admin_info['payment_method']) ? '0' : '1';
- $this->assign('res', $res);
- $this->assign('isGiveAct', $isGiveAct);
- $this->assign('payment_method', $payment_method);
- $this->assign('aid', $res['activity_id']);
- $this->assign('payUrl', $pay_url);
- $this->assign('toUrl', $to_url);
- $this->assign('goods_id', $res['goods_id']);
- $this->assign('isRange', $is_range);
- return $this->fetch();
- }
- }
|