$value) { $string .= $name.$value; } } $string = $secret . $string . $timestamp; return md5($string); } public static function orderList($params, $retry = 0) { try { $url = config('capacity.request_url'); $response = HttpService::httpPost($url, json_encode($params), true); if($response === false && $retry <5) { // 发起重试 $retry++; return CapacityService::orderList($params, $retry); } $responseData = json_decode($response, 1); Log::logInfo('容量订单', [ 'params' => $params, 'response' => $responseData ], 'CapacityOrderList'); if((isset($responseData['code']) && $responseData['code'] != 0) || !isset($responseData['data']['data'])) { $errMsg = $responseData['msg'] ?? ''; EmailQueue::rPush('获取容量平台下的订单信息返回错误', $errMsg, ['song.shen@kuxuan-inc.com'], '猎羽'); Log::logError('获取容量平台下的订单信息返回错误', ['response' => $responseData], 'CapacityApi'); return [[], 0]; } $data = $responseData['data']['data'] ?? []; $count= $responseData['data']['dataCount'] ?? 0; return [$data, $count]; } catch (\Exception $e) { EmailQueue::rPush('获取容量平台下的订单信息返回错误', '', ['song.shen@kuxuan-inc.com'], '猎羽'); Log::logError('获取容量平台下的订单信息返回错误', [ 'line' => $e->getLine(), 'msg' => $e->getMessage() ], 'CapacityApi-Exception'); return [[], 0]; } } public static function appList($params, $retry=0) { try { $url = config('capacity.request_url'); $response = HttpService::httpPost($url, json_encode($params), true); if($response === false && $retry <5) { // 发起重试 $retry++; return CapacityService::appList($params, $retry); } $responseData = json_decode($response, 1); Log::logInfo('应用列表', [$responseData], 'CapacityAppList'); if(isset($responseData['code']) && $responseData['code'] != 0) { EmailQueue::rPush('获取容量平台下的渠道信息返回错误', $responseData['msg'], ['song.shen@kuxuan-inc.com'], '猎羽'); Log::logError('获取容量平台下的订单信息返回错误', ['response' => $responseData], 'CapacityApi'); return []; } return $responseData['data'] ?? []; } catch (\Exception $e) { EmailQueue::rPush('获取容量平台下的渠道信息返回错误', '', ['song.shen@kuxuan-inc.com'], '猎羽'); Log::logError('获取容量平台下的渠道信息返回错误', [ 'line' => $e->getLine(), 'msg' => $e->getMessage() ], 'CapacityApi-Exception'); } return []; } public static function saveUserList($data) { $type = $data['type'] ?? null; if(empty($type)) { EmailQueue::rPush('容量平台推送数据异常', $data, ['song.shen@kuxuan-inc.com'], '猎羽'); return [500, '数据类型异常']; } if('订单' == $type) { $res = DjOrderService::saveCapacityOrder($data); } else { $res = CapacityUser::saveCapacityUser($data); } if(!$res) { return [500, '保存失败']; } return [0, '保存成功']; } public static function dealPayInfo($order) { // 支付状态 $order['pay_status'] = 0; switch($order['payStatus']) { case '已支付': $order['pay_status'] = 1; break; case '预支付': $order['pay_status'] = 0; break; case '已退款': $order['pay_status'] = -1; break; } // 支付渠道以及订单金额分成比例 $order['order_pay_type'] = 0; $payType = 1; switch($order['payType']) { case '微信支付-jsapi': $order['order_pay_type'] = 2; $payType = 2; break; case '头条支付': $order['order_pay_type'] = 3; $payType = 2; break; case '快手支付': $order['order_pay_type'] = 4; $payType = 2; break; case '支付宝app支付': $order['order_pay_type'] = 5; $payType = 2; break; case '小程序虚拟支付': $order['order_pay_type'] = 1; break; default: EmailQueue::rPush('容量平台支付类型异常', json_encode($order, 256), 'song.shen@kuxuan-inc.com', '猎羽'); break; } # 获取订单金额分成比例(不用区分是否为小程序虚拟支付) // $shareInProportionArr = OrderService::getOrderShareInProportion(6); $playletName = $order['compilationsTitle'] ?? null; $shareInProportionArr = OrderService::getOrderShareInProportionNew($order['order_source'], $playletName, $order['sys_group_id']); $shareInProportion = $shareInProportionArr[$payType] ?? 1; # 计算分成后的金额 $order['origin_pay_money'] = $order['moneyFen']; if(3 == $order['sys_group_id']) { $order['moneyFen'] = $order['origin_pay_money'] * $shareInProportion; } return $order; } public static function getDeviceType($userAgent) { if(strpos($userAgent, 'Android') !== false) { return 1; } else if (strpos($userAgent, 'iPhone') !== false || strpos($userAgent, 'iPad')) { return 2; } else if (strpos($userAgent, 'Windows') !== false){ return 0; } else { EmailQueue::rPush('第三方平台设备类型异常', json_encode([ 'platform' => '容量', 'msg' => '设备类型字段值不符合预期', 'ua' => $userAgent ], 256), ['song.shen@kuxuan-inc.com'], '猎羽'); return 0; } } }