Commit 659ad841 authored by zazaname's avatar zazaname

增加渠道下单

parent e4e2d607
......@@ -8,6 +8,9 @@ interface ISdkFactory
// 登录
public function login( $verInfo, $gameInfo, $request): array;
// 创建订单号
public function createOrder( $verInfo, $gameInfo, $request): string;
// 支付
public function pay( $verInfo, $gameInfo, $request): array;
}
......@@ -68,6 +68,17 @@ class Jiuzi implements ISdkFactory
];
}
/**
* 创建订单号
* @param $verInfo
* @param $gameInfo
* @param $request
* @return array
*/
public function createOrder($verInfo,$gameInfo, $request): string{
return '';
}
/**
* 按渠道的格式返回
* @param $statusCode
......
......@@ -62,5 +62,30 @@ class SdkManager
return $sdkObj->pay($verInfo,$gameInfo, $params);
}
/**
* 返回渠道订单号
* @param $verInfo
* @param $gameInfo
* @param $params
* @return array
*/
public function createOrder($verInfo, $gameInfo, $params): string
{
$channelClass = ucfirst($verInfo->ver_class);
try {
/** @var ISdkFactory $sdkObj */
$sdkFileClass = "App\\Http\\InterfaceClass\\SdkImpl\\{$channelClass}";
$sdkObj = new $sdkFileClass;
if (!$sdkObj instanceof ISdkFactory) {
throw new RuntimeException($channelClass . '不是ISdkFactory子类!');
}
} catch (Exception $e) {
$msg = '创建' . $channelClass . '类失败!';
throw new RuntimeException($msg);
}
return $sdkObj->createOrder($verInfo,$gameInfo, $params);
}
}
......@@ -43,6 +43,22 @@ class PayService
if (empty($params['app_id']) || empty($params['ctype']) || empty($params['money']) || empty($params['uid'])) {
return error("提交参数异常!");
}
//获取游戏表配置
$gameInfo = DB::table("app_games_config")
->where(['app_id' => $params['app_id']])->first();
if (is_null($gameInfo)) {
return error('该游戏配置不存在,app_id:' . $params['app_id']);
}
// 获取渠道表配置
$verInfo = DB::table("app_ver_game as avg")
->leftJoin('app_ver as av', 'avg.ver', '=', 'av.ver_class')
->where(['app_id' => $params['app_id'], 'ver_code' => $params['ctype']])->first();
if (is_null($verInfo)) {
return error('该游戏渠道没配置,app_id:' . $params['app_id']);
}
// 走一下渠道的下单接口,如果部分渠道没有,则返回空
$sdkManager = new SdkManager();
$channel_order_id = $sdkManager->createOrder($verInfo, $gameInfo, $params);
// 查找融合用户信息
$userInfo = DB::table('app_member')->where(['uid' => $params['uid']])->first();
// 入库
......@@ -51,6 +67,7 @@ class PayService
'uid' => $params['uid'],
'order_id' => $orderId,
'cp_order_id' => $params['cp_order_id'],
'channel_order_id' => $channel_order_id,
'veruniqid' => $userInfo->veruniqid,
'ver' => $params['ctype'],
'appid' => $params['app_id'],
......@@ -66,7 +83,7 @@ class PayService
'create_time' => date('Y-m-d H:i:s')
];
$model->insert($insertData);
return success('success',['order_id' => $orderId]);
return success('success',['order_id' => $orderId,'channel_order_id'=>$channel_order_id]);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment