input('msgType'); $timestamp = $request->input('timestamp'); $nonce = $request->input('nonce'); $signature = $request->input('signature'); $orderPay = $request->input('orderPay'); $platformId = $request->input('platformId'); $sysPlatformId = 'BcJV6mb504Kt2lML'; if(empty($orderPay)) { // 在柚子端填写回调地址回调使用 return 'success'; } // 将接收到的数据保存的日志文件中 Log::logInfo(json_encode($request->all(), JSON_UNESCAPED_UNICODE), [$platformId], 'youziOrder'); # 此处逻辑为在柚子后台配置回传链接时使用 if($msgType != 'orderPay') { return 'success'; } if($platformId != $sysPlatformId) { EmailQueue::rPush('柚子订单回传platformId与预期不符', json_encode([ 'request_platform_id' => $platformId, 'sys_platform_id' => $sysPlatformId, 'desc' => '杭州猎豆' ]), ['song.shen@kuxuan-inc.com', 'xiaohua.hou@kuxuan-inc.com'], '猎羽'); } // 查询app_id对应的token $conf = PlatformOrderConf::getTokenByPlatformId($platformId); if(empty($conf->token)) { return 'fail'; } // 根据配置找到对应的系统账号组,用于在数据看板中区分订单所属账号 $orderPay['sys_group_id'] = $conf->sys_group_id; // 数据校验 $check = MsgService::checkSignature($nonce, $timestamp, $conf->token, $signature); if($check === false) { return 'fail'; } try{ // 将数据保存入数据库 DjOrderService::youziOrderSave($orderPay, 1, 1, $platformId); } catch (\Exception $exception) { Log::logError('保存柚子订单数据异常', [ 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()], 'callBackOrderError'); $this->exceptionHandler('callBackOrder', json_encode([ 'err_msg' => '保存柚子订单数据异常', 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString(), ])); return 'fail'; } return 'success'; } // 嘉书平台 小程序订单 public function jiashuOrderCallBack(Request $request) { $timestamp = $request->input('timestamp'); $nonce = $request->input('nonce'); $signature = $request->input('signature'); $orderPay = $request->input('orderPay'); $appId = '3a8vJ2t0K5XkH5Wl'; // 将接收到的数据保存的日志文件中 Log::logInfo(json_encode($request->all(), JSON_UNESCAPED_UNICODE), [], 'jiashuOrder'); // 查询app_id对应的token $conf = PlatformOrderConf::getTokenByPlatformId($appId); if(empty($conf->token)) { return 'fail'; } // 根据配置找到对应的系统账号组,用于在数据看板中区分订单所属账号 $orderPay['sys_group_id'] = $conf->sys_group_id; // 数据校验 $check = MsgService::checkSignature($nonce, $timestamp, $conf->token, $signature); if($check === false) { return 'fail'; } try{ DjOrderService::jiashuOrderSave($orderPay, $appId); } catch (\Exception $exception) { Log::logError('保存嘉书订单数据异常', [ 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()], 'callBackOrderError'); $this->exceptionHandler('callBackOrder', json_encode([ 'err_msg' => '保存嘉书订单数据异常', 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString(), ])); return 'fail'; } return 'success'; } # 迈步平台 小程序订单 public function orderCallBack(Request $request) { $platformId = $request->input('platformId'); $timestamp = $request->input('timestamp'); $nonce = $request->input('nonce'); $signature = $request->input('signature'); $orderPay = $request->input('orderPay'); // 将接收到的数据保存的日志文件中 Log::logInfo(json_encode($request->all(), JSON_UNESCAPED_UNICODE), [], 'callBackOrder'); // 查询app_id对应的token $conf = PlatformOrderConf::getTokenByPlatformId($platformId); if(empty($conf->token)) { return 'fail'; } // 根据配置找到对应的系统账号组,用于在数据看板中区分订单所属账号 $orderPay['sys_group_id'] = $conf->sys_group_id; // 数据校验 $check = MsgService::checkSignatureNew($nonce, $timestamp, $conf->token, $platformId, $signature); if($check === false) { return 'fail'; } try{ DjOrderService::unifyOrderSave($orderPay, $platformId); } catch (\Exception $exception) { Log::logError('保存其他平台订单数据异常', [ 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()], 'callBackOrderError'); $this->exceptionHandler('callBackOrder', json_encode([ 'err_msg' => '保存其他平台订单数据异常', 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString(), ])); return 'fail'; } return 'success'; } public function exceptionHandler($key, $message) { $val = RedisModel::get($key); if(empty($val)) { EmailQueue::rPush('订单保存异常', $message, ['song.shen@kuxuan-inc.com'], []); RedisModel::set($key, 1); RedisModel::expire($key, 30*60); } } // 嘉书平台 H5订单 public function jiashuWebOrderCallBack(Request $request) { // 将接收到的数据保存的日志文件中 Log::logInfo(json_encode($request->all(), JSON_UNESCAPED_UNICODE), [], 'callBackOrderWeb'); # 因为嘉书方不提供签名逻辑以及失败重试逻辑,因此要尽量保证该接口稳定 try{ DjOrderService::jiashuWebOrderSave($request->all()); } catch (\Exception $exception) { Log::logError('保存嘉书H5订单数据异常', [ 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()], 'callBackOrderError'); $this->exceptionHandler('callBackOrder', json_encode([ 'err_msg' => '保存嘉书H5订单数据异常', 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString(), ])); return ['code' => '-1', 'message' => 'system error']; } return ['code' => 0, 'message' => 'ok']; } // 杭州剧有戏-柚子平台 public function juyouxiYouziOrderCallBack(Request $request) { $msgType = $request->input('msgType'); $timestamp = $request->input('timestamp'); $nonce = $request->input('nonce'); $signature = $request->input('signature'); $orderPay = $request->input('orderPay'); $platformId = $request->input('platformId'); $sysPlatformId = 'mNUdMhDNC20CvYLe'; if(empty($orderPay)) { // 在柚子端填写回调地址回调使用 return 'success'; } // 将接收到的数据保存的日志文件中 Log::logInfo(json_encode($request->all(), JSON_UNESCAPED_UNICODE), [$platformId], 'youziOrder'); if($msgType != 'orderPay') { return 'success'; } if($platformId != $sysPlatformId) { EmailQueue::rPush('柚子订单回传platformId与预期不符', json_encode([ 'request_platform_id' => $platformId, 'sys_platform_id' => $sysPlatformId, 'desc' => '剧有戏' ]), ['song.shen@kuxuan-inc.com', 'xiaohua.hou@kuxuan-inc.com'], '猎羽'); } // 查询app_id对应的token $conf = PlatformOrderConf::getTokenByPlatformId($platformId); if(empty($conf->token)) { Log::logError('保存杭州剧有戏柚子订单数据异常', ['未查询到token'], 'orderTest'); return 'fail'; } // 根据配置找到对应的系统账号组,用于在数据看板中区分订单所属账号 $orderPay['sys_group_id'] = $conf->sys_group_id; // 数据校验 $check = MsgService::checkSignature($nonce, $timestamp, $conf->token, $signature); if($check === false) { Log::logError('保存杭州剧有戏柚子订单数据异常', ['数据校验失败'], 'orderTest'); return 'fail'; } try{ // 将数据保存入数据库 DjOrderService::youziOrderSave($orderPay, 1, 1, $platformId, 2); } catch (\Exception $exception) { Log::logError('保存杭州剧有戏柚子订单数据异常', [ 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()], 'callBackOrderError'); $this->exceptionHandler('callBackOrder', json_encode([ 'err_msg' => '保存杭州剧有戏柚子订单数据异常', 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString(), ])); return 'fail'; } return 'success'; } # 点众阳光 public function platformOrderCallBack(Request $request) { $timestamp = $request->input('timestamp'); $nonce = $request->input('nonce'); $signature = $request->input('signature'); $orderPay = $request->input('orderPay'); $platformId = $request->input('platformId'); // 将接收到的数据保存的日志文件中 Log::logInfo(json_encode($request->all(), JSON_UNESCAPED_UNICODE), [$platformId], 'platformOrder'); $taskId = $request->input('taskId', ''); $xurl = $request->input('xurl', ''); if(!empty($taskId)) { # 主动同步下来的订单 return HttpService::httpGet('https://idea-ad.wenxingshuju.com/sunshine/orderList?'.http_build_query($request->all())); } // 查询app_id对应的token $conf = PlatformOrderConf::getTokenByPlatformId($platformId); if(empty($conf->token)) { Log::logError('保存订单数据异常', ['未查询到token'], 'platformOrder'); return 'fail'; } // 根据配置找到对应的系统账号组,用于在数据看板中区分订单所属账号 $orderPay['sys_group_id'] = $conf->sys_group_id; $orderPay['order_source'] = $conf->order_source; $orderPay['platform_id'] = $platformId; // 数据校验 $check = MsgService::checkSignatureNew($nonce, $timestamp, $conf->token, $platformId, $signature); if($check === false) { Log::logError('保存订单数据异常', ['数据校验失败'], 'platformOrder'); return 'fail'; } try{ // 将数据保存入数据库 DjOrderService::platformOrderCallBack($orderPay); } catch (\Exception $exception) { Log::logError('保存第三方订单数据异常', [ 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()], 'platformOrder'); $this->exceptionHandler('callBackOrder', json_encode([ 'err_msg' => '保存第三方订单数据异常', 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString(), ])); return 'fail'; } return 'success'; } # 接收容量平台用户和订单信息 public function capacityUserCallBack(Request $request) { // 将接收到的数据保存的日志文件中 Log::logInfo(json_encode($request->all(), JSON_UNESCAPED_UNICODE), [], 'CapacityUser'); $platformId = $request->input('platformId'); try{ // 查询app_id对应的token $conf = PlatformOrderConf::getTokenByPlatformId($platformId); if(empty($conf->token)) { Log::logError('保存订单数据异常', ['未查询到token'], 'CapacityUserError'); return json_encode($response = [ 'code' => 1102, 'msg' => '', ]); } // 根据配置找到对应的系统账号组,用于在数据看板中区分订单所属账号 $data = $request->all(); $data['sys_group_id'] = $conf->sys_group_id; $data['order_source'] = $conf->order_source; $data['platform_id'] = $platformId; // 将数据保存入数据库 list($code, $msg) = CapacityService::saveUserList($data); $response = [ 'code' => $code, 'msg' => $msg, ]; } catch (\Exception $exception) { Log::logError('保存容量用户数据异常', [ 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()], 'CapacityUserError'); $this->exceptionHandler('callBackOrder', json_encode([ 'err_msg' => '保存容量用户数据异常', 'params' => json_decode(json_encode($request->all()), 1), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString(), ])); $response = [ 'code' => 1102, 'msg' => '', ]; } return json_encode($response); } }