Commit 95bb1a5f authored by 万继龙's avatar 万继龙

Merge branch 'develop' into 'test'

Develop

See merge request bp/pay!13
parents 40de9a0b 71f1acca
...@@ -7,6 +7,7 @@ namespace App\Exception; ...@@ -7,6 +7,7 @@ namespace App\Exception;
* 重写Handle的render方法,实现自定义异常消息 * 重写Handle的render方法,实现自定义异常消息
*/ */
use Api\PhpUtils\Log\FileLog;
use Helpers\ApiResponse; use Helpers\ApiResponse;
use Yaf\Registry; use Yaf\Registry;
...@@ -38,6 +39,6 @@ class ErrorHandler ...@@ -38,6 +39,6 @@ class ErrorHandler
*/ */
private function recordErrorLog($msg) private function recordErrorLog($msg)
{ {
// LogUtil::error('Error handler', $msg); FileLog::error('Error handler', $msg);
} }
} }
\ No newline at end of file
...@@ -21,10 +21,10 @@ class RefundException extends BaseException ...@@ -21,10 +21,10 @@ class RefundException extends BaseException
7 => '退款处理中请稍等', 7 => '退款处理中请稍等',
8 => '退款消息类型匹配失败,请管理员关注!', 8 => '退款消息类型匹配失败,请管理员关注!',
9 => 'ping++退款消息格式错误,请管理员关注!', 9 => 'pingxx退款消息格式错误,请管理员关注!',
10 => 'ping++退单状态异常,请管理员关注!', 10 => 'pingxx退单状态异常,请管理员关注!',
11 => 'ping++退单缺少matadata!', 11 => 'pingxx退单缺少matadata!',
12 => 'ping++未支付订单不允许退款。', 12 => 'pingxx未支付订单不允许退款。',
13 => 'ping++存在多次支付场景,请联系管理员确认。', 13 => 'pingxx订单可能存在多次成功支付,需人工确认处理。',
]; ];
} }
...@@ -77,7 +77,7 @@ class Logger { ...@@ -77,7 +77,7 @@ class Logger {
public static function log($level, $message, $content, $tag) { public static function log($level, $message, $content, $tag) {
if (!defined('LOG_PATH')) { if (!defined('LOG_PATH')) {
define('LOG_PATH', '/var/log/'); define('LOG_PATH', ROOT_PATH.'/logs/');
} }
switch ($level) { switch ($level) {
......
...@@ -2,11 +2,9 @@ ...@@ -2,11 +2,9 @@
use App\Base\Base; use App\Base\Base;
use App\Models\order\mysql\PayOrder;
use App\Services\pay\PayService; use App\Services\pay\PayService;
use App\Services\refund\RefundService; use App\Services\refund\RefundService;
use App\Models\order\mysql\CallbackLog; use App\Models\order\mysql\CallbackLog;
use App\Services\pingxx\PingxxService;
class CallbackController extends Base class CallbackController extends Base
{ {
...@@ -15,69 +13,55 @@ class CallbackController extends Base ...@@ -15,69 +13,55 @@ class CallbackController extends Base
*/ */
public function payAction() public function payAction()
{ {
try{ $raw_data = file_get_contents('php://input');
$raw_data = file_get_contents('php://input'); $paySrv = new PayService();
$paySrv = new PayService(); $data = json_decode($raw_data, true);
$data = json_decode($raw_data, true); if(!empty($data['data']['object'])) {
/**/ if($data['type'] == 'charge.succeeded') {
if(!empty($data['data']['object'])) { $merchant_order_no = $data['data']['object']['order_no'];
} else {
if($data['type'] == 'charge.succeeded') { $merchant_order_no = $data['data']['object']['merchant_order_no'];
$merchant_order_no = $data['data']['object']['order_no'];
} else {
$merchant_order_no = $data['data']['object']['merchant_order_no'];
}
CallbackLog::insert([
'type'=>$data['type'] ?? '',
'merchant_order_no'=>$merchant_order_no ?? '',
'object_id'=>$data['data']['object']['id'] ?? '',
'data'=>base64_encode(gzcompress($raw_data)), //压缩存储
]);
} }
//$str = gzuncompress(base64_decode($info['data']));
$ret = $paySrv->call_back($data); CallbackLog::insert([
$this->success(['result'=>$ret]); 'type'=>$data['type'] ?? '',
'merchant_order_no'=>$merchant_order_no ?? '',
}catch (Exception $e) { 'object_id'=>$data['data']['object']['id'] ?? '',
throw $e; 'data'=>base64_encode(gzcompress($raw_data)), //压缩存储
$this->failed('500', $e->getMessage()); ]);
} }
//$str = gzuncompress(base64_decode($info['data']));
$ret = $paySrv->call_back($data);
$this->success(['result'=>$ret]);
} }
public function refundAction() { public function refundAction() {
try{ $raw_data = file_get_contents('php://input');
$raw_data = file_get_contents('php://input'); $data = json_decode($raw_data, true);
$data = json_decode($raw_data, true);
if(!empty($data['data']['object'])) {
if(!empty($data['data']['object'])) { if($data['type'] == 'refund.succeeded') {
$merchant_order_no = $data['data']['object']['order_no'];
if($data['type'] == 'refund.succeeded') { } else {
$merchant_order_no = $data['data']['object']['order_no']; $merchant_order_no = $data['data']['object']['merchant_order_no'];
} else {
$merchant_order_no = $data['data']['object']['merchant_order_no'];
}
CallbackLog::insert([
'type'=>$data['type'] ?? '',
'merchant_order_no'=>$merchant_order_no ?? '',
'object_id'=>$data['data']['object']['id'] ?? '',
'data'=>base64_encode(gzcompress($raw_data)), //压缩存储
]);
} }
CallbackLog::insert([
$refundSrv = new RefundService(); 'type'=>$data['type'] ?? '',
$ret = $refundSrv->call_back($data); 'merchant_order_no'=>$merchant_order_no ?? '',
$this->success(['result'=>$ret]); 'object_id'=>$data['data']['object']['id'] ?? '',
'data'=>base64_encode(gzcompress($raw_data)), //压缩存储
}catch (Exception $e) { ]);
$this->failed('500', $e->getMessage());
} }
$refundSrv = new RefundService();
$ret = $refundSrv->call_back($data);
$this->success(['result'=>$ret]);
} }
} }
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
use App\Base\Base; use App\Base\Base;
use App\Exception\custom\PayException;
use App\Exception\custom\RefundException;
use App\Services\pay\PayService; use App\Services\pay\PayService;
use App\Services\refund\RefundService; use App\Services\refund\RefundService;
use Api\PhpUtils\Log\FileLog; use Api\PhpUtils\Log\FileLog;
......
...@@ -14,15 +14,16 @@ class Hook extends \Yaf\Plugin_Abstract { ...@@ -14,15 +14,16 @@ class Hook extends \Yaf\Plugin_Abstract {
public function routerShutdown(\Yaf\Request_Abstract $request, \Yaf\Response_Abstract $response) { public function routerShutdown(\Yaf\Request_Abstract $request, \Yaf\Response_Abstract $response) {
/*---Debug Begin---*/ /*---Debug Begin---*/
if((defined('_IS_DEBUG') && _IS_DEBUG) && (isset($_REQUEST['__debug']) && strpos($_REQUEST['__debug'], _DEBUG_PASS) !== false)) if((defined('_IS_DEBUG') && _IS_DEBUG) || (isset($_REQUEST['__debug']) && strpos($_REQUEST['__debug'], _DEBUG_PASS) !== false))
{ {
// $_REQUEST['__debug'] = _DEBUG_PASS + 1 (2 数字表示级别 ) // $_REQUEST['__debug'] = _DEBUG_PASS + 1 (2 数字表示级别 )
$debug_level = intval(substr($_REQUEST['__debug'], -1)); if(!empty($_REQUEST['__debug'])) {
if ($debug_level > 0) { $debug_level = intval(substr($_REQUEST['__debug'], -1));
define('DEBUG_LEVEL', $debug_level ); } else {
} else { $debug_level = 1;
define('DEBUG_LEVEL', 1); }
} define('DEBUG_LEVEL', $debug_level );
//Debug模式将错误打开 //Debug模式将错误打开
ini_set('display_errors', true); ini_set('display_errors', true);
//设置错误级别 //设置错误级别
......
...@@ -107,6 +107,7 @@ class PayService ...@@ -107,6 +107,7 @@ class PayService
'pay_order_status' => Dictionary::O_PAY_STATUS_PAYED, 'pay_order_status' => Dictionary::O_PAY_STATUS_PAYED,
'third_order_id' => $ret['id'], 'third_order_id' => $ret['id'],
]; ];
//todo 需要做补偿
//PayOrder::update($edit, ['pay_order_id' => $pay_order['pay_order_id']]); //PayOrder::update($edit, ['pay_order_id' => $pay_order['pay_order_id']]);
throw new PayException(['cus' => 5]); throw new PayException(['cus' => 5]);
...@@ -114,6 +115,7 @@ class PayService ...@@ -114,6 +115,7 @@ class PayService
$edit = [ $edit = [
'expire_time' => date('Y-m-d H:i:s'), 'expire_time' => date('Y-m-d H:i:s'),
]; ];
//todo 需要做状态同步,不仅仅是更新状态
PayOrder::update($edit, ['pay_order_id' => $pay_order['pay_order_id']]); PayOrder::update($edit, ['pay_order_id' => $pay_order['pay_order_id']]);
throw new PayException(['cus' => 6]); throw new PayException(['cus' => 6]);
...@@ -383,7 +385,8 @@ class PayService ...@@ -383,7 +385,8 @@ class PayService
//如果是不可退款商品,则需进入结算队列 //如果是不可退款商品,则需进入结算队列
foreach ($this->order_items as $r) { foreach ($this->order_items as $r) {
// 收集直接到账信息 // 收集直接到账信息
if($r['rule_refund'] == 1 ) { //分销商品一定是不可退 //rule_refund 退款规则:1到期自动退款,2购买后不允许退款,3到期后不退款
if($r['rule_refund'] == 2 ) { //分销商品一定是不可退
PayOrderItem::update([ PayOrderItem::update([
'can_notify_account'=>1, 'can_notify_account'=>1,
'can_notify_account_time'=>date('Y-m-d H:i:s') 'can_notify_account_time'=>date('Y-m-d H:i:s')
......
...@@ -69,7 +69,7 @@ class RefundService ...@@ -69,7 +69,7 @@ class RefundService
// 存在多次支付的场景需要人工介入处理, 修复订单支付金额,退款金额 // 存在多次支付的场景需要人工介入处理, 修复订单支付金额,退款金额
if($pay['amount_paid'] > $pay['actual_amount']) { if($pay['amount_paid'] > $pay['actual_amount']) {
FileLog::error('pay-service: 订单存在多次支付成功,需人工处理。', json_encode($pay, JSON_UNESCAPED_UNICODE)); FileLog::error('pay-service: 订单可能存在多次成功支付,需人工确认处理。', json_encode($pay, JSON_UNESCAPED_UNICODE));
throw new RefundException(['cus' => 13]); throw new RefundException(['cus' => 13]);
} }
...@@ -215,7 +215,7 @@ class RefundService ...@@ -215,7 +215,7 @@ class RefundService
$wx_clear = PayOrderClearing::getMaster('*', [ $wx_clear = PayOrderClearing::getMaster('*', [
'order_id'=>$where['order_id'], 'order_id'=>$where['order_id'],
'pay_order_id'=>$pay_order['pay_order_id'], 'pay_order_id'=>$pay_order['pay_order_id'],
'pay_type'=>406 //三方渠道手续费 'pay_sub_type'=>406 //三方渠道手续费
] ]
); );
......
<?php <?php
namespace Daemon; namespace Daemon;
use Api\PhpServices\Daemon\DaemonServiceInterface; use Api\PhpServices\Daemon\DaemonServiceInterface;
use Api\PhpUtils\Log\FileLog;
use App\Models\order\mysql\PayOrderItem; use App\Models\order\mysql\PayOrderItem;
use App\Services\pay\PayService; use App\Services\pay\PayService;
...@@ -16,29 +13,19 @@ class Wallet implements DaemonServiceInterface ...@@ -16,29 +13,19 @@ class Wallet implements DaemonServiceInterface
*/ */
public function run() public function run()
{ {
if (!empty($data['LIMIT'])) {
$where['LIMIT'] = $data['LIMIT'];
}
if (!empty($data['ORDER'])) {
$where['ORDER'] = 'can_notify_account_time ASC';
}
$where['can_notify_account'] = 1; $where['can_notify_account'] = 1;
$where['notify_account_times[<]'] = 5; $where['notify_account_times[<]'] = 5;
$where['can_notify_account_time[>]'] = time() - 86400;
$where['ORDER'] = 'can_notify_account_time ASC'; $where['ORDER'] = 'can_notify_account_time ASC';
$where['LIMIT'] = [0, 10]; $where['LIMIT'] = [0, 50];
$list = PayOrderItem::selectMaster('*', $where); $list = PayOrderItem::selectMaster('*', $where);
$payService = new PayService(); $payService = new PayService();
foreach ($list as $row) { foreach ($list as $row) {
$payService->sync_account_wallet($row['order_item_id']); $payService->sync_account_wallet($row['order_item_id']);
} }
if(empty($list)) { $step = empty($list) ? 120 : 5;
sleep(120); sleep($step);
}
} }
} }
\ No newline at end of file
<?php <?php
ini_set("display_errors", "On"); /* 根据 yaf.environ 配置设置报错处理方式 */
$environ = ini_get('yaf.environ');
if(in_array($environ, ['dev'])) {
ini_set("display_errors", "On");
error_reporting(E_ALL);
// 异常信息等级
define('_ERROR_LEVEL', E_ALL);
define('_IS_DEBUG', true);
} else {
ini_set("display_errors", "Off");
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
// 异常信息等级
define('_ERROR_LEVEL', E_ALL & ~E_DEPRECATED & ~E_STRICT);
define('_IS_DEBUG', false);
}
/* 定义这个常量是为了在application.ini中引用*/ /* 定义这个常量是为了在application.ini中引用*/
define('ROOT_PATH', realpath(__DIR__.'/../')); define('ROOT_PATH', realpath(__DIR__.'/../'));
define('APP_PATH', realpath(__DIR__.'/../application')); define('APP_PATH', realpath(__DIR__.'/../application'));
define('LOG_PATH', realpath(__DIR__.'/../logs') . '/');
define('APP_START', microtime(true)); define('APP_START', microtime(true));
// 调试参数 __debug 的值 // 调试参数 __debug 的值
define('_DEBUG_PASS', 'debugpass'); // 为了避免调试信息泄漏,请定义自己的密钥 define('_DEBUG_PASS', 'debugpass'); // 为了避免调试信息泄漏,请定义自己的密钥
// 是否开启调试状态
define('_IS_DEBUG', true);
// 异常信息等级
define('_ERROR_LEVEL', E_ALL);
$application = new Yaf\Application( ROOT_PATH . "/conf/application.ini"); $application = new Yaf\Application( ROOT_PATH . "/conf/application.ini");
......
...@@ -8,9 +8,9 @@ class IdCertification ...@@ -8,9 +8,9 @@ class IdCertification
{ {
private const key = '_v7QkFPgzb887YD6BuBqzHPJMJalJ6Zt'; private const key = '_v7QkFPgzb887YD6BuBqzHPJMJalJ6Zt';
private const secret = 'mDenoicZs2U_wd2jVmQQpCOPeM8jaFRu'; private const secret = 'mDenoicZs2U_wd2jVmQQpCOPeM8jaFRu';
private const kuangshi_ocr_url = 'https://api.megvii.com/faceid/v3/ocridcard'; public const kuangshi_ocr_url = 'https://api.megvii.com/faceid/v3/ocridcard';
private const kuangshi_get_token = 'https://api.megvii.com/faceid/v3/sdk/get_biz_token'; public const kuangshi_get_token = 'https://api.megvii.com/faceid/v3/sdk/get_biz_token';
private const kuangshi_face_compare = 'https://api.megvii.com/faceid/v3/sdk/verify'; public const kuangshi_face_compare = 'https://api.megvii.com/faceid/v3/sdk/verify';
/** /**
* 身份证合法校验 * 身份证合法校验
...@@ -232,6 +232,7 @@ class IdCertification ...@@ -232,6 +232,7 @@ class IdCertification
$final_data['birth_year'] = $ocr_data['response']['birth_year']['result'] ?? ''; $final_data['birth_year'] = $ocr_data['response']['birth_year']['result'] ?? '';
$final_data['completeness'] = $ocr_data['response']['completeness'] ?? -1; $final_data['completeness'] = $ocr_data['response']['completeness'] ?? -1;
$final_data['legality'] = $ocr_data['response']['legality'] ?? (object)[]; $final_data['legality'] = $ocr_data['response']['legality'] ?? (object)[];
$final_data['code'] = $ocr_data['response']['code'] ?? -1;
return $final_data; return $final_data;
} }
...@@ -247,6 +248,7 @@ class IdCertification ...@@ -247,6 +248,7 @@ class IdCertification
$final_data['valid_date_end'] = $ocr_data['response']['valid_date_end']['result'] ?? ''; $final_data['valid_date_end'] = $ocr_data['response']['valid_date_end']['result'] ?? '';
$final_data['completeness'] = $ocr_data['response']['completeness'] ?? -1; $final_data['completeness'] = $ocr_data['response']['completeness'] ?? -1;
$final_data['legality'] = $ocr_data['response']['legality'] ?? (object)[]; $final_data['legality'] = $ocr_data['response']['legality'] ?? (object)[];
$final_data['code'] = $ocr_data['response']['code'] ?? -1;
return $final_data; return $final_data;
} }
} }
\ No newline at end of file
...@@ -7,7 +7,7 @@ class SocialCreditCertification ...@@ -7,7 +7,7 @@ class SocialCreditCertification
{ {
private const account = 'BJyimingzhineng'; private const account = 'BJyimingzhineng';
private const app_key = 'deee9c9877e5452f8838cfc5130ac5ad'; private const app_key = 'deee9c9877e5452f8838cfc5130ac5ad';
private const ocr_bussiness_url = 'http://apistore.xmturui.com/apistore/ocr-new'; public const ocr_bussiness_url = 'http://apistore.xmturui.com/apistore/ocr-new';
private const engine_type = 'blic-new'; private const engine_type = 'blic-new';
/** /**
......
...@@ -8,7 +8,7 @@ class ThreeElementsCertification ...@@ -8,7 +8,7 @@ class ThreeElementsCertification
{ {
private const app_key = '392df35aa98721c597cf20b85d21eebc'; private const app_key = '392df35aa98721c597cf20b85d21eebc';
//运营商三要素检测接口 //运营商三要素检测接口
private const test_mobile3_ele_Sim_url = 'https://api.goodsdatas.com:8443/credit/Mobile3EleSim'; public const test_mobile3_ele_Sim_url = 'https://api.goodsdatas.com:8443/credit/Mobile3EleSim';
//加密需要的相关参数 //加密需要的相关参数
private const salt = 'A99BC8325635E303'; private const salt = 'A99BC8325635E303';
......
...@@ -13,6 +13,7 @@ namespace Api\PhpServices\JwUser; ...@@ -13,6 +13,7 @@ namespace Api\PhpServices\JwUser;
use Api\PhpUtils\Common\TimeOut; use Api\PhpUtils\Common\TimeOut;
use Api\PhpUtils\Http\Request; use Api\PhpUtils\Http\Request;
use App\Exception\custom\CodeSpecialException; use App\Exception\custom\CodeSpecialException;
use Api\PhpUtils\Log\FileLog;
class JwUser class JwUser
{ {
...@@ -24,6 +25,7 @@ class JwUser ...@@ -24,6 +25,7 @@ class JwUser
*/ */
public function getUserInfo($params) public function getUserInfo($params)
{ {
$url = config('interface', 'service.jw_user.get_user_info'); $url = config('interface', 'service.jw_user.get_user_info');
if (!$url) { if (!$url) {
throw new CodeSpecialException("failed"); throw new CodeSpecialException("failed");
...@@ -34,11 +36,13 @@ class JwUser ...@@ -34,11 +36,13 @@ class JwUser
} }
$params = ["mobilePhone" => $params['mobile']]; $params = ["mobilePhone" => $params['mobile']];
$user_info = (new TimeOut())->runGet($url, $params); //$user_info = (new TimeOut())->runGet($url, $params);
$user_info = (new Request())->get($url, $params);
FileLog::info('jw_user_getUserInfo', json_encode($user_info));
if (!$user_info) { if (!$user_info) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
} }
return $user_info; return !empty($user_info['response']) ? $user_info['response'] : [];
} }
/** /**
* 获取单条信息 * 获取单条信息
...@@ -56,11 +60,13 @@ class JwUser ...@@ -56,11 +60,13 @@ class JwUser
} }
$params = ["userId" => $params['user_id']]; $params = ["userId" => $params['user_id']];
$user_info = (new TimeOut())->runPost($url, $params); //$user_info = (new TimeOut())->runPost($url, $params);
$user_info = (new Request())->post($url, $params, 0, '', '', 0,true,'jw_user');
FileLog::info('jw_user_getUserByUserId', json_encode($user_info));
if (!$user_info) { if (!$user_info) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
} }
return $user_info; return !empty($user_info['response']) ? $user_info['response'] : [];
} }
public function getUserList($params) public function getUserList($params)
...@@ -75,11 +81,13 @@ class JwUser ...@@ -75,11 +81,13 @@ class JwUser
} }
$params = ["userIds" => $params['user_id']]; $params = ["userIds" => $params['user_id']];
$user_info = (new TimeOut())->runPost($url, $params); //$user_info = (new TimeOut())->runPost($url, $params);
$user_info = (new Request())->post($url, $params, 0, '', '', 0,true,'jw_user');
FileLog::info('jw_user_getUserList', json_encode($user_info));
if (!$user_info) { if (!$user_info) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
} }
return $user_info; return !empty($user_info['response']) ? $user_info['response'] : [];
} }
...@@ -95,11 +103,13 @@ class JwUser ...@@ -95,11 +103,13 @@ class JwUser
throw new CodeSpecialException("failed"); throw new CodeSpecialException("failed");
} }
$params = []; $params = [];
$city_list = (new TimeOut())->runGet($url, $params); //$city_list = (new TimeOut())->runGet($url, $params);
$city_list = (new Request())->get($url, $params);
FileLog::info('jw_user_getAllCityTree', json_encode($city_list));
if (!$city_list) { if (!$city_list) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
} }
return $city_list; return !empty($city_list['response']) ? $city_list['response'] : [];
} }
...@@ -118,11 +128,13 @@ class JwUser ...@@ -118,11 +128,13 @@ class JwUser
if (empty($params)) { if (empty($params)) {
throw new CodeSpecialException("failed"); throw new CodeSpecialException("failed");
} }
$pushToken = (new TimeOut())->runPost($url, $params); //$pushToken = (new TimeOut())->runPost($url, $params);
$pushToken = (new Request())->post($url, $params, 0, '', '', 0,true,'jw_user');
FileLog::info('jw_user_savePushToken', json_encode($pushToken));
if (!$pushToken) { if (!$pushToken) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
} }
return $pushToken; return !empty($pushToken['response']) ? $pushToken['response'] : [];
} }
/** /**
...@@ -141,11 +153,13 @@ class JwUser ...@@ -141,11 +153,13 @@ class JwUser
} }
$params = ["userIds" => $params['user_id']]; $params = ["userIds" => $params['user_id']];
$list = (new TimeOut())->runPost($url, $params); //$list = (new TimeOut())->runPost($url, $params);
$list = (new Request())->post($url, $params, 0, '', '', 0,true,'jw_user');
FileLog::info('jw_user_getUserListWithDynamic', json_encode($list));
if (!$list) { if (!$list) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
} }
return $list; return !empty($list['response']) ? $list['response'] : [];
} }
/** /**
...@@ -164,28 +178,30 @@ class JwUser ...@@ -164,28 +178,30 @@ class JwUser
} }
$params = ["userId" => $params['user_id']]; $params = ["userId" => $params['user_id']];
$list = (new TimeOut())->runPost($url, $params); //$list = (new TimeOut())->runPost($url, $params);
$list = (new Request())->post($url, $params, 0, '', '', 0,true,'jw_user');
FileLog::info('jw_user_getUserDigg', json_encode($list));
if (!$list) { if (!$list) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
} }
return $list; return !empty($list['response']) ? $list['response'] : [];
} }
/** /**
* 给简网同步生活号 * 给简网同步生活号
*/ */
public static function saveUpdateLife($params) public static function saveUpdateLife($params)
{ {
$url = config('interface', 'service.jw_user.save_update_life'); $url = config('interface', 'service.jw_user.save_update_life');
if (!$url) { if (!$url) {
throw new CodeSpecialException("failed"); throw new CodeSpecialException("failed");
} }
//$ret = (new TimeOut())->runPost($url, $params);
$ret = (new TimeOut())->runPost($url, $params); $ret = (new Request())->post($url, $params, 0, '', '', 0,true,'jw_user');
FileLog::info('jw_user_saveUpdateLife', json_encode($ret));
if (!$ret) { if (!$ret) {
throw new CodeSpecialException("timeout"); throw new CodeSpecialException("timeout");
} }
return $ret; return !empty($ret['response']) ? $ret['response'] : [];
} }
} }
\ No newline at end of file
<?php
namespace Api\PhpServices\Ksy;
use Api\PhpUtils\Http\HttpUtil;
/**
* 文档: http://ydwiki.yidian-inc.com/pages/viewpage.action?pageId=68515904
* Class Ks3Api
* @package Api\PhpServices\Ksy
*/
class Ks3Api
{
const KSYUN_SK = "3wm9z0P0ja6NceaZYf477EDZrJs7dSSZ";
const KSYUN_AK = "47DA6034D64E7023";
const KS_DATE_SCHEME = 'D, d M Y H:i:s \G\M\T';
const BASE_URL = "http://image-upload.int.yidian-inc.com";
const BASE_GEN_URL = "http://image-urlgen.int.yidian-inc.com";
const PATH_GEN = "/v1/key/gen";
const PATH_SIGNATURE = "/v1/ks3/signature";
const PATH_PIC_ENCRYPT_URL = "/v1/url/gen";
const PATH_PIC_UPLOAD = "/upload";
const AUDIT_ID = "shqbp";
const TYPE_QUALIFICATION = "shq_qualification";//商户资质
const TYPE_GOODS = "shq_goods";//商品图片
public static $typeList = [
self::TYPE_QUALIFICATION,
self::TYPE_GOODS
];
/**
* 获取bucket与objectKey
* @param $type
* @return mixed
*/
public static function gen($type)
{
$url = self::BASE_URL . self::PATH_GEN;
$timestamp = self::msectime();
$md5Str = $type . "&" . $timestamp . "&" . self::KSYUN_SK;
$signature = self::KSYUN_AK . ":" . md5($md5Str);
$params = [
"timestamp" => $timestamp,
"signature" => $signature,
"type" => $type,
];
return HttpUtil::post($url, $params);
}
/**
* 获取KS签名
* @param $resource
* @param $httpMethod
* @param $contentType
* @param $contentMd5
* @param $headers
* @return array
*/
public static function signature($resource, $httpMethod, $contentType, $contentMd5, $headers, $date)
{
$url = self::BASE_URL . self::PATH_SIGNATURE;
$timestamp = self::msectime();
$md5Str = $httpMethod . "&" . $contentType . "&" . $contentMd5 . "&" . $date . "&" . $resource . "&" . $headers . "&" . $timestamp . "&" . self::KSYUN_SK;
$signature = self::KSYUN_AK . ":" . md5($md5Str);
$params = [
"timestamp" => $timestamp,
"signature" => $signature,
"http_method" => $httpMethod,
"content_type" => $contentType,
"date" => $date,
"content_md5" => $contentMd5,
"resource" => $resource,
"headers" => $headers,
];
return HttpUtil::post($url, $params);
}
/**
* 生成图片访问加密链接
* @param $imageId
* @param $authId
* @param $widthSize
* @param $highSize
* @param int $expirationTime
* @return mixed
*/
public static function picEncryptUrl($imageId, $widthSize = 0, $highSize = 0, $expirationTime = 60 * 60 * 24 * 365)
{
$url = self::BASE_GEN_URL . self::PATH_PIC_ENCRYPT_URL;
$timestamp = self::msectime();
$extend = [];
$extend["expiration_time"] = $expirationTime;
if (!empty($widthSize) && !empty($highSize)) {
$extend["query"] = "type=thumbnail_" . $widthSize . "x" . $highSize;
}
$extendJsonStr = json_encode($extend);
$md5Str = $extendJsonStr . "&" . $imageId . "&" . self::AUDIT_ID . "&" . $timestamp . "&" . self::KSYUN_SK;
$signature = self::KSYUN_AK . ":" . md5($md5Str);
$contentType = 'multipart/form-data';
$params = [
"image_id" => $imageId,
"auth_id" => self::AUDIT_ID,
"timestamp" => $timestamp,
"signature" => $signature,
"content_type" => $contentType,
"extend" => $extendJsonStr,
];
return HttpUtil::post($url, $params);
}
/**
* 上传图片
* @param int $type
* @return mixed
*/
public static function upload($type)
{
$url = self::BASE_URL . self::PATH_PIC_UPLOAD;
$timestamp = self::msectime();
$handle = fopen($_FILES['file']['tmp_name'], 'r');
$content = fread($handle, filesize($_FILES['file']['tmp_name']));
$extend = ["type" => $type];
$extendJsonStr = json_encode($extend);
$md5Str = $extendJsonStr . "&" . md5($content) . "&" . $timestamp . "&" . self::KSYUN_SK;
$signature = self::KSYUN_AK . ":" . md5($md5Str);
$params = [
"pic" => new \CURLFile($_FILES['file']['tmp_name'], $_FILES['file']['type']),
"timestamp" => $timestamp,
"signature" => $signature,
"extend" => $extendJsonStr,
];
return HttpUtil::post($url, $params);
}
/**
* 时间戳(毫秒)
* @return float
*/
private static function msectime()
{
list($msec, $sec) = explode(' ', microtime());
return (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
}
}
\ No newline at end of file
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace Api\PhpServices\Ksy; namespace Api\PhpServices\Ksy;
use Api\PhpUtils\Http\Request; use Api\PhpUtils\Http\Request;
use Api\PhpUtils\Mon\MonUtil;
use GuzzleHttp\TransferStats;
class Ksyun class Ksyun
{ {
...@@ -41,6 +43,12 @@ class Ksyun ...@@ -41,6 +43,12 @@ class Ksyun
]; ];
$res = (new Request())->post(self::get_down_from_ksyun, $post_data,50, 'json',[],1,true); $res = (new Request())->post(self::get_down_from_ksyun, $post_data,50, 'json',[],1,true);
if(isset($res['response']['code'])){
$code = $res['response']['code'];
}else{
$code = -1;
}
(new MonUtil())::proxyMon(self::get_down_from_ksyun, $code, 'merchant',round((new TransferStats())->getHandlerStat('total_time'),4) * 1000);
if (isset($res['code'],$res['response']['status']) && $res['response']['status'] === 'success') { if (isset($res['code'],$res['response']['status']) && $res['response']['status'] === 'success') {
return $res['response']['data']; return $res['response']['data'];
} }
......
This diff is collapsed.
...@@ -338,7 +338,7 @@ class ClassLoader ...@@ -338,7 +338,7 @@ class ClassLoader
* Loads the given class or interface. * Loads the given class or interface.
* *
* @param string $class The name of the class * @param string $class The name of the class
* @return bool|null True if loaded, null otherwise * @return true|null True if loaded, null otherwise
*/ */
public function loadClass($class) public function loadClass($class)
{ {
...@@ -347,6 +347,8 @@ class ClassLoader ...@@ -347,6 +347,8 @@ class ClassLoader
return true; return true;
} }
return null;
} }
/** /**
......
This diff is collapsed.
...@@ -18,6 +18,7 @@ return array( ...@@ -18,6 +18,7 @@ return array(
'Api\\PhpServices\\Idgen\\Idgen' => $vendorDir . '/api/php_services/src/Idgen/Idgen.php', 'Api\\PhpServices\\Idgen\\Idgen' => $vendorDir . '/api/php_services/src/Idgen/Idgen.php',
'Api\\PhpServices\\Interaction\\InterDynamic' => $vendorDir . '/api/php_services/src/Interaction/InterDynamic.php', 'Api\\PhpServices\\Interaction\\InterDynamic' => $vendorDir . '/api/php_services/src/Interaction/InterDynamic.php',
'Api\\PhpServices\\JwUser\\JwUser' => $vendorDir . '/api/php_services/src/JwUser/JwUser.php', 'Api\\PhpServices\\JwUser\\JwUser' => $vendorDir . '/api/php_services/src/JwUser/JwUser.php',
'Api\\PhpServices\\Ksy\\Ks3Api' => $vendorDir . '/api/php_services/src/Ksy/Ks3Api.php',
'Api\\PhpServices\\Ksy\\Ksyun' => $vendorDir . '/api/php_services/src/Ksy/Ksyun.php', 'Api\\PhpServices\\Ksy\\Ksyun' => $vendorDir . '/api/php_services/src/Ksy/Ksyun.php',
'Api\\PhpServices\\LifeAccount\\Account' => $vendorDir . '/api/php_services/src/LifeAccount/Account.php', 'Api\\PhpServices\\LifeAccount\\Account' => $vendorDir . '/api/php_services/src/LifeAccount/Account.php',
'Api\\PhpServices\\Login\\Login' => $vendorDir . '/api/php_services/src/Login/Login.php', 'Api\\PhpServices\\Login\\Login' => $vendorDir . '/api/php_services/src/Login/Login.php',
...@@ -50,6 +51,7 @@ return array( ...@@ -50,6 +51,7 @@ return array(
'Api\\PhpUtils\\Elastic\\Manager\\DocumentManager' => $vendorDir . '/api/php_utils/src/Elastic/Manager/DocumentManager.php', 'Api\\PhpUtils\\Elastic\\Manager\\DocumentManager' => $vendorDir . '/api/php_utils/src/Elastic/Manager/DocumentManager.php',
'Api\\PhpUtils\\Elastic\\Manager\\IndexManager' => $vendorDir . '/api/php_utils/src/Elastic/Manager/IndexManager.php', 'Api\\PhpUtils\\Elastic\\Manager\\IndexManager' => $vendorDir . '/api/php_utils/src/Elastic/Manager/IndexManager.php',
'Api\\PhpUtils\\Http\\Base' => $vendorDir . '/api/php_utils/src/Http/Base.php', 'Api\\PhpUtils\\Http\\Base' => $vendorDir . '/api/php_utils/src/Http/Base.php',
'Api\\PhpUtils\\Http\\HttpUtil' => $vendorDir . '/api/php_utils/src/Http/HttpUtil.php',
'Api\\PhpUtils\\Http\\Request' => $vendorDir . '/api/php_utils/src/Http/Request.php', 'Api\\PhpUtils\\Http\\Request' => $vendorDir . '/api/php_utils/src/Http/Request.php',
'Api\\PhpUtils\\Hystrix\\ApcuStateStorage' => $vendorDir . '/api/php_utils/src/Hystrix/ApcuStateStorage.php', 'Api\\PhpUtils\\Hystrix\\ApcuStateStorage' => $vendorDir . '/api/php_utils/src/Hystrix/ApcuStateStorage.php',
'Api\\PhpUtils\\Hystrix\\DemoCommand' => $vendorDir . '/api/php_utils/src/Hystrix/DemoCommand.php', 'Api\\PhpUtils\\Hystrix\\DemoCommand' => $vendorDir . '/api/php_utils/src/Hystrix/DemoCommand.php',
......
...@@ -252,6 +252,7 @@ class ComposerStaticInit449f7c51756999ca9c3a3daf8077484c ...@@ -252,6 +252,7 @@ class ComposerStaticInit449f7c51756999ca9c3a3daf8077484c
'Api\\PhpServices\\Idgen\\Idgen' => __DIR__ . '/..' . '/api/php_services/src/Idgen/Idgen.php', 'Api\\PhpServices\\Idgen\\Idgen' => __DIR__ . '/..' . '/api/php_services/src/Idgen/Idgen.php',
'Api\\PhpServices\\Interaction\\InterDynamic' => __DIR__ . '/..' . '/api/php_services/src/Interaction/InterDynamic.php', 'Api\\PhpServices\\Interaction\\InterDynamic' => __DIR__ . '/..' . '/api/php_services/src/Interaction/InterDynamic.php',
'Api\\PhpServices\\JwUser\\JwUser' => __DIR__ . '/..' . '/api/php_services/src/JwUser/JwUser.php', 'Api\\PhpServices\\JwUser\\JwUser' => __DIR__ . '/..' . '/api/php_services/src/JwUser/JwUser.php',
'Api\\PhpServices\\Ksy\\Ks3Api' => __DIR__ . '/..' . '/api/php_services/src/Ksy/Ks3Api.php',
'Api\\PhpServices\\Ksy\\Ksyun' => __DIR__ . '/..' . '/api/php_services/src/Ksy/Ksyun.php', 'Api\\PhpServices\\Ksy\\Ksyun' => __DIR__ . '/..' . '/api/php_services/src/Ksy/Ksyun.php',
'Api\\PhpServices\\LifeAccount\\Account' => __DIR__ . '/..' . '/api/php_services/src/LifeAccount/Account.php', 'Api\\PhpServices\\LifeAccount\\Account' => __DIR__ . '/..' . '/api/php_services/src/LifeAccount/Account.php',
'Api\\PhpServices\\Login\\Login' => __DIR__ . '/..' . '/api/php_services/src/Login/Login.php', 'Api\\PhpServices\\Login\\Login' => __DIR__ . '/..' . '/api/php_services/src/Login/Login.php',
...@@ -284,6 +285,7 @@ class ComposerStaticInit449f7c51756999ca9c3a3daf8077484c ...@@ -284,6 +285,7 @@ class ComposerStaticInit449f7c51756999ca9c3a3daf8077484c
'Api\\PhpUtils\\Elastic\\Manager\\DocumentManager' => __DIR__ . '/..' . '/api/php_utils/src/Elastic/Manager/DocumentManager.php', 'Api\\PhpUtils\\Elastic\\Manager\\DocumentManager' => __DIR__ . '/..' . '/api/php_utils/src/Elastic/Manager/DocumentManager.php',
'Api\\PhpUtils\\Elastic\\Manager\\IndexManager' => __DIR__ . '/..' . '/api/php_utils/src/Elastic/Manager/IndexManager.php', 'Api\\PhpUtils\\Elastic\\Manager\\IndexManager' => __DIR__ . '/..' . '/api/php_utils/src/Elastic/Manager/IndexManager.php',
'Api\\PhpUtils\\Http\\Base' => __DIR__ . '/..' . '/api/php_utils/src/Http/Base.php', 'Api\\PhpUtils\\Http\\Base' => __DIR__ . '/..' . '/api/php_utils/src/Http/Base.php',
'Api\\PhpUtils\\Http\\HttpUtil' => __DIR__ . '/..' . '/api/php_utils/src/Http/HttpUtil.php',
'Api\\PhpUtils\\Http\\Request' => __DIR__ . '/..' . '/api/php_utils/src/Http/Request.php', 'Api\\PhpUtils\\Http\\Request' => __DIR__ . '/..' . '/api/php_utils/src/Http/Request.php',
'Api\\PhpUtils\\Hystrix\\ApcuStateStorage' => __DIR__ . '/..' . '/api/php_utils/src/Hystrix/ApcuStateStorage.php', 'Api\\PhpUtils\\Hystrix\\ApcuStateStorage' => __DIR__ . '/..' . '/api/php_utils/src/Hystrix/ApcuStateStorage.php',
'Api\\PhpUtils\\Hystrix\\DemoCommand' => __DIR__ . '/..' . '/api/php_utils/src/Hystrix/DemoCommand.php', 'Api\\PhpUtils\\Hystrix\\DemoCommand' => __DIR__ . '/..' . '/api/php_utils/src/Hystrix/DemoCommand.php',
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://gitlab.yidian-inc.com/bp/php_services.git", "url": "https://gitlab.yidian-inc.com/bp/php_services.git",
"reference": "58888c4a083e384080d78606f362809a89b8c672" "reference": "e68700976b8cca3ecf4de5bfdb8c0df1276a25bd"
}, },
"require": { "require": {
"api/php_utils": "dev-master", "api/php_utils": "dev-master",
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
"perftools/php-profiler": "^0.18.0", "perftools/php-profiler": "^0.18.0",
"php": "7.2.*" "php": "7.2.*"
}, },
"time": "2021-07-09T13:44:16+00:00", "time": "2021-07-14T13:59:01+00:00",
"default-branch": true, "default-branch": true,
"type": "library", "type": "library",
"installation-source": "source", "installation-source": "source",
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://gitlab.yidian-inc.com/bp/php_utils.git", "url": "https://gitlab.yidian-inc.com/bp/php_utils.git",
"reference": "6495e3a31134e644072208c19610924912f4683a" "reference": "3c343d9deec02d60db43c034d1c5916b024eed3a"
}, },
"require": { "require": {
"elasticsearch/elasticsearch": "~7.0", "elasticsearch/elasticsearch": "~7.0",
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
"mongodb/mongodb": "1.4.3", "mongodb/mongodb": "1.4.3",
"php": "7.2.*" "php": "7.2.*"
}, },
"time": "2021-07-10T12:30:06+00:00", "time": "2021-07-14T12:48:42+00:00",
"default-branch": true, "default-branch": true,
"type": "library", "type": "library",
"installation-source": "source", "installation-source": "source",
...@@ -1282,12 +1282,12 @@ ...@@ -1282,12 +1282,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git", "url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "36b691b0bdbc963fb610da193a48b4c009d03a62" "reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/36b691b0bdbc963fb610da193a48b4c009d03a62", "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/6f981ee24cf69ee7ce9736146d1c57c2780598a8",
"reference": "36b691b0bdbc963fb610da193a48b4c009d03a62", "reference": "6f981ee24cf69ee7ce9736146d1c57c2780598a8",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
...@@ -1299,7 +1299,7 @@ ...@@ -1299,7 +1299,7 @@
"require": { "require": {
"php": ">=7.1" "php": ">=7.1"
}, },
"time": "2021-06-09T13:36:38+00:00", "time": "2021-07-12T14:48:14+00:00",
"default-branch": true, "default-branch": true,
"type": "library", "type": "library",
"extra": { "extra": {
...@@ -1890,12 +1890,12 @@ ...@@ -1890,12 +1890,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-php80.git", "url": "https://github.com/symfony/polyfill-php80.git",
"reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0" "reference": "19d03c391c6abb6791f5f757fb36e551bffeaa68"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/eca0bf41ed421bed1b57c4958bab16aa86b757d0", "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/19d03c391c6abb6791f5f757fb36e551bffeaa68",
"reference": "eca0bf41ed421bed1b57c4958bab16aa86b757d0", "reference": "19d03c391c6abb6791f5f757fb36e551bffeaa68",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
...@@ -1907,7 +1907,7 @@ ...@@ -1907,7 +1907,7 @@
"require": { "require": {
"php": ">=7.1" "php": ">=7.1"
}, },
"time": "2021-02-19T12:13:01+00:00", "time": "2021-07-13T14:34:27+00:00",
"default-branch": true, "default-branch": true,
"type": "library", "type": "library",
"extra": { "extra": {
...@@ -1958,7 +1958,7 @@ ...@@ -1958,7 +1958,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-php80/tree/v1.23.0" "source": "https://github.com/symfony/polyfill-php80/tree/main"
}, },
"funding": [ "funding": [
{ {
......
This diff is collapsed.
...@@ -16,7 +16,7 @@ This component provides features added to PHP 8.0 core: ...@@ -16,7 +16,7 @@ This component provides features added to PHP 8.0 core:
- [`get_resource_id`](https://php.net/get_resource_id) - [`get_resource_id`](https://php.net/get_resource_id)
More information can be found in the More information can be found in the
[main Polyfill README](https://github.com/symfony/polyfill/blob/master/README.md). [main Polyfill README](https://github.com/symfony/polyfill/blob/main/README.md).
License License
======= =======
......
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