Commit c3486a12 by 王召彬

Merge branch 'master' of http://139.199.22.180/tencent/services

parents 106a74d1 bcec4cfd
...@@ -12,10 +12,10 @@ use Hdll\Services\Common\Exception\CommonException; ...@@ -12,10 +12,10 @@ use Hdll\Services\Common\Exception\CommonException;
/** /**
* @Bean() * @Bean()
* Class {className} * Class {daoName}
* @package App\Models\Dao * @package App\Models\Dao
*/ */
class {className} class {daoName}
{ {
public function create(array $info) : {entityName} public function create(array $info) : {entityName}
...@@ -29,14 +29,14 @@ class {className} ...@@ -29,14 +29,14 @@ class {className}
return ${varEntityName}; 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} ...@@ -45,7 +45,7 @@ class {className}
* @param $updateInfo * @param $updateInfo
* @return mixed * @return mixed
*/ */
public function updateByCondition($condition, $updateInfo) public function updateByCondition(array $condition, array $updateInfo)
{ {
return {entityName}::updateAll($updateInfo, $condition)->getResult(); return {entityName}::updateAll($updateInfo, $condition)->getResult();
} }
...@@ -57,9 +57,19 @@ class {className} ...@@ -57,9 +57,19 @@ class {className}
* @param $updateInfo * @param $updateInfo
* @return mixed * @return mixed
*/ */
public function updateOne($condition, $updateInfo) public function updateOne(array $condition, array $updateInfo)
{ {
return {entityName}::updateOne($updateInfo, $condition)->getResult(); 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
...@@ -30,7 +30,7 @@ class GenerateCommand ...@@ -30,7 +30,7 @@ class GenerateCommand
* *
* @Options * @Options
* -n,--n the dao name * -n,--n the dao name
* -e,--e the entity name * -en,--en the entity name
* *
* @Example * @Example
* php swoft generate:dao -e entityName [-n daoName] * php swoft generate:dao -e entityName [-n daoName]
...@@ -83,9 +83,23 @@ class GenerateCommand ...@@ -83,9 +83,23 @@ class GenerateCommand
$dataPath = $appPath.'/Models/Data/'.$dataName.'.php'; $dataPath = $appPath.'/Models/Data/'.$dataName.'.php';
$templatePath = $appPath.'/Commands/Common/ClassTemplate/Data/ClassTemplate'; $templatePath = $appPath.'/Commands/Common/ClassTemplate/Data/ClassTemplate';
$content = file_get_contents($templatePath); $content = file_get_contents($templatePath);
$content = str_replace('{dataName}', $dataName, $content);
$content = str_replace("{daoName}", $daoName, $content); preg_match_all('/(?<={)\w+(?=})/', $content, $vars);
$content = str_replace("{varDaoName}", lcfirst($daoName), $content); $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); file_put_contents($dataPath, $content);
...@@ -98,7 +112,7 @@ class GenerateCommand ...@@ -98,7 +112,7 @@ class GenerateCommand
private function generateDao($output,$daoName, $entityName) private function generateDao($output,$daoName, $entityName)
{ {
if ( empty($entityName) ) { if ( empty($entityName) ) {
$output->writeln("the en option is required", true, true); $output->writeln("the entity name is required", true, true);
} }
$daoName = empty($daoName)?$entityName.'Dao':$daoName; $daoName = empty($daoName)?$entityName.'Dao':$daoName;
...@@ -109,12 +123,50 @@ class GenerateCommand ...@@ -109,12 +123,50 @@ class GenerateCommand
$content = file_get_contents($templatePath); $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("{{$var}}", $$var,$content);
$content = str_replace("{varEntityName}", lcfirst($entityName), $content);
}
$daoPath = file_exists($daoPath)?$daoPath.'.gen':$daoPath;
file_put_contents($daoPath,$content); 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
...@@ -21,11 +21,15 @@ use Hdll\Services\Common\Entity\User; ...@@ -21,11 +21,15 @@ use Hdll\Services\Common\Entity\User;
class Smscode 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 ...@@ -93,7 +97,7 @@ class Smscode
private function getKey($mobile) private function getKey($mobile)
{ {
return 'smscode:' . md5($this->sellerId . '|' . $mobile); return 'smscode:' . md5($this->number . '|' . $mobile);
} }
} }
\ No newline at end of file
<?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
...@@ -13,4 +13,9 @@ class RedisKeyEnum ...@@ -13,4 +13,9 @@ class RedisKeyEnum
const ORDER_RESERVATION = self::PREFIX."order_reservation_"; const ORDER_RESERVATION = self::PREFIX."order_reservation_";
const ORDER_RESERVATION_NOTICE = self::PREFIX."order_reservation_notice_";
} }
\ No newline at end of file
...@@ -21,20 +21,24 @@ class TencentSMS implements SenderInterface ...@@ -21,20 +21,24 @@ class TencentSMS implements SenderInterface
private $param; 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->phone = $phone;
$this->template = $template; $this->template = $template;
$this->param = $param; $this->param = $param;
$this->storeId = $storeId;
} }
public function format() public function format()
{ {
$this->data[$this->sendType] = [ $this->data[$this->sendType] = [
[ [
'templateId' => $this->template, 'storeId' => $this->storeId,
'templateId' => $this->template,
'phoneNumber' => $this->phone, 'phoneNumber' => $this->phone,
'param' => $this->param, 'param' => $this->param,
] ]
]; ];
......
...@@ -22,11 +22,11 @@ class NoticeExtension ...@@ -22,11 +22,11 @@ class NoticeExtension
/** /**
* 发送消息通知 * 发送消息通知
* *
* @param int $sendTime * @param $sendTime
* @param mixed ...$senders * @param mixed ...$senders
* @return bool|mixed * @return bool|mixed
*/ */
public function send(int $sendTime, ... $senders) public function send($sendTime, ... $senders)
{ {
$data = []; $data = [];
......
...@@ -15,8 +15,8 @@ use Swoft\Core\ResultInterface; ...@@ -15,8 +15,8 @@ use Swoft\Core\ResultInterface;
/** /**
* The interface of demo service * The interface of demo service
* *
* @method ResultInterface deferSend(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(int $storeId, array $sendTypes, array $data, int $sendTime, string $redisKey) :bool * @method ResultInterface deferCancelSend(string $redisKey):bool
*/ */
interface NoticeInterface interface NoticeInterface
{ {
...@@ -50,6 +50,7 @@ interface NoticeInterface ...@@ -50,6 +50,7 @@ interface NoticeInterface
* 短信发送消息数据结构 * 短信发送消息数据结构
$data[NoticeEnum::TYPE_TENCENT_SMS] = [ $data[NoticeEnum::TYPE_TENCENT_SMS] = [
[ [
'storeId' => 198
"templateId" => "178822", //模板id "templateId" => "178822", //模板id
"phoneNumber" => "17558430002", "phoneNumber" => "17558430002",
"param" => [ //模板变量名 "param" => [ //模板变量名
...@@ -80,11 +81,11 @@ interface NoticeInterface ...@@ -80,11 +81,11 @@ interface NoticeInterface
* *
* @param array $sendTypes * @param array $sendTypes
* @param array $data * @param array $data
* @param int $sendTime //发送时间,立即返送填0 * @param $sendTime //如果需要多个时间段发送则填写时间戳数组例如:[15800000,1580000]
* @param string $redisKey //发送事件的redis key(如果定时发送消息,中途需要取消则需要传入此项) * @param string $redisKey //发送事件的redis key(如果定时发送消息,中途需要取消则需要传入此项)
* @return mixed * @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;
/** /**
......
...@@ -22,7 +22,6 @@ use Swoft\Core\ResultInterface; ...@@ -22,7 +22,6 @@ use Swoft\Core\ResultInterface;
* @method ResultInterface deferModifyReservById(int $storeId, int $id, array $data) * @method ResultInterface deferModifyReservById(int $storeId, int $id, array $data)
* @method ResultInterface defermarkReservFinished(int $storeId, int $orderId) * @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 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) * @method ResultInterface deferCancelReservByOrderId(int $storeId, int $orderId, string $memo)
*/ */
interface ReservationInterface interface ReservationInterface
...@@ -97,15 +96,6 @@ 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); 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取消该订单下的所有预约 * 根据订单id取消该订单下的所有预约
* *
* @param integer $storeId * @param integer $storeId
......
...@@ -34,10 +34,10 @@ interface SubStoreInterface ...@@ -34,10 +34,10 @@ interface SubStoreInterface
* 获取storeId获取所有子店铺列表 * 获取storeId获取所有子店铺列表
* *
* @param int $storeId * @param int $storeId
* @param int $state 子店铺状态筛选,0表示正常,1表示关闭,10表示列出所有 * @param int $state 子店铺状态筛选,1表示正常,2表示关闭,0表示列出所有
* @return array * @return array
*/ */
public function getSubStoreList(int $storeId, int $state = 0); public function getSubStoreList(int $storeId, int $state = 1);
/** /**
* 修改子店铺信息 * 修改子店铺信息
...@@ -48,7 +48,7 @@ interface SubStoreInterface ...@@ -48,7 +48,7 @@ interface SubStoreInterface
* $data字段说明: * $data字段说明:
* subStoreName // 门店名称 * subStoreName // 门店名称
* mobile // 门店联系手机 * mobile // 门店联系手机
* state // 0表示正常状态,1关闭状态 * state // 1表示正常状态,2关闭状态
* storeAddr // 店铺地址 * storeAddr // 店铺地址
* lntLat // 店铺坐标 * lntLat // 店铺坐标
* storeHours // 营业时间 * storeHours // 营业时间
......
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