123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576 |
- <?php
- namespace App\Http\Controllers\QuickApp\Activity;
- use App\Cache\Activity\ActivityCache;
- use App\Consts\ErrorConst;
- use App\Http\Controllers\QuickApp\Activity\Transformers\ReBuildData;
- use App\Libs\ApiResponse;
- use App\Libs\Utils;
- use App\Modules\Activity\Services\ActivityService;
- use App\Modules\Channel\Services\ChannelService;
- use App\Modules\Product\Services\ProductService;
- use App\Modules\SendOrder\Models\QappSendOrder;
- use App\Modules\SendOrder\Models\QuickAppSendOrder;
- use App\Modules\Subscribe\Services\OrderService;
- use App\Modules\User\Models\QappChannelAccount;
- use App\Modules\User\Models\User;
- use Illuminate\Http\Request;
- use App\Http\Controllers\QuickApp\BaseController;
- use Redis;
- use DB;
- use Log;
- class ActivityController extends BaseController
- {
- use ApiResponse;
- //渠道自定义活动 可以多少充值
- 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 = $this->getPayUrlByChannelId() . '?' . 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)]);
- }
- public function commonActivity(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $token = $request->input('token');
- $activity_info = ActivityService::getByToken($token);
- if ($activity_info && isset($activity_info->setting) && empty(!$activity_info->setting)) {
- $imgs = json_decode($activity_info->setting, 1);
- $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);
- $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
- if ($request->input('redirect_url')) {
- $redirect_url = $request->input('redirect_url');
- $redirect_url = urldecode($redirect_url);
- }
- $product_id = $activity_info->product_id;
- if ($activity_info->id == 6000) {
- $imgs['page_bd_img'] = 'https://cdn-novel.iycdm.com/h5/activity-2019-04-29/bg2.jpg';
- $product_id = 5788;
- }
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- 'pay_redirect_url' => $redirect_url,
- 'limit' => 100,
- ];
- $url = $this->getPayUrlByChannelId() . '?' . http_build_query($param);
- return view('pay.order.common', ['url' => $url, 'code' => 0, 'img' => $imgs]);
- } else if (time() <= strtotime($activity_info->start_time)) {
- return view('pay.order.common', ['url' => [], 'code' => 1, 'img' => $imgs]);
- } else {
- return view('pay.order.common', ['url' => [], 'code' => 2, 'img' => $imgs]);
- }
- }
- $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- return redirect()->to($default_url);
- }
- public function crmActivity(Request $request)
- {
- $default_url = env('H5_SCHEME', 'https') . '://site' . $this->en_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- $token = $request->input('token');
- if (!$token) {
- return redirect()->to($default_url);
- }
- $activity_info = ActivityService::getByToken($token);
- if (!$activity_info) {
- return redirect()->to($default_url);
- }
- $crm = $request->get('crm', 'crm');
- $img = \GuzzleHttp\json_decode($activity_info->setting, 1);
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => 'crm',
- 'pay_redirect_url' => $default_url . 'person',
- 'limit' => 100,
- 'crm' => $crm
- ];
- $product_info = ProductService::getProductSingle($activity_info->product_id);
- $url = $this->getPayUrlByChannelId() . '?' . http_build_query($param);
- $fee = $product_info->price * 100 + $product_info->given;
- return view('crm.crmActivity', ['url' => $url, 'img' => $img['button'], 'fee' => $fee]);
- }
- public function crmYearActivity(Request $request)
- {
- $default_url = env('H5_SCHEME', 'https') . '://site' . $this->en_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- $activity_info = ActivityService::getById(11378);
- if (!$activity_info) {
- return redirect()->to($default_url);
- }
- $crm = $request->get('crm', 'crm_year_activity');
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $activity_info->product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => 'crm',
- 'pay_redirect_url' => $default_url . 'person',
- 'limit' => 100,
- 'crm' => $crm
- ];
- $url = $this->getPayUrlByChannelId() . '?' . http_build_query($param);
- $is_get = 0;
- $discount_coupon = DB::table('discount_coupons')->where('uid', $this->uid)->where('activity_id', $activity_info->id)->count();
- if ($discount_coupon) {
- $is_get = 1;
- } else {
- DB::table('discount_coupons')->insert([
- 'uid' => $this->uid,
- 'activity_id' => $activity_info->id,
- 'created_at' => date('Y-m-d H:i:s'),
- 'updated_at' => date('Y-m-d H:i:s')
- ]);
- }
- return view('crm.crmYearActivityV2', ['url' => $url, 'is_get' => $is_get]);
- }
- public function channelCustomActivityV3(Request $request)
- {
- $uid = $this->uid;
- $token = $request->get('token');
- $from = $request->input('fromtype', 'main');
- $channelId = (int)$this->distribution_channel_id;
- $activity = ActivityService::getByToken($token);
- $activityId = getProp($activity, 'id');
- if (!$activityId || !getProp($activity, 'setting') || (int)getProp($activity, 'create_type') !== 5 ||
- (int)getProp($activity, 'distribution_channel_id') !== $channelId) {
- Utils::throwError(ErrorConst::ACTIVITY_NOT_FOUND);
- }
- // 获取用户信息
- $user = User::getUser($this->uid);
- $sendOrderId = getProp($user, 'send_order_id');
- // 用户派单的信息是否跟创建该活动的子账号一致
- // $qappAccountId = (int)getProp($activity, 'qapp_account_id');
- // if ($qappAccountId && $sendOrderId) {
- // $sendOrder = QappSendOrder::getSendOrderById($sendOrderId);
- // $qappAccount = QappChannelAccount::getByAccount(getProp($sendOrder, 'account'));
- // if ($qappAccountId !== (int)getProp($qappAccount, 'id')) {
- // Utils::throwError(ErrorConst::ACTIVITY_INVALID);
- // }
- // }
- // 活动开始时间判断
- if (getProp($activity, 'start_time') > date('Y-m-d H:i:s')) {
- Utils::throwError(ErrorConst::ACTIVITY_NOT_START);
- }
- // 活动结束时间判断
- if (getProp($activity, 'end_time') < date('Y-m-d H:i:s')) {
- Utils::throwError(ErrorConst::ACTIVITY_IS_END);
- }
- // 活动pv、uv统计
- $date = date('Y-m-d');
- ActivityCache::incrActivityPv($activityId, $date);
- ActivityCache::zAddActivityUv($activityId, $date, $uid);
- // 获取支付相关信息
- $settingJson = getProp($activity, 'setting');
- $setting = json_decode($settingJson, true);
- $settingProducts = getProp($setting, 'product_info');
- $productIds = array_column($settingProducts, 'product_id');
- $products = ProductService::getProductsByIds($productIds);
- // 组装返回数据
- $data = compact('uid', 'activity', 'products', 'setting', 'settingProducts', 'from');
- return $this->success($data, [new ReBuildData(), 'buildActivityDetail']);
- }
- public function channelCustomActivityV2(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $token = $request->get('token');
- $activity_info = ActivityService::getByToken($token);
- if ($activity_info && isset($activity_info->setting) && empty(!$activity_info->setting) &&
- $activity_info->create_type == 5 &&
- $activity_info->distribution_channel_id == $this->distribution_channel_id
- ) {
- $setting = json_decode($activity_info->setting, 1);
- $select_options = 1;
- $page = 'pay.activity-template.channelCommonTemplate';
- if (isset($setting['product_info']) && count($setting['product_info']) > 1) {
- $select_options = 2;
- $page = 'pay.activity-template.channelCommonTemplate2';
- }
- $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);
- $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
- if ($request->input('redirect_url')) {
- $redirect_url = $request->input('redirect_url');
- $redirect_url = urldecode($redirect_url);
- }
- $imgs = [
- 'page_bd_img' => $setting['page_bd_img'],
- 'page_btn_pre_img' => $setting['page_btn_pre_img'],
- 'page_btn_doing_img' => $setting['page_btn_doing_img'],
- 'page_btn_end_img' => $setting['page_btn_end_img']
- ];
- $bg_color = $setting['page_bd_color'];
- $product_id = $activity_info->product_id;
- $product_info = ProductService::getProductSingle($product_id);
- $limit_times = (!isset($setting['limit_times']) || !$setting['limit_times']) ? 100 : $setting['limit_times'];
- $tip = '';
- if ($limit_times != '100' && $product_info->type != 'YEAR_ORDER') {
- $tip = sprintf('活动期间充%s送%s限购%s次', (float)$product_info->price, $product_info->given / 100, $limit_times);
- }
- $price = $product_info->price;
- $given = $product_info->given / 100;
- $tip_list = [];
- $pay_option_list = [];
- if ($select_options == 2) {
- foreach ($setting['product_info'] as $product_item) {
- $product_detail = ProductService::getProductSingle($product_item['product_id']);
- if ($product_item['limit']) {
- $tip_list[] = sprintf('活动期间充%s送%s限购%s次', (float)$product_detail->price, $product_detail->given / 100, $product_item['limit']);
- } else {
- $tip_list[] = sprintf('活动期间充%s送%s不限次数', (float)$product_detail->price, $product_detail->given / 100);
- }
- $pay_option_list[] = [
- 'price' => (float)$product_detail->price,
- 'given' => $product_detail->given / 100,
- 'total' => (int)($product_detail->price * 100) + $product_detail->given,
- 'url' => 'javascript:void(0)'
- ];
- }
- }
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- if ($select_options == 1) {
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $product_id,
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- 'pay_redirect_url' => $redirect_url,
- 'limit' => $limit_times,
- ];
- $url = $this->getPayUrlByChannelId() . '?' . http_build_query($param);
- } else {
- $url = '';
- foreach ($setting['product_info'] as $k => $product_item) {
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $product_item['product_id'],
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- 'pay_redirect_url' => $redirect_url,
- 'limit' => $product_item['limit'],
- ];
- if ($k == 0) {
- $url = $this->getPayUrlByChannelId() . '?' . http_build_query($param);
- }
- $pay_option_list[$k]['url'] = $this->getPayUrlByChannelId() . '?' . http_build_query($param);
- }
- }
- return view($page, ['url' => $url, 'code' => 0, 'img' => $imgs, 'bg_color' => $bg_color, 'tip' => $tip, 'start_time' => date('Y年m月d日', strtotime($activity_info->start_time)),
- 'end_time' => date('Y年m月d日', strtotime($activity_info->end_time)), 'price' => $price, 'given' => $given, 'pay_option_list' => $pay_option_list, 'tip_list' => $tip_list]);
- } else if (time() <= strtotime($activity_info->start_time)) {
- return view($page, ['url' => 'javascript:void(0)', 'code' => 1, 'img' => $imgs, 'bg_color' => $bg_color, 'tip' => $tip, 'start_time' => date('Y年m月d日', strtotime($activity_info->start_time)),
- 'end_time' => date('Y年m月d日', strtotime($activity_info->end_time)), 'price' => $price, 'given' => $given, 'pay_option_list' => $pay_option_list, 'tip_list' => $tip_list]);
- } else {
- return view($page, ['url' => 'javascript:void(0)', 'code' => 2, 'img' => $imgs, 'bg_color' => $bg_color, 'tip' => $tip, 'start_time' => date('Y年m月d日', strtotime($activity_info->start_time)),
- 'end_time' => date('Y年m月d日', strtotime($activity_info->end_time)), 'price' => $price, 'given' => $given, 'pay_option_list' => $pay_option_list, 'tip_list' => $tip_list]);
- }
- }
- $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- return redirect()->to($default_url);
- }
- public function commonActivityV2(Request $request)
- {
- $token = $request->get('token');
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $activity_info = ActivityService::getByToken($token);
- $default_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- if (!$activity_info) return redirect()->to($default_url);
- if (!in_array($activity_info->create_type, [1, 2, 3, 4])) {
- return redirect()->to($default_url);
- }
- //内部站点的活动
- if ($activity_info->create_type == 2 && !isInnerSites($this->distribution_channel_id)) {
- return redirect()->to($default_url);
- }
- //外部站点活动
- if ($activity_info->create_type == 3 && isInnerSites($this->distribution_channel_id)) {
- return redirect()->to($default_url);
- }
- //单独站点
- if ($activity_info->create_type == 7 && $this->distribution_channel_id != $activity_info->distribution_channel_id) {
- return redirect()->to($default_url);
- }
- $setting = json_decode($activity_info->setting, 1);
- $product_info = $setting['products'];
- //$product_info = stripslashes($product_info);
- //$product_info = json_decode($product_info,1);
- if (!$product_info) {
- return redirect()->to($default_url);
- }
- $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
- if ($request->get('redirect_url')) {
- $redirect_url = $request->input('redirect_url');
- $redirect_url = urldecode($redirect_url);
- }
- $from = $request->get('fromtype', 'main');
- $count = count($product_info);
- $bg_color = $setting['page_bd_color'];
- //统计
- $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);
- if ($count > 5 || $count < 1) return redirect()->to($default_url);
- if (time() > strtotime($activity_info->start_time) && time() < strtotime($activity_info->end_time)) {
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- $activity_status = 0;
- } else if (time() <= strtotime($activity_info->start_time)) {
- $activity_status = 1;
- } else {
- $activity_status = 2;
- }
- $tips = explode("\n", $setting['rule']);
- $imgs = [
- 'page_bd_img' => $setting['page_bd_img'],
- 'page_btn_pre_img' => $setting['page_btn_pre_img'],
- 'page_btn_doing_img' => $setting['page_btn_doing_img'],
- 'page_btn_end_img' => $setting['page_btn_end_img']
- ];
- $title = $activity_info->name;
- $page = 'pay.activity-template.commonTemplate';
- $page_config = [];
- $default_select_product = $product_info[0]['id'];
- foreach ($product_info as $value) {
- if ($value['is_default']) $default_select_product = $value['id'];
- }
- $default_select_product_link = '';
- foreach ($product_info as $item) {
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $item['id'],
- 'activity_id' => $activity_info->id,
- 'fromtype' => $from,
- 'pay_redirect_url' => $redirect_url,
- 'limit' => isset($item['limit_times']) ? $item['limit_times'] : 100,
- ];
- if ($activity_status == 0) {
- $url = $this->getPayUrlByChannelId() . '?' . http_build_query($param);
- } else {
- $url = 'javascript:void(0)';
- }
- $page_config[] = [
- 'unselected_img' => $item['unselected_img'],
- 'selected_img' => $item['selected_img'],
- 'url' => $url,
- 'is_select' => $item['id'] == $default_select_product ? 1 : 0
- ];
- if ($item['id'] == $default_select_product) {
- $default_select_product_link = $url;
- }
- }
- $data = ['code' => $activity_status, 'img' => $imgs,
- 'bg_color' => $bg_color, 'start_time' => date('Y年m月d日', strtotime($activity_info->start_time)),
- 'end_time' => date('Y年m月d日', strtotime($activity_info->end_time)), 'tips' => $tips,
- 'page_config' => $page_config, 'title' => $title,
- 'default_link' => $default_select_product_link
- ];
- return view($page, $data);
- }
- private function getPayUrlByChannelId()
- {
- $channel = ChannelService::getDistributionChannel($this->distribution_channel_id);
- $pay_url = getPayUrl($channel->pay_merchant_id);
- return $pay_url;
- }
- public function pageSpreadActivity(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $activity_id = 49365;
- $product_id = 14835;
- $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_id, $this->distribution_channel_id, date('Y-m-d'));
- $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
- $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
- if ($request->get('redirect_url')) {
- $redirect_url = $request->get('redirect_url');
- $redirect_url = urldecode($redirect_url);
- }
- $limit_status = OrderService::userParticipateActivityLimit($this->uid, $activity_id, $product_id, 1);
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $product_id,
- 'activity_id' => $activity_id,
- 'fromtype' => $from,
- 'pay_redirect_url' => $redirect_url,
- 'limit' => 1,
- ];
- $url = $this->getPayUrlByChannelId() . '?' . http_build_query($param);
- $result_data = ['url' => $url, 'class' => 'pay', 'text' => '立即充值', 'price' => 18, 'given' => 10, 'get' => 2800, 'limit' => 1];
- if ($limit_status) {
- //充值过了
- $result_data = ['url' => 'javascript:void(0)', 'class' => 'unpay', 'text' => '充值次数已达上限', 'price' => 18, 'given' => 10, 'get' => '2800', 'limit' => 1];
- }
- return view('pay.activity.pageSpreadAvtivity', $result_data);
- }
- public function channelYearNew288(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $id = 53536;
- $activity_info = ActivityService::getById($id);
- if ($activity_info && $activity_info->product_id) {
- $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);
- $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' => 0,
- 'pay_redirect_url' => env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person'
- ];
- $channel = ChannelService::getDistributionChannel($this->distribution_channel_id);
- $pay_url = getPayUrl($channel->pay_merchant_id);
- $url = $pay_url . '?' . http_build_query($param);
- return view('pay.activity.channelYearNew288', ['url' => $url]);
- }
- $url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/';
- return redirect()->to($url);
- }
- public function pageSpreadActivity28(Request $request)
- {
- $encode_distribution_channel_id = encodeDistributionChannelId($this->distribution_channel_id);
- $activity_id = 60510;
- $product_id = 15786;
- $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_id, $this->distribution_channel_id, date('Y-m-d'));
- $pv_key = sprintf($pv_key_format, $activity_id, $this->distribution_channel_id);
- $redirect_url = env('H5_SCHEME', 'https') . '://site' . $encode_distribution_channel_id . '.' . env('CUSTOM_HOST') . '.com/person';
- if ($request->get('redirect_url')) {
- $redirect_url = $request->get('redirect_url');
- $redirect_url = urldecode($redirect_url);
- }
- //$limit_status = OrderService::userParticipateActivityLimit($this->uid, $activity_id, $product_id, 1);
- Redis::sadd($uv_key, $this->uid);
- Redis::hincrby($pv_key, date('Y-m-d'), 1);
- $param = [
- 'uid' => $this->uid,
- 'distribution_channel_id' => $this->distribution_channel_id,
- 'product_id' => $product_id,
- 'activity_id' => $activity_id,
- 'fromtype' => $from,
- 'pay_redirect_url' => $redirect_url,
- 'limit' => 1,
- ];
- $url = $this->getPayUrlByChannelId() . '?' . http_build_query($param);
- $result_data = ['url' => $url, 'class' => 'pay', 'text' => '立即充值', 'price' => 28, 'given' => 28, 'get' => 5600, 'limit' => 0];
- return view('pay.activity.pageSpreadAvtivity', $result_data);
- }
- }
|