Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pay
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
pay
Commits
4e36f12b
Commit
4e36f12b
authored
Jul 30, 2021
by
万继龙
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into 'master'
Develop See merge request bp/pay!36
parents
b3249df5
2f4a19b3
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
157 additions
and
73 deletions
+157
-73
PayService.php
application/services/pay/PayService.php
+0
-3
.gitignore
vendor/api/php_services/.gitignore
+5
-0
Ks3Api.php
vendor/api/php_services/src/Ksy/Ks3Api.php
+8
-4
GetImage.php
vendor/api/php_services/src/ShopImage/GetImage.php
+12
-7
Msg.php
vendor/api/php_services/src/Wechat/Msg.php
+12
-12
.gitignore
vendor/api/php_utils/.gitignore
+5
-0
GoodsSkuId.php
vendor/api/php_utils/src/Common/GoodsSkuId.php
+4
-2
Rsa.php
vendor/api/php_utils/src/Common/Rsa.php
+58
-0
HttpUtil.php
vendor/api/php_utils/src/Http/HttpUtil.php
+5
-0
MysqlClusterBase.php
vendor/api/php_utils/src/Mysql/MysqlClusterBase.php
+29
-20
installed.json
vendor/composer/installed.json
+11
-17
installed.php
vendor/composer/installed.php
+5
-5
bootstrap.php
vendor/symfony/polyfill-php80/bootstrap.php
+3
-3
No files found.
application/services/pay/PayService.php
View file @
4e36f12b
...
@@ -275,9 +275,6 @@ class PayService
...
@@ -275,9 +275,6 @@ class PayService
;
;
}
}
return
[
'pay_order_id'
=>
$pay_order_id
];
return
[
'pay_order_id'
=>
$pay_order_id
];
}
}
...
...
vendor/api/php_services/.gitignore
0 → 100644
View file @
4e36f12b
composer.lock
/vendor/
.idea
.DS_Store
.project
\ No newline at end of file
vendor/api/php_services/src/Ksy/Ks3Api.php
View file @
4e36f12b
...
@@ -53,7 +53,8 @@ class Ks3Api
...
@@ -53,7 +53,8 @@ class Ks3Api
$genRes
=
HttpUtil
::
post
(
$url
,
$params
);
$genRes
=
HttpUtil
::
post
(
$url
,
$params
);
$end
=
microtime
(
true
);
$end
=
microtime
(
true
);
$totalTime
=
round
((
$end
-
$begin
),
4
)
*
1000
;
$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
;
return
$genRes
;
}
}
...
@@ -90,7 +91,8 @@ class Ks3Api
...
@@ -90,7 +91,8 @@ class Ks3Api
$signatureRes
=
HttpUtil
::
post
(
$url
,
$params
);
$signatureRes
=
HttpUtil
::
post
(
$url
,
$params
);
$end
=
microtime
(
true
);
$end
=
microtime
(
true
);
$totalTime
=
round
((
$end
-
$begin
),
4
)
*
1000
;
$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
;
return
$signatureRes
;
}
}
...
@@ -130,7 +132,8 @@ class Ks3Api
...
@@ -130,7 +132,8 @@ class Ks3Api
$encryptRes
=
HttpUtil
::
post
(
$url
,
$params
);
$encryptRes
=
HttpUtil
::
post
(
$url
,
$params
);
$end
=
microtime
(
true
);
$end
=
microtime
(
true
);
$totalTime
=
round
((
$end
-
$begin
),
4
)
*
1000
;
$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
;
return
$encryptRes
;
}
}
...
@@ -163,7 +166,8 @@ class Ks3Api
...
@@ -163,7 +166,8 @@ class Ks3Api
$uploadRes
=
HttpUtil
::
post
(
$url
,
$params
);
$uploadRes
=
HttpUtil
::
post
(
$url
,
$params
);
$end
=
microtime
(
true
);
$end
=
microtime
(
true
);
$totalTime
=
round
((
$end
-
$begin
),
4
)
*
1000
;
$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
;
return
$uploadRes
;
}
}
...
...
vendor/api/php_services/src/ShopImage/GetImage.php
View file @
4e36f12b
...
@@ -172,18 +172,23 @@ class GetImage
...
@@ -172,18 +172,23 @@ class GetImage
imagecopyresized
(
$im
,
$goods_im
,
47
,
173
,
0
,
0
,
$goods_size
,
$goods_size
,
$goods_size
,
$goods_size
);
imagecopyresized
(
$im
,
$goods_im
,
47
,
173
,
0
,
0
,
$goods_size
,
$goods_size
,
$goods_size
,
$goods_size
);
// 底部二维码
// 底部二维码
$qr
=
new
QR
(
$qr_string
);
//$qr = new QR($qr_string);
$qr_size
=
100
;
$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
->
setSize
(
$qr_size
);
$qr
->
setRoundBlockSize
(
QrCode
::
ROUND_BLOCK_SIZE_MODE_MARGIN
);
$qr
_string
=
$qr
->
writeString
(
);
$qr_string
=
$qr
->
get
();
//
$qr_string = $qr->get();
$qr_img
=
imagecreatefromstring
(
$qr_string
);
$qr_img
=
imagecreatefromstring
(
$qr_string
);
list
(
$qr_w
,
$qr_h
)
=
getimagesizefromstring
(
$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
,
1
95
,
1160
,
333333
,
$this
->
font_m
,
"长按扫码快速抢券"
);
imagettftext
(
$im
,
21
,
0
,
2
95
,
1160
,
333333
,
$this
->
font_m
,
"长按扫码快速抢券"
);
imagettftext
(
$im
,
16
,
0
,
1
95
,
1200
,
666666
,
$this
->
font_r
,
"分享自 生活圈APP"
);
imagettftext
(
$im
,
16
,
0
,
2
95
,
1200
,
666666
,
$this
->
font_r
,
"分享自 生活圈APP"
);
// 底部logo
// 底部logo
$logo_path
=
__DIR__
.
'/images/3_logo.png'
;
$logo_path
=
__DIR__
.
'/images/3_logo.png'
;
...
...
vendor/api/php_services/src/Wechat/Msg.php
View file @
4e36f12b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
namespace
Api\PhpServices\Wechat
;
namespace
Api\PhpServices\Wechat
;
use
Api\PhpUtils\Common\TimeOut
;
use
Api\PhpUtils\Http\Request
;
use
Api\PhpUtils\Http\HttpUtil
;
use
Api\PhpUtils\Http\HttpUtil
;
use
App\Exception\custom\CodeSpecialException
;
use
App\Exception\custom\CodeSpecialException
;
...
@@ -11,34 +9,36 @@ class Msg
...
@@ -11,34 +9,36 @@ class Msg
{
{
/**
/**
* 发送微信模版消息
* 发送微信模版消息
*
* @param $user_id 简网用户id
* @param $mobile 手机号
* @param $app_id 微信公众号或者小程序appid
* @param $template 短信模版
* @param $template_id 模版id
* @param $page_url 跳转页面
* @param $type 公众号或者小程序
* @param $param = [] 数组,多个参数传值
* @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'
);
$url
=
config
(
'interface'
,
'interaction.index.wechat'
);
if
(
!
$url
)
{
if
(
!
$url
)
{
throw
new
CodeSpecialException
(
"failed"
);
throw
new
CodeSpecialException
(
"failed"
);
}
}
$params
=
[
$params
=
[
'app_id'
=>
$app_id
,
'secret'
=>
$secret
,
'user_id'
=>
$user_id
,
'user_id'
=>
$user_id
,
'app_id'
=>
$app_id
,
'template_id'
=>
$template_id
,
'template_id'
=>
$template_id
,
'page_url'
=>
$page_url
,
'type'
=>
$type
,
'type'
=>
$type
,
'params'
=>
$param
'params'
=>
$param
];
];
$
sms
=
(
new
TimeOut
())
->
runG
et
(
$url
,
$params
);
$
msg
=
HttpUtil
::
g
et
(
$url
,
$params
);
if
(
!
$
sms
)
{
if
(
!
$
msg
)
{
throw
new
CodeSpecialException
(
"timeout"
);
throw
new
CodeSpecialException
(
"timeout"
);
}
}
if
(
!
empty
(
$
sms
)
&&
$sms
[
'code'
]
==
0
)
{
if
(
!
empty
(
$
msg
)
&&
isset
(
$msg
[
'response'
][
'code'
])
&&
$msg
[
'response'
]
[
'code'
]
==
0
)
{
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
$msg
[
'response'
]
;
}
}
}
}
}
}
vendor/api/php_utils/.gitignore
0 → 100644
View file @
4e36f12b
composer.lock
/vendor/
.idea
.DS_Store
.project
\ No newline at end of file
vendor/api/php_utils/src/Common/GoodsSkuId.php
View file @
4e36f12b
...
@@ -11,14 +11,16 @@ class GoodsSkuId
...
@@ -11,14 +11,16 @@ class GoodsSkuId
* category_1_id 一级分类的id,两位,不足两位在十位补零
* category_1_id 一级分类的id,两位,不足两位在十位补零
* category_2_id 二级分类的id,两位,不足三位在百位补零
* category_2_id 二级分类的id,两位,不足三位在百位补零
* spu 商品类型,1虚拟商品,2实体商品
* spu 商品类型,1虚拟商品,2实体商品
* goodsType 1、(默认)第三方商品 2、自营商品
*
*
* @param $id
* @param $id
* @param $category1Id
* @param $category1Id
* @param $category2Id
* @param $category2Id
* @param $spuType
* @param $spuType
* @param $goodsType
* @return string
* @return string
*/
*/
public
static
function
generateGoodSkuId
(
$id
,
$category1Id
,
$category2Id
,
$spuType
)
public
static
function
generateGoodSkuId
(
$id
,
$category1Id
,
$category2Id
,
$spuType
,
$goodsType
=
1
)
{
{
if
(
strlen
(
$category1Id
)
==
1
)
{
if
(
strlen
(
$category1Id
)
==
1
)
{
$category1Id
=
"0"
.
$category1Id
;
$category1Id
=
"0"
.
$category1Id
;
...
@@ -26,7 +28,7 @@ class GoodsSkuId
...
@@ -26,7 +28,7 @@ class GoodsSkuId
if
(
strlen
(
$category2Id
)
==
2
)
{
if
(
strlen
(
$category2Id
)
==
2
)
{
$category2Id
=
"0"
.
$category2Id
;
$category2Id
=
"0"
.
$category2Id
;
}
}
$idStr
=
$id
.
$category1Id
.
$category2Id
.
$spuType
;
$idStr
=
$id
.
$category1Id
.
$category2Id
.
$spuType
.
$goodsType
;
//转62进制
//转62进制
$tmp
=
BaseConvert
::
decToOther
(
$idStr
);
$tmp
=
BaseConvert
::
decToOther
(
$idStr
);
...
...
vendor/api/php_utils/src/Common/Rsa.php
View file @
4e36f12b
...
@@ -179,6 +179,56 @@ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUbC5cW6K/XPjfdljTRSP5YtZG
...
@@ -179,6 +179,56 @@ MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDUbC5cW6K/XPjfdljTRSP5YtZG
gHM3r3EWS2bUGHTZZLAd6KGrIP2985c9ODd3s3/JvYmrh/N3djFy3MYhZm5P6iGt
gHM3r3EWS2bUGHTZZLAd6KGrIP2985c9ODd3s3/JvYmrh/N3djFy3MYhZm5P6iGt
kRlCF7Jac58/9V4lDhQiMzjclfpWR6s3aMBEwx5g2gFhjnnlSZRnYofRPqsB1JhB
kRlCF7Jac58/9V4lDhQiMzjclfpWR6s3aMBEwx5g2gFhjnnlSZRnYofRPqsB1JhB
1ZirI2if7kWNBz+BTwIDAQAB
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-----'
;
-----END PUBLIC KEY-----'
;
/**
/**
* TEST SERVER端私钥与客户端公钥
* TEST SERVER端私钥与客户端公钥
...
@@ -235,6 +285,14 @@ mnRjVUtXBgEF0A9xt2QVNMQovtjJ2rkg43gVByDKbOsUqbJYjA12IpALMdECHCMl
...
@@ -235,6 +285,14 @@ mnRjVUtXBgEF0A9xt2QVNMQovtjJ2rkg43gVByDKbOsUqbJYjA12IpALMdECHCMl
'pub_key'
=>
self
::
TEST_MERCHANT_H5_PUBLIC_KEY_STR
,
'pub_key'
=>
self
::
TEST_MERCHANT_H5_PUBLIC_KEY_STR
,
'pri_key'
=>
self
::
TEST_MERCHANT_H5_PRIVATE_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'
=>
[
'test'
=>
[
'pub_key'
=>
self
::
TEST_PUBLIC_KEY_STR
,
'pub_key'
=>
self
::
TEST_PUBLIC_KEY_STR
,
'pri_key'
=>
self
::
TEST_PRIVATE_KEY_STR
,
'pri_key'
=>
self
::
TEST_PRIVATE_KEY_STR
,
...
...
vendor/api/php_utils/src/Http/HttpUtil.php
View file @
4e36f12b
...
@@ -196,6 +196,11 @@ class HttpUtil
...
@@ -196,6 +196,11 @@ class HttpUtil
{
{
$ch
=
curl_init
(
$url
);
$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
)
if
(
is_resource
(
$ch
)
===
true
)
{
{
curl_setopt
(
$ch
,
CURLOPT_FAILONERROR
,
true
);
curl_setopt
(
$ch
,
CURLOPT_FAILONERROR
,
true
);
...
...
vendor/api/php_utils/src/Mysql/MysqlClusterBase.php
View file @
4e36f12b
...
@@ -158,10 +158,7 @@ abstract class MysqlClusterBase
...
@@ -158,10 +158,7 @@ abstract class MysqlClusterBase
}
}
// 读取配置文件内容
// 读取配置文件内容
self
::
$iniConf
=
config
(
'mysql'
,
static
::
CONFIG_INDEX
);
self
::
loadCfg
();
if
(
!
self
::
$iniConf
)
{
throw
new
\Exception
(
'mysql config not exist'
);
}
// 获取库分片索引
// 获取库分片索引
$dbShardingIndex
=
self
::
getDatabaseShardingIndex
();
$dbShardingIndex
=
self
::
getDatabaseShardingIndex
();
...
@@ -256,9 +253,11 @@ abstract class MysqlClusterBase
...
@@ -256,9 +253,11 @@ abstract class MysqlClusterBase
*
*
* @param string $type 读或写类型
* @param string $type 读或写类型
* @return void
* @return void
* @throws \Exception
*/
*/
private
static
function
getDbServerPort
(
$type
,
$dbShardingIndex
)
private
static
function
getDbServerPort
(
$type
,
$dbShardingIndex
)
{
{
self
::
loadCfg
();
$server
=
''
;
$server
=
''
;
$port
=
0
;
$port
=
0
;
$host
=
self
::
$iniConf
[
$type
][
'host'
];
$host
=
self
::
$iniConf
[
$type
][
'host'
];
...
@@ -307,8 +306,12 @@ abstract class MysqlClusterBase
...
@@ -307,8 +306,12 @@ abstract class MysqlClusterBase
* 获取数据库分片数量
* 获取数据库分片数量
*
*
* @return integer
* @return integer
* @throws \Exception
*/
*/
private
static
function
getDbShardingCount
()
{
private
static
function
getDbShardingCount
()
{
self
::
loadCfg
();
$host
=
self
::
$iniConf
[
static
::
WRITE
][
'host'
];
$host
=
self
::
$iniConf
[
static
::
WRITE
][
'host'
];
$hostList
=
explode
(
','
,
$host
);
$hostList
=
explode
(
','
,
$host
);
self
::
$dbShardingCount
=
count
(
$hostList
);
self
::
$dbShardingCount
=
count
(
$hostList
);
...
@@ -393,9 +396,12 @@ abstract class MysqlClusterBase
...
@@ -393,9 +396,12 @@ abstract class MysqlClusterBase
* 获取ini中的option配置,必须用\PDO::ATTR_STRINGIFY_FETCHES对应的int数值
* 获取ini中的option配置,必须用\PDO::ATTR_STRINGIFY_FETCHES对应的int数值
*
*
* @return array
* @return array
* @throws \Exception
*/
*/
public
static
function
getDbOptions
()
public
static
function
getDbOptions
()
{
{
self
::
loadCfg
();
$options
=
[];
$options
=
[];
if
(
isset
(
self
::
$iniConf
[
'options'
]))
{
if
(
isset
(
self
::
$iniConf
[
'options'
]))
{
foreach
(
self
::
$iniConf
[
'options'
]
as
$item
)
{
foreach
(
self
::
$iniConf
[
'options'
]
as
$item
)
{
...
@@ -571,6 +577,21 @@ abstract class MysqlClusterBase
...
@@ -571,6 +577,21 @@ abstract class MysqlClusterBase
return
false
;
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
...
@@ -627,6 +648,7 @@ abstract class MysqlClusterBase
*
*
* @param int $dbShardingColumnValue
* @param int $dbShardingColumnValue
* @return bool
* @return bool
* @throws \Exception
*/
*/
public
static
function
beginTransaction
(
$dbShardingColumnValue
=
0
,
$dbShardingCompatColumnValue
=
0
)
public
static
function
beginTransaction
(
$dbShardingColumnValue
=
0
,
$dbShardingCompatColumnValue
=
0
)
{
{
...
@@ -634,10 +656,7 @@ abstract class MysqlClusterBase
...
@@ -634,10 +656,7 @@ abstract class MysqlClusterBase
self
::
$dbShardingCompatColumnValue
=
$dbShardingCompatColumnValue
;
self
::
$dbShardingCompatColumnValue
=
$dbShardingCompatColumnValue
;
// 读取配置文件内容
// 读取配置文件内容
self
::
$iniConf
=
config
(
'mysql'
,
static
::
CONFIG_INDEX
);
self
::
loadCfg
();
if
(
!
self
::
$iniConf
)
{
throw
new
\Exception
(
'mysql config not exist'
);
}
// 获取库分片索引
// 获取库分片索引
self
::
$transationIndex
=
self
::
getDatabaseShardingIndex
();
self
::
$transationIndex
=
self
::
getDatabaseShardingIndex
();
...
@@ -726,15 +745,10 @@ abstract class MysqlClusterBase
...
@@ -726,15 +745,10 @@ abstract class MysqlClusterBase
* 获取所有分片连接
* 获取所有分片连接
*
*
* @return array
* @return array
* @throws \Exception
*/
*/
public
static
function
getWriteConnectionList
()
public
static
function
getWriteConnectionList
()
{
{
// 读取配置文件内容
self
::
$iniConf
=
config
(
'mysql'
,
static
::
CONFIG_INDEX
);
if
(
!
self
::
$iniConf
)
{
throw
new
\Exception
(
'mysql config not exist'
);
}
// 获取库分片数量
// 获取库分片数量
self
::
getDbShardingCount
();
self
::
getDbShardingCount
();
...
@@ -749,15 +763,10 @@ abstract class MysqlClusterBase
...
@@ -749,15 +763,10 @@ abstract class MysqlClusterBase
* 获取所有分片连接
* 获取所有分片连接
*
*
* @return array
* @return array
* @throws \Exception
*/
*/
public
static
function
getReadConnectionList
()
public
static
function
getReadConnectionList
()
{
{
// 读取配置文件内容
self
::
$iniConf
=
config
(
'mysql'
,
static
::
CONFIG_INDEX
);
if
(
!
self
::
$iniConf
)
{
throw
new
\Exception
(
'mysql config not exist'
);
}
// 获取库分片数量
// 获取库分片数量
self
::
getDbShardingCount
();
self
::
getDbShardingCount
();
...
...
vendor/composer/installed.json
View file @
4e36f12b
...
@@ -6,8 +6,8 @@
...
@@ -6,8 +6,8 @@
"version_normalized"
:
"dev-master"
,
"version_normalized"
:
"dev-master"
,
"source"
:
{
"source"
:
{
"type"
:
"git"
,
"type"
:
"git"
,
"url"
:
"https://git
lab.yidian-inc.com
/bp/php_services.git"
,
"url"
:
"https://git
.yidian-inc.com:8021
/bp/php_services.git"
,
"reference"
:
"
7018d960b3d6c07fcc92a06011ab8973edd928c0
"
"reference"
:
"
2a29f932b1ad8c1d5af3ca94269db3c04f794606
"
},
},
"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-2
7T13:52:48
+00:00"
,
"time"
:
"2021-07-2
9T08:09:54
+00:00"
,
"default-branch"
:
true
,
"default-branch"
:
true
,
"type"
:
"library"
,
"type"
:
"library"
,
"installation-source"
:
"source"
,
"installation-source"
:
"source"
,
...
@@ -33,8 +33,8 @@
...
@@ -33,8 +33,8 @@
"version_normalized"
:
"dev-master"
,
"version_normalized"
:
"dev-master"
,
"source"
:
{
"source"
:
{
"type"
:
"git"
,
"type"
:
"git"
,
"url"
:
"https://git
lab.yidian-inc.com
/bp/php_utils.git"
,
"url"
:
"https://git
.yidian-inc.com:8021
/bp/php_utils.git"
,
"reference"
:
"
9dffcd9a08965d274c92810d2331bfa634d8f85a
"
"reference"
:
"
5409e99a7ab318bc7fe3cf8b8495f13527f8a6c7
"
},
},
"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-2
7T13:46:20
+00:00"
,
"time"
:
"2021-07-2
9T12:03:53
+00:00"
,
"default-branch"
:
true
,
"default-branch"
:
true
,
"type"
:
"library"
,
"type"
:
"library"
,
"installation-source"
:
"source"
,
"installation-source"
:
"source"
,
...
@@ -1877,24 +1877,18 @@
...
@@ -1877,24 +1877,18 @@
"source"
:
{
"source"
:
{
"type"
:
"git"
,
"type"
:
"git"
,
"url"
:
"https://github.com/symfony/polyfill-php80.git"
,
"url"
:
"https://github.com/symfony/polyfill-php80.git"
,
"reference"
:
"1
9d03c391c6abb6791f5f757fb36e551bffeaa68
"
"reference"
:
"1
100343ed1a92e3a38f9ae122fc0eb21602547be
"
},
},
"dist"
:
{
"dist"
:
{
"type"
:
"zip"
,
"type"
:
"zip"
,
"url"
:
"https://api.github.com/repos/symfony/polyfill-php80/zipball/19d03c391c6abb6791f5f757fb36e551bffeaa68"
,
"url"
:
"https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be"
,
"reference"
:
"19d03c391c6abb6791f5f757fb36e551bffeaa68"
,
"reference"
:
"1100343ed1a92e3a38f9ae122fc0eb21602547be"
,
"shasum"
:
""
,
"shasum"
:
""
"mirrors"
:
[
{
"url"
:
"https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%"
,
"preferred"
:
true
}
]
},
},
"require"
:
{
"require"
:
{
"php"
:
">=7.1"
"php"
:
">=7.1"
},
},
"time"
:
"2021-07-
13T14:34:27
+00:00"
,
"time"
:
"2021-07-
28T13:41:28
+00:00"
,
"default-branch"
:
true
,
"default-branch"
:
true
,
"type"
:
"library"
,
"type"
:
"library"
,
"extra"
:
{
"extra"
:
{
...
...
vendor/composer/installed.php
View file @
4e36f12b
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
'type'
=>
'project'
,
'type'
=>
'project'
,
'install_path'
=>
__DIR__
.
'/../../'
,
'install_path'
=>
__DIR__
.
'/../../'
,
'aliases'
=>
array
(),
'aliases'
=>
array
(),
'reference'
=>
'
f6f4dab64859cb2af08951813be34e8e7ba6865d
'
,
'reference'
=>
'
4344b1a08092f0c211fa8f5d43917b561a12a704
'
,
'name'
=>
'bp/pay'
,
'name'
=>
'bp/pay'
,
'dev'
=>
true
,
'dev'
=>
true
,
),
),
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
'aliases'
=>
array
(
'aliases'
=>
array
(
0
=>
'9999999-dev'
,
0
=>
'9999999-dev'
,
),
),
'reference'
=>
'
7018d960b3d6c07fcc92a06011ab8973edd928c0
'
,
'reference'
=>
'
2a29f932b1ad8c1d5af3ca94269db3c04f794606
'
,
'dev_requirement'
=>
false
,
'dev_requirement'
=>
false
,
),
),
'api/php_utils'
=>
array
(
'api/php_utils'
=>
array
(
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
'aliases'
=>
array
(
'aliases'
=>
array
(
0
=>
'9999999-dev'
,
0
=>
'9999999-dev'
,
),
),
'reference'
=>
'
9dffcd9a08965d274c92810d2331bfa634d8f85a
'
,
'reference'
=>
'
5409e99a7ab318bc7fe3cf8b8495f13527f8a6c7
'
,
'dev_requirement'
=>
false
,
'dev_requirement'
=>
false
,
),
),
'bacon/bacon-qr-code'
=>
array
(
'bacon/bacon-qr-code'
=>
array
(
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
'type'
=>
'project'
,
'type'
=>
'project'
,
'install_path'
=>
__DIR__
.
'/../../'
,
'install_path'
=>
__DIR__
.
'/../../'
,
'aliases'
=>
array
(),
'aliases'
=>
array
(),
'reference'
=>
'
f6f4dab64859cb2af08951813be34e8e7ba6865d
'
,
'reference'
=>
'
4344b1a08092f0c211fa8f5d43917b561a12a704
'
,
'dev_requirement'
=>
false
,
'dev_requirement'
=>
false
,
),
),
'dasprid/enum'
=>
array
(
'dasprid/enum'
=>
array
(
...
@@ -300,7 +300,7 @@
...
@@ -300,7 +300,7 @@
'aliases'
=>
array
(
'aliases'
=>
array
(
0
=>
'1.23.x-dev'
,
0
=>
'1.23.x-dev'
,
),
),
'reference'
=>
'1
9d03c391c6abb6791f5f757fb36e551bffeaa68
'
,
'reference'
=>
'1
100343ed1a92e3a38f9ae122fc0eb21602547be
'
,
'dev_requirement'
=>
false
,
'dev_requirement'
=>
false
,
),
),
'symfony/property-access'
=>
array
(
'symfony/property-access'
=>
array
(
...
...
vendor/symfony/polyfill-php80/bootstrap.php
View file @
4e36f12b
...
@@ -26,13 +26,13 @@ if (!function_exists('preg_last_error_msg')) {
...
@@ -26,13 +26,13 @@ if (!function_exists('preg_last_error_msg')) {
function
preg_last_error_msg
()
:
string
{
return
p\Php80
::
preg_last_error_msg
();
}
function
preg_last_error_msg
()
:
string
{
return
p\Php80
::
preg_last_error_msg
();
}
}
}
if
(
!
function_exists
(
'str_contains'
))
{
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'
))
{
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'
))
{
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'
))
{
if
(
!
function_exists
(
'get_debug_type'
))
{
function
get_debug_type
(
$value
)
:
string
{
return
p\Php80
::
get_debug_type
(
$value
);
}
function
get_debug_type
(
$value
)
:
string
{
return
p\Php80
::
get_debug_type
(
$value
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment