|
@@ -24,46 +24,11 @@ use Illuminate\Http\Request;
|
|
|
use Log;
|
|
|
use Redis;
|
|
|
use DB;
|
|
|
+use EasyWeChat\Support\XML;
|
|
|
|
|
|
class MonthOrderController extends Controller
|
|
|
{
|
|
|
|
|
|
- public function getH5RedirectUrl(Request $request)
|
|
|
- {
|
|
|
- $app_id = 'Aekgrv87yo5wxnl715';
|
|
|
- $app_secret = '57gwsnd158ib2sn7wluq5716brp8fzm';
|
|
|
- $key = 'sn7wluq5716brp8fzm';
|
|
|
- //$plan_id = 124768;
|
|
|
- $plan_id = 39603;
|
|
|
- $user_id = 10008;
|
|
|
- $ip = _getIp();
|
|
|
- $sign = _sign(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip'), $key . $key);
|
|
|
- $sign = strtoupper($sign);
|
|
|
- $client = new Client();
|
|
|
- Log::info(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip', 'sign'));
|
|
|
- $url = 'http://pap.manyuedu.org/h5.php?' . http_build_query(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip', 'sign'));
|
|
|
- //$url = 'http://pap.manyuedu.org/?'.http_build_query(compact('app_id','app_secret','plan_id','user_id','ip','sign'));
|
|
|
- return $client->get($url)->getBody()->getContents();
|
|
|
- }
|
|
|
-
|
|
|
- public function getWechatRedirectUrl(Request $request)
|
|
|
- {
|
|
|
- $app_id = 'Aekgrv87yo5wxnl715';
|
|
|
- $app_secret = '57gwsnd158ib2sn7wluq5716brp8fzm';
|
|
|
- $key = 'sn7wluq5716brp8fzm';
|
|
|
- //$plan_id = 124768;
|
|
|
- $plan_id = 39603;
|
|
|
- $user_id = 10008;
|
|
|
- $ip = _getIp();
|
|
|
- $sign = _sign(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip'), $key . $key);
|
|
|
- $sign = strtoupper($sign);
|
|
|
- $client = new Client();
|
|
|
- Log::info(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip', 'sign'));
|
|
|
- //$url = 'http://pap.manyuedu.org/h5.php?'.http_build_query(compact('app_id','app_secret','plan_id','user_id','ip','sign'));
|
|
|
- $url = 'http://pap.manyuedu.org/?' . http_build_query(compact('app_id', 'app_secret', 'plan_id', 'user_id', 'ip', 'sign'));
|
|
|
- return $client->get($url)->getBody()->getContents();
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
public function signCallBack(Request $request)
|
|
|
{
|
|
@@ -179,6 +144,16 @@ class MonthOrderController extends Controller
|
|
|
'day_num'=>7
|
|
|
]);
|
|
|
}
|
|
|
+
|
|
|
+ if($type == 'QUARTER'){
|
|
|
+ YearOrderService::save_vip_order_daynum([
|
|
|
+ 'uid' => $uid,
|
|
|
+ 'distribution_channel_id' => $user_info->distribution_channel_id,
|
|
|
+ 'fee' => $price / 100,
|
|
|
+ 'send_order_id' => 0,
|
|
|
+ 'day_num'=>92
|
|
|
+ ]);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -267,11 +242,7 @@ class MonthOrderController extends Controller
|
|
|
'trade_no','result_code','sign','created_at','updated_at','type'
|
|
|
)
|
|
|
]);
|
|
|
- }catch (\Exception $e){
|
|
|
- Log::error('recordOrderCallBack error');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ }catch (\Exception $e){Log::error('recordOrderCallBack error');}
|
|
|
}
|
|
|
|
|
|
protected function successPayPushMsg($uid,$type)
|
|
@@ -319,14 +290,157 @@ class MonthOrderController extends Controller
|
|
|
private function userProperty($uid){
|
|
|
try{
|
|
|
$userproperty = UserDivisionCpcPropertyService::calculateUserPropertyV2($uid);
|
|
|
- if(!$userproperty) {
|
|
|
- return ;
|
|
|
- }
|
|
|
+ if(!$userproperty) return ;
|
|
|
UserDivisionCpcPropertyService::createorUpdateV2($userproperty);
|
|
|
}catch (\Exception $e){
|
|
|
Log::error('month userProperty error');
|
|
|
Log::error($e);
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ public function signCallBackV2(Request $request)
|
|
|
+ {
|
|
|
+ Log::info('V2--signCallBack--------------------------------------V2----signCallBack');
|
|
|
+ Log::info($request->all());
|
|
|
+ Log::info($request->getMethod());
|
|
|
+
|
|
|
+ $content = $request->getContent();
|
|
|
+ Log::info('$request->getContent() is :');
|
|
|
+ Log::info($content);
|
|
|
+ libxml_disable_entity_loader(true);
|
|
|
+ $xml = XML::parse(strval($content));
|
|
|
+ Log::info('xml is');
|
|
|
+ Log::info($xml);
|
|
|
+ if (!$xml || !is_array($xml)) return response(XML::build(['return_code'=>'fail','return_msg'=>'fail']));
|
|
|
+ if($xml['return_code'] != 'SUCCESS' && $xml['result_code'] != 'SUCCESS'){
|
|
|
+ $result = ['return_code'=>'SUCCESS','return_msg'=>'OK'];
|
|
|
+ return response(XML::build($result));
|
|
|
+ }
|
|
|
+ $sign = _sign($xml,UserMonthService::MONTH_PAY_KEY);
|
|
|
+ if($sign != $xml['sign']){
|
|
|
+ Log::info('sign error');
|
|
|
+ Log::info('request sign is: '.$xml['sign'].',my sign is :'.$sign);
|
|
|
+ $result = ['return_code'=>'fail','return_msg'=>'sign fail'];
|
|
|
+ return response(XML::build($result));
|
|
|
+ }
|
|
|
+ $plan_id = $xml['plan_id'];
|
|
|
+ $type = 'MONTH';
|
|
|
+ $fee = 0;
|
|
|
+ if($plan_id == env('MONTH_ORDER_PLAN_ID')){
|
|
|
+ $fee = 700;
|
|
|
+ $type = 'MONTH';
|
|
|
+ }
|
|
|
+
|
|
|
+ if($plan_id == env('MONTH_WEEK_ORDER_PLAN_ID')){
|
|
|
+ $fee = 3000;
|
|
|
+ $type = 'WEEK';
|
|
|
+ }
|
|
|
+
|
|
|
+ if($plan_id == env('MONTH_QUARTER_ORDER_PLAN_ID')){
|
|
|
+ $fee = 10000;
|
|
|
+ $type = 'QUARTER';
|
|
|
+ }
|
|
|
|
|
|
+ $user_id = $xml['contract_code'];
|
|
|
+ $change_type = $xml['change_type'];
|
|
|
+
|
|
|
+ $user_info = UserService::getById($user_id);
|
|
|
+ if (!$user_info) {
|
|
|
+ Log::error('signCallBack user is not exist,uid is :' . $user_id);
|
|
|
+ $result = ['return_code'=>'fail','return_msg'=>'user not exist'];
|
|
|
+ return response(XML::build($result));
|
|
|
+ }
|
|
|
+ UserMonthService::monthOrderSignRecord([
|
|
|
+ 'uid'=>$user_id,
|
|
|
+ 'plan_id'=>$plan_id,
|
|
|
+ 'contract_code'=>$xml['contract_code'],
|
|
|
+ 'openid'=>$xml['openid'],
|
|
|
+ 'change_type'=>$change_type,
|
|
|
+ 'operate_time'=>$xml['operate_time'],
|
|
|
+ 'contract_id'=>$xml['contract_id'],
|
|
|
+ 'contract_expired_time'=>$xml['contract_expired_time'],
|
|
|
+ 'contract_termination_mode'=>$xml['contract_termination_mode'],
|
|
|
+ 'request_serial'=>$xml['request_serial']
|
|
|
+
|
|
|
+ ]);
|
|
|
+ UserMonthService::createSign($user_id, $plan_id, $change_type, $user_info->openid,$type);
|
|
|
+ if($type == 'ADD'){
|
|
|
+ UserMonthService::monthPayApplypap($user_id,$xml['contract_id'],$fee,'追书云包季扣款','47.97.95.151','sign_back',\GuzzleHttp\json_encode(['uid'=>$user_id,'plan_id'=>$plan_id]));
|
|
|
+ }
|
|
|
+ Log::info('signCallBack-------------------end-----------------------signCallBack');
|
|
|
+ $result = ['return_code'=>'SUCCESS','return_msg'=>'OK'];
|
|
|
+ return response(XML::build($result));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function orderCallBackV2(Request $request)
|
|
|
+ {
|
|
|
+ Log::info('V2--------orderCallBack-----------------------------------v2-------orderCallBack');
|
|
|
+ $content = $request->getContent();
|
|
|
+ Log::info('orderCallBackV2 $request->getContent() is :');
|
|
|
+ Log::info($content);
|
|
|
+ libxml_disable_entity_loader(true);
|
|
|
+ $xml = XML::parse(strval($content));
|
|
|
+ Log::info('orderCallBackV2 xml is:');
|
|
|
+ Log::info($xml);
|
|
|
+ if (!$xml || !is_array($xml)) return response(XML::build(['return_code'=>'fail','return_msg'=>'fail']));
|
|
|
+
|
|
|
+ UserMonthService::monthCallBackRecordV2([
|
|
|
+ 'openid'=>isset($xml['openid'])?$xml['openid']:'',
|
|
|
+ 'bank_type'=>isset($xml['bank_type'])?$xml['bank_type']:'',
|
|
|
+ 'total_fee'=>isset($xml['total_fee'])?$xml['total_fee']:0,
|
|
|
+ 'cash_fee'=>isset($xml['cash_fee'])?$xml['cash_fee']:0,
|
|
|
+ 'trade_state'=>isset($xml['trade_state'])?$xml['trade_state']:'',
|
|
|
+ 'transaction_id'=>isset($xml['transaction_id'])?$xml['transaction_id']:'',
|
|
|
+ 'out_trade_no'=>isset($xml['out_trade_no'])?$xml['out_trade_no']:'',
|
|
|
+ 'attach'=>isset($xml['attach'])?$xml['attach']:'',
|
|
|
+ 'time_end'=>isset($xml['time_end'])?$xml['time_end']:'',
|
|
|
+ 'contract_id'=>isset($xml['contract_id'])?$xml['contract_id']:'',
|
|
|
+ 'result_code'=>isset($xml['result_code'])?$xml['result_code']:'',
|
|
|
+ 'err_code'=>isset($xml['err_code'])?$xml['err_code']:'',
|
|
|
+ 'result'=>json_encode($xml),
|
|
|
+ 'uid'=>isset($xml['attach']) && !empty($xml['attach']) ? json_decode($xml['attach'],1)['uid']:0
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $sign = _sign($xml,UserMonthService::MONTH_PAY_KEY);
|
|
|
+ if($sign != $xml['sign']){
|
|
|
+ Log::info('orderCallBackV2 sign error');
|
|
|
+ Log::info('orderCallBackV2 request sign is: '.$xml['sign'].',my sign is :'.$sign);
|
|
|
+ $result = ['return_code'=>'fail','return_msg'=>'sign fail'];
|
|
|
+ return response(XML::build($result));
|
|
|
+ }
|
|
|
+
|
|
|
+ if($xml['return_code'] == 'SUCCESS' && $xml['result_code'] == 'SUCCESS') {
|
|
|
+ $attach = json_decode($xml['attach'], 1);
|
|
|
+ $plan_id = $attach['plan_id'];
|
|
|
+ $user_id = $attach['uid'];
|
|
|
+ $total_fee = $xml['total_fee'];
|
|
|
+ $trade_no = $xml['transaction_id'];
|
|
|
+ $out_trade_no = $xml['out_trade_no'];
|
|
|
+
|
|
|
+ $type = 'MONTH';
|
|
|
+ $product_id = 6826;
|
|
|
+ if ($plan_id == env('MONTH_ORDER_PLAN_ID')) {
|
|
|
+ $type = 'MONTH';
|
|
|
+ $product_id = 6826;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($plan_id == env('MONTH_WEEK_ORDER_PLAN_ID')) {
|
|
|
+ $type = 'WEEK';
|
|
|
+ $product_id = 7394;
|
|
|
+ }
|
|
|
+
|
|
|
+ if($plan_id == env('MONTH_QUARTER_ORDER_PLAN_ID')){
|
|
|
+ $type = 'QUARTER';
|
|
|
+ }
|
|
|
+ if (!UserMonthService::getOrderByOrder($trade_no, $out_trade_no)) {
|
|
|
+ UserMonthService::createLOrder($user_id, $plan_id, $total_fee, $trade_no, $out_trade_no, $type);
|
|
|
+ $this->addOrderAndVip($user_id, $out_trade_no, $trade_no, $total_fee, $product_id, $type);
|
|
|
+ $this->successPayPushMsg($user_id, $type);
|
|
|
+ $this->userProperty($user_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Log::info('orderCallBack--------------------endend----------------------orderCallBack');
|
|
|
+ $result = ['return_code'=>'SUCCESS','return_msg'=>'OK'];
|
|
|
+ return response(XML::build($result));
|
|
|
}
|
|
|
}
|