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
c3486a12
Commit
c3486a12
authored
Oct 23, 2018
by
王召彬
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://139.199.22.180/tencent/services
parents
106a74d1
bcec4cfd
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
131 additions
and
42 deletions
+131
-42
src/Commands/ClassTemplate/Dao/ClassTemplate
+19
-8
src/Commands/GenerateCommand
+61
-8
src/Common/Lib/Smscode.php
+9
-4
src/Notice/Enum/NoticeRecordEnum.php
+19
-0
src/Notice/Enum/RedisKeyEnum.php
+6
-0
src/Notice/Extensions/Notice/TencentSMS.php
+7
-3
src/Notice/Extensions/NoticeExtension.php
+2
-2
src/Notice/Lib/NoticeInterface.php
+5
-4
src/Reservation/Lib/ReservationInterface.php
+0
-10
src/Store/Lib/SubStoreInterface.php
+3
-3
No files found.
src/Commands/ClassTemplate/Dao/ClassTemplate
View file @
c3486a12
...
...
@@ -12,10 +12,10 @@ use Hdll\Services\Common\Exception\CommonException;
/**
* @Bean()
* Class {
class
Name}
* Class {
dao
Name}
* @package App\Models\Dao
*/
class {
class
Name}
class {
dao
Name}
{
public function create(array $info) : {entityName}
...
...
@@ -29,14 +29,14 @@ class {className}
return ${varEntityName};
}
public function selectInfoByCondition(
$condition, $field
)
public function selectInfoByCondition(
array $condition, array $option
)
{
return {entityName}::findAll($condition,
['fields' => $field]
)->getResult();
return {entityName}::findAll($condition,
$option
)->getResult();
}
public function getInfoByCondition(
$condition, $field
)
public function getInfoByCondition(
array $condition, array $option
)
{
return {entityName}::findOne($condition,
['fields' => $field]
)->getResult();
return {entityName}::findOne($condition,
$option
)->getResult();
}
/**
...
...
@@ -45,7 +45,7 @@ class {className}
* @param $updateInfo
* @return mixed
*/
public function updateByCondition(
$condition,
$updateInfo)
public function updateByCondition(
array $condition, array
$updateInfo)
{
return {entityName}::updateAll($updateInfo, $condition)->getResult();
}
...
...
@@ -57,9 +57,19 @@ class {className}
* @param $updateInfo
* @return mixed
*/
public function updateOne(
$condition,
$updateInfo)
public function updateOne(
array $condition, array
$updateInfo)
{
return {entityName}::updateOne($updateInfo, $condition)->getResult();
}
public function delOne(array $condition)
{
return {entityName}::deleteOne($condition)->getResult();
}
public function delAll(array $condition)
{
return {entityName}::deleteAll($condition)->getResult();
}
}
\ No newline at end of file
src/Commands/GenerateCommand
View file @
c3486a12
...
...
@@ -30,7 +30,7 @@ class GenerateCommand
*
* @Options
* -n,--n the dao name
* -e
,--e
the entity name
* -e
n,--en
the entity name
*
* @Example
* php swoft generate:dao -e entityName [-n daoName]
...
...
@@ -83,9 +83,23 @@ class GenerateCommand
$dataPath = $appPath.'/Models/Data/'.$dataName.'.php';
$templatePath = $appPath.'/Commands/Common/ClassTemplate/Data/ClassTemplate';
$content = file_get_contents($templatePath);
$content = str_replace('{dataName}', $dataName, $content);
$content = str_replace("{daoName}", $daoName, $content);
$content = str_replace("{varDaoName}", lcfirst($daoName), $content);
preg_match_all('/(?<={)\w+(?=})/', $content, $vars);
$vars = isset($vars[0])?$vars[0]:[];
foreach ( $vars as $var ) {
if ( strpos($var, 'var') !== false ) {
$name = str_replace('var', '', $var);
$name = lcfirst($name);
$$var = lcfirst($$name);
var_dump($var, $$var);
}
$content = str_replace("{{$var}}", $$var,$content);
}
$dataPath = file_exists($dataPath)?$dataPath.'.gen':$dataPath;
file_put_contents($dataPath, $content);
...
...
@@ -98,7 +112,7 @@ class GenerateCommand
private function generateDao($output,$daoName, $entityName)
{
if ( empty($entityName) ) {
$output->writeln("the en
option
is required", true, true);
$output->writeln("the en
tity name
is required", true, true);
}
$daoName = empty($daoName)?$entityName.'Dao':$daoName;
...
...
@@ -109,12 +123,50 @@ class GenerateCommand
$content = file_get_contents($templatePath);
$content = str_replace("{className}", $daoName,$content);
preg_match_all('/(?<={)\w+(?=})/', $content, $vars);
$vars = isset($vars[0])?$vars[0]:[];
foreach ( $vars as $var ) {
if ( strpos($var, 'var') !== false ) {
$name = str_replace('var', '', $var);
$name = lcfirst($name);
$$var = lcfirst($$name);
var_dump($var, $$var);
}
$content = str_replace("{entityName}", $entityName, $content);
$content = str_replace("{varEntityName}", lcfirst($entityName), $content);
$content = str_replace("{{$var}}", $$var,$content);
}
$daoPath = file_exists($daoPath)?$daoPath.'.gen':$daoPath;
file_put_contents($daoPath,$content);
}
/**
* 解析模板中变量
*
* @param string $content
* @return string
*/
private function parseVar(string $content):string
{
preg_match_all('/(?<={)\w+(?=})/', $content, $vars);
$vars = isset($vars[0])?$vars[0]:[];
foreach ( $vars as $var ) {
if ( strpos($var, 'var') !== false ) {
$name = str_replace('var', '', $var);
$name = lcfirst($name);
$$var = lcfirst($$name);
var_dump($var, $$var);
}
$content = str_replace("{{$var}}", $$var,$content);
}
return $content;
}
}
\ No newline at end of file
src/Common/Lib/Smscode.php
View file @
c3486a12
...
...
@@ -21,11 +21,15 @@ use Hdll\Services\Common\Entity\User;
class
Smscode
{
protected
$
sellerId
;
protected
$
number
;
public
function
__construct
()
public
function
__construct
(
$number
=
null
)
{
$this
->
sellerId
=
App
::
getBean
(
User
::
class
)
->
getId
();
if
(
$number
!==
null
)
{
$this
->
number
=
$number
;
}
else
{
$this
->
number
=
App
::
getBean
(
User
::
class
)
->
getId
();
}
}
/**
...
...
@@ -93,7 +97,7 @@ class Smscode
private
function
getKey
(
$mobile
)
{
return
'smscode:'
.
md5
(
$this
->
sellerId
.
'|'
.
$mobile
);
return
'smscode:'
.
md5
(
$this
->
number
.
'|'
.
$mobile
);
}
}
\ No newline at end of file
src/Notice/Enum/NoticeRecordEnum.php
0 → 100644
View file @
c3486a12
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/22
* Time: 14:11
*/
namespace
Hdll\Services\Notice\Enum
;
class
NoticeRecordEnum
{
const
TYPE_TENCENT_SMS
=
1
;
const
STATE_SUCCESS
=
1
;
const
STATE_FAIL
=
2
;
}
\ No newline at end of file
src/Notice/Enum/RedisKeyEnum.php
View file @
c3486a12
...
...
@@ -13,4 +13,9 @@ class RedisKeyEnum
const
ORDER_RESERVATION
=
self
::
PREFIX
.
"order_reservation_"
;
const
ORDER_RESERVATION_NOTICE
=
self
::
PREFIX
.
"order_reservation_notice_"
;
}
\ No newline at end of file
src/Notice/Extensions/Notice/TencentSMS.php
View file @
c3486a12
...
...
@@ -21,20 +21,24 @@ class TencentSMS implements SenderInterface
private
$param
;
public
function
__construct
(
string
$phone
,
string
$template
,
array
$param
)
private
$storeId
;
public
function
__construct
(
string
$phone
,
string
$template
,
array
$param
,
int
$storeId
)
{
$this
->
phone
=
$phone
;
$this
->
template
=
$template
;
$this
->
param
=
$param
;
$this
->
storeId
=
$storeId
;
}
public
function
format
()
{
$this
->
data
[
$this
->
sendType
]
=
[
[
'templateId'
=>
$this
->
template
,
'storeId'
=>
$this
->
storeId
,
'templateId'
=>
$this
->
template
,
'phoneNumber'
=>
$this
->
phone
,
'param'
=>
$this
->
param
,
'param'
=>
$this
->
param
,
]
];
...
...
src/Notice/Extensions/NoticeExtension.php
View file @
c3486a12
...
...
@@ -22,11 +22,11 @@ class NoticeExtension
/**
* 发送消息通知
*
* @param
int
$sendTime
* @param $sendTime
* @param mixed ...$senders
* @return bool|mixed
*/
public
function
send
(
int
$sendTime
,
...
$senders
)
public
function
send
(
$sendTime
,
...
$senders
)
{
$data
=
[];
...
...
src/Notice/Lib/NoticeInterface.php
View file @
c3486a12
...
...
@@ -15,8 +15,8 @@ use Swoft\Core\ResultInterface;
/**
* The interface of demo service
*
* @method ResultInterface deferSend(int $storeId, array $sendTypes, array $data,
int
$sendTime, string $redisKey) :bool
* @method ResultInterface deferCancelSend(
int $storeId, array $sendTypes, array $data, int $sendTime, string $redisKey)
:bool
* @method ResultInterface deferSend(int $storeId, array $sendTypes, array $data, $sendTime, string $redisKey) :bool
* @method ResultInterface deferCancelSend(
string $redisKey)
:bool
*/
interface
NoticeInterface
{
...
...
@@ -50,6 +50,7 @@ interface NoticeInterface
* 短信发送消息数据结构
$data[NoticeEnum::TYPE_TENCENT_SMS] = [
[
'storeId' => 198
"templateId" => "178822", //模板id
"phoneNumber" => "17558430002",
"param" => [ //模板变量名
...
...
@@ -80,11 +81,11 @@ interface NoticeInterface
*
* @param array $sendTypes
* @param array $data
* @param
int $sendTime //发送时间,立即返送填0
* @param
$sendTime //如果需要多个时间段发送则填写时间戳数组例如:[15800000,1580000]
* @param string $redisKey //发送事件的redis key(如果定时发送消息,中途需要取消则需要传入此项)
* @return mixed
*/
public
function
send
(
array
$sendTypes
,
array
$data
,
int
$sendTime
,
string
$redisKey
=
''
)
:
bool
;
public
function
send
(
array
$sendTypes
,
array
$data
,
$sendTime
,
string
$redisKey
=
''
)
:
bool
;
/**
...
...
src/Reservation/Lib/ReservationInterface.php
View file @
c3486a12
...
...
@@ -22,7 +22,6 @@ use Swoft\Core\ResultInterface;
* @method ResultInterface deferModifyReservById(int $storeId, int $id, array $data)
* @method ResultInterface defermarkReservFinished(int $storeId, int $orderId)
* @method ResultInterface deferAddReservation(int $storeId, int $orderId, int $buyerId, int $cmanId, int $reservTime, string $memo, int $type)
* @method ResultInterface deferCancelReservById(int $storeId, int $id)
* @method ResultInterface deferCancelReservByOrderId(int $storeId, int $orderId, string $memo)
*/
interface
ReservationInterface
...
...
@@ -97,15 +96,6 @@ interface ReservationInterface
public
function
addReservation
(
int
$storeId
,
int
$orderId
,
int
$buyerId
,
int
$cmanId
,
int
$reservTime
,
string
$memo
,
int
$type
);
/**
* 取消某个预约
*
* @param integer $storeId
* @param integer $id
* @return boolean 返回取消结果
*/
public
function
cancelReservById
(
int
$storeId
,
int
$id
);
/**
* 根据订单id取消该订单下的所有预约
*
* @param integer $storeId
...
...
src/Store/Lib/SubStoreInterface.php
View file @
c3486a12
...
...
@@ -34,10 +34,10 @@ interface SubStoreInterface
* 获取storeId获取所有子店铺列表
*
* @param int $storeId
* @param int $state 子店铺状态筛选,
0表示正常,1表示关闭,1
0表示列出所有
* @param int $state 子店铺状态筛选,
1表示正常,2表示关闭,
0表示列出所有
* @return array
*/
public
function
getSubStoreList
(
int
$storeId
,
int
$state
=
0
);
public
function
getSubStoreList
(
int
$storeId
,
int
$state
=
1
);
/**
* 修改子店铺信息
...
...
@@ -48,7 +48,7 @@ interface SubStoreInterface
* $data字段说明:
* subStoreName // 门店名称
* mobile // 门店联系手机
* state //
0表示正常状态,1
关闭状态
* state //
1表示正常状态,2
关闭状态
* storeAddr // 店铺地址
* lntLat // 店铺坐标
* storeHours // 营业时间
...
...
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