|
@@ -0,0 +1,62 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Http\Controllers\Wap\Web;
|
|
|
+
|
|
|
+use App\Modules\Activity\Services\ActivityService;
|
|
|
+use Illuminate\Http\Request;
|
|
|
+use App\Http\Controllers\Wap\BaseController;
|
|
|
+use Redis;
|
|
|
+use DB;
|
|
|
+
|
|
|
+class ActivityController extends BaseController
|
|
|
+{
|
|
|
+
|
|
|
+ //渠道自定义活动 可以多少充值
|
|
|
+ public function channelCustomActivity(Request $request){
|
|
|
+ $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
|
|
|
+ $token = $request->input('token');
|
|
|
+ $activity_info = ActivityService::getByToken($token);
|
|
|
+ $img = 'https://cdn-novel.iycdm.com/h5/activity-chanel-custom/btn48.jpg';
|
|
|
+ if ($activity_info && $activity_info->product_id) {
|
|
|
+ $customer_activity_info = DB::table('channel_custom_activity')->where('product_id',$activity_info->product_id)->select('setting')->first();
|
|
|
+ if($customer_activity_info && $customer_activity_info->setting){
|
|
|
+ $img = json_decode($customer_activity_info->setting,1)['img'];
|
|
|
+ }
|
|
|
+ $from = $request->input('fromtype', 'main');
|
|
|
+ $uv_key_format = 'activity:%s:distribution_channel_id:%s:date:%s:uv';
|
|
|
+ $pv_key_format = 'activity:%s:distribution_channel_id:%s:pv';
|
|
|
+ $uv_key = sprintf($uv_key_format, $activity_info->id, $this->distribution_channel_id, date('Y-m-d'));
|
|
|
+ $pv_key = sprintf($pv_key_format, $activity_info->id, $this->distribution_channel_id);
|
|
|
+ Redis::sadd($uv_key, $this->uid);
|
|
|
+ Redis::hincrby($pv_key, date('Y-m-d'), 1);
|
|
|
+ //$order = Order::where('uid',$this->uid)->where('status','PAID')->where('activity_id',$activity_info->id)->count();
|
|
|
+ //渠道不符合
|
|
|
+ if ($activity_info->distribution_channel_id != $this->distribution_channel_id) {
|
|
|
+ return view('pay.activity.ChannelCustomerV1', ['url' => '###', 'img'=>$img,'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
|
|
|
+ }
|
|
|
+ //活动未开始
|
|
|
+ if (time() < strtotime($activity_info->start_time)) {
|
|
|
+ return view('pay.activity.ChannelCustomerV1', ['url' => '###', 'img'=>$img, 'code' => -3, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
|
|
|
+ }
|
|
|
+ //活动结束
|
|
|
+ if (time() > strtotime($activity_info->end_time)) {
|
|
|
+ return view('pay.activity.ChannelCustomerV1', ['url' => '###', 'img'=>$img, 'code' => -1, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
|
|
|
+ $param = [
|
|
|
+ 'uid' => $this->uid,
|
|
|
+ 'distribution_channel_id' => $this->distribution_channel_id,
|
|
|
+ 'product_id' => $activity_info->product_id,
|
|
|
+ 'activity_id' => $activity_info->id,
|
|
|
+ 'fromtype' => $from,
|
|
|
+ 'limit' => 100,
|
|
|
+ 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
|
|
|
+ ];
|
|
|
+ $url = env('CREATE_PAY_URL') . '?' . http_build_query($param);
|
|
|
+ return view('pay.activity.ChannelCustomerV1', ['url' => $url, 'img'=>$img, 'code' => 0, 'start_time' => date('Y-m-d', strtotime($activity_info->start_time)), 'end_time' => date('Y-m-d', strtotime($activity_info->end_time) - 100)]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return view('pay.activity.ChannelCustomerV1', ['url' => '###', 'img'=>$img, 'code' => -1, 'start_time' => date('Y-m-d', time() - 86400 * 2), 'end_time' => date('Y-m-d', time() - 86400)]);
|
|
|
+ }
|
|
|
+}
|