|
@@ -67,12 +67,13 @@ class OrdersController extends Controller
|
|
|
$product_id = $request->has('product_id') ? $request->get('product_id') : '';
|
|
|
$uid = $request->has('uid') ? $request->get('uid') : '';
|
|
|
$distribution_channel_id = $request->has('distribution_channel_id') ? $request->get('distribution_channel_id') : '';
|
|
|
+ $p_channel_id = $request->has('p_channel_id') ? $request->get('p_channel_id') : 0;
|
|
|
$pay_redirect_url = $request->has('pay_redirect_url') ? $request->get('pay_redirect_url') : '';
|
|
|
$send_order_id = $request->has('send_order_id') ? $request->get('send_order_id') : 0;
|
|
|
$activity_id = $request->has('activity_id') ? $request->get('activity_id') : 0;
|
|
|
$ip = $request->has('ip') ? $request->get('ip') : '';
|
|
|
$n = $request->has('n') ? $request->get('n') : 0;
|
|
|
- $pmi = $request->has('pmi') ? $request->get('pmi') : 0;
|
|
|
+
|
|
|
if ($send_order_id && strlen($send_order_id) > 50) {
|
|
|
try {
|
|
|
$send_order_id = decrypt($send_order_id);
|
|
@@ -100,7 +101,7 @@ class OrdersController extends Controller
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- $suid= $request->get('suid',0);
|
|
|
+ $suid = $request->get('suid', 0);
|
|
|
|
|
|
if ($suid) {
|
|
|
$user_info = UserService::getById($uid);
|
|
@@ -110,7 +111,7 @@ class OrdersController extends Controller
|
|
|
if (empty($product_id) || empty($uid) || empty($distribution_channel_id) || empty($pay_redirect_url)) {
|
|
|
return response()->error('WAP_PARAM_ERROR');
|
|
|
}
|
|
|
- if($suid && $suid == $uid){
|
|
|
+ if ($suid && $suid == $uid) {
|
|
|
return back();
|
|
|
}
|
|
|
$openid = $request->has('openid') ? $request->get('openid') : '';
|
|
@@ -129,27 +130,26 @@ class OrdersController extends Controller
|
|
|
$fromtype = 'main';
|
|
|
}
|
|
|
|
|
|
+ if (!$openid) {
|
|
|
+ $transfer_channel_id = $this->transfer($distribution_channel_id);
|
|
|
+ if ($transfer_channel_id) {
|
|
|
+ $p_channel_id = $distribution_channel_id;
|
|
|
+ $distribution_channel_id = $transfer_channel_id;
|
|
|
+ }
|
|
|
+ }
|
|
|
//根据分校id获取支付配置id
|
|
|
Log::info($request->all());
|
|
|
$channel = ChannelService::getById($distribution_channel_id);
|
|
|
if (!$channel || !$channel->pay_merchant_id) {
|
|
|
return response()->error('WAP_PARAM_ERROR');
|
|
|
}
|
|
|
- if(!$pmi && in_array($distribution_channel_id,explode(',',redisEnv('MIWAN_TRANSFER_CHANNEL_ID',1)))){
|
|
|
- $random = random_int(1,100);
|
|
|
- $miwan_transfer_probability = redisEnv('MIWAN_TRANSFER_PROBABILITY',0);
|
|
|
- $miwan_transfer_pay_merchant_id = redisEnv('MIWAN_TRANSFER_PAY_MERCHANT_ID',0);
|
|
|
- if($miwan_transfer_pay_merchant_id && $random <= $miwan_transfer_probability){
|
|
|
- $channel->pay_merchant_id = $miwan_transfer_pay_merchant_id;
|
|
|
- }
|
|
|
- }
|
|
|
- if($pmi) $channel->pay_merchant_id = $pmi;
|
|
|
+
|
|
|
//获取支付类型
|
|
|
- $pay_merchant = DB::table('pay_merchants')->select('id','appid', 'source', 'config_info')->where('id', $channel->pay_merchant_id)->where('is_enabled', 1)->first();
|
|
|
+ $pay_merchant = DB::table('pay_merchants')->select('id', 'appid', 'source', 'config_info')->where('id', $channel->pay_merchant_id)->where('is_enabled', 1)->first();
|
|
|
if (!$pay_merchant || !$pay_merchant->appid || !$pay_merchant->source) return response()->error('WAP_PARAM_ERROR');
|
|
|
- if($pay_merchant->source == 'PALMPAYV2'){
|
|
|
+ if ($pay_merchant->source == 'PALMPAYV2') {
|
|
|
|
|
|
- return redirect()->to($this->paympay($request,$pay_merchant));
|
|
|
+ return redirect()->to($this->paympay($request, $pay_merchant));
|
|
|
}
|
|
|
//重定向 获取用户信息的次数
|
|
|
$n++;
|
|
@@ -161,13 +161,13 @@ class OrdersController extends Controller
|
|
|
}
|
|
|
if (empty($openid)) {
|
|
|
$trade_no = date("YmdHis") . str_shuffle(hexdec(uniqid()));
|
|
|
- if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']){
|
|
|
+ if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) {
|
|
|
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$ip = get_client_ip();
|
|
|
}
|
|
|
- $pmi = $channel->pay_merchant_id;
|
|
|
- $params = compact('uid', 'product_id', 'distribution_channel_id', 'send_order_id', 'bid', 'trade_no', 'pay_redirect_url', 'fromtype', 'activity_id', 'n','suid','ip','pmi');
|
|
|
+
|
|
|
+ $params = compact('uid', 'product_id', 'distribution_channel_id', 'send_order_id', 'bid', 'trade_no', 'pay_redirect_url', 'fromtype', 'activity_id', 'n', 'suid', 'ip', 'p_channel_id');
|
|
|
|
|
|
$redirect_url = env('CREATE_PAY_URL') . '?' . http_build_query($params);
|
|
|
//$redirect_url = env('CREATE_PAY_URL').'?uid='.$uid.'&product_id='.$product_id.'&distribution_channel_id='
|
|
@@ -183,10 +183,10 @@ class OrdersController extends Controller
|
|
|
if ($order_info) return response()->error('WAP_SYS_ERROR');
|
|
|
|
|
|
$cid = $request->has('cid') ? $request->get('cid') : '';
|
|
|
- $product_info = ProductService::getProductSingle($product_id,false);
|
|
|
+ $product_info = ProductService::getProductSingle($product_id, false);
|
|
|
//新用户只能冲一次
|
|
|
//Log::info('新用户只能冲一次:' .$product_info->type);
|
|
|
- if($this->isNewUserSecondCharge($product_info->type,$product_id,$uid)){
|
|
|
+ if ($this->isNewUserSecondCharge($product_info->type, $product_id, $uid)) {
|
|
|
$url = env('PROTOCOL', 'https') . '://site' . encodeDistributionChannelId($distribution_channel_id) . '.' . env('CUSTOM_HOST', 'leyuee') . '.com/pay';
|
|
|
return redirect()->to($url);
|
|
|
}
|
|
@@ -197,16 +197,19 @@ class OrdersController extends Controller
|
|
|
|
|
|
try {
|
|
|
$send_order_id = (int)Redis::hget('book_read:' . $uid, 'send_order_id');
|
|
|
- } catch (\Exception $e) {}
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ }
|
|
|
|
|
|
- $this->updateUserSendOrderId($uid,$send_order_id);
|
|
|
+ $this->updateUserSendOrderId($uid, $send_order_id);
|
|
|
if (in_array($uid, explode(',', env('TEST_UID')))) {
|
|
|
$price = 1;
|
|
|
}
|
|
|
if ($bid) {
|
|
|
try {
|
|
|
$bid = Hashids::decode($bid)[0];
|
|
|
- } catch (\Exception $e) {$bid = 0;}
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $bid = 0;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
try {
|
|
@@ -232,7 +235,7 @@ class OrdersController extends Controller
|
|
|
$data['openid'] = $openid;//
|
|
|
|
|
|
$data['body'] = 'novel read';
|
|
|
- $official_name = $this->getSubscribeOfficialName($uid,$distribution_channel_id);
|
|
|
+ $official_name = $this->getSubscribeOfficialName($uid, $distribution_channel_id);
|
|
|
if ($official_name) {
|
|
|
$data['body'] = '搜索公众号' . $official_name . ',请继续阅读';
|
|
|
}
|
|
@@ -256,9 +259,9 @@ class OrdersController extends Controller
|
|
|
$order_type = 'BOOK';
|
|
|
} elseif ($product_info->type == 'TICKET_RECHARGE') {
|
|
|
$order_type = 'RECHARGE';
|
|
|
- } elseif($product_info->type == 'NEW_USER'){
|
|
|
+ } elseif ($product_info->type == 'NEW_USER') {
|
|
|
$order_type = 'RECHARGE';
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$order_type = 'UNKNOWN';
|
|
|
}
|
|
|
/*
|
|
@@ -283,7 +286,7 @@ class OrdersController extends Controller
|
|
|
$send_order_name = $send_order_info->name;
|
|
|
}
|
|
|
}
|
|
|
- if($suid){
|
|
|
+ if ($suid) {
|
|
|
$user_info = UserService::getById($uid);
|
|
|
$distribution_channel_id = $user_info->distribution_channel_id;
|
|
|
}
|
|
@@ -305,15 +308,20 @@ class OrdersController extends Controller
|
|
|
'from_bid' => $from_bid,
|
|
|
'from_type' => $fromtype,
|
|
|
'activity_id' => $activity_id,
|
|
|
- 'inner_send_order_id'=>$inner_send_order_id
|
|
|
+ 'inner_send_order_id' => $inner_send_order_id
|
|
|
];
|
|
|
$result = $this->createUnPayOrder($init_order);
|
|
|
|
|
|
//订单创建成功后增加统计
|
|
|
- if($result)
|
|
|
- {
|
|
|
+ if ($result) {
|
|
|
$this->orderCreated($init_order);
|
|
|
$this->recordOtherParam($result->id, $uid);
|
|
|
+ if($p_channel_id){
|
|
|
+ //miwa 转换
|
|
|
+ OrderParamService::createByParam([
|
|
|
+ 'order_id'=>$result->id,'gxhp'=>'mw_transfer','appid'=>'','bid'=>$bid,'data_hour_key'=>'','times'=>'','distribution_channel_id'=>$p_channel_id
|
|
|
+ ]);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if ($request->get('suid')) {
|
|
@@ -347,7 +355,7 @@ class OrdersController extends Controller
|
|
|
// }
|
|
|
|
|
|
if ($suid) {
|
|
|
- $prize_fee = (int)(($product_info->price*100)*0.1);
|
|
|
+ $prize_fee = (int)(($product_info->price * 100) * 0.1);
|
|
|
$help_pay_page_channel_id = env('HELP_PAY_PAGE_CHANNEL_ID', 123);
|
|
|
$help_pay_page_channel_id = $distribution_channel_id;
|
|
|
$url_format = '%s://site%s.%s.com/helppay?back=%s&su=%s';
|
|
@@ -370,45 +378,46 @@ class OrdersController extends Controller
|
|
|
Log::info($pay_info);
|
|
|
Log::info('jsSdkSign---- :' . $jsSdkSign);
|
|
|
$pay_order = $trade_no;
|
|
|
-
|
|
|
+
|
|
|
// 注册动作-》创建订单
|
|
|
$action_type = 'CreateOrder';
|
|
|
$param = [
|
|
|
- 'openid' => isset($openid)?$openid:'0',
|
|
|
- 'uid' =>isset($uid)?$uid:'0',
|
|
|
- 'order_sn' => isset($trade_no)?$trade_no:'0',
|
|
|
- 'amount' => isset($price)?$price:'0',
|
|
|
+ 'openid' => isset($openid) ? $openid : '0',
|
|
|
+ 'uid' => isset($uid) ? $uid : '0',
|
|
|
+ 'order_sn' => isset($trade_no) ? $trade_no : '0',
|
|
|
+ 'amount' => isset($price) ? $price : '0',
|
|
|
];
|
|
|
- UserService::PushUserActionToQueue($action_type,$distribution_channel_id,$param);
|
|
|
-
|
|
|
+ UserService::PushUserActionToQueue($action_type, $distribution_channel_id, $param);
|
|
|
+
|
|
|
return view('pay.order.index', compact('pay_info', 'referer', 'jsSdkSign', 'pay_order'));
|
|
|
}
|
|
|
|
|
|
|
|
|
- private function paympay(Request $request,$pay_merchant){
|
|
|
- $product_id = $request->get('product_id');
|
|
|
+ private function paympay(Request $request, $pay_merchant)
|
|
|
+ {
|
|
|
+ $product_id = $request->get('product_id');
|
|
|
$uid = $request->get('uid');
|
|
|
$distribution_channel_id = $request->get('distribution_channel_id');
|
|
|
$pay_redirect_url = $request->get('pay_redirect_url');
|
|
|
- $send_order_id = $request->get('send_order_id',0) ;
|
|
|
- $activity_id = $request->get('activity_id',0) ;
|
|
|
- $suid= $request->get('suid',0);
|
|
|
+ $send_order_id = $request->get('send_order_id', 0);
|
|
|
+ $activity_id = $request->get('activity_id', 0);
|
|
|
+ $suid = $request->get('suid', 0);
|
|
|
$bid = $request->has('bid') ? $request->get('bid') : 0;
|
|
|
$hash_bid = $bid;
|
|
|
- $fromtype = $request->has('fromtype') ? $request->get('fromtype') : $request->get('from','main');
|
|
|
+ $fromtype = $request->has('fromtype') ? $request->get('fromtype') : $request->get('from', 'main');
|
|
|
|
|
|
//根据分校id获取支付配置id
|
|
|
Log::info($request->all());
|
|
|
|
|
|
- $trade_no =$trade_no = date("YmdHis") . str_shuffle(hexdec(uniqid()));
|
|
|
+ $trade_no = $trade_no = date("YmdHis") . str_shuffle(hexdec(uniqid()));
|
|
|
$order_info = OrderService::getByTradeNo($trade_no);
|
|
|
if ($order_info) return response()->error('WAP_SYS_ERROR');
|
|
|
|
|
|
$cid = $request->has('cid') ? $request->get('cid') : '';
|
|
|
- $product_info = ProductService::getProductSingle($product_id,false);
|
|
|
+ $product_info = ProductService::getProductSingle($product_id, false);
|
|
|
//新用户只能冲一次
|
|
|
//Log::info('新用户只能冲一次:' .$product_info->type);
|
|
|
- if($this->isNewUserSecondCharge($product_info->type,$product_id,$uid)){
|
|
|
+ if ($this->isNewUserSecondCharge($product_info->type, $product_id, $uid)) {
|
|
|
$url = env('PROTOCOL', 'https') . '://site' . encodeDistributionChannelId($distribution_channel_id) . '.' . env('CUSTOM_HOST', 'leyuee') . '.com/pay';
|
|
|
return redirect()->to($url);
|
|
|
}
|
|
@@ -419,9 +428,10 @@ class OrdersController extends Controller
|
|
|
if (!$send_order_id) {
|
|
|
try {
|
|
|
$send_order_id = (int)Redis::hget('book_read:' . $uid, 'send_order_id');
|
|
|
- } catch (\Exception $e) {}
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ }
|
|
|
}
|
|
|
- $this->updateUserSendOrderId($uid,$send_order_id);
|
|
|
+ $this->updateUserSendOrderId($uid, $send_order_id);
|
|
|
if (in_array($uid, explode(',', env('TEST_UID')))) {
|
|
|
$price = 1;
|
|
|
}
|
|
@@ -438,9 +448,9 @@ class OrdersController extends Controller
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
|
}
|
|
|
- if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']){
|
|
|
+ if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR']) {
|
|
|
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$ip = get_client_ip();
|
|
|
}
|
|
|
$data = [];
|
|
@@ -448,7 +458,7 @@ class OrdersController extends Controller
|
|
|
$data['price'] = $price;
|
|
|
$data['create_ip'] = $ip;
|
|
|
$data['body'] = 'novel read';
|
|
|
- $official_name = $this->getSubscribeOfficialName($uid,$distribution_channel_id);
|
|
|
+ $official_name = $this->getSubscribeOfficialName($uid, $distribution_channel_id);
|
|
|
if ($official_name) {
|
|
|
$data['body'] = '搜索公众号' . $official_name . ',请继续阅读';
|
|
|
}
|
|
@@ -461,9 +471,9 @@ class OrdersController extends Controller
|
|
|
$order_type = 'BOOK';
|
|
|
} elseif ($product_info->type == 'TICKET_RECHARGE') {
|
|
|
$order_type = 'RECHARGE';
|
|
|
- } elseif($product_info->type == 'NEW_USER'){
|
|
|
+ } elseif ($product_info->type == 'NEW_USER') {
|
|
|
$order_type = 'RECHARGE';
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$order_type = 'UNKNOWN';
|
|
|
}
|
|
|
|
|
@@ -474,7 +484,7 @@ class OrdersController extends Controller
|
|
|
$send_order_name = $send_order_info->name;
|
|
|
}
|
|
|
}
|
|
|
- if($suid){
|
|
|
+ if ($suid) {
|
|
|
$user_info = UserService::getById($uid);
|
|
|
$distribution_channel_id = $user_info->distribution_channel_id;
|
|
|
}
|
|
@@ -496,13 +506,12 @@ class OrdersController extends Controller
|
|
|
'from_bid' => $from_bid,
|
|
|
'from_type' => $fromtype,
|
|
|
'activity_id' => $activity_id,
|
|
|
- 'inner_send_order_id'=>$inner_send_order_id
|
|
|
+ 'inner_send_order_id' => $inner_send_order_id
|
|
|
];
|
|
|
$result = $this->createUnPayOrder($init_order);
|
|
|
|
|
|
//订单创建成功后增加统计
|
|
|
- if($result)
|
|
|
- {
|
|
|
+ if ($result) {
|
|
|
$this->orderCreated($init_order);
|
|
|
$this->recordOtherParam($result->id, $uid);
|
|
|
}
|
|
@@ -511,7 +520,7 @@ class OrdersController extends Controller
|
|
|
}
|
|
|
|
|
|
if ($suid) {
|
|
|
- $prize_fee = (int)(($product_info->price*100)*0.1);
|
|
|
+ $prize_fee = (int)(($product_info->price * 100) * 0.1);
|
|
|
//$help_pay_page_channel_id = env('HELP_PAY_PAGE_CHANNEL_ID', 123);
|
|
|
$help_pay_page_channel_id = $distribution_channel_id;
|
|
|
$url_format = '%s://site%s.%s.com/helppay?back=%s&su=%s';
|
|
@@ -544,19 +553,19 @@ class OrdersController extends Controller
|
|
|
\Log::info('$wechatPay ok-------------------');
|
|
|
$pay_info = $wechatPay->send($data);
|
|
|
\Log::info('send ok-------------------');
|
|
|
-
|
|
|
+
|
|
|
// 注册动作-》创建订单
|
|
|
$action_type = 'CreateOrder';
|
|
|
$param = [
|
|
|
- 'openid' => isset($openid)?$openid:'0',
|
|
|
- 'uid' =>isset($uid)?$uid:'0',
|
|
|
- 'order_sn' => isset($trade_no)?$trade_no:'0',
|
|
|
- 'amount' => isset($price)?$price:'0',
|
|
|
+ 'openid' => isset($openid) ? $openid : '0',
|
|
|
+ 'uid' => isset($uid) ? $uid : '0',
|
|
|
+ 'order_sn' => isset($trade_no) ? $trade_no : '0',
|
|
|
+ 'amount' => isset($price) ? $price : '0',
|
|
|
];
|
|
|
\Log::info('FUCK_PALMPAYV2');
|
|
|
- UserService::PushUserActionToQueue($action_type,$distribution_channel_id,$param);
|
|
|
-
|
|
|
-
|
|
|
+ UserService::PushUserActionToQueue($action_type, $distribution_channel_id, $param);
|
|
|
+
|
|
|
+
|
|
|
return $pay_info;
|
|
|
}
|
|
|
|
|
@@ -565,8 +574,8 @@ class OrdersController extends Controller
|
|
|
$order = $request->get('order');
|
|
|
$order = (string)$order;
|
|
|
$url = urldecode($request->get('redirect'));
|
|
|
- if(substr_count($url,'?') >1){
|
|
|
- $url = str_replace_last('?','&',$url);
|
|
|
+ if (substr_count($url, '?') > 1) {
|
|
|
+ $url = str_replace_last('?', '&', $url);
|
|
|
}
|
|
|
$url_info = parse_url($url);
|
|
|
if (isset($url_info['query']) && !empty($url_info['query'])) {
|
|
@@ -580,20 +589,21 @@ class OrdersController extends Controller
|
|
|
return redirect($url);
|
|
|
}
|
|
|
}
|
|
|
- if(isset($url_info['path']) && str_contains($url_info['path'], 'pay')){
|
|
|
+ if (isset($url_info['path']) && str_contains($url_info['path'], 'pay')) {
|
|
|
$url = sprintf('%s://%s/recent', $url_info['scheme'], $url_info['host']);
|
|
|
return redirect($url);
|
|
|
}
|
|
|
return view('pay.order.wait', compact('order', 'url'));
|
|
|
}
|
|
|
|
|
|
- private function isNewUserSecondCharge($charge_type,$product_id,$uid){
|
|
|
+ private function isNewUserSecondCharge($charge_type, $product_id, $uid)
|
|
|
+ {
|
|
|
//Log::info('新用户只能冲一次:' .$charge_type);
|
|
|
- if($charge_type == 'NEW_USER'){
|
|
|
- $result = OrderService::getUserOrderByProductId($uid,$product_id);
|
|
|
+ if ($charge_type == 'NEW_USER') {
|
|
|
+ $result = OrderService::getUserOrderByProductId($uid, $product_id);
|
|
|
//Log::info('isNewUserSecondCharge-------------------------');
|
|
|
//Log::info($result);
|
|
|
- if($result){
|
|
|
+ if ($result) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -604,15 +614,13 @@ class OrdersController extends Controller
|
|
|
private function orderCreated($init_order)
|
|
|
{
|
|
|
try {
|
|
|
- if(isset($init_order['pay_merchant_id']))
|
|
|
- {
|
|
|
- $key = 'pay_merchant:'.$init_order['pay_merchant_id'];
|
|
|
- Redis::hincrby($key,'unpaid_num',1);
|
|
|
- Redis::hset($key,'last_create_time', time());
|
|
|
+ if (isset($init_order['pay_merchant_id'])) {
|
|
|
+ $key = 'pay_merchant:' . $init_order['pay_merchant_id'];
|
|
|
+ Redis::hincrby($key, 'unpaid_num', 1);
|
|
|
+ Redis::hset($key, 'last_create_time', time());
|
|
|
}
|
|
|
|
|
|
- }catch (\Exception $e)
|
|
|
- {
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -621,14 +629,12 @@ class OrdersController extends Controller
|
|
|
private function orderPaid($init_order)
|
|
|
{
|
|
|
try {
|
|
|
- if(isset($init_order['pay_merchant_id']))
|
|
|
- {
|
|
|
- $key = 'pay_merchant:'.$init_order['pay_merchant_id'];
|
|
|
- Redis::hset($key,'unpaid_num',0);
|
|
|
+ if (isset($init_order['pay_merchant_id'])) {
|
|
|
+ $key = 'pay_merchant:' . $init_order['pay_merchant_id'];
|
|
|
+ Redis::hset($key, 'unpaid_num', 0);
|
|
|
}
|
|
|
|
|
|
- }catch (\Exception $e)
|
|
|
- {
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -761,9 +767,9 @@ class OrdersController extends Controller
|
|
|
$price = $product->price;
|
|
|
$bid = $remarks['bid'];
|
|
|
//$this->updateOrderTotal($trade_no,$transaction_id);
|
|
|
- $prize_fee = (int)(($product->price*100)*0.1);
|
|
|
- $this->substituteOrderPrice($order->id,$prize_fee);
|
|
|
- $this->smartPushTestBookPaidUv($order->from_bid,$order->uid,$order->price);
|
|
|
+ $prize_fee = (int)(($product->price * 100) * 0.1);
|
|
|
+ $this->substituteOrderPrice($order->id, $prize_fee);
|
|
|
+ $this->smartPushTestBookPaidUv($order->from_bid, $order->uid, $order->price);
|
|
|
//获取用户充值次数
|
|
|
$order->pay_type = $this->getChargeTimes($order->uid);
|
|
|
// 更新其他定制Order表
|
|
@@ -836,15 +842,15 @@ class OrdersController extends Controller
|
|
|
$key = 'leyuee:to_send_not_pay_uid:distribution_channel_id:' . $distribution_channel_id;
|
|
|
Redis::hdel($key, $uid);
|
|
|
DB::commit();
|
|
|
-
|
|
|
+
|
|
|
// 注册动作-》回调订单
|
|
|
$action_type = 'CallBackOrder';
|
|
|
$param = [
|
|
|
- 'order_sn' => isset($trade_no)?$trade_no:'0',
|
|
|
- 'openid' => isset($uid)?$uid:'0',// 没有openid,用uid写log
|
|
|
+ 'order_sn' => isset($trade_no) ? $trade_no : '0',
|
|
|
+ 'openid' => isset($uid) ? $uid : '0',// 没有openid,用uid写log
|
|
|
];
|
|
|
- UserService::PushUserActionToQueue($action_type,$distribution_channel_id,$param);
|
|
|
-
|
|
|
+ UserService::PushUserActionToQueue($action_type, $distribution_channel_id, $param);
|
|
|
+
|
|
|
return true;
|
|
|
} catch (\Exception $e) {
|
|
|
DB::rollback();
|
|
@@ -921,9 +927,9 @@ class OrdersController extends Controller
|
|
|
Log::info($product);
|
|
|
|
|
|
Log::info('product_type:' . $product->type);
|
|
|
- $prize_fee = (int)(($product->price*100)*0.1);
|
|
|
- $this->substituteOrderPrice($order->id,$prize_fee);
|
|
|
- $this->smartPushTestBookPaidUv($order->from_bid,$order->uid,$order->price);
|
|
|
+ $prize_fee = (int)(($product->price * 100) * 0.1);
|
|
|
+ $this->substituteOrderPrice($order->id, $prize_fee);
|
|
|
+ $this->smartPushTestBookPaidUv($order->from_bid, $order->uid, $order->price);
|
|
|
//获取用户充值次数
|
|
|
$order->pay_type = $this->getChargeTimes($order->uid);
|
|
|
// 更新其他定制Order表
|
|
@@ -961,7 +967,7 @@ class OrdersController extends Controller
|
|
|
'pay_merchant_id','create_ip','bid','transaction_id'
|
|
|
)
|
|
|
);*/
|
|
|
- } elseif ($product->type == 'TICKET_RECHARGE' || $product->type=='NEW_USER') {
|
|
|
+ } elseif ($product->type == 'TICKET_RECHARGE' || $product->type == 'NEW_USER') {
|
|
|
Log::info('TICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGE');
|
|
|
$order_type = 'RECHARGE';
|
|
|
$this->userCharge($product, $uid);
|
|
@@ -1009,7 +1015,7 @@ class OrdersController extends Controller
|
|
|
Log::info('receive_allinpay_ept:' . $e->getMessage());
|
|
|
Log::info('pay_callback_end fail');
|
|
|
echo 'fail';
|
|
|
- return ;
|
|
|
+ return;
|
|
|
}
|
|
|
Log::info('pay_callback_end');
|
|
|
|
|
@@ -1053,9 +1059,9 @@ class OrdersController extends Controller
|
|
|
try {
|
|
|
$product = ProductService::getProductSingle($order->product_id);
|
|
|
$transaction_id = $data['oid_paybill'];
|
|
|
- $prize_fee = (int)(($product->price*100));
|
|
|
- $this->substituteOrderPrice($order->id,$prize_fee);
|
|
|
- $this->smartPushTestBookPaidUv($order->from_bid,$order->uid,$order->price);
|
|
|
+ $prize_fee = (int)(($product->price * 100));
|
|
|
+ $this->substituteOrderPrice($order->id, $prize_fee);
|
|
|
+ $this->smartPushTestBookPaidUv($order->from_bid, $order->uid, $order->price);
|
|
|
//获取用户充值次数
|
|
|
$order->pay_type = $this->getChargeTimes($order->uid);
|
|
|
// 更新其他定制Order表
|
|
@@ -1077,7 +1083,7 @@ class OrdersController extends Controller
|
|
|
$order->pay_end_at = date('Y-m-d H:i:s');
|
|
|
$order->transaction_id = $transaction_id;
|
|
|
$order->save();
|
|
|
- } elseif ($product->type == 'TICKET_RECHARGE' || $product->type=='NEW_USER') {
|
|
|
+ } elseif ($product->type == 'TICKET_RECHARGE' || $product->type == 'NEW_USER') {
|
|
|
Log::info('TICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGE');
|
|
|
$order_type = 'RECHARGE';
|
|
|
$this->userCharge($product, $uid);
|
|
@@ -1107,7 +1113,7 @@ class OrdersController extends Controller
|
|
|
DB::rollBack();
|
|
|
Log::info('lianlian:' . $e->getMessage());
|
|
|
echo 'fail';
|
|
|
- return ;
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
echo 'success';
|
|
@@ -1167,9 +1173,9 @@ class OrdersController extends Controller
|
|
|
Log::info($product);
|
|
|
|
|
|
Log::info('product_type:' . $product->type);
|
|
|
- $prize_fee = (int)(($product->price*100)*0.1);
|
|
|
- $this->substituteOrderPrice($order->id,$prize_fee);
|
|
|
- $this->smartPushTestBookPaidUv($order->from_bid,$order->uid,$order->price);
|
|
|
+ $prize_fee = (int)(($product->price * 100) * 0.1);
|
|
|
+ $this->substituteOrderPrice($order->id, $prize_fee);
|
|
|
+ $this->smartPushTestBookPaidUv($order->from_bid, $order->uid, $order->price);
|
|
|
//获取用户充值次数
|
|
|
$order->pay_type = $this->getChargeTimes($order->uid);
|
|
|
// 更新其他定制Order表
|
|
@@ -1191,7 +1197,7 @@ class OrdersController extends Controller
|
|
|
$order->pay_end_at = date('Y-m-d H:i:s');
|
|
|
$order->transaction_id = $transaction_id;
|
|
|
$order->save();
|
|
|
- } elseif ($product->type == 'TICKET_RECHARGE' || $product->type=='NEW_USER') {
|
|
|
+ } elseif ($product->type == 'TICKET_RECHARGE' || $product->type == 'NEW_USER') {
|
|
|
Log::info('TICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGETICKET_RECHARGE');
|
|
|
$order_type = 'RECHARGE';
|
|
|
$this->userCharge($product, $uid);
|
|
@@ -1221,14 +1227,14 @@ class OrdersController extends Controller
|
|
|
Log::info('redis remote error-----------------------');
|
|
|
Log::info($e);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 注册动作-》回调订单
|
|
|
$action_type = 'CallBackOrder';
|
|
|
$param = [
|
|
|
- 'order_sn' => isset($trade_no)?$trade_no:'0',
|
|
|
- 'openid' => isset($uid)?$uid:'0',// 没有openid,用uid写log
|
|
|
+ 'order_sn' => isset($trade_no) ? $trade_no : '0',
|
|
|
+ 'openid' => isset($uid) ? $uid : '0',// 没有openid,用uid写log
|
|
|
];
|
|
|
- UserService::PushUserActionToQueue($action_type,$distribution_channel_id,$param);
|
|
|
+ UserService::PushUserActionToQueue($action_type, $distribution_channel_id, $param);
|
|
|
|
|
|
}
|
|
|
} else {
|
|
@@ -1446,7 +1452,7 @@ class OrdersController extends Controller
|
|
|
$delay = 0;
|
|
|
$url = env('PROTOCOL') . '://site' . encodeDistributionChannelId($data->distribution_channel_id) . '.' . env('CUSTOM_HOST') . '.com/continue';;
|
|
|
$content = sprintf($content_format, $data->nickname ? $data->nickname : '匿名', $uid, $money_text, $url);
|
|
|
- foreach ($force_sub_info as $item){
|
|
|
+ foreach ($force_sub_info as $item) {
|
|
|
$res['openid'] = $item->openid;
|
|
|
$res['appid'] = $item->appid;
|
|
|
$res['content'] = $content;
|
|
@@ -1483,26 +1489,27 @@ class OrdersController extends Controller
|
|
|
}
|
|
|
|
|
|
//灵界的推送统计\App\Modules\Statistic\Services\WapVisitStatService::customerAllStats
|
|
|
- try{
|
|
|
- if($order->from_type){
|
|
|
- $pv = Redis::hget('push:distribution_channel_id:allpv' ,$order->from_type);
|
|
|
- if($pv){
|
|
|
- Redis::sadd('push:all:paidnum:from:' . $order->from_type,$order->uid);
|
|
|
- $old = Redis::hget('push:all:paidamount' ,$order->from_type);
|
|
|
- if($old){
|
|
|
- Redis::hset('push:all:paidamount' ,$order->from_type,$old+$order->price);
|
|
|
- }else{
|
|
|
- Redis::hset('push:all:paidamount' ,$order->from_type,$order->price);
|
|
|
+ try {
|
|
|
+ if ($order->from_type) {
|
|
|
+ $pv = Redis::hget('push:distribution_channel_id:allpv', $order->from_type);
|
|
|
+ if ($pv) {
|
|
|
+ Redis::sadd('push:all:paidnum:from:' . $order->from_type, $order->uid);
|
|
|
+ $old = Redis::hget('push:all:paidamount', $order->from_type);
|
|
|
+ if ($old) {
|
|
|
+ Redis::hset('push:all:paidamount', $order->from_type, $old + $order->price);
|
|
|
+ } else {
|
|
|
+ Redis::hset('push:all:paidamount', $order->from_type, $order->price);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(isset($order->pay_merchant_id) && $order->pay_merchant_id)//临时统计队列清0 用于报警
|
|
|
+ if (isset($order->pay_merchant_id) && $order->pay_merchant_id)//临时统计队列清0 用于报警
|
|
|
{
|
|
|
- $key = 'pay_merchant:'.$order->pay_merchant_id;
|
|
|
- Redis::hset($key,'unpaid_num',0);
|
|
|
+ $key = 'pay_merchant:' . $order->pay_merchant_id;
|
|
|
+ Redis::hset($key, 'unpaid_num', 0);
|
|
|
}
|
|
|
- }catch (\Exception $e){}
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1513,10 +1520,10 @@ class OrdersController extends Controller
|
|
|
|
|
|
private function getSubscribeV2($uid)
|
|
|
{
|
|
|
- return DB::table('force_subscribe_users')->where('uid',$uid)->where('is_subscribed', 1)->get();
|
|
|
+ return DB::table('force_subscribe_users')->where('uid', $uid)->where('is_subscribed', 1)->get();
|
|
|
}
|
|
|
|
|
|
- public function getSubscribeOfficialName($uid,$distribution_channel_id)
|
|
|
+ public function getSubscribeOfficialName($uid, $distribution_channel_id)
|
|
|
{
|
|
|
$subscribe = $this->getSubscribe($uid);
|
|
|
if ($subscribe && isset($subscribe->appid)) {
|
|
@@ -1529,16 +1536,17 @@ class OrdersController extends Controller
|
|
|
if (isset($res->nickname) && !empty($res->nickname)) {
|
|
|
return $res->nickname;
|
|
|
}
|
|
|
- try{
|
|
|
+ try {
|
|
|
$official = DB::table('official_accounts')
|
|
|
->where('distribution_channel_id', $distribution_channel_id)
|
|
|
- ->where('is_auth',1)
|
|
|
- ->orderBy('id','desc')
|
|
|
+ ->where('is_auth', 1)
|
|
|
+ ->orderBy('id', 'desc')
|
|
|
->select('nickname')->first();
|
|
|
if ($official && isset($official->nickname)) {
|
|
|
return $official->nickname;
|
|
|
}
|
|
|
- }catch (\Exception $e){}
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ }
|
|
|
return '';
|
|
|
}
|
|
|
|
|
@@ -1561,7 +1569,7 @@ class OrdersController extends Controller
|
|
|
$phone_arr = ['15868100210', '18072713392', '15088790066', '13858057394', '18668029091', '18668420256'];
|
|
|
//$phone_arr = ['18668029091'];
|
|
|
|
|
|
- $param = ['pay_id'=>$pay_merchant_id];
|
|
|
+ $param = ['pay_id' => $pay_merchant_id];
|
|
|
if ($n) {
|
|
|
$template_type = 'pay_channel_remind';
|
|
|
//$content = '支付通道:' . $pay_merchant_id . ',获取授权信息失败';
|
|
@@ -1571,10 +1579,10 @@ class OrdersController extends Controller
|
|
|
}
|
|
|
if ($change) {
|
|
|
$template_type = 'pay_channel_change';
|
|
|
- $param = ['pay_id'=>$pay_merchant_id,'new_pay_id'=>$change_pay_id];
|
|
|
+ $param = ['pay_id' => $pay_merchant_id, 'new_pay_id' => $change_pay_id];
|
|
|
}
|
|
|
foreach ($phone_arr as $phone) {
|
|
|
- AliSMS::send($phone, $template_type,$param);
|
|
|
+ AliSMS::send($phone, $template_type, $param);
|
|
|
}
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
@@ -1587,23 +1595,25 @@ class OrdersController extends Controller
|
|
|
SubstituteOrderService::createOrder($order_id, $uid, $pay_uid);
|
|
|
}
|
|
|
|
|
|
- private function recordOtherParam($order_id, $uid){
|
|
|
- $gxhp = ReadRecordService::getByField($uid,'gxhp');
|
|
|
- if($gxhp){
|
|
|
- OrderParamService::create($order_id,$gxhp);
|
|
|
-}
|
|
|
-}
|
|
|
+ private function recordOtherParam($order_id, $uid)
|
|
|
+ {
|
|
|
+ $gxhp = ReadRecordService::getByField($uid, 'gxhp');
|
|
|
+ if ($gxhp) {
|
|
|
+ OrderParamService::create($order_id, $gxhp);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- private function substituteOrderPrice($order_id,$prize_fee=500)
|
|
|
+ private function substituteOrderPrice($order_id, $prize_fee = 500)
|
|
|
{
|
|
|
SubstituteOrderService::SubstituteOrderPrize($order_id, $prize_fee);
|
|
|
}
|
|
|
|
|
|
- private function updateUserSendOrderId(int $uid,$send_order_id){
|
|
|
- if($send_order_id && $uid){
|
|
|
+ private function updateUserSendOrderId(int $uid, $send_order_id)
|
|
|
+ {
|
|
|
+ if ($send_order_id && $uid) {
|
|
|
$user = UserService::getById($uid);
|
|
|
- if($user && !$user->send_order_id){
|
|
|
- UserService::updateInfo($uid,compact('send_order_id'));
|
|
|
+ if ($user && !$user->send_order_id) {
|
|
|
+ UserService::updateInfo($uid, compact('send_order_id'));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1614,18 +1624,19 @@ class OrdersController extends Controller
|
|
|
* @param $uid
|
|
|
* @param $price
|
|
|
*/
|
|
|
- private function smartPushTestBookPaidUv($bid,$uid,$price){
|
|
|
+ private function smartPushTestBookPaidUv($bid, $uid, $price)
|
|
|
+ {
|
|
|
$smart_bid = ReadRecordService::getSmartPush($uid);
|
|
|
- if( $smart_bid && in_array($bid,$smart_bid) ){
|
|
|
- try{
|
|
|
+ if ($smart_bid && in_array($bid, $smart_bid)) {
|
|
|
+ try {
|
|
|
$key = 'smartPushTestBookPaidUv:bid:%s';
|
|
|
- Redis::sadd(sprintf($key,$bid),$uid);
|
|
|
- $now_amount = Redis::hget('smartPushTestBookPaidAmount',$bid);
|
|
|
- if(!$now_amount){
|
|
|
+ Redis::sadd(sprintf($key, $bid), $uid);
|
|
|
+ $now_amount = Redis::hget('smartPushTestBookPaidAmount', $bid);
|
|
|
+ if (!$now_amount) {
|
|
|
$now_amount = 0;
|
|
|
}
|
|
|
- Redis::hset('smartPushTestBookPaidAmount',$bid,$now_amount+$price);
|
|
|
- }catch (\Exception $e){
|
|
|
+ Redis::hset('smartPushTestBookPaidAmount', $bid, $now_amount + $price);
|
|
|
+ } catch (\Exception $e) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1635,8 +1646,23 @@ class OrdersController extends Controller
|
|
|
* @param $uid
|
|
|
* @return int
|
|
|
*/
|
|
|
- private function getChargeTimes($uid) {
|
|
|
+ private function getChargeTimes($uid)
|
|
|
+ {
|
|
|
$count = OrderService::getUserChargeTimes($uid);
|
|
|
- return $count+1;
|
|
|
+ return $count + 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //米玩 订单转移
|
|
|
+ private function transfer($distribution_channel_id)
|
|
|
+ {
|
|
|
+ if (in_array($distribution_channel_id, explode(',', redisEnv('MIWAN_TRANSFER_CHANNEL_ID', 1)))) {
|
|
|
+ $random = random_int(1, 100);
|
|
|
+ $miwan_transfer_probability = redisEnv('MIWAN_TRANSFER_PROBABILITY', 0);
|
|
|
+ $miwan_transfer_to_channel_id = redisEnv('MIWAN_TRANSFER_TO_CHANNEL_ID', 0);
|
|
|
+ if ($miwan_transfer_to_channel_id && $random <= $miwan_transfer_probability) {
|
|
|
+ return $miwan_transfer_to_channel_id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
}
|
|
|
}
|