This commit is contained in:
youda 2025-05-13 19:50:01 +08:00
parent 0d3c550f5b
commit 29f6592d2d
3 changed files with 31 additions and 10 deletions

View File

@ -942,7 +942,7 @@ class Mall extends Base
throw new \Exception(isset($payRes['msg']) ? $payRes['msg'] : "购买失败,请刷新重试");
}
$order_num = $payRes['data']['order_no'];
// 创建钻石订单
$order_id = DiamondOrder::insertGetId([
'order_no' => $order_num,
@ -955,22 +955,22 @@ class Mall extends Base
'status' => DiamondOrder::STATUS_PENDING,
'created_at' => date('Y-m-d H:i:s')
]);
if (!$order_id) {
throw new \Exception("订单创建失败");
}
Db::commit();
// 删除redis锁
$redis->del($redis_key);
return $this->renderSuccess("下单成功", [
'status' => 1,
'order_num' => $order_num,
'res' => $payRes['data']['res'],
]);
} catch (\Exception $e) {
Db::rollback();
// 删除redis锁
@ -978,4 +978,24 @@ class Mall extends Base
return $this->renderError($e->getMessage());
}
}
public function get_diamond_order_log()
{
$user_id = $this->getuserid();
if ($user_id == 0) {
return $this->renderError("未登录");
}
$order_num = request()->param('order_num', '');
$diamond_order = DiamondOrder::where('order_no', '=', $order_num)->find();
if (!$diamond_order) {
return $this->renderError("订单不存在");
}
if ($diamond_order['user_id'] != $user_id) {
return $this->renderError("无权限查看");
}
if ($diamond_order['status'] != DiamondOrder::STATUS_SUCCESS) {
return $this->renderError("订单未成功");
}
return $this->renderSuccess($diamond_order['reward_log']);
}
}

View File

@ -242,4 +242,5 @@ Route::any('getAddressDetail', 'Other/getAddressDetail');
# 钻石管理
#============================
Route::any('get_diamond_list', 'Mall/get_diamond_list');
Route::any('createOrderProducts', 'Mall/createOrderProducts');
Route::any('createOrderProducts', 'Mall/createOrderProducts');
Route::any('get_diamond_order_log', 'Mall/get_diamond_order_log');

View File

@ -71,9 +71,9 @@ class H5Platform extends BasePlatform
// 生成新的支付通知URL
$notifyUrl = generatePayNotifyUrl($payment_type, $order_type, $user_id, $order_no, $callback_nonce_str);
$is_test = $user['istest'];
// if ($is_test == 2) {
// $price = 0.01;
// }
if ($is_test == 2) {
$price = 0.01;
}
$returnUrl = urldecode($returnUrl);
//2. 发起API调用以支付能力下的统一收单交易创建接口为例
$result = Factory::payment()