Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
services
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tencent
services
Commits
2755624a
Commit
2755624a
authored
Feb 25, 2019
by
liwotian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge up
parent
93d398a7
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
130 additions
and
42 deletions
+130
-42
src/Cmq/Topic.php
+29
-5
src/Common/ClsLogger/ClsLog.php
+7
-4
src/Common/Config/CfgCenter.php
+2
-2
src/Common/Config/config.php
+22
-26
src/Common/Lib/Xcrypt.php
+3
-3
src/GroupBooking/Enum/RecordEnum.php
+2
-0
src/Order/Lib/SellerOrderInterface.php
+4
-0
src/Schedule/Lib/ScheduleInterface.php
+10
-0
src/SellerDistribution/Enum/SellerDistributionCmqEnum.php
+2
-0
src/Store/Enum/StoreCmqEnum.php
+11
-0
src/Store/Lib/EntrustedInterface.php
+32
-0
src/Store/Lib/StoreInterface.php
+2
-2
src/Vip/Lib/VipInterface.php
+4
-0
No files found.
src/Cmq/Topic.php
View file @
2755624a
...
...
@@ -2,6 +2,7 @@
namespace
Hdll\Services\Cmq
;
use
Hdll\Services\Common\Config\CfgCenter
;
use
Swoft\App
;
use
Hdll\Services\Common\Lib\Xcrypt
;
...
...
@@ -40,6 +41,7 @@ class Topic
}
$this
->
cmq_client
->
create_topic
(
$params
);
}
/*
* get attributes
*
...
...
@@ -172,6 +174,7 @@ class Topic
return
$retMessageList
;
}
/* 列出Topic的Subscriptoin
@type topic_name :string
...
...
@@ -250,18 +253,39 @@ class Topic
* @return mixed
* @author work
*/
public
function
cryptPushMessage
(
string
$message
,
$vTagList
=
null
,
$routingKey
=
null
){
public
function
cryptPushMessage
(
string
$message
,
$vTagList
=
null
,
$routingKey
=
null
)
{
$cryptMessage
=
Xcrypt
::
encrypt
(
$message
);
$tryTimes
=
0
;
do
{
$res
=
$this
->
publish_message
(
$cryptMessage
,
$vTagList
,
$routingKey
);
do
{
$res
=
$this
->
publish_message
(
$cryptMessage
,
$vTagList
,
$routingKey
);
$tryTimes
++
;
}
while
(
$res
[
'code'
]
!=
0
&&
$tryTimes
<
3
);
}
while
(
$res
[
'code'
]
!=
0
&&
$tryTimes
<
3
);
if
(
$tryTimes
>=
3
)
{
if
(
$tryTimes
>=
3
)
{
App
::
error
(
"[消息队列失败]:
$message
"
);
}
$this
->
TopicLog
(
$message
,
$cryptMessage
,
$vTagList
,
$res
);
return
$res
;
}
protected
function
TopicLog
(
$message
,
$cryptMessage
,
$tagName
,
$response
)
{
$data
=
[
'tagName'
=>
$tagName
,
'topName'
=>
$this
->
topic_name
,
'message'
=>
$message
,
'cryptMessage'
=>
$cryptMessage
,
'createTime'
=>
time
(),
'response'
=>
json_encode
(
$response
),
];
try
{
$db
=
CfgCenter
::
dbConnect
();
$db
->
insert
(
'topic_log'
,
$data
);
}
catch
(
\Exception
$e
){
App
::
error
(
"消息主题日志记录失败:"
.
$e
->
getMessage
()
.
'---'
.
json_encode
(
$data
));
}
}
}
src/Common/ClsLogger/ClsLog.php
View file @
2755624a
...
...
@@ -50,6 +50,7 @@ class ClsLog
private
static
function
uploadToCls
(
$topicId
,
$pbData
)
{
$authorization
=
ClsSignature
::
create
();
$uri
=
'http://ap-beijing.cls.myqcloud.com/structuredlog?topic_id='
.
$topicId
;
for
(
$n
=
0
;
$n
<
3
;
$n
++
){
$res
=
(
new
Client
)
->
post
(
$uri
,
[
'headers'
=>
[
'Host'
=>
'ap-beijing.cls.myqcloud.com'
,
...
...
@@ -57,15 +58,17 @@ class ClsLog
'Content-Type'
=>
'application/x-protobuf'
,
],
'body'
=>
$pbData
,
'timeout'
=>
2
0
,
'timeout'
=>
3
0
,
]);
if
(
$res
->
getResponse
()
->
getStatusCode
()
!=
200
)
{
if
(
$res
->
getResponse
()
->
getStatusCode
()
==
200
)
{
return
true
;
}
Coroutine
::
sleep
(
1
);
}
$msg
=
'上传腾讯云日志服务失败:'
.
$res
->
getResult
();
self
::
writeClsErrors
(
$msg
);
return
false
;
}
return
true
;
}
/**
* 腾讯日志服务上传时产生错误,这种错误需要记录在本地文件
...
...
src/Common/Config/CfgCenter.php
View file @
2755624a
...
...
@@ -54,7 +54,7 @@ class CfgCenter
}
$valObj
=
json_decode
(
$result
[
0
][
'value'
]);
if
(
!
is_object
(
$valObj
))
{
return
;
return
[
$name
,
$result
[
0
][
'value'
]]
;
}
$keys
=
''
;
foreach
(
$keyArr
as
$key
)
{
...
...
@@ -68,7 +68,7 @@ class CfgCenter
return
[
trim
(
$rkey
,
':'
),
$valObj
];
}
p
rotected
static
function
dbConnect
()
p
ublic
static
function
dbConnect
()
{
if
(
\env
(
'ENVIRONMENT'
,
''
)
==
''
)
{
// 返回线上数据库连接
...
...
src/Common/Config/config.php
View file @
2755624a
<?php
return
[
'qCloud'
=>
[
'Bucket'
=>
'hdll-1257143824'
,
'APPID'
=>
'1257143824'
,
'SecretId'
=>
'AKIDseHj18kua0KTSJ4g9SadbVEnEUZVjvPj'
,
'SecretKey'
=>
'IPL5g5PaaSAzd6NSO8gEmLxcN4pTzJSQ'
,
'Region'
=>
'ap-shanghai'
],
'alisms'
=>
[
'accessKeyId'
=>
'EjBn9zQxyEkKHyAA'
,
'accessKeySecret'
=>
'AN276rwCcqCkFUVt1GLCbAy8jnj52t'
,
],
'cls'
=>
[
'appid'
=>
'1257143824 '
,
'secretId'
=>
'AKIDseHj18kua0KTSJ4g9SadbVEnEUZVjvPj'
,
'secretKey'
=>
'IPL5g5PaaSAzd6NSO8gEmLxcN4pTzJSQ'
,
],
'cmq'
=>
[
'intranet_host'
=>
'http://cmq-topic-bj.api.tencentyun.com'
,
//内网
'internet_host'
=>
'https://cmq-topic-bj.api.qcloud.com'
,
//外网
'secretId'
=>
'AKIDYRW1cG2iVIg8dAoCe86vhNuA7A5oNknk'
,
'secretKey'
=>
'z0ymS7xfLrP6Sk2EKHWaXN6d0EIxX0IQ'
,
],
'cryptKey'
=>
'ebf032f01aa2093be3ee2ee2c137hdll'
,
];
\ No newline at end of file
namespace
Hdll\Services\Common\Config
;
use
Swoft\Redis\Redis
;
use
Swoft\App
;
const
CACHE_PREFIX
=
'CONFIG_CACHE:'
;
$redis
=
App
::
getBean
(
Redis
::
class
);
$data
=
$redis
->
get
(
CACHE_PREFIX
.
'all'
);
if
(
empty
(
$data
))
{
$db
=
CfgCenter
::
dbConnect
();
$arr
=
$db
->
select
(
'config'
,
[
'name'
,
'value'
]);
foreach
(
$arr
as
$key
=>
$value
)
{
$v_arr
=
json_decode
(
$value
[
'value'
],
true
);
$data
[
$value
[
'name'
]]
=
empty
(
$v_arr
)
?
$value
[
'value'
]
:
$v_arr
;
}
$redis
->
set
(
CACHE_PREFIX
.
'all'
,
json_encode
(
$data
));
}
else
{
$data
=
json_decode
(
$data
,
true
);
}
return
$data
;
\ No newline at end of file
src/Common/Lib/Xcrypt.php
View file @
2755624a
<?php
namespace
Hdll\Services\Common\Lib
;
use
Hdll\Services\Common\Config\CfgCenter
;
use
Swoft\App
;
use
Swoft\Redis\Redis
;
class
Xcrypt
{
const
CRYPT
=
'crypt'
;
const
CRYPT
=
'crypt
Key
'
;
public
static
function
encrypt
(
string
$str
,
$key
=
''
)
...
...
@@ -41,8 +42,7 @@ class Xcrypt
}
private
static
function
getKey
(){
$redis
=
App
::
getBean
(
Redis
::
class
);
$key
=
$redis
->
get
(
self
::
CRYPT
);
$key
=
CfgCenter
::
get
(
self
::
CRYPT
);
if
(
empty
(
$key
)){
throw
new
\Exception
(
'加密密钥获取失败!'
);
}
...
...
src/GroupBooking/Enum/RecordEnum.php
View file @
2755624a
...
...
@@ -13,4 +13,5 @@ class RecordEnum
const
START_NOT_PAY
=
10
;
//未支付
const
START_PAY
=
20
;
//已支付
const
CLOSED
=
30
;
//已关闭
const
FINISH
=
40
;
//已完成
}
\ No newline at end of file
src/Order/Lib/SellerOrderInterface.php
View file @
2755624a
...
...
@@ -13,6 +13,7 @@ use Swoft\Core\ResultInterface;
* @method ResultInterface deferSellerCreateOrder(int $sellerId,int $storeId,int $itemId,int $selectedNum,int $orderType,float $total,float $goodsPrice,string $goodsName)
* @method ResultInterface deferGetOrderInfoBySn(int $storeId, string $orderSn)
* @method ResultInterface deferUpdateInfoById(int $storeId,int $orderId, array $updateInfo)
* @method ResultInterface deferGetSellerOrderByStoreId(int $storeId, int $itemId)
* Interface SellerOrderInterface
* @package Hdll\Services\Order\Lib
*/
...
...
@@ -36,4 +37,6 @@ interface SellerOrderInterface
public
function
updateInfoById
(
int
$storeId
,
int
$orderId
,
array
$updateInfo
);
public
function
getSellerOrderByStoreId
(
int
$storeId
,
int
$itemId
);
}
\ No newline at end of file
src/Schedule/Lib/ScheduleInterface.php
View file @
2755624a
...
...
@@ -18,6 +18,7 @@ use Swoft\Core\ResultInterface;
*
* @method ResultInterface deferGetScheduleList(int $storeId, int $month, int $cmanId = 0)
* @method ResultInterface deferGetScheduleByDateId(int $storeId, int $dateId, int $cmanId = 0)
* @method ResultInterface deferIsOffday(int $storeId, int $dateId, int $cmanId = 0)
* @method ResultInterface deferUpdateSchedule(int $storeId, int $cmanId, int $dateId, array $data)
* @method ResultInterface deferAddSchedule(int $storeId, int $cmanId, int $dateId, array $data)
*/
...
...
@@ -43,6 +44,15 @@ interface ScheduleInterface
public
function
getScheduleByDateId
(
int
$storeId
,
int
$dateId
,
int
$cmanId
=
0
);
/**
* 判断某天是否是休息日
*
* @param integer $storeId
* @param integer $dateId 要查询的日期id,格式要求如:20180803
* @return bool 如是休息日,返回true
*/
public
function
isOffday
(
int
$storeId
,
int
$dateId
,
int
$cmanId
=
0
);
/**
* 根据dateId修改某个日程的信息
*
* @param integer $storeId
...
...
src/SellerDistribution/Enum/SellerDistributionCmqEnum.php
View file @
2755624a
...
...
@@ -10,4 +10,5 @@ class SellerDistributionCmqEnum{
const
ADD_TOTAL
=
'addTotal'
;
const
REFUND_ADD_BALANCE
=
'refundAddBalance'
;
const
UPDATE_BILL
=
'updateBill'
;
const
SAVE_BILL
=
'saveBill'
;
}
\ No newline at end of file
src/Store/Enum/StoreCmqEnum.php
0 → 100644
View file @
2755624a
<?php
namespace
Hdll\Services\Store\Enum
;
class
StoreCmqEnum
{
const
TOPIC
=
'store'
;
const
ADD_VIP_TIME
=
'addVipTime'
;
}
\ No newline at end of file
src/Store/Lib/EntrustedInterface.php
0 → 100644
View file @
2755624a
<?php
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://doc.swoft.org
* @contact group@swoft.org
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/
namespace
Hdll\Services\Store\Lib
;
use
Swoft\Core\ResultInterface
;
/**
* The interface of store service
*
* @method ResultInterface deferGetEntrustedData(int $storeId, array $fields = [])
*/
interface
EntrustedInterface
{
/**
* 根据店铺id获取对应的托管配置
*
* @param int $storeId
* @param array $fields 字段列表
* @return bool
*/
public
function
getEntrustedData
(
int
$storeId
,
array
$fields
=
[]);
}
\ No newline at end of file
src/Store/Lib/StoreInterface.php
View file @
2755624a
...
...
@@ -19,7 +19,7 @@ use Swoft\Core\ResultInterface;
* @method ResultInterface deferIsNormal(int $storeId)
* @method ResultInterface deferGetStoreByStoreId(int $storeId)
* @method ResultInterface deferGetStoreBySellerId(int $sellerId)
* @method ResultInterface deferGetListBySellerIds(array $sellerIds)
* @method ResultInterface deferGetListBySellerIds(array $sellerIds
, array $fields = []
)
* @method ResultInterface deferGetStoreByMobile(int $mobile, array $fields = [])
* @method ResultInterface deferUpdateStore(int $storeId, array $data)
* @method ResultInterface deferAddVipTime(int $storeId, int $days)
...
...
@@ -69,7 +69,7 @@ interface StoreInterface
* mobile 注册手机号
* edition 是否VIP 2 表示是VIP
*/
public
function
getListBySellerIds
(
array
$sellerIds
);
public
function
getListBySellerIds
(
array
$sellerIds
,
array
$fields
=
[]
);
/**
* 根据注册手机号获取店铺信息
...
...
src/Vip/Lib/VipInterface.php
View file @
2755624a
...
...
@@ -13,6 +13,7 @@ use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferOpenVip($storeId, $orderId, $money)
* @method ResultInterface deferGetVip($vipId)
* @method ResultInterface deferTryVipCountByReferId(int $referId)
* Interface SellerInterface
* @package App\Lib
*/
...
...
@@ -22,4 +23,6 @@ interface VipInterface
public
function
openVip
(
$storeId
,
$orderId
);
public
function
getVip
(
int
$vipId
);
public
function
tryVipCountByReferId
(
int
$referId
);
}
\ No newline at end of file
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