|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Http\Controllers\Wap\Order;
|
|
|
|
|
|
+use App\Modules\Subscribe\Models\Order;
|
|
|
use App\Http\Controllers\Wap\BaseController;
|
|
|
use App\Modules\Book\Services\BookConfigService;
|
|
|
use App\Modules\Channel\Services\ChannelService;
|
|
@@ -11,6 +12,7 @@ use App\Modules\OfficialAccount\Services\ForceSubscribeService;
|
|
|
use App\Modules\Statistic\Services\AdVisitStatService;
|
|
|
use App\Modules\Statistic\Services\DataAnalysisSelectUserService;
|
|
|
use App\Modules\User\Services\ForceSubscribeUserIService;
|
|
|
+use App\Modules\User\Services\UserDivisionPropertyService;
|
|
|
use App\Modules\User\Services\UserService;
|
|
|
use App\Modules\Book\Services\BookService;
|
|
|
use App\Modules\Channel\Services\PayTemplateService;
|
|
@@ -34,6 +36,9 @@ class OrdersController extends BaseController
|
|
|
*/
|
|
|
|
|
|
private $force_subscribe_info;
|
|
|
+
|
|
|
+ private $chargeList;
|
|
|
+
|
|
|
/**
|
|
|
* @apiVersion 1.0.0
|
|
|
* @apiDescription 充值列表
|
|
@@ -201,7 +206,7 @@ class OrdersController extends BaseController
|
|
|
\Log::info('order:$template_id:' . $template_id);
|
|
|
\Log::info('order:$distribution_channel_id:' . ($this->distribution_channel_id));
|
|
|
$book_config = null;
|
|
|
- if($bid){
|
|
|
+ if ($bid) {
|
|
|
$bid = Hashids::decode($bid)[0];
|
|
|
//$book = BookService::getBookById($bid);
|
|
|
$book_config = BookConfigService::getBookById($bid);
|
|
@@ -209,12 +214,13 @@ class OrdersController extends BaseController
|
|
|
if ($template_id == 2) { //模板2只有在长篇小说过来的用户才显示
|
|
|
//部分渠道需要2元模板不管哪个入口进来都展示
|
|
|
$exclude_channels = explode(',', env('PRICE_TWO_SHOW_ALL_CHANNEL'));
|
|
|
+
|
|
|
if(!in_array($this->distribution_channel_id,$exclude_channels))
|
|
|
{
|
|
|
if($book_config){
|
|
|
if($book_config->charge_type == 'BOOK') $template_id = 1;
|
|
|
}else{
|
|
|
- $template_id = 1;
|
|
|
+ //$template_id = 1;
|
|
|
}
|
|
|
/*if ($bid) {
|
|
|
$bid = Hashids::decode($bid)[0];
|
|
@@ -242,25 +248,26 @@ class OrdersController extends BaseController
|
|
|
}*/
|
|
|
|
|
|
//男频站点 支付模板
|
|
|
- if( ($male_site_template = $this->maleSite($this->distribution_channel_id)) ){
|
|
|
+ if (($male_site_template = $this->maleSite($this->distribution_channel_id))) {
|
|
|
//\Log::info('$male_site_template is: '.$male_site_template);
|
|
|
$template_id = $male_site_template;
|
|
|
}
|
|
|
|
|
|
- if( ($compare_id = $this->templateCompare()) ){
|
|
|
+ /*if( ($compare_id = $this->templateCompare()) ){
|
|
|
$template_id = $compare_id;
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
/*if( ($comparev2_id = $this->templateCompareV2()) ){
|
|
|
$template_id = $comparev2_id;
|
|
|
}*/
|
|
|
-
|
|
|
+ $this->outstandingYearOrder($this->uid);
|
|
|
\Log::info('recordFirstIntoPayPage:$template_id:' . $template_id);
|
|
|
$res = ProductService::getChargeProduct($template_id);
|
|
|
if (!$res) {
|
|
|
return response()->error('WAP_SYS_ERROR');
|
|
|
}
|
|
|
-
|
|
|
+ $this->chargeList = $res;
|
|
|
+ $this->exchangeList();
|
|
|
/*if ($this->send_order_id) {
|
|
|
try {
|
|
|
Redis::sadd('pay_page_uv' . $this->send_order_id, $this->uid);
|
|
@@ -276,27 +283,27 @@ class OrdersController extends BaseController
|
|
|
//yqLog('user')->info('user is ',['user'=>$user]);
|
|
|
//yqLog('user')->info('user is ',['charge_count'=>$user->charge_count]);
|
|
|
$data = [];
|
|
|
- $appad =0;
|
|
|
- if(in_array($this->distribution_channel_id,explode(',',env('ADS_OPEN_SITE')))){
|
|
|
+ $appad = 0;
|
|
|
+ if (in_array($this->distribution_channel_id, explode(',', env('ADS_OPEN_SITE')))) {
|
|
|
$appad = $this->appad();
|
|
|
$my_bid = $bid;
|
|
|
- if($appad) {
|
|
|
- try{
|
|
|
- AdvertiseUsersService::addAdAccessRec(['uid'=>$this->uid,
|
|
|
- 'bid'=>$my_bid,
|
|
|
- 'position'=>'RECHARGE',
|
|
|
- 'created_at'=>date('Y-m-d H:i:s'),
|
|
|
- 'updated_at'=>date('Y-m-d H:i:s'),
|
|
|
- 'remark'=>$request->url()
|
|
|
+ if ($appad) {
|
|
|
+ try {
|
|
|
+ AdvertiseUsersService::addAdAccessRec(['uid' => $this->uid,
|
|
|
+ 'bid' => $my_bid,
|
|
|
+ 'position' => 'RECHARGE',
|
|
|
+ 'created_at' => date('Y-m-d H:i:s'),
|
|
|
+ 'updated_at' => date('Y-m-d H:i:s'),
|
|
|
+ 'remark' => $request->url()
|
|
|
]);
|
|
|
- }catch(\Exception $e){
|
|
|
- \Log::error('insert into advertise_access_rec failded:'.$e->getMessage());
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ \Log::error('insert into advertise_access_rec failded:' . $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//\Log::info('ad-tu:uid:'.$uid.':'.$appad);
|
|
|
foreach ($res as $v) {
|
|
|
- if($template_id == 7 && $book_config && $book_config->charge_type == 'BOOK' && $v->price == 2){
|
|
|
+ if ($template_id == 7 && $book_config && $book_config->charge_type == 'BOOK' && $v->price == 2) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -317,7 +324,7 @@ class OrdersController extends BaseController
|
|
|
'today_special' => false,
|
|
|
'save_text' => round($v->given / 100, 1) . '元',
|
|
|
'product_id' => $v->id,
|
|
|
- 'show_free_ads'=>$appad
|
|
|
+ 'show_free_ads' => $appad
|
|
|
];
|
|
|
$data[] = $temp;
|
|
|
} elseif ($v->type == 'YEAR_ORDER') {
|
|
@@ -334,7 +341,7 @@ class OrdersController extends BaseController
|
|
|
'today_special' => false,
|
|
|
'save_text' => $save_text,
|
|
|
'product_id' => $v->id,
|
|
|
- 'show_free_ads'=>$appad
|
|
|
+ 'show_free_ads' => $appad
|
|
|
];
|
|
|
$data[] = $temp;
|
|
|
} else {
|
|
@@ -357,7 +364,7 @@ class OrdersController extends BaseController
|
|
|
'today_special' => $v->is_default == 1 ? true : false,
|
|
|
'save_text' => $save_text,
|
|
|
'product_id' => $v->id,
|
|
|
- 'show_free_ads'=>$appad
|
|
|
+ 'show_free_ads' => $appad
|
|
|
];
|
|
|
$data[] = $temp;
|
|
|
}
|
|
@@ -544,10 +551,10 @@ class OrdersController extends BaseController
|
|
|
$chapter_model = new ChapterOrderService();
|
|
|
$page_size = $request->input('page_size', 15);
|
|
|
$chapter_order = $chapter_model->getByUid($this->uid, $page_size);
|
|
|
- foreach ($chapter_order as $item){
|
|
|
- if($item->fee == 0){
|
|
|
- $result = AdVisitStatService::getInfoV2($this->uid,$item->cid,['UNLOCK','UNLOCK_2']);
|
|
|
- if($result) $item->fee = '解锁';
|
|
|
+ foreach ($chapter_order as $item) {
|
|
|
+ if ($item->fee == 0) {
|
|
|
+ $result = AdVisitStatService::getInfoV2($this->uid, $item->cid, ['UNLOCK', 'UNLOCK_2']);
|
|
|
+ if ($result) $item->fee = '解锁';
|
|
|
}
|
|
|
}
|
|
|
return response()->pagination(new ChapterOrderTransformer(), $chapter_order);
|
|
@@ -647,13 +654,13 @@ class OrdersController extends BaseController
|
|
|
{
|
|
|
$start_time = env('RECORD_FIRST_VISIT_PAY_PAGE_TIME');
|
|
|
$template_id = 0;
|
|
|
- if (in_array($this->distribution_channel_id,[123,211]) && $start_time && $this->uid) {
|
|
|
+ if (in_array($this->distribution_channel_id, [123, 211]) && $start_time && $this->uid) {
|
|
|
$user = $this->_user_info;
|
|
|
if (strtotime($user->created_at) > $start_time) {
|
|
|
$old = DB::table('user_first_visit_pay_page')->where('uid', $this->uid)->select('uid', 'template_type')->first();
|
|
|
if ($old) {
|
|
|
$template_id = $old->template_type;
|
|
|
- if($template_id) return $template_id;
|
|
|
+ if ($template_id) return $template_id;
|
|
|
}
|
|
|
if ($bid && $bid == 1148) {
|
|
|
$template_id = $this->uid % 2 == 0 ? 2 : 1;
|
|
@@ -674,13 +681,14 @@ class OrdersController extends BaseController
|
|
|
return $template_id;
|
|
|
}
|
|
|
|
|
|
- private function templateCompare(){
|
|
|
+ private function templateCompare()
|
|
|
+ {
|
|
|
//if(!in_array($this->distribution_channel_id,[2,14,211,155,4427,4488,256,691,146,255,722,4364,5,202,318,4237,266,196,273,4236,148,8,4241,160,271,4053,123,4334,4487,4593,695,4025,4426,4174])){
|
|
|
/*$start_time = env('TEMPLATE_COMPARE_START_TIME_3',0);
|
|
|
if(!$start_time){
|
|
|
return 0;
|
|
|
}*/
|
|
|
- if(!in_array($this->distribution_channel_id,[14,123,211,5,8,160,4236,4237,4241,374,243,244,245,320,321,324,337,338,538,539,751,752,753,754,4331,4384,4578,4580,4768,4769,4778,130,163,164,165,166,4126])){
|
|
|
+ if (!in_array($this->distribution_channel_id, [14, 123, 211, 5, 8, 160, 4236, 4237, 4241, 374, 243, 244, 245, 320, 321, 324, 337, 338, 538, 539, 751, 752, 753, 754, 4331, 4384, 4578, 4580, 4768, 4769, 4778, 130, 163, 164, 165, 166, 4126])) {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -689,8 +697,8 @@ class OrdersController extends BaseController
|
|
|
return 0;
|
|
|
}*/
|
|
|
$template_id = 0;
|
|
|
- $user = DataAnalysisSelectUserService::getByUidAndType($this->uid,'TEMPLATE_COMPARE_V3');
|
|
|
- if($user){
|
|
|
+ $user = DataAnalysisSelectUserService::getByUidAndType($this->uid, 'TEMPLATE_COMPARE_V3');
|
|
|
+ if ($user) {
|
|
|
$template_id = $user->attach;
|
|
|
}
|
|
|
|
|
@@ -698,25 +706,26 @@ class OrdersController extends BaseController
|
|
|
}
|
|
|
|
|
|
|
|
|
- private function templateCompareV2(){
|
|
|
- $start_time = env('TEMPLATE_COMPARE_START_TIME',0);
|
|
|
- if(!$start_time){
|
|
|
+ private function templateCompareV2()
|
|
|
+ {
|
|
|
+ $start_time = env('TEMPLATE_COMPARE_START_TIME', 0);
|
|
|
+ if (!$start_time) {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- if(!in_array($this->distribution_channel_id,[2,146 ,155 ,255 ,256 ,691 ,722 ,4364 ,695 ,4174 ,4025 ,4593 ,4426 ,4742 ,4053 ,4334 ,4487])){
|
|
|
+ if (!in_array($this->distribution_channel_id, [2, 146, 155, 255, 256, 691, 722, 4364, 695, 4174, 4025, 4593, 4426, 4742, 4053, 4334, 4487])) {
|
|
|
return 0;
|
|
|
}
|
|
|
$user = $this->_user_info;
|
|
|
- if(strtotime($user->created_at) < $start_time){
|
|
|
+ if (strtotime($user->created_at) < $start_time) {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- $user = DataAnalysisSelectUserService::getByUidAndType($this->uid,'TEMPLATE_COMPAREV2');
|
|
|
- if($user){
|
|
|
+ $user = DataAnalysisSelectUserService::getByUidAndType($this->uid, 'TEMPLATE_COMPAREV2');
|
|
|
+ if ($user) {
|
|
|
$template_id = $user->attach;
|
|
|
- }else{
|
|
|
- $template_id = $this->uid % 2 == 0? 1:6;
|
|
|
+ } else {
|
|
|
+ $template_id = $this->uid % 2 == 0 ? 1 : 6;
|
|
|
DataAnalysisSelectUserService::create(
|
|
|
$this->uid,
|
|
|
$this->distribution_channel_id,
|
|
@@ -727,41 +736,82 @@ class OrdersController extends BaseController
|
|
|
return $template_id;
|
|
|
}
|
|
|
|
|
|
- private function maleSite($distribution_channel_id){
|
|
|
+ private function maleSite($distribution_channel_id)
|
|
|
+ {
|
|
|
$info = ChannelService::getChannelCompanyInfo($distribution_channel_id);
|
|
|
//\Log::info('maleSite info is:');
|
|
|
//\Log::info($info);
|
|
|
- if($info && isset($info->fans_gender)){
|
|
|
- if($info->fans_gender == 1){
|
|
|
+ if ($info && isset($info->fans_gender)) {
|
|
|
+ if ($info->fans_gender == 1) {
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- private function appad(){
|
|
|
- if($this->force_subscribe_info){
|
|
|
+ private function appad()
|
|
|
+ {
|
|
|
+ if ($this->force_subscribe_info) {
|
|
|
$force_subscribe_info = $this->force_subscribe_info;
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$force_subscribe_info = $this->force_subscribe_info = ForceSubscribeService::forceSubscribeUsersByUid(['uid' => $this->uid]);
|
|
|
}
|
|
|
- if(!$force_subscribe_info){
|
|
|
+ if (!$force_subscribe_info) {
|
|
|
return 0;
|
|
|
}
|
|
|
//\Log::info('force1:'.json_encode($force_subscribe_info));
|
|
|
$force_sub_user_by_openid = ForceSubscribeUserIService::getForceSubscribeByUidOpenid($this->uid);
|
|
|
- if($force_sub_user_by_openid){
|
|
|
+ if ($force_sub_user_by_openid) {
|
|
|
$force_subscribe_info = $force_sub_user_by_openid;
|
|
|
//\Log::info('force:'.json_encode($force_subscribe_info));
|
|
|
}
|
|
|
- if($force_subscribe_info->subscribe_time &&
|
|
|
- (time()-strtotime($force_subscribe_info->subscribe_time) >=3*86400)
|
|
|
+ if ($force_subscribe_info->subscribe_time &&
|
|
|
+ (time() - strtotime($force_subscribe_info->subscribe_time) >= 3 * 86400)
|
|
|
&& !OrderService::isPaidUserByOpenid($force_subscribe_info->openid) &&
|
|
|
!AdvertiseUserQueueService::getUserAdvertise($this->uid) &&
|
|
|
- in_array($this->distribution_channel_id,explode(',',env('ADS_OPEN_SITE')))
|
|
|
- ){
|
|
|
+ in_array($this->distribution_channel_id, explode(',', env('ADS_OPEN_SITE')))
|
|
|
+ ) {
|
|
|
return 1;
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
+
|
|
|
+ private function outstandingYearOrder($uid)
|
|
|
+ {
|
|
|
+ if (!in_array($this->distribution_channel_id, explode(',', env('OUTSTANDING_YEAR_ORDER_SITE')))) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ $exist = DataAnalysisSelectUserService::getByUidAndType($uid, 'OUTSTANDING_YEAR_ORDER');
|
|
|
+ if($exist) return '';
|
|
|
+ $userDivisionProperty = UserDivisionPropertyService::getUserProperty($uid);
|
|
|
+ if (!$userDivisionProperty) return '';
|
|
|
+
|
|
|
+ if ($userDivisionProperty != 'high') return '';
|
|
|
+
|
|
|
+ if ($uid % 2 == 0) {
|
|
|
+ $template_id = 1;
|
|
|
+ } else {
|
|
|
+ $template_id = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ DataAnalysisSelectUserService::create(
|
|
|
+ $uid,
|
|
|
+ $this->distribution_channel_id,
|
|
|
+ 'OUTSTANDING_YEAR_ORDER',
|
|
|
+ -1, $template_id);
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+
|
|
|
+ public function exchangeList(){
|
|
|
+ foreach ($this->chargeList as &$item){
|
|
|
+ if(!$item->switch_to) continue;
|
|
|
+ $order = Order::where('uid',$this->uid)->where('status','PAID')->where('product_id',$item->id)->first();
|
|
|
+ if($order){
|
|
|
+ $change = ProductService::getProductSingle($item->switch_to);
|
|
|
+ $item->id = $change->id;
|
|
|
+ $item->price = $change->price;
|
|
|
+ $item->given = $change->given;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|