Commit 4de1c466 authored by wanjilong's avatar wanjilong

add: 1. 调整发号器必须整数,2. 增加ping++订单支付

parent f4eeef64
......@@ -24,5 +24,6 @@ class PayException extends BaseException
12 => '订单不存在,请核对',
13 => '生活号获取管理员ID失败,请联系管理员',
14 => '支付订单预结算失败,结算资金不能负数,请核对配置',
15 => '支付订单金额与实际支付金额不等,请管理员关注',
];
}
......@@ -28,7 +28,7 @@ class Sdk {
*/
$data = (new Request())->post($url, $params,2000, 'json');
FileLog::info('sdk_call:' . 'services return', json_encode(['url'=>$url, $headers, 'req'=>$params, 'res'=>$data]));
FileLog::info('sdk_call:' . 'services return', json_encode(['url'=>$url, $headers, 'req'=>$params, 'res'=>$data], JSON_UNESCAPED_UNICODE));
/*
[
"http_code"=> 200,
......
......@@ -42,11 +42,9 @@ class CallbackController extends Base
}
$ret = $paySrv->call_back($data);
$this->success(['result'=>$ret]);
}catch (Exception $e) {
http_response_code(500);
$this->failed('500', $e->getMessage());
}
}
......
......@@ -120,7 +120,19 @@ class PayService
$ret['exist'] = true;
}
return $ret;
// 创建支付单
$payment = [
'charge_order_no'=> $order['pay_order_id'],
'charge_amount'=> $order['payment'],
'channel'=> 'wx',
];
$pay = PingxxService::getInstance()->pay($ret['id'], $payment);
if (!empty($pay['error'])) {
throw new \Exception($pay['error']['message'], '2001');
}
return $pay;
}
/**
......@@ -165,6 +177,10 @@ class PayService
return ['pay_order_id' => $pay_order_id];
}
if($pay_order['pay_amount'] != $object['actual_amount']) {
throw new PayException(['cus' => 15]);
}
//获取订单 + 子单 + 分销信息
$ret = OrderService::getFullOrderData($pay_order['order_id'], $pay_order['user_id']);
if (empty($ret['result']['order_info'])) {
......@@ -272,7 +288,7 @@ class PayService
], ['order_item_id' => $order_item_id, 'can_notify_account' => 1]);
} catch (\Exception $e) {
FileLog::error('wallet: 钱包同步失败', json_encode($wallet_list), $e);
FileLog::error('wallet: 钱包同步失败', json_encode($wallet_list, JSON_UNESCAPED_UNICODE), $e);
//补偿处理
PayOrderItem::update([
'notify_account_status' => 0,
......@@ -486,7 +502,7 @@ class PayService
$log_string = json_encode([
'life_account_id'=>$this->order_info['life_account_id'],
'ret'=>$ret,
]);
], JSON_UNESCAPED_UNICODE);
FileLog::error('pay:', '获取生活号管理员失败', $log_string);
throw new PayException(['cus'=>13]);
......@@ -595,6 +611,7 @@ class PayService
private function get_idgen_id($number, $count = 1)
{
$number = intval($number);
$res = Idgen::get(appConfig('idgen.partner'), appConfig('idgen.key'), [], [[
"type" => "55c768",
'number' => $number,
......
......@@ -43,7 +43,7 @@ class PingxxService
try {
FileLog::info('ping++:' . '退款订单发起', json_encode($refundData));
FileLog::info('ping++:' . '退款订单发起', json_encode($refundData, JSON_UNESCAPED_UNICODE));
$royalty_users = [];
$ret = OrderRefund::create(
......@@ -56,7 +56,7 @@ class PingxxService
'refund_mode' => 'to_source', //退款模式。原路退回:to_source,退至余额:to_balance。默认为原路返回。
]
);
FileLog::info('ping++:' . '退款订单返回', json_encode(['res'=>$ret]));
FileLog::info('ping++:' . '退款订单返回', json_encode(['res'=>$ret], JSON_UNESCAPED_UNICODE));
$response = json_decode($ret, true);
return $response;
......@@ -83,9 +83,9 @@ class PingxxService
*/
public function getRefund($orderId, $refundId) {
try {
FileLog::info('ping++:' . '退款查询发起', json_encode(['orderId'=>$orderId, 'refundId'=>$refundId]));
FileLog::info('ping++:' . '退款查询发起', json_encode(['orderId'=>$orderId, 'refundId'=>$refundId], JSON_UNESCAPED_UNICODE));
$ret = OrderRefund::retrieve($orderId, $refundId);
FileLog::info('ping++:' . '退款查询返回', json_encode(['res'=>$ret]));
FileLog::info('ping++:' . '退款查询返回', json_encode(['res'=>$ret], JSON_UNESCAPED_UNICODE));
$respose = json_decode($ret, true);
return $respose;
......@@ -111,7 +111,7 @@ class PingxxService
public function createOrder($order, $metadata) {
try {
FileLog::info('ping++:' . '创建订单发起', json_encode($order));
FileLog::info('ping++:' . '创建订单发起', json_encode($order, JSON_UNESCAPED_UNICODE));
$royalty_users = [];
$ret = Order::create(
[
......@@ -129,7 +129,7 @@ class PingxxService
]
);
FileLog::info('ping++:' . '创建订单返回', json_encode(['res'=>$ret]));
FileLog::info('ping++:' . '创建订单返回', json_encode(['res'=>$ret], JSON_UNESCAPED_UNICODE));
$respose = json_decode($ret, true);
return $respose;
......@@ -157,6 +157,36 @@ class PingxxService
}
}
public function pay($orderId, $pay) {
$params = [
'charge_order_no' => substr(md5(time()), 0, 10),
'charge_amount' => 100,
'channel' => 'alipay_qr',
];
try {
FileLog::info('ping++:' . '订单pay发起', json_encode($pay, JSON_UNESCAPED_UNICODE));
$ret = Order::pay($orderId, $pay);
FileLog::info('ping++:' . '订单pay返回', json_encode(['res'=>$ret], JSON_UNESCAPED_UNICODE));
$respose = json_decode($ret, true);
return $respose;
} catch (\Pingpp\Error\Base $e) {
// 捕获报错信息
if ($e->getHttpStatus() != null) {
return json_decode($e->getHttpBody(), true);
} else {
return [
'error'=>['message'=>$e->getMessage()],
'type'=>'http error',
];
}
}
}
/**
* @param $orderId
* 订单查询
......@@ -167,7 +197,7 @@ class PingxxService
FileLog::info('ping++:' . '查询订单发起', json_encode(['orderId'=>$orderId]));
$ret = Order::retrieve($orderId);
FileLog::info('ping++:' . '查询订单返回', json_encode(['res'=>$ret]));
FileLog::info('ping++:' . '查询订单返回', json_encode(['res'=>$ret], JSON_UNESCAPED_UNICODE));
$respose = json_decode($ret, true);
return $respose;
......
......@@ -247,6 +247,7 @@ class RefundService
private function get_idgen_id($number, $count = 1)
{
$number = intval($number);
$res = Idgen::get(appConfig('idgen.partner'), appConfig('idgen.key'), [], [[
"type" => "55c768",
'number' => $number,
......
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