Commit 4e36f12b authored by 万继龙's avatar 万继龙

Merge branch 'develop' into 'master'

Develop

See merge request bp/pay!36
parents b3249df5 2f4a19b3
......@@ -275,9 +275,6 @@ class PayService
;
}
return ['pay_order_id' => $pay_order_id];
}
......
composer.lock
/vendor/
.idea
.DS_Store
.project
\ No newline at end of file
......@@ -53,7 +53,8 @@ class Ks3Api
$genRes = HttpUtil::post($url, $params);
$end = microtime(true);
$totalTime = round(($end - $begin), 4) * 1000;
MonUtil::proxyMon($url, $genRes["response"]['code'], 'ks3api', $totalTime);
$resCode = $genRes["response"]['code'] === 0 ? 200 : $genRes["response"]['code'];
MonUtil::proxyMon($url, $resCode, 'ks3api', $totalTime);
return $genRes;
}
......@@ -90,7 +91,8 @@ class Ks3Api
$signatureRes = HttpUtil::post($url, $params);
$end = microtime(true);
$totalTime = round(($end - $begin), 4) * 1000;
MonUtil::proxyMon($url, $signatureRes["response"]['code'], 'ks3api', $totalTime);
$resCode = $signatureRes["response"]['code'] === 0 ? 200 : $signatureRes["response"]['code'];
MonUtil::proxyMon($url, $resCode, 'ks3api', $totalTime);
return $signatureRes;
}
......@@ -130,7 +132,8 @@ class Ks3Api
$encryptRes = HttpUtil::post($url, $params);
$end = microtime(true);
$totalTime = round(($end - $begin), 4) * 1000;
MonUtil::proxyMon($url, $encryptRes["response"]['code'], 'ks3api', $totalTime);
$resCode = $encryptRes["response"]['code'] === 0 ? 200 : $encryptRes["response"]['code'];
MonUtil::proxyMon($url, $resCode, 'ks3api', $totalTime);
return $encryptRes;
}
......@@ -163,7 +166,8 @@ class Ks3Api
$uploadRes = HttpUtil::post($url, $params);
$end = microtime(true);
$totalTime = round(($end - $begin), 4) * 1000;
MonUtil::proxyMon($url, $uploadRes["response"]['code'], 'ks3api', $totalTime);
$resCode = $uploadRes["response"]['code'] === 0 ? 200 : $uploadRes["response"]['code'];
MonUtil::proxyMon($url, $resCode, 'ks3api', $totalTime);
return $uploadRes;
}
......
......@@ -172,18 +172,23 @@ class GetImage
imagecopyresized($im, $goods_im, 47, 173, 0, 0, $goods_size, $goods_size,$goods_size, $goods_size);
// 底部二维码
$qr = new QR($qr_string);
$qr_size = 100;
//$qr = new QR($qr_string);
$qr_size = 170;
// $qr->setSize($qr_size);
// $qr->setRoundBlockSize(QrCode::ROUND_BLOCK_SIZE_MODE_MARGIN);
// $qr_string = $qr->get();
$qr = new QrCode($qr_string);
$qr->setSize($qr_size);
$qr->setRoundBlockSize(QrCode::ROUND_BLOCK_SIZE_MODE_MARGIN);
$qr_string = $qr->get();
$qr_string = $qr->writeString();
//$qr_string = $qr->get();
$qr_img = imagecreatefromstring($qr_string);
list($qr_w,$qr_h) = getimagesizefromstring($qr_string);
imagecopyresized($im, $qr_img, 49, 1102, 0, 0, $qr_size, $qr_size, $qr_size, $qr_size);
imagecopyresized($im, $qr_img, 0, 1065, 0, 0, $qr_size, $qr_size, 190, 190);
// 底部文字
imagettftext($im, 21,0, 195, 1160, 333333 ,$this->font_m, "长按扫码快速抢券");
imagettftext($im, 16,0, 195, 1200, 666666 ,$this->font_r, "分享自 生活圈APP");
imagettftext($im, 21,0, 295, 1160, 333333 ,$this->font_m, "长按扫码快速抢券");
imagettftext($im, 16,0, 295, 1200, 666666 ,$this->font_r, "分享自 生活圈APP");
// 底部logo
$logo_path = __DIR__.'/images/3_logo.png';
......
......@@ -2,8 +2,6 @@
namespace Api\PhpServices\Wechat;
use Api\PhpUtils\Common\TimeOut;
use Api\PhpUtils\Http\Request;
use Api\PhpUtils\Http\HttpUtil;
use App\Exception\custom\CodeSpecialException;
......@@ -11,34 +9,36 @@ class Msg
{
/**
* 发送微信模版消息
*
* @param $mobile 手机号
* @param $template 短信模版
* @param $user_id 简网用户id
* @param $app_id 微信公众号或者小程序appid
* @param $template_id 模版id
* @param $page_url 跳转页面
* @param $type 公众号或者小程序
* @param $param = [] 数组,多个参数传值
*/
public static function send($app_id, $secret, $template_id, $user_id, $type, $param = [])
public static function send($user_id, $app_id, $template_id, $page_url, $type, $param = [])
{
$url = config('interface', 'interaction.index.wechat');
if (!$url) {
throw new CodeSpecialException("failed");
}
$params = [
'app_id' => $app_id,
'secret' => $secret,
'user_id' => $user_id,
'app_id' => $app_id,
'template_id' => $template_id,
'page_url' => $page_url,
'type' => $type,
'params' => $param
];
$sms = (new TimeOut())->runGet($url, $params);
if (!$sms) {
$msg = HttpUtil::get($url, $params);
if (!$msg) {
throw new CodeSpecialException("timeout");
}
if (!empty($sms) && $sms['code'] == 0) {
if (!empty($msg) && isset($msg['response']['code']) && $msg['response']['code'] == 0) {
return true;
} else {
return false;
return $msg['response'];
}
}
}
composer.lock
/vendor/
.idea
.DS_Store
.project
\ No newline at end of file
......@@ -11,14 +11,16 @@ class GoodsSkuId
* category_1_id 一级分类的id,两位,不足两位在十位补零
* category_2_id 二级分类的id,两位,不足三位在百位补零
* spu 商品类型,1虚拟商品,2实体商品
* goodsType 1、(默认)第三方商品 2、自营商品
*
* @param $id
* @param $category1Id
* @param $category2Id
* @param $spuType
* @param $goodsType
* @return string
*/
public static function generateGoodSkuId($id, $category1Id, $category2Id, $spuType)
public static function generateGoodSkuId($id, $category1Id, $category2Id, $spuType, $goodsType = 1)
{
if (strlen($category1Id) == 1) {
$category1Id = "0" . $category1Id;
......@@ -26,7 +28,7 @@ class GoodsSkuId
if (strlen($category2Id) == 2) {
$category2Id = "0" . $category2Id;
}
$idStr = $id . $category1Id . $category2Id . $spuType;
$idStr = $id . $category1Id . $category2Id . $spuType . $goodsType;
//转62进制
$tmp = BaseConvert::decToOther($idStr);
......
......@@ -179,6 +179,56 @@ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUbC5cW6K/XPjfdljTRSP5YtZG
gHM3r3EWS2bUGHTZZLAd6KGrIP2985c9ODd3s3/JvYmrh/N3djFy3MYhZm5P6iGt
kRlCF7Jac58/9V4lDhQiMzjclfpWR6s3aMBEwx5g2gFhjnnlSZRnYofRPqsB1JhB
1ZirI2if7kWNBz+BTwIDAQAB
-----END PUBLIC KEY-----';
/**
* 商户系统拼单小程序 SERVER端私钥与客户端公钥
*/
const MERCHANT_PUB_PIN_PRIVATE_KEY_STR = '-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMq5OJZpmPbfrGAt
JIvPQEEYr0edc4U7LmUArp17tUeknqNfFc0pXuWABIkMTeZuKspDf1ehfYPCVnGs
gWIYvECAdAvMH8TpgNMl6Bc7hjRY89gZUuIx5SK0kw8xJ1z2SlQ4at2PiUnNjYYC
ydyipoHOAXYgpEbcX4OGEF6P6E/nAgMBAAECgYBQsOULScDvExzjs1RGqhnjT1YF
ZXCj6WiQH3Nhj+oaODZExQZCgWMaaphjjJg9TkCN/cvkL41sMqCB4q4lQ786H/8P
flBDGyngi9vjmZBdsmllDNi7kwcAtl8xk7YaHzQuIZ49dOzL/qQggCHokgvbBRXh
NI1AYBm/G8C8H0DE8QJBAOlKL4LQuoOtg49+qpw73snNOkEnFzn6nClud7w/wHR1
I82nmesyadcjVoJA9Lb1/AA9/MXV5RQeZ8Ckn//42SUCQQDedUsl4jtpuLz+QYv4
994ASsGBSGLE3BAPI1YClA8oVDRYMQydbZMgeZ8AspZtnmBifbcoOM/q+VbBomNk
pfUbAkEAkUCMhnG5v6T4hg7C4ZXxaEqs28YgEwxz0OQkDwTOqnQI/9I75pI0DizF
f0I8W/Kanff6e59rC3TG+s5FhNYHNQJBAJtOlCpcqVID8Z4osMoeclUN286gdKQv
Zt7Ksq+WIobrUqgHhmEaMM9JWaKpC7B4E55vWkGweCf574G8F1wbKOUCQHtD5JLr
B/84pKhIkdbhfdTReLbxz3/mRZM+RGFvbXvr5yr5ihcFHtIgHsmrIYbBccJdd42s
kZ5U8STIJSCkBZo=
-----END PRIVATE KEY-----';
const MERCHANT_PUB_PIN_PUBLIC_KEY_STR = '-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDGmANRSw3T4ztQ8ZWMw+cW70Zg
9yOwQV0oWp9Zce8eCLoRgFVFeajeQ1BT59tQ3bR4Qwg/gL8ZKf9JanxNyINQY8th
CKIYerOCxgr0QPKiQCVL7BTZNj7m91OdVmsYfJty1YihM43a5op62T0OJk/4mF2H
Txl13uSJhZgM9szI7wIDAQAB
-----END PUBLIC KEY-----';
/**
* 商户系统拼单小程序-测试 SERVER端私钥与客户端公钥
*/
const TEST_MERCHANT_PUB_PIN_PRIVATE_KEY_STR = '-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAOOfrgheB6r+85+1
97tfjq6+R/FhWg4T+GXOZ5pimMNwf/yOLYbC+HITvHKoEExymf2Um6i6dnJjU7zl
AjmbzK0TSab0exz1tNxnBSE/nt5G06n5f2FOYMAu67iseQ97aGYDGbRWakSjdYTx
jPoKT7dG8cC6RdIW7aJDCceNIeGBAgMBAAECgYByZakIaYF/Dd0Q0lor4E2MQvNT
O7MPyjeXqtFkxNKzvpGEM0xsIwbMBmE6Wn6+fQYpbIuClBu9R3ApSgsBOuz0yBGM
e/DNmAifZn1EFVQRm+Li//poLfl3HE2oj0dJhPRiCyoxeWhP76zxP+v0IXwopZbF
W0jP+ojto8q2zx/75QJBAPxFSQisRdMV1KxbyZzT2clYwRB5Dfqdh2SmaJ6Mms+o
Ua9e6lgD7/K1C+3GCtIkDHSlhnNNMRwIItpCe8r7RZcCQQDm/R5it0UvpWZzYCEn
iXMvavwp3+PCTftpxS9/CWrWQCk5C4wW7l5j+Be6f0e4cboOr6kaiPXkF8qn/SF6
S+SnAkBNs6GNNFLFc6Hv/M2aqn4YUGgXBNJTcRX04HS08SX19ChE1f1kYsIThcRI
1okatNPJUfqZpRsNQUxK4dNzb/W9AkBJ+S3N91tU0udoc5SqkL4upVh0IJtUEp09
VkTLrjxkuM960VPf1B6ubTlMJI7XZrRrF55UPSBiF6xy+AHMpJlpAkEAhNVjlx+x
9qDJ23tHTDFxN0dl2IK+Xz3j9HDNvb5SdO+pcIvQvVg9UUc5xnkXmVm35RwqeA6O
2P6ROLCijjotzw==
-----END PRIVATE KEY-----';
const TEST_MERCHANT_PUB_PIN_PUBLIC_KEY_STR = '-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCFOU3D4aULZuJ3IyRGmPhwn5g
zIcDvT2EEZMJ+ePgi0Oax/P3z25m5758okGs1lrS93vDWO7lbsgQn5mnuKuqmuj6
M3BP/vOildi+3oTZcjQTV2deebIrhW4p96DvTqQ7ixVAEi4of3XoITA00J8hfNy9
jDprGYGJ5yeTuRRHlQIDAQAB
-----END PUBLIC KEY-----';
/**
* TEST SERVER端私钥与客户端公钥
......@@ -235,6 +285,14 @@ mnRjVUtXBgEF0A9xt2QVNMQovtjJ2rkg43gVByDKbOsUqbJYjA12IpALMdECHCMl
'pub_key' => self::TEST_MERCHANT_H5_PUBLIC_KEY_STR,
'pri_key' => self::TEST_MERCHANT_H5_PRIVATE_KEY_STR,
],
'merchant-pub-pin' => [
'pub_key' => self::MERCHANT_PUB_PIN_PUBLIC_KEY_STR,
'pri_key' => self::MERCHANT_PUB_PIN_PRIVATE_KEY_STR,
],
'test-merchant-pub-pin' => [
'pub_key' => self::TEST_MERCHANT_PUB_PIN_PUBLIC_KEY_STR,
'pri_key' => self::TEST_MERCHANT_PUB_PIN_PRIVATE_KEY_STR,
],
'test' => [
'pub_key' => self::TEST_PUBLIC_KEY_STR,
'pri_key' => self::TEST_PRIVATE_KEY_STR,
......
......@@ -196,6 +196,11 @@ class HttpUtil
{
$ch = curl_init($url);
// CURLOPT_POSTFIELDS 不支持多维数组
if (is_array($post) && count($post) != count($post, COUNT_RECURSIVE)) {
$post = http_build_query($post);
}
if (is_resource($ch) === true)
{
curl_setopt($ch, CURLOPT_FAILONERROR, true);
......
......@@ -158,10 +158,7 @@ abstract class MysqlClusterBase
}
// 读取配置文件内容
self::$iniConf = config('mysql', static::CONFIG_INDEX);
if (!self::$iniConf) {
throw new \Exception('mysql config not exist');
}
self::loadCfg();
// 获取库分片索引
$dbShardingIndex = self::getDatabaseShardingIndex();
......@@ -256,9 +253,11 @@ abstract class MysqlClusterBase
*
* @param string $type 读或写类型
* @return void
* @throws \Exception
*/
private static function getDbServerPort($type, $dbShardingIndex)
{
self::loadCfg();
$server = '';
$port = 0;
$host = self::$iniConf[$type]['host'];
......@@ -307,8 +306,12 @@ abstract class MysqlClusterBase
* 获取数据库分片数量
*
* @return integer
* @throws \Exception
*/
private static function getDbShardingCount() {
self::loadCfg();
$host = self::$iniConf[static::WRITE]['host'];
$hostList = explode(',', $host);
self::$dbShardingCount = count($hostList);
......@@ -393,9 +396,12 @@ abstract class MysqlClusterBase
* 获取ini中的option配置,必须用\PDO::ATTR_STRINGIFY_FETCHES对应的int数值
*
* @return array
* @throws \Exception
*/
public static function getDbOptions()
{
self::loadCfg();
$options = [];
if (isset(self::$iniConf['options'])) {
foreach (self::$iniConf['options'] as $item) {
......@@ -571,6 +577,21 @@ abstract class MysqlClusterBase
return false;
}
/**
* @param bool $flush
* @throws \Exception
* 加载配置文件,支持强更新
*/
private static function loadCfg($flush = false) {
if($flush || empty(self::$iniConf)) {
//重新加载 ini
self::$iniConf = config('mysql', static::CONFIG_INDEX);
if (!self::$iniConf) {
throw new \Exception('mysql yaconf ini config not exist');
}
}
}
/**
* 格式化返回结果
*
......@@ -627,6 +648,7 @@ abstract class MysqlClusterBase
*
* @param int $dbShardingColumnValue
* @return bool
* @throws \Exception
*/
public static function beginTransaction($dbShardingColumnValue = 0, $dbShardingCompatColumnValue = 0)
{
......@@ -634,10 +656,7 @@ abstract class MysqlClusterBase
self::$dbShardingCompatColumnValue = $dbShardingCompatColumnValue;
// 读取配置文件内容
self::$iniConf = config('mysql', static::CONFIG_INDEX);
if (!self::$iniConf) {
throw new \Exception('mysql config not exist');
}
self::loadCfg();
// 获取库分片索引
self::$transationIndex = self::getDatabaseShardingIndex();
......@@ -726,15 +745,10 @@ abstract class MysqlClusterBase
* 获取所有分片连接
*
* @return array
* @throws \Exception
*/
public static function getWriteConnectionList()
{
// 读取配置文件内容
self::$iniConf = config('mysql', static::CONFIG_INDEX);
if (!self::$iniConf) {
throw new \Exception('mysql config not exist');
}
// 获取库分片数量
self::getDbShardingCount();
......@@ -749,15 +763,10 @@ abstract class MysqlClusterBase
* 获取所有分片连接
*
* @return array
* @throws \Exception
*/
public static function getReadConnectionList()
{
// 读取配置文件内容
self::$iniConf = config('mysql', static::CONFIG_INDEX);
if (!self::$iniConf) {
throw new \Exception('mysql config not exist');
}
// 获取库分片数量
self::getDbShardingCount();
......
......@@ -6,8 +6,8 @@
"version_normalized": "dev-master",
"source": {
"type": "git",
"url": "https://gitlab.yidian-inc.com/bp/php_services.git",
"reference": "7018d960b3d6c07fcc92a06011ab8973edd928c0"
"url": "https://git.yidian-inc.com:8021/bp/php_services.git",
"reference": "2a29f932b1ad8c1d5af3ca94269db3c04f794606"
},
"require": {
"api/php_utils": "dev-master",
......@@ -15,7 +15,7 @@
"perftools/php-profiler": "^0.18.0",
"php": "7.2.*"
},
"time": "2021-07-27T13:52:48+00:00",
"time": "2021-07-29T08:09:54+00:00",
"default-branch": true,
"type": "library",
"installation-source": "source",
......@@ -33,8 +33,8 @@
"version_normalized": "dev-master",
"source": {
"type": "git",
"url": "https://gitlab.yidian-inc.com/bp/php_utils.git",
"reference": "9dffcd9a08965d274c92810d2331bfa634d8f85a"
"url": "https://git.yidian-inc.com:8021/bp/php_utils.git",
"reference": "5409e99a7ab318bc7fe3cf8b8495f13527f8a6c7"
},
"require": {
"elasticsearch/elasticsearch": "~7.0",
......@@ -46,7 +46,7 @@
"mongodb/mongodb": "1.4.3",
"php": "7.2.*"
},
"time": "2021-07-27T13:46:20+00:00",
"time": "2021-07-29T12:03:53+00:00",
"default-branch": true,
"type": "library",
"installation-source": "source",
......@@ -1877,24 +1877,18 @@
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php80.git",
"reference": "19d03c391c6abb6791f5f757fb36e551bffeaa68"
"reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/19d03c391c6abb6791f5f757fb36e551bffeaa68",
"reference": "19d03c391c6abb6791f5f757fb36e551bffeaa68",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
"url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be",
"reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"time": "2021-07-13T14:34:27+00:00",
"time": "2021-07-28T13:41:28+00:00",
"default-branch": true,
"type": "library",
"extra": {
......
......@@ -5,7 +5,7 @@
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => 'f6f4dab64859cb2af08951813be34e8e7ba6865d',
'reference' => '4344b1a08092f0c211fa8f5d43917b561a12a704',
'name' => 'bp/pay',
'dev' => true,
),
......@@ -18,7 +18,7 @@
'aliases' => array(
0 => '9999999-dev',
),
'reference' => '7018d960b3d6c07fcc92a06011ab8973edd928c0',
'reference' => '2a29f932b1ad8c1d5af3ca94269db3c04f794606',
'dev_requirement' => false,
),
'api/php_utils' => array(
......@@ -29,7 +29,7 @@
'aliases' => array(
0 => '9999999-dev',
),
'reference' => '9dffcd9a08965d274c92810d2331bfa634d8f85a',
'reference' => '5409e99a7ab318bc7fe3cf8b8495f13527f8a6c7',
'dev_requirement' => false,
),
'bacon/bacon-qr-code' => array(
......@@ -47,7 +47,7 @@
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => 'f6f4dab64859cb2af08951813be34e8e7ba6865d',
'reference' => '4344b1a08092f0c211fa8f5d43917b561a12a704',
'dev_requirement' => false,
),
'dasprid/enum' => array(
......@@ -300,7 +300,7 @@
'aliases' => array(
0 => '1.23.x-dev',
),
'reference' => '19d03c391c6abb6791f5f757fb36e551bffeaa68',
'reference' => '1100343ed1a92e3a38f9ae122fc0eb21602547be',
'dev_requirement' => false,
),
'symfony/property-access' => array(
......
......@@ -26,13 +26,13 @@ if (!function_exists('preg_last_error_msg')) {
function preg_last_error_msg(): string { return p\Php80::preg_last_error_msg(); }
}
if (!function_exists('str_contains')) {
function str_contains(string $haystack, string $needle): bool { return p\Php80::str_contains($haystack, $needle); }
function str_contains(?string $haystack, ?string $needle): bool { return p\Php80::str_contains($haystack ?? '', $needle ?? ''); }
}
if (!function_exists('str_starts_with')) {
function str_starts_with(string $haystack, string $needle): bool { return p\Php80::str_starts_with($haystack, $needle); }
function str_starts_with(?string $haystack, ?string $needle): bool { return p\Php80::str_starts_with($haystack ?? '', $needle ?? ''); }
}
if (!function_exists('str_ends_with')) {
function str_ends_with(string $haystack, string $needle): bool { return p\Php80::str_ends_with($haystack, $needle); }
function str_ends_with(?string $haystack, ?string $needle): bool { return p\Php80::str_ends_with($haystack ?? '', $needle ?? ''); }
}
if (!function_exists('get_debug_type')) {
function get_debug_type($value): string { return p\Php80::get_debug_type($value); }
......
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