Commit 300e7231 by feixiang

Merge branch 'master' into dev

parents 3892cf64 dea1ceae
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/29
* Time: 12:03
*/
namespace Hdll\Services\Auth\Enum;
class AuthEnum
{
const SCOPE_BUYER = 1; //买家
const SCOPE_CMAN = 2; //手艺人
const SCOPE_SELLER = 3; //卖家
const SCOPE_ADMIN = 4;//管理员
}
\ No newline at end of file
......@@ -9,8 +9,8 @@ namespace Hdll\Services\Auth\Enum;
class AuthError
{
const GET_TOKEN_ERROR = ["msg" => "获取token失败", "code" => 500, "errorCode" => 25103];
const NOT_FOUND_USER = ["msg" => "获取用户信息失败", "code" => 404, "errorCode" => 25104];
const GET_TOKEN_ERROR = ["msg" => "获取token失败", "code" => 401, "errorCode" => 25103];
const NOT_FOUND_USER = ["msg" => "获取用户信息失败", "code" => 401, "errorCode" => 25104];
public static function atranslate($message,$param)
......
......@@ -15,4 +15,11 @@ class BargainEnum
const STATUS_NORMAL = 10; //待支付
//paystatus
const HAVE_PAY =2;
const PAY_EXCEPTION = 3;
const PAY_REFUND = 4; // 退款
}
\ No newline at end of file
......@@ -10,14 +10,14 @@
namespace Hdll\Services\Bargain\Lib;
use Hdll\Services\Bargain\Enum\BargainEnum;
use Swoft\Core\ResultInterface;
/**
* The interface of demo service
*
* @method ResultInterface deferGetgoodsinfo( int $limit_id)
* @method ResultInterface deferGetBargainInfo( int $limit_id)
* @method ResultInterface deferGetgoodsinfo(int $limit_id)
* @method ResultInterface deferGetBargainInfo(int $limit_id)
*/
interface BargainInterface
{
......@@ -26,18 +26,17 @@ interface BargainInterface
* 获取砍价商品的 商品信息
* @param int $bargain_id
* @return {
"name" 名称
"image" 图片
"price" 价格
"activityName" 活动名称
* "name" 名称
* "image" 图片
* "price" 价格
* "activityName" 活动名称
* }
*/
public function getGoodsInfo(
int $stordId,int $bargain_id
int $stordId, int $bargain_id
);
/**
* 通过商品id 获取是否 有砍价活动
* @param int $storeId
......@@ -46,9 +45,22 @@ interface BargainInterface
*
*/
public function getBargainInfo(
int $storeId,int $goodsId
int $storeId, int $goodsId
);
/**
* 支付 状态 回馈接口
* @param string $storeId //
* @param int $bargainbranchId // 砍价活动id
* @param int $status // BargainEnum::HAVE_PAY 成功支付 BargainEnum::PAY_EXCEPTION:未支付 (已经过期或者支付异常)
* @return mixed
*/
public function payStatus(
string $storeId,
int $bargainbranchId,
int $status , //
int $orderId);
}
......
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/31
* Time: 17:25
*/
namespace Hdll\Services\Buyer\Enum;
class BillEnum
{
const STATE_BALANCE_FALSE = 1; //未入账
const STATE_BALANCE_TRUE = 2; //已入账
}
\ No newline at end of file
......@@ -39,5 +39,16 @@ interface BillInterface{
public function getListByOrderId(int $storeId, int $orderId);
public function updateByCondition(int $storeId, array $condition, array $info);
/**
* 退款成功逻辑
*
* @param $storeId
* @param $orderId
* @return mixed
*/
public function refundSuccess($storeId, $orderId);
}
\ No newline at end of file
......@@ -52,4 +52,13 @@ interface CommissionInterface
*/
public function addTotalCommission($storeId, $buyerId, $money);
/**
* 增加冻结金额
*
* @param int $storeId
* @param int $orderId
* @return mixed
*/
public function addExpectCommission(int $storeId, int $orderId);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/30
* Time: 9:50
*/
namespace Hdll\Services\Buyer\Lib;
use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferDelByStoreId(int $storeId)
* Interface Footprint
* @package Hdll\Services\Buyer\Lib
*/
interface FootprintInterface
{
public function delByStoreId(int $storeId) : bool;
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/18
* Time: 13:58
*/
namespace Hdll\Services\BuyerDistribution\Enum;
class DistributionEnum
{
const STATE_BALANCE_FALSE = 0; //未入账
const STATE_BALANCE_TRUE = 1; //已入账
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Argericy
* Date: 2018/7/23
* Time: 15:54
*/
namespace App\Models\Dao;
use App\Models\Entity\{entityName};
use Swoft\Bean\Annotation\Bean;
use Hdll\Services\Common\Exception\CommonException;
/**
* @Bean()
* Class {className}
* @package App\Models\Dao
*/
class {className}
{
public function create(array $info) : {entityName}
{
${varEntityName} = new {entityName}($info);
$res = ${varEntityName}->save()->getResult();
if ( $res === false ) {
throw new CommonException(["msg" => "数据库操作错误", "code" => 500]);
}
return ${varEntityName};
}
public function selectInfoByCondition($condition, $field)
{
return {entityName}::findAll($condition, ['fields' => $field])->getResult();
}
public function getInfoByCondition($condition, $field)
{
return {entityName}::findOne($condition, ['fields' => $field])->getResult();
}
/**
* 根据条件更新信息
* @param $condition
* @param $updateInfo
* @return mixed
*/
public function updateByCondition($condition, $updateInfo)
{
return {entityName}::updateAll($updateInfo, $condition)->getResult();
}
/**
* 更新一条记录
*
* @param $condition
* @param $updateInfo
* @return mixed
*/
public function updateOne($condition, $updateInfo)
{
return {entityName}::updateOne($updateInfo, $condition)->getResult();
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Argericy
* Date: 2018/9/29
* Time: 11:35
*/
namespace App\Models\Data;
use App\Models\Dao\{daoName};
use Swoft\Bean\Annotation\Bean;
use Swoft\Bean\Annotation\Inject;
/**
* @Bean()
*
* Class {dataName}
* @package App\Models\Data
*/
class {dataName}
{
/**
* @Inject()
* @var {daoName}
*/
private ${varDaoName};
}
\ No newline at end of file
<?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 App\Commands\Common;
use Swoft\Console\Bean\Annotation\Command;
use Swoft\Console\Bean\Annotation\Mapping;
use Swoft\Console\Input\Input;
use Swoft\Console\Output\Output;
/**
* generate dao,data layer commands
*
* @Command(coroutine=false)
*/
class GenerateCommand
{
/**
* this generate command
*
* @Usage
* generate:dao [options]
*
* @Options
* -n,--n the dao name
* -e,--e the entity name
*
* @Example
* php swoft generate:dao -e entityName [-n daoName]
*
* @param Input $input
* @param Output $output
*
* @Mapping("dao")
*/
public function Dao(Input $input, Output $output)
{
$className = $input->getOpt('n');
$entityName = $input->getOpt('e');
$this->generateDao($output, $className, $entityName);
}
/**
* this generate command
*
* @Usage
* generate:all [options]
*
* @Options
* -n,--n the dao name
* -e,--e the entity name
*
* @Example
* php swoft generate:dao -e entityName [-n dataName] [--dao-name daoName]
*
* @param Input $input
* @param Output $output
*
* @Mapping("all")
*/
public function all(Input $input, Output $output)
{
$dataName = $input->getOpt('n');
$entityName = $input->getOpt('e');
$daoName = $input->getOpt('dao-name');
$appPath = alias('@app');
$dataName = empty($dataName)?$entityName.'Data':$dataName;
//generateDao
$daoName = empty($daoName)?$entityName.'Dao':$daoName;
$this->generateDao($output, $daoName, $entityName);
//generateData
$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);
file_put_contents($dataPath, $content);
}
private function generateDao($output,$daoName, $entityName)
{
if ( empty($entityName) ) {
$output->writeln("the en option is required", true, true);
}
$daoName = empty($daoName)?$entityName.'Dao':$daoName;
$daoPath = alias("@app").'/Models/Dao/'.$daoName.'.php';
$templatePath = alias("@app").'/Commands/Common/ClassTemplate/Dao/ClassTemplate';
$content = file_get_contents($templatePath);
$content = str_replace("{className}", $daoName,$content);
$content = str_replace("{entityName}", $entityName, $content);
$content = str_replace("{varEntityName}", lcfirst($entityName), $content);
file_put_contents($daoPath,$content);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/12
* Time: 13:32
*/
namespace Hdll\Services\Common\Bean\Annotation;
use Doctrine\Common\Annotations\Annotation\Target;
/**
* @Annotation
* @Target({"ALL"})
* Class Auth
* @package App\Bean\Annotation
*/
class Auth
{
private $scope=0;
private $option='==';
public function __construct(array $values)
{
if (isset($values['scope'])) {
$this->scope = $values['scope'];
}
if (isset($values['option'])) {
$this->option = $values['option'];
}
}
public function setScope($scope)
{
return $this->scope = $scope;
}
public function setOption($option)
{
return $this->option = $option;
}
public function getScope()
{
return $this->scope;
}
public function getOption()
{
return $this->option;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/12
* Time: 13:32
*/
namespace Hdll\Services\Common\Bean\Annotation;
use Doctrine\Common\Annotations\Annotation\Target;
/**
* @Annotation
* @Target("ALL")
* Class Auth
* @package App\Bean\Annotation
*/
class Split
{
private $num=100;
public function __construct(array $values)
{
if (isset($values['num'])) {
$this->num = $values['num'];
}
}
public function setNum($num)
{
$this->num = $num;
}
public function getNum()
{
return $this->num;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/12
* Time: 13:44
*/
namespace Hdll\Services\Common\Bean\Collector;
use Hdll\Services\Common\Bean\Annotation\Auth;
use Swoft\Bean\CollectorInterface;
class AuthCollector implements CollectorInterface
{
/**
* @var array
*/
private static $auth = [];
public static function collect(string $className,
$objectAnnotation = null,
string $propertyName = '',
string $methodName = '',
$propertyValue = null)
{
if ($objectAnnotation instanceof Auth) {
$scope = $objectAnnotation->getScope();
$option = $objectAnnotation->getOption();
if ( $methodName ==='' ) {
self::$auth[$className]['scope'] = $scope;
self::$auth[$className]['option'] = $option;
} else {
self::$auth[$className]['methods'][$methodName]['scope'] = $scope;
self::$auth[$className]['methods'][$methodName]['option'] = $option;
}
}
}
public static function getCollector()
{
return self::$auth;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/12
* Time: 13:44
*/
namespace Hdll\Services\Common\Bean\Collector;
use Hdll\Services\Common\Bean\Annotation\Split;
use Swoft\Bean\CollectorInterface;
use Swoft\Db\Bean\Collector\EntityCollector;
class SplitCollector implements CollectorInterface
{
/**
* @var array
*/
private static $split = [];
public static function collect(string $className,
$objectAnnotation = null,
string $propertyName = '',
string $methodName = '',
$propertyValue = null)
{
if ($objectAnnotation instanceof Split) {
$entityCollector = EntityCollector::getCollector();
self::$split[$className]['table'] = $entityCollector[$className]['table']['name'];
self::$split[$className]['num'] = $objectAnnotation->getNum();
self::$split['map'][$className] = $entityCollector[$className]['table']['name'];
}
}
public static function getCollector()
{
return self::$split;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/12
* Time: 13:43
*/
namespace Hdll\Services\Common\Bean\Parser;
use Hdll\Services\Common\Bean\Collector\AuthCollector;
use Swoft\Bean\Annotation\Scope;
use Swoft\Bean\Parser\AbstractParser;
/**
* @uses AuthParser
* Class AuthParser
* @package App\Bean\Parser
*/
class AuthParser extends AbstractParser
{
public function parser(string $className,
$objectAnnotation = null,
string $propertyName = '',
string $methodName = '',
$propertyValue = null)
{
AuthCollector::collect($className, $objectAnnotation, $propertyName, $methodName, $propertyValue);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/12
* Time: 13:43
*/
namespace Hdll\Services\Common\Bean\Parser;
use Hdll\Services\Common\Bean\Collector\SplitCollector;
use Swoft\Bean\Annotation\Scope;
use Swoft\Bean\Parser\AbstractParser;
/**
* @uses SplitParser
* Class AuthParser
* @package App\Bean\Parser
*/
class SplitParser extends AbstractParser
{
public function parser(string $className,
$objectAnnotation = null,
string $propertyName = '',
string $methodName = '',
$propertyValue = null)
{
$beanName = $className;
$scope = Scope::SINGLETON;
SplitCollector::collect($className, $objectAnnotation, $propertyName, $methodName, $propertyValue);
return [$beanName, $scope, ""];
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/13
* Time: 13:28
*/
namespace Hdll\Services\Common\Bean\Wrapper;
use Hdll\Services\Common\Bean\Annotation\Auth;
use Swoft\Bean\Wrapper\AbstractWrapper;
class AuthWrapper extends AbstractWrapper
{
/**
* @var array 解析哪些注解(类级)
*/
protected $classAnnotations = [
Auth::class
];
/**
* @var array 解析哪些注解(属性级)
*/
protected $propertyAnnotations = [
Auth::class
]
;
/**
* @var array 解析哪些注解(方法级)
*/
protected $methodAnnotations = [
Auth::class
];
/**
* 是否解析类注解
* @param array $annotations
* @return bool
*/
public function isParseClassAnnotations(array $annotations): bool
{
return true;
}
/**
* 是否解析属性注解
* @param array $annotations
* @return bool
*/
public function isParsePropertyAnnotations(array $annotations): bool
{
return true;
}
/**
* 是否解析方法注解
* @param array $annotations
* @return bool
*/
public function isParseMethodAnnotations(array $annotations): bool
{
return true;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/13
* Time: 13:28
*/
namespace Hdll\Services\Common\Bean\Wrapper;
use Hdll\Services\Common\Bean\Annotation\Split;
use Swoft\Bean\Wrapper\AbstractWrapper;
class SplitWrapper extends AbstractWrapper
{
/**
* @var array 解析哪些注解(类级)
*/
protected $classAnnotations = [
Split::class
];
/**
* @var array 解析哪些注解(属性级)
*/
protected $propertyAnnotations = [
Split::class
]
;
/**
* @var array 解析哪些注解(方法级)
*/
protected $methodAnnotations = [
Split::class
];
/**
* 是否解析类注解
* @param array $annotations
* @return bool
*/
public function isParseClassAnnotations(array $annotations): bool
{
return true;
}
/**
* 是否解析属性注解
* @param array $annotations
* @return bool
*/
public function isParsePropertyAnnotations(array $annotations): bool
{
return true;
}
/**
* 是否解析方法注解
* @param array $annotations
* @return bool
*/
public function isParseMethodAnnotations(array $annotations): bool
{
return true;
}
}
\ No newline at end of file
<?php
/**
* Auto generated from CLS.proto at 2018-09-07 06:03:23
*
* cls package
*/
namespace Hdll\Services\Common\ClsLogger\Cls {
/**
* Log message
*/
class Log extends \ProtobufMessage
{
/* Field index constants */
const TIME = 1;
const CONTENTS = 2;
/* @var array Field descriptors */
protected static $fields = array(
self::TIME => array(
'name' => 'time',
'required' => true,
'type' => \ProtobufMessage::PB_TYPE_INT,
),
self::CONTENTS => array(
'name' => 'contents',
'repeated' => true,
'type' => '\Hdll\Services\Common\ClsLogger\Cls\Log_Content'
),
);
/**
* Constructs new message container and clears its internal state
*/
public function __construct()
{
$this->reset();
}
/**
* Clears message values and sets default ones
*
* @return null
*/
public function reset()
{
$this->values[self::TIME] = null;
$this->values[self::CONTENTS] = array();
}
/**
* Returns field descriptors
*
* @return array
*/
public function fields()
{
return self::$fields;
}
/**
* Sets value of 'time' property
*
* @param integer $value Property value
*
* @return null
*/
public function setTime($value)
{
return $this->set(self::TIME, $value);
}
/**
* Returns value of 'time' property
*
* @return integer
*/
public function getTime()
{
$value = $this->get(self::TIME);
return $value === null ? (integer)$value : $value;
}
/**
* Appends value to 'contents' list
*
* @param \Hdll\Services\Common\ClsLogger\Cls\Log_Content $value Value to append
*
* @return null
*/
public function appendContents(\Hdll\Services\Common\ClsLogger\Cls\Log_Content $value)
{
return $this->append(self::CONTENTS, $value);
}
/**
* Clears 'contents' list
*
* @return null
*/
public function clearContents()
{
return $this->clear(self::CONTENTS);
}
/**
* Returns 'contents' list
*
* @return \Hdll\Services\Common\ClsLogger\Cls\Log_Content[]
*/
public function getContents()
{
return $this->get(self::CONTENTS);
}
/**
* Returns 'contents' iterator
*
* @return \ArrayIterator
*/
public function getContentsIterator()
{
return new \ArrayIterator($this->get(self::CONTENTS));
}
/**
* Returns element from 'contents' list at given offset
*
* @param int $offset Position in list
*
* @return \Hdll\Services\Common\ClsLogger\Cls\Log_Content
*/
public function getContentsAt($offset)
{
return $this->get(self::CONTENTS, $offset);
}
/**
* Returns count of 'contents' list
*
* @return int
*/
public function getContentsCount()
{
return $this->count(self::CONTENTS);
}
}
}
\ No newline at end of file
<?php
/**
* Auto generated from CLS.proto at 2018-09-07 06:03:23
*
* cls package
*/
namespace Hdll\Services\Common\ClsLogger\Cls {
/**
* LogGroup message
*/
class LogGroup extends \ProtobufMessage
{
/* Field index constants */
const LOGS = 1;
const CONTEXTFLOW = 2;
const FILENAME = 3;
const SOURCE = 4;
/* @var array Field descriptors */
protected static $fields = array(
self::LOGS => array(
'name' => 'logs',
'repeated' => true,
'type' => '\Hdll\Services\Common\ClsLogger\Cls\Log'
),
self::CONTEXTFLOW => array(
'name' => 'contextFlow',
'required' => false,
'type' => \ProtobufMessage::PB_TYPE_STRING,
),
self::FILENAME => array(
'name' => 'filename',
'required' => false,
'type' => \ProtobufMessage::PB_TYPE_STRING,
),
self::SOURCE => array(
'name' => 'source',
'required' => false,
'type' => \ProtobufMessage::PB_TYPE_STRING,
),
);
/**
* Constructs new message container and clears its internal state
*/
public function __construct()
{
$this->reset();
}
/**
* Clears message values and sets default ones
*
* @return null
*/
public function reset()
{
$this->values[self::LOGS] = array();
$this->values[self::CONTEXTFLOW] = null;
$this->values[self::FILENAME] = null;
$this->values[self::SOURCE] = null;
}
/**
* Returns field descriptors
*
* @return array
*/
public function fields()
{
return self::$fields;
}
/**
* Appends value to 'logs' list
*
* @param \Hdll\Services\Common\ClsLogger\Cls\Log $value Value to append
*
* @return null
*/
public function appendLogs(\Hdll\Services\Common\ClsLogger\Cls\Log $value)
{
return $this->append(self::LOGS, $value);
}
/**
* Clears 'logs' list
*
* @return null
*/
public function clearLogs()
{
return $this->clear(self::LOGS);
}
/**
* Returns 'logs' list
*
* @return \Hdll\Services\Common\ClsLogger\Cls\Log[]
*/
public function getLogs()
{
return $this->get(self::LOGS);
}
/**
* Returns 'logs' iterator
*
* @return \ArrayIterator
*/
public function getLogsIterator()
{
return new \ArrayIterator($this->get(self::LOGS));
}
/**
* Returns element from 'logs' list at given offset
*
* @param int $offset Position in list
*
* @return \Hdll\Services\Common\ClsLogger\Cls\Log
*/
public function getLogsAt($offset)
{
return $this->get(self::LOGS, $offset);
}
/**
* Returns count of 'logs' list
*
* @return int
*/
public function getLogsCount()
{
return $this->count(self::LOGS);
}
/**
* Sets value of 'contextFlow' property
*
* @param string $value Property value
*
* @return null
*/
public function setContextFlow($value)
{
return $this->set(self::CONTEXTFLOW, $value);
}
/**
* Returns value of 'contextFlow' property
*
* @return string
*/
public function getContextFlow()
{
$value = $this->get(self::CONTEXTFLOW);
return $value === null ? (string)$value : $value;
}
/**
* Sets value of 'filename' property
*
* @param string $value Property value
*
* @return null
*/
public function setFilename($value)
{
return $this->set(self::FILENAME, $value);
}
/**
* Returns value of 'filename' property
*
* @return string
*/
public function getFilename()
{
$value = $this->get(self::FILENAME);
return $value === null ? (string)$value : $value;
}
/**
* Sets value of 'source' property
*
* @param string $value Property value
*
* @return null
*/
public function setSource($value)
{
return $this->set(self::SOURCE, $value);
}
/**
* Returns value of 'source' property
*
* @return string
*/
public function getSource()
{
$value = $this->get(self::SOURCE);
return $value === null ? (string)$value : $value;
}
}
}
\ No newline at end of file
<?php
/**
* Auto generated from CLS.proto at 2018-09-07 06:03:23
*
* cls package
*/
namespace Hdll\Services\Common\ClsLogger\Cls {
/**
* LogGroupList message
*/
class LogGroupList extends \ProtobufMessage
{
/* Field index constants */
const LOGGROUPLIST = 1;
/* @var array Field descriptors */
protected static $fields = array(
self::LOGGROUPLIST => array(
'name' => 'logGroupList',
'repeated' => true,
'type' => '\Hdll\Services\Common\ClsLogger\Cls\LogGroup'
),
);
/**
* Constructs new message container and clears its internal state
*/
public function __construct()
{
$this->reset();
}
/**
* Clears message values and sets default ones
*
* @return null
*/
public function reset()
{
$this->values[self::LOGGROUPLIST] = array();
}
/**
* Returns field descriptors
*
* @return array
*/
public function fields()
{
return self::$fields;
}
/**
* Appends value to 'logGroupList' list
*
* @param \Hdll\Services\Common\ClsLogger\Cls\LogGroup $value Value to append
*
* @return null
*/
public function appendLogGroupList(\Hdll\Services\Common\ClsLogger\Cls\LogGroup $value)
{
return $this->append(self::LOGGROUPLIST, $value);
}
/**
* Clears 'logGroupList' list
*
* @return null
*/
public function clearLogGroupList()
{
return $this->clear(self::LOGGROUPLIST);
}
/**
* Returns 'logGroupList' list
*
* @return \Hdll\Services\Common\ClsLogger\Cls\LogGroup[]
*/
public function getLogGroupList()
{
return $this->get(self::LOGGROUPLIST);
}
/**
* Returns 'logGroupList' iterator
*
* @return \ArrayIterator
*/
public function getLogGroupListIterator()
{
return new \ArrayIterator($this->get(self::LOGGROUPLIST));
}
/**
* Returns element from 'logGroupList' list at given offset
*
* @param int $offset Position in list
*
* @return \Hdll\Services\Common\ClsLogger\Cls\LogGroup
*/
public function getLogGroupListAt($offset)
{
return $this->get(self::LOGGROUPLIST, $offset);
}
/**
* Returns count of 'logGroupList' list
*
* @return int
*/
public function getLogGroupListCount()
{
return $this->count(self::LOGGROUPLIST);
}
}
}
\ No newline at end of file
<?php
/**
* Auto generated from CLS.proto at 2018-09-07 06:03:23
*
* cls package
*/
namespace Hdll\Services\Common\ClsLogger\Cls {
/**
* Content message embedded in Log message
*/
class Log_Content extends \ProtobufMessage
{
/* Field index constants */
const KEY = 1;
const VALUE = 2;
/* @var array Field descriptors */
protected static $fields = array(
self::KEY => array(
'name' => 'key',
'required' => true,
'type' => \ProtobufMessage::PB_TYPE_STRING,
),
self::VALUE => array(
'name' => 'value',
'required' => true,
'type' => \ProtobufMessage::PB_TYPE_STRING,
),
);
/**
* Constructs new message container and clears its internal state
*/
public function __construct()
{
$this->reset();
}
/**
* Clears message values and sets default ones
*
* @return null
*/
public function reset()
{
$this->values[self::KEY] = null;
$this->values[self::VALUE] = null;
}
/**
* Returns field descriptors
*
* @return array
*/
public function fields()
{
return self::$fields;
}
/**
* Sets value of 'key' property
*
* @param string $value Property value
*
* @return null
*/
public function setKey($value)
{
return $this->set(self::KEY, $value);
}
/**
* Returns value of 'key' property
*
* @return string
*/
public function getKey()
{
$value = $this->get(self::KEY);
return $value === null ? (string)$value : $value;
}
/**
* Sets value of 'value' property
*
* @param string $value Property value
*
* @return null
*/
public function setValue($value)
{
return $this->set(self::VALUE, $value);
}
/**
* Returns value of 'value' property
*
* @return string
*/
public function getValue()
{
$value = $this->get(self::VALUE);
return $value === null ? (string)$value : $value;
}
}
}
\ No newline at end of file
<?php
namespace Hdll\Services\Common\ClsLogger;
use Swoft\App;
use Swoole\Coroutine;
use Swoole\Coroutine\MySQL\Exception;
use Swoft\HttpClient\Client;
use Hdll\Services\Common\ClsLogger\Cls\LogGroupList;
use Hdll\Services\Common\ClsLogger\Cls\LogGroup;
use Hdll\Services\Common\ClsLogger\Cls\Log_Content;
use Hdll\Services\Common\ClsLogger\Cls\Log;
class ClsLog
{
const TOPICID_ERROR = '11b19b11-c6b3-45fc-ab1a-7a531558fb57';
const TOPICID_NOTICE = 'b84f9396-d17a-4e61-88a8-11e032755732';
public static function error($msgText, $key = ''){
$key = empty($key) ? APP_NAME : APP_NAME.':'.$key;
$pbData = self::createPbData($key, $msgText);
return self::uploadToCls(self::TOPICID_ERROR, $pbData);
}
public static function notice($msgText, $key = '') {
$key = empty($key) ? APP_NAME : APP_NAME.':'.$key;
$pbData = self::createPbData($key, $msgText);
return self::uploadToCls(self::TOPICID_NOTICE, $pbData);
}
private static function createPbData($key, $value)
{
$logGroupList = new LogGroupList;
$logGroup = new LogGroup;
$log = new Log;
$logContent = new Log_Content;
$logContent->setKey($key);
$logContent->setValue($value);
$log->appendContents($logContent);
$log->setTime(time());
$logGroup->appendLogs($log);
$logGroup->setSource(APP_NAME);
$logGroupList->appendLogGroupList($logGroup);
return $logGroupList->serializeToString();
}
private static function uploadToCls($topicId, $pbData) {
$authorization = ClsSignature::create();
$uri = 'http://ap-beijing.cls.myqcloud.com/structuredlog?topic_id='.$topicId;
$res = (new Client)->post($uri, [
'headers' => [
'Host' => 'ap-beijing.cls.myqcloud.com',
'Authorization' => $authorization,
'Content-Type' => 'application/x-protobuf',
],
'body'=>$pbData,
'timeout' => 20,
]);
if($res->getResponse()->getStatusCode() != 200) {
$msg = '上传腾讯云日志服务失败:'.$res->getResult();
self::writeClsErrors($msg);
return false;
}
return true;
}
/**
* 腾讯日志服务上传时产生错误,这种错误需要记录在本地文件
*
* @return void
*/
private static function writeClsErrors($messageText) {
$filename = 'cls_error.log';
$logFile = \alias('@runtime').'/logs/'.$filename;
if (App::isCoContext()) {
// 协程写
go(function () use ($logFile, $messageText) {
$res = Coroutine::writeFile($logFile, $messageText, FILE_APPEND);
if ($res === false) {
throw new \InvalidArgumentException("Unable to append to log file: {$filename}");
}
});
} else {
$fp = fopen($logFile, 'a');
if ($fp === false) {
throw new \InvalidArgumentException("Unable to append to log file: {$filename}");
}
flock($fp, LOCK_EX);
fwrite($fp, $messageText);
flock($fp, LOCK_UN);
fclose($fp);
}
}
}
<?php
namespace Hdll\Services\Common\ClsLogger;
class ClsSignature
{
public static function create(){
$signTime = (time()-10).';'.(time()+300);
$configs = include dirname(__FILE__, 2).'/Config/config.php';
$sha1edHttpString = sha1("post\n/structuredlog\n\n\n");
$stringToSign = "sha1\n{$signTime}\n{$sha1edHttpString}\n";
$signKey = hash_hmac('sha1', $signTime, $configs['cls']['secretKey']);
$signature = hash_hmac('sha1', $stringToSign, $signKey);
$authorization = 'q-sign-algorithm=sha1&q-ak='.$configs['cls']['secretId']
."&q-sign-time={$signTime}&q-key-time={$signTime}&q-header-list=&q-url-param-list=&q-signature={$signature}";
return $authorization;
}
}
<?php
namespace Hdll\Services\Common\ClsLogger;
use Monolog\Handler\AbstractProcessingHandler;
use Swoft\App;
use Swoole\Coroutine;
/**
* 自定义日志处理器,记录到腾讯云Cls
*
* @uses LogHandler
*/
class LogHandler extends AbstractProcessingHandler
{
/**
* @var array 输出包含日志级别集合
*/
protected $levels = [];
/**
* @var string 对应腾讯CLS的主题ID
*/
protected $topicId;
/**
* 批量输出日志
*
* @param array $records 日志记录集合
*
* @return bool
*/
public function handleBatch(array $records)
{
$records = $this->recordFilter($records);
if (empty($records)) {
return true;
}
$lines = array_column($records, 'formatted');
$this->write($lines);
}
/**
* 输出到腾讯云CLS
*
* @param array $records 日志记录集合
*/
protected function write(array $records)
{
$messageText = implode(" __||__ ", $records);
if($this->topicId == ClsLog::TOPICID_ERROR) {
ClsLog::error($messageText);
} else if($this->topicId == ClsLog::TOPICID_NOTICE) {
ClsLog::notice($messageText);
}
}
/**
* 记录过滤器
*
* @param array $records 日志记录集合
*
* @return array
*/
private function recordFilter(array $records)
{
$messages = [];
foreach ($records as $record) {
if (!isset($record['level'])) {
continue;
}
if (!$this->isHandling($record)) {
continue;
}
$record = $this->processRecord($record);
$search1 = strpos($record['messages'], '[http://testapi.2b3.cn:80/]');
$search2 = strpos($record['messages'], '[http://api.2b3.cn:80/]');
if($search1 !== false || $search2 !== false) {
continue;
}
$record['formatted'] = $this->getFormatter()->format($record);
$messages[] = $record;
}
return $messages;
}
/**
* check是否输出日志
*
* @param array $record
*
* @return bool
*/
public function isHandling(array $record)
{
if (empty($this->levels)) {
return true;
}
return in_array($record['level'], $this->levels);
}
}
#线上环境公共配置项:
......@@ -11,5 +11,10 @@ return [
'alisms' => [
'accessKeyId' => 'EjBn9zQxyEkKHyAA',
'accessKeySecret' => 'AN276rwCcqCkFUVt1GLCbAy8jnj52t',
]
],
'cls' => [
'appid' => '1257143824 ',
'secretId' => 'AKIDseHj18kua0KTSJ4g9SadbVEnEUZVjvPj',
'secretKey' => 'IPL5g5PaaSAzd6NSO8gEmLxcN4pTzJSQ',
],
];
\ No newline at end of file
<?php
/*
* This file is part of Swoft.
* (c) Swoft <group@swoft.org>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return [
'clsErrorLogHandler' => [
'class' => \Hdll\Services\Common\ClsLogger\LogHandler::class,
'topicId' => \Hdll\Services\Common\ClsLogger\ClsLog::TOPICID_ERROR,
'formatter' => '${lineFormatter}',
'levels' => [
\Swoft\Log\Logger::ERROR,
\Swoft\Log\Logger::WARNING,
\Swoft\Log\Logger::CRITICAL,
],
],
'clsNoticeLogHandler' => [
'class' => \Hdll\Services\Common\ClsLogger\LogHandler::class,
'topicId' => \Hdll\Services\Common\ClsLogger\ClsLog::TOPICID_NOTICE,
'formatter' => '${lineFormatter}',
'levels' => [
\Swoft\Log\Logger::NOTICE,
\Swoft\Log\Logger::INFO,
\Swoft\Log\Logger::DEBUG,
\Swoft\Log\Logger::TRACE,
],
],
'logger' => [
'name' => APP_NAME,
'enable' => true,
'flushInterval' => 100,
'flushRequest' => true,
'handlers' => [
'${clsErrorLogHandler}',
'${clsNoticeLogHandler}',
],
],
];
......@@ -93,12 +93,17 @@ class CommonEntity extends Model
//获取注解里的table
$res = new \ReflectionClass(static::class);
self::$commentString = $res->getDocComment();
if ( false !== strpos(self::$commentString,"{split}") && !App::$isInTest) {
$commentString = $res->getDocComment();
if (
(
false !== strpos($commentString,"{split}")
|| false !== strpos($commentString,"@Split")
)
&& !App::$isInTest) {
$dbNum = self::getDbNum();
$tableName = self::getTableName().'_'.$dbNum;
self::setTableName($tableName);
$tableName = self::getTableName($commentString).'_'.$dbNum;
//self::setTableName($tableName);
return $tableName;
} else {
......@@ -143,9 +148,10 @@ class CommonEntity extends Model
* 获取原始表名
* @return string
*/
protected static function getTableName()
protected static function getTableName($commentString = '')
{
preg_match('/(?<=Table\(name=").*(?="\))/', self::$commentString, $matches);
$commentString = $commentString === ''?self::$commentString:$commentString;
preg_match('/(?<=Table\(name=").*(?="\))/', $commentString, $matches);
return $tableName = isset($matches[0])?$matches[0]:'';
}
}
\ No newline at end of file
<?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 Swoft\Db;
use Hdll\Services\Common\Entity\Split;
/**
* Query
*/
class Query
{
/**
* Query查询分表处理
* @param string $tableName
* @param string|null $alias
* @return QueryBuilder
* @throws Exception\DbException
*/
public static function table(string $tableName, string $alias = null): QueryBuilder
{
$query = new QueryBuilder();
//初始化分表
$tableName = Split::initSplit($tableName, $query);
$query = $query->table($tableName, $alias);
return $query;
}
}
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/18
* Time: 10:21
*/
namespace Hdll\Services\Common\Entity;
use Hdll\Services\Common\Bean\Collector\SplitCollector;
use Hdll\Services\Common\Enum\TestEnum;
use Hdll\Services\Common\Exception\CommonException;
use Swoft\App;
use Swoft\Core\RequestContext;
use Swoft\Db\Bean\Collector\EntityCollector;
use Swoft\Db\QueryBuilder;
class Split
{
public static function initSplit($tableName, QueryBuilder $query)
{
$collector = SplitCollector::getCollector();//分表搜集器
if ( $collector['map'] !== null && is_array($collector['map'])) {
$map = array_flip($collector['map']);
}
if ( ! self::isTesting() ) {
//如果是实体且为分表实体
if (strpos($tableName, '\\') !== false && isset($collector[$tableName])) {
$className = $tableName;
$tableName = $collector[$tableName]['table'];
$entityCollector = EntityCollector::getCollector();
//设置分表对应的className
EntityCollector::setCollector($tableName.'_'.self::getDbNum($className), $tableName);
//获取分表名
$tableName = $tableName.'_'.self::getDbNum($className);
//设置分表类型
$query->selectInstance($entityCollector[$className]['instance']);
} elseif ( isset($map[$tableName]) ) { //非实体且分表
$className = $map[$tableName];
$defaultTbleName = $tableName;
$tableName = $tableName.'_'.self::getDbNum($className);
//设置分表对应的className
EntityCollector::setCollector($tableName, $defaultTbleName);
}
}
return $tableName;
}
private function getDbNum($className)
{
$splitCollector = SplitCollector::getCollector();
$splitNum = $splitCollector[$className]['num'];
$data = RequestContext::getContextData();
$storeId = $data['userInfo']['storeId'];
if ( empty($storeId) ) {
throw new CommonException(["msg" => "参数异常,获取店铺信息失败。"]);
}
return $storeId % $splitNum;
}
private function isTesting()
{
/**@var User $user**/
$user = App::getBean(User::class);
return $user->getTestFlag() === TestEnum::TEST_STORE_ID;
}
}
\ No newline at end of file
......@@ -11,8 +11,11 @@
namespace Hdll\Services\Common\Entity;
use Hdll\Services\Auth\Enum\AuthError;
use Hdll\Services\Common\Lib\Redis;
use Hdll\Services\Common\Enum\TestEnum;
use Swoft\App;
use Swoft\Bean\Annotation\Bean;
use Swoft\Core\RequestContext;
use Swoft\Redis\Redis;
/**
* 用户实体
......@@ -25,106 +28,96 @@ use Swoft\Bean\Annotation\Bean;
*/
class User
{
private $id;
private $nickname;
private $storeId;
private $headImg;
private $token;
private $sessionKey;
private $scope;
private $referId;
private $unionid;
private $openId;
public function __construct($token='')
{
}
public function getId()
{
return $this->id;
return $this->getValue('id');
}
public function setTestFlag()
{
$this->setValue('testFlag', TestEnum::TEST_STORE_ID);
}
public function getTestFlag()
{
return $this->getValue('testFlag');
}
public function getNickname()
{
return $this->nickname;
return $this->getValue('nickname');
}
public function getStoreId()
{
return $this->storeId;
return $this->getValue('storeId');
}
public function getHeadImg()
{
return $this->headImg;
return $this->getValue('headImg');
}
public function getToken()
{
return $this->token;
return $this->getValue('token');
}
public function setId($value)
{
return $this->id = $value;
$this->setValue('id', $value);
}
public function setNickname($value)
{
return $this->nickname = $value;
$this->setValue('nickname', $value);
}
public function setStoreId($value)
{
return $this->storeId = $value;
$this->setValue('storeId', $value);
}
public function setHeadImg($value)
{
return $this->headImg = $value;
$this->setValue('headImg', $value);
}
public function setSessionKey($value)
{
$this->sessionKey = $value;
$this->setValue('sessionKey', $value);
}
public function setOpenId($value)
{
$this->openId = $value;
$this->setValue('openid', $value);
}
public function setUnionid($value)
{
$this->unionid = $value;
$this->setValue('unionid', $value);
}
public function setReferId($value)
{
$this->referId = $value;
$this->setValue('referId', $value);
}
public function setScope($value)
{
$this->scope = $value;
$this->setValue('scope', $value);
}
public function setToken($value)
{
$this->token = $value;
$this->setValue('token', $value);
}
......@@ -141,28 +134,28 @@ class User
public function getSessionKey()
{
return $this->sessionKey;
return $this->getValue('sessionKey');
}
public function getOpenId()
{
return $this->openId;
return $this->getValue('openid');
}
public function getUnionid()
{
return $this->unionid;
return $this->getValue('unionid');
}
public function getReferId()
{
return $this->referId;
return $this->getValue('referId');
}
public function getScope()
{
return $this->scope;
return $this->getValue('scope');
}
......@@ -172,25 +165,36 @@ class User
return [false,AuthError::GET_TOKEN_ERROR];
}
/**
* @var Redis $redis
*/
$redis = new Redis();
$redis->setPrefix("AUTH:");
$info = $redis->get($token);
$redis = App::getBean(Redis::class);
$info = $redis->get("AUTH:".$token);
if ( empty($info) ) {
return [false,AuthError::NOT_FOUND_USER];
}
$info = json_decode($info, true);
$this->fill($info);
//$this->fill($info);
RequestContext::setContextData(['userInfo' => $info]);
return true;
}
private function getValue($key)
{
$data = RequestContext::getContextData();
return $data['userInfo'][$key]??'';
}
private function setValue($key, $value='')
{
$userInfo = [];
$userInfo['userInfo'][$key] = $value;
RequestContext::removeContextDataByChildKey('userInfo', $key);
RequestContext::setContextData($userInfo);
}
}
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/25
* Time: 13:22
*/
namespace Hdll\Services\Common\Enum;
class TestEnum
{
const TEST_STORE_ID = true;
}
......@@ -53,7 +53,7 @@ class Smscode
} else {
$count = 1;
}
$vcode = mt_rand(10000, 99999);
$vcode = mt_rand(1000, 9999);
$alisms = new Alisms(
$signName ?? Alisms::SN_01,
$templateCode ?? Alisms::TPL_01,
......
......@@ -26,10 +26,8 @@ class Upload
public function __construct(array $config = [])
{
if (empty($config)) {
/**@var Config */
$bConfig = \Swoft\App::getBean('config');
$bConfig->load('@vendor/hdll/services/src/Common/Config');
$config = $bConfig->get('qCloud');
$config = include alias('@vendor/hdll/services/src/Common/Config').'/config.php';
$config = $config['qCloud'];
}
$this->Bucket = $config['Bucket'];
$this->Region = $config['Region'];
......@@ -68,4 +66,27 @@ class Upload
}
return $result;
}
public function uploadStream($stream, $name = '')
{
$cosClient = new Client(
[
'region' => $this->Region,
'credentials' => [
'secretId' => $this->SecretId,
'secretKey' => $this->SecretKey,
]
]
);
try {
$result = $cosClient->Upload(
$this->Bucket,
$name,
$stream
);
} catch (\Exception $e) {
throw new CommonException(['msg' => $e->getMessage()]);
}
return $result;
}
}
\ No newline at end of file
......@@ -69,7 +69,7 @@ class AuthPoolConfig extends PoolProperties
* the time of connect timeout
*
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -21,12 +21,14 @@ use Swoft\Bean\Annotation\Value;
class BargainPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_BARGAIN_URI', 'bargain:8099'));
}
protected $name = 'bargain';
/**
......@@ -69,7 +71,7 @@ class BargainPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......@@ -84,8 +86,7 @@ class BargainPoolConfig extends PoolProperties
* @var array
*/
protected $uri = [
'172.21.0.13:8099',
'172.16.255.4:8099',
'bargain:8099'
];
/**
......
......@@ -25,7 +25,7 @@ class BuyerPoolConfig extends PoolProperties
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_AUTH_URI', 'buyer:8099'));
$this->uri = explode(',', env('RPC_BUYER_URI', 'buyer:8099'));
}
/**
......@@ -68,7 +68,7 @@ class BuyerPoolConfig extends PoolProperties
* the time of connect timeout
*
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -70,7 +70,7 @@ class GoodsPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -69,7 +69,7 @@ class GroupBookingPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -67,7 +67,7 @@ class NoticePoolConfig extends PoolProperties
* the time of connect timeout
*
*/
protected $timeout = 50;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -33,7 +33,7 @@ class OrderPoolConfig extends PoolProperties
*
* @var int
*/
protected $minActive = 5;
protected $minActive = 15;
/**
* the maximum number of active connections
......@@ -68,7 +68,7 @@ class OrderPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -67,7 +67,7 @@ class PayPoolConfig extends PoolProperties
* the time of connect timeout
*
*/
protected $timeout = 50;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -68,7 +68,7 @@ class ReservationPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -68,7 +68,7 @@ class SchedulePoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -70,7 +70,7 @@ class SellerDistributionPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -69,7 +69,7 @@ class SellerPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
<?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\Common\Pool\Config;
use Swoft\Bean\Annotation\Bean;
use Swoft\Pool\PoolProperties;
use Swoft\Bean\Annotation\Value;
/**
* @Bean()
* the config of service bargain
*/
class StateLessPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_STATELESS_URI', 'stateless:8099'));
}
protected $name = 'stateless';
/**
* Minimum active number of connections
*
* @var int
*/
protected $minActive = 5;
/**
* the maximum number of active connections
*
* @var int
*/
protected $maxActive = 50;
/**
* the maximum number of wait connections
*
* @var int
*/
protected $maxWait = 100;
/**
* Maximum waiting time
*
* @var int
*/
protected $maxWaitTime = 3;
/**
* Maximum idle time
*
* @var int
*/
protected $maxIdleTime = 60;
/**
* the time of connect timeout
*
* @var int
*/
protected $timeout = 200;
/**
* the addresses of connection
*
* <pre>
* [
* '127.0.0.1:88',
* '127.0.0.1:88'
* ]
* </pre>
* @Value(name="", env="${RPC_BARGAIN_URI}")
* @var array
*/
protected $uri = [
'172.21.0.34:8099',
'172.16.255.241:8099',
];
/**
* whether to user provider(consul/etcd/zookeeper)
*
* @var bool
*/
protected $useProvider = false;
/**
* the default balancer is random balancer
*
* @var string
*/
protected $balancer = '';
/**
* the default provider is consul provider
*
* @var string
*/
protected $provider = '';
}
......@@ -68,7 +68,7 @@ class StorePoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -22,10 +22,11 @@ class TimeLimitBuyPoolConfig extends PoolProperties
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_TIMELIMITBUY_URI', 'timelimitbuy:8099'));
$this->uri = explode(',', env('RPC_TIMELIMITBUY_URI', 'timelimitbuy:8099'));
}
protected $name = 'bargain';
protected $name = 'timelimitname';
/**
* Minimum active number of connections
......@@ -67,7 +68,7 @@ class TimeLimitBuyPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......@@ -82,8 +83,7 @@ class TimeLimitBuyPoolConfig extends PoolProperties
* @var array
*/
protected $uri = [
'172.21.0.34:8099',
'172.16.255.241:8099',
'timelimtbuy:8099',
];
/**
......
<?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\Common\Pool\Config;
use Swoft\Bean\Annotation\Bean;
use Swoft\Pool\PoolProperties;
/**
* the config of service WithdrawCash
*
* @Bean()
*/
class TransferPoolConfig extends PoolProperties
{
public function __construct()
{
$this->uri=explode(',',env('RPC_TRANSFER_URI','transfer:8099'));
}
protected $name = 'transfer';
/**
* Minimum active number of connections
*
* @var int
*/
protected $minActive = 5;
/**
* the maximum number of active connections
*
* @var int
*/
protected $maxActive = 50;
/**
* the maximum number of wait connections
*
* @var int
*/
protected $maxWait = 100;
/**
* Maximum waiting time
*
* @var int
*/
protected $maxWaitTime = 3;
/**
* Maximum idle time
*
* @var int
*/
protected $maxIdleTime = 60;
/**
* the time of connect timeout
*
* @var int
*/
protected $timeout = 200;
/**
* the addresses of connection
*
* <pre>
* [
* '127.0.0.1:88',
* '127.0.0.1:88'
* ]
* </pre>
*
* @var array
*/
protected $uri = [];
/**
* whether to user provider(consul/etcd/zookeeper)
*
* @var bool
*/
protected $useProvider = false;
/**
* the default balancer is random balancer
*
* @var string
*/
protected $balancer = '';
/**
* the default provider is consul provider
*
* @var string
*/
protected $provider = '';
}
......@@ -70,7 +70,7 @@ class VipPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -67,7 +67,7 @@ class WithdrawCashPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/14
* Time: 10:00
*/
namespace Hdll\Services\Common\Traits;
trait EntityCollectorTrait
{
public static function setCollector($tableName, $defaultTableName)
{
return ! isset(self::$entities[$tableName]) && self::$entities[$tableName] = &self::$entities[$defaultTableName];
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/26
* Time: 9:38
*/
namespace Hdll\Services\Feedback\Enum;
class FeedbackEnum
{
const ORIGIN_BUYER = 1; //前台反馈
const ORIGIN_SELLER = 2; //后台反馈
const ORIGINS = [
self::ORIGIN_BUYER,
self::ORIGIN_SELLER,
];
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/26
* Time: 9:42
*/
namespace Hdll\Services\Feedback\Enum;
class ReplyEnum
{
const ORIGIN_USER = 1; //用户回复
const ORIGIN_ADMIN = 2; //管理员回复
const ORIGINS = [
self::ORIGIN_USER,
self::ORIGIN_ADMIN
];
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/20
* Time: 15:48
*/
namespace Hdll\Services\Goods\Enum;
class AuthEnum
{
const EVERYONE = 0;//任何人
const BUYER = 1;//买家
const CRAFTSMAN = 2;//手艺人
const SELLER = 3;//卖家
const ADMIN = 4;//管理员
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/26
* Time: 16:00
*/
namespace Hdll\Services\Goods\Enum;
class GoodsEnum{
const ON_OFFER = 0;//出售中
const SOLD_OUT = 1;//下架
const SELL_OUT = 2;//售完
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/26
* Time: 16:00
*/
namespace Hdll\Services\Goods\Enum;
class GoodsEvaluateEnum{
const GOOD = 1;//好评
const MEDIUM = 2;//中评
const BAD = 3;//差评
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/26
* Time: 16:00
*/
namespace Hdll\Services\Goods\Enum;
class StarEnum
{
const STAR = 1;//点赞
const CANCEL = 2;//取消点赞
const HAS_START_KEY = 'hasStar';
const STAR_KEY = 'star';
}
\ No newline at end of file
......@@ -12,6 +12,9 @@ use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferGet($storeId, $id)
* @method ResultInterface deferIncSales($storeId, $goodsId)
* @method ResultInterface deferDecSales($storeId, $goodsId)
* @method ResultInterface deferGetServiceByGoodsId($storeId, $goodsId)
* Interface GoodsInterface
* @package Hdll\Services\Goods\Lib
*/
......@@ -39,4 +42,34 @@ interface GoodsInterface
*/
public function get($storeId, $id);
/**
* 增加商品销量
* 减少商品库存
* @param $storeId
* @param $goodsId
* @return mixed
* @author Administrator
*/
public function incSales($storeId, $goodsId);
/**
* 减少商品销量
* 增加商品库存
* @param $storeId
* @param $goodsId
* @return mixed
* @author Administrator
*/
public function decSales($storeId, $goodsId);
/**
* 获取商品服务
* @param $storeId
* @param $goodsId
* @return mixed
* @author Administrator
*/
public function getServiceByGoodsId($storeId,$goodsId);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/20
* Time: 15:48
*/
namespace Hdll\Services\GroupBooking\Enum;
class AuthEnum
{
const EVERYONE = 0;//任何人
const BUYER = 1;//买家
const CRAFTSMAN = 2;//手艺人
const SELLER = 3;//卖家
const ADMIN = 4;//管理员
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/8
* Time: 17:20
*/
namespace Hdll\Services\GroupBooking\Enum;
class BranchEnum
{
const START_NOT_PAY = 10;//发起未支付
const START_PAY = 20;//发起已支付
const REACH = 30;//达成条件
const CLOSE= 40;//关闭
const REDIS_ACTIVITY_KEY = "groupBooking";
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/8
* Time: 17:20
*/
namespace Hdll\Services\GroupBooking\Enum;
class GroupBookingEnum
{
const ACTIVITY_NOT_START = 1;//未开始
const ACTIVITY_ON = 2;//已开始
const ACTIVITY_OFF = 3;//已结束
const ONLINE = 1;//上线
const DOWNLINE = 2;//下线
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/8
* Time: 17:20
*/
namespace Hdll\Services\GroupBooking\Enum;
class RecordEnum
{
const START_NOT_PAY = 10;//未支付
const START_PAY = 20;//已支付
const CLOSED = 30;//已关闭
}
\ No newline at end of file
......@@ -19,8 +19,18 @@ use Swoft\Core\ResultInterface;
interface GroupBookingInterface{
public function paySuccess($orderId);
public function paySuccess($orderId,$storeId);
public function hasActivity($storeId,$goodsId);
/**
* 关闭拼团
* @param $storeId
* @param $buyerId
* @param $orderId
* @return mixed
* @author Administrator
*/
public function closeRecord($storeId, $buyerId, $orderId);
}
\ No newline at end of file
......@@ -14,8 +14,4 @@ class LimitTimeBuyEnum
//订单状态
const STATUS_NORMAL = 10; //待支付
}
\ No newline at end of file
<?php
namespace Hdll\Services\LimitTimeBuy\Enum;
class LimitTimeOrderEnum
{
//订单状态
const STATUS_NORMAL = 1; //待支付 1未支付2已经支付3异常
const STATUS_HAVE_PAY =2; // 已经支付
const STATUS_PAY_EXCEPTION =3; // 支付异常或过期未付
const STATUS_PAY_REFUND =4 ; // 退款
}
\ No newline at end of file
......@@ -10,6 +10,7 @@
namespace Hdll\Services\LimitTimeBuy\Lib;
use Hdll\Services\LimitTimeBuy\Enum\LimitTimeOrderEnum;
use Swoft\Core\ResultInterface;
/**
......@@ -44,10 +45,10 @@ interface LimitTimeBuyInterface
* 获取限时购商品的 商品信息
* @param int $limit_id
* @return {
"name" 名称
"image" 图片
"price" 价格
"activityName" 活动名称
* "name" 名称
* "image" 图片
* "price" 价格
* "activityName" 活动名称
* }
*/
public function getLimitGoods(
......@@ -66,4 +67,18 @@ interface LimitTimeBuyInterface
);
/**
* 支付 状态 回馈接口
* @param string $store_id
* @param int $limit_id
* @param int $status // 2.LimitTimeOrderEnum::STATUS_HAVE_PAY 成功支付 3:LimitTimeOrderEnum::STATUS_PAY_EXCEPTION 未支付 (已经过期或者支付异常)4 LimitTimeOrderEnum::STATUS_PAY_REFUND 退款
* @param int $orderId
* @return bool|mixed
* @throws ConException
*/
public function payStatus(
string $store_id,
int $limit_id,
int $status,
int $orderId);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/4
* Time: 10:46
*/
namespace Hdll\Services\Notice\Common;
class WxMiniNotice
{
/**
* 微信小程序page生成
*
* 用法:
* WxMiniNotice::generatePage("pages/orderShow/orderShow",['orderId' => $orderInfo['id'], 'storeId' => $orderInfo['storeId']])
* 生成
* pages/orderShow/orderShow?orderId=1&storeId=7
* @param string $page
* @param array $param
* @return string
*/
public static function generatePage(string $page, array $param)
{
$param['origin'] = $param['origin']??'notice';
$param = http_build_query($param);
return $page.'?'.$param;
}
}
\ No newline at end of file
......@@ -9,7 +9,8 @@ namespace Hdll\Services\Notice\Enum;
class FormIdEnum
{
const TYPE_FORM = 0;
const TYPE_FORM = 1;
const TYPE_PAY = 2;
const TYPE_PAY = 1;
}
\ No newline at end of file
......@@ -11,22 +11,27 @@ namespace Hdll\Services\Notice\Enum;
class NoticeEnum
{
//商家小程序发送
const TYPE_MINI_BACKEND_SEND= 1;
const TYPE_MINI_BACKEND_SEND= 100;
//腾讯sms发送
const TYPE_TENCENT_SMS = 2;
const TYPE_TENCENT_SMS = 150;
//买家小程序消息推送
const TYPE_MINI_FRONTEND_SEND= 3;
const TYPE_MINI_FRONTEND_SEND= 101;
const TYPE_MP_SEND= 102;
const SEND_TYPES = [
self::TYPE_MINI_BACKEND_SEND,
self::TYPE_TENCENT_SMS,
self::TYPE_MINI_FRONTEND_SEND
self::TYPE_MINI_FRONTEND_SEND,
self::TYPE_MP_SEND,
];
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/28
* Time: 14:50
*/
namespace Hdll\Services\Notice\Enum;
class RedisKeyEnum
{
const PREFIX = "notice:";
const ORDER_RESERVATION = self::PREFIX."order_reservation_";
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/6
* Time: 10:23
*/
namespace Hdll\Services\Notice\Extensions\Notice;
use Hdll\Services\Notice\Common\WxMiniNotice;
use Hdll\Services\Notice\Enum\NoticeEnum;
class MiniBackendSender implements SenderInterface
{
private $sendType = NoticeEnum::TYPE_MINI_BACKEND_SEND;
private $data;
private $user;
private $page;
private $sendData;
private $template;
public function __construct(array $user,array $page, array $sendData, string $template)
{
$this->user = $user;
$this->page = $page;
$this->sendData = $sendData;
$this->template = $template;
}
/**
* 格式化数据
*/
public function format()
{
//$sendType
$this->data[$this->sendType] = [
"uid" => $this->user['id'], //用户的id
"template_id" => $this->template,//消息模板id
"page" => WxMiniNotice::generatePage(
$this->page['page'],
$this->page['param']
), //消息模板页面
];
foreach ( $this->sendData as $key => $data ) {
$key +=1;
$this->data[$this->sendType]['data']["keyword{$key}"]['value'] = $data;
}
}
/**
* 获取发送数据
*
* @return mixed
*/
public function getData ()
{
return $this->data;
}
/**
* 获取发送类型
*
* @return array
*/
public function getSendType()
{
return [$this->sendType];
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/6
* Time: 10:23
*/
namespace Hdll\Services\Notice\Extensions\Notice;
use Hdll\Services\Notice\Common\WxMiniNotice;
use Hdll\Services\Notice\Enum\NoticeEnum;
/**
* Class MiniFrontendSender
* @package Hdll\Services\Notice\Extensions\Notice
*/
class MiniFrontendSender implements SenderInterface
{
private $sendType = NoticeEnum::TYPE_MINI_FRONTEND_SEND;
private $data;
private $user;
private $page;
private $sendData;
private $template;
/**
*
* $send = new MiniFrontendSender( ['id' => 1, 'storeId' => 198],
* [
* 'page' => 'pages/orderShow/orderShow',
* 'param' => ['orderId' => 1, 'storeId' => 168]
* ],
* [
* 1 => 'aaaaaaa',
* 2 => 'msg',
* 3 => '您好,您申请的退款不符合条件被拒绝',
* ],
* 'jcqYc-gHjkv-T8pDW8wjYFha0TKzCJTV3yNeGY3JW-0'
* );
* MiniFrontendSender constructor.
*
* @param array $user
* @param array $page
* @param array $sendData
* @param string $template
*/
public function __construct(array $user,array $page, array $sendData, string $template)
{
$this->user = $user;
$this->page = $page;
$this->sendData = $sendData;
$this->template = $template;
}
/**
* 格式化数据
*/
public function format()
{
//$sendType
$this->data[$this->sendType] = [
"uid" => $this->user['id'], //用户的id
"storeId" => $this->user['storeId'], //店铺的id
"template_id" => $this->template,//消息模板id
"page" => WxMiniNotice::generatePage(
$this->page['page'],
$this->page['param']
), //消息模板页面
];
foreach ( $this->sendData as $key => $data ) {
$key +=1;
$this->data[$this->sendType]['data']["keyword{$key}"]['value'] = $data;
}
}
/**
* 获取发送数据
*
* @return mixed
*/
public function getData ()
{
return $this->data;
}
/**
* 获取发送类型
*
* @return array
*/
public function getSendType()
{
return [$this->sendType];
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/9
* Time: 10:50
*/
namespace Hdll\Services\Notice\Extensions\Notice;
use Hdll\Services\Notice\Common\WxMiniNotice;
use Hdll\Services\Notice\Enum\NoticeEnum;
class MpSender implements SenderInterface
{
private $sendType = NoticeEnum::TYPE_MP_SEND;
private $data;
private $unionId;
private $miniprogram;
private $sendData;
private $template;
public function __construct(string $unionId,array $miniprogram, array $sendData, string $template)
{
$this->unionId = $unionId;
$this->miniprogram = $miniprogram;
$this->sendData = $sendData;
$this->template = $template;
}
public function format()
{
$this->data[$this->sendType] = [
'unionId' => $this->unionId,
'template_id' => $this->template,
'miniprogram' => [
'appid' => $this->miniprogram['appId'], //小程序appid
'pagepath' => WxMiniNotice::generatePage(
$this->miniprogram['page'],
$this->miniprogram['param']
)//小程序页面
],
'data' => $this->sendData
];
}
public function getData()
{
return $this->data;
}
public function getSendType()
{
return [$this->sendType];
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/6
* Time: 10:21
*/
namespace Hdll\Services\Notice\Extensions\Notice;
interface SenderInterface
{
public function format();
public function getData ();
public function getSendType();
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/10
* Time: 14:53
*/
namespace Hdll\Services\Notice\Extensions\Notice;
use Hdll\Services\Notice\Enum\NoticeEnum;
class TencentSMS implements SenderInterface
{
private $sendType = NoticeEnum::TYPE_TENCENT_SMS;
private $data;
private $phone;
private $template;
private $param;
public function __construct(string $phone, string $template, array $param)
{
$this->phone = $phone;
$this->template = $template;
$this->param = $param;
}
public function format()
{
$this->data[$this->sendType] = [
[
'templateId' => $this->template,
'phoneNumber' => $this->phone,
'param' => $this->param,
]
];
}
public function getData()
{
$this->data;
}
public function getSendType()
{
return [$this->sendType];
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/10/9
* Time: 9:22
*/
namespace Hdll\Services\Notice\Extensions;
use Hdll\Services\Notice\Extensions\Notice\SenderInterface;
use Hdll\Services\Notice\Lib\NoticeInterface;
class NoticeExtension
{
private $notice;
public function __construct(NoticeInterface $notice)
{
$this->notice = $notice;
}
/**
* 发送消息通知
*
* @param int $sendTime
* @param mixed ...$senders
* @return bool|mixed
*/
public function send(int $sendTime, ... $senders)
{
$data = [];
$sendType = [];
foreach ( $senders as $sender ) {
if ( ! $sender instanceof SenderInterface) {
continue;
}
if ( in_array($sender->getSendType(), $sendType) ) {
continue;
}
$sender->format();
$data += $sender->getData();
$sendType += $sender->getSendType();
}
return $this->notice->send($sendType, $data, $sendTime);
}
}
\ No newline at end of file
......@@ -15,7 +15,8 @@ use Swoft\Core\ResultInterface;
/**
* The interface of demo service
*
* @method ResultInterface deferSend(int $sendType, array $data, int $sendTime)
* @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
*/
interface NoticeInterface
{
......@@ -25,6 +26,7 @@ interface NoticeInterface
* 微信发送消息数据结构
* $data[NoticeEnum::TYPE_MINI_BACKEND_SEND] = [
"uid" => 1, //用户的id
* "storeId" => 1, //店铺id
"template_id" => "1kZ_RkkWfRrpufXNdmJYBpIhgk7ccCtPrypeJQ9WRwM",//消息模板id
"page" => "index", //消息模板页面
"data" => [ //消息模板数据
......@@ -46,20 +48,50 @@ interface NoticeInterface
*
* 短信发送消息数据结构
$data[NoticeEnum::TENCENT_SMS] = [
$data[NoticeEnum::TYPE_TENCENT_SMS] = [
[
"templateId" => "178822", //模板id
"phoneNumber" => "18812345678",
"phoneNumber" => "17558430002",
"param" => [ //模板变量名
"1580",
"5"
]
]
];
*
* 微信公众号发送实例
$data[NoticeEnum::TYPE_MP_SEND] = [
'unionId' => 'o3lFcs8xoWfQUlhzTiP5uZI6A7Hc', //填写用户的unionId
'template_id' => 'zwUBuoKVRJkumLwGkippA46XfmLsmwJD906HC-wqOks',
'miniprogram' => [
'appid' => 'wx3b3b2df942634cdd', //小程序appid
'pagepath' => 'pages/start/start'//小程序页面
],
'data' => [
'first' => 'first',
'keyword1' => '姓名',
'keyword2' => '1213456',
'keyword3' => '测试门店',
'keyword4' => '门店地址',
'keyword5' => 'test',
'remark' => 'remark'
]
];
*
* @param array $sendTypes
* @param array $data
* @param int $sendTime //发送时间,立即返送填0
* @param string $redisKey //发送事件的redis key(如果定时发送消息,中途需要取消则需要传入此项)
* @return mixed
*/
public function send(array $sendTypes, array $data, int $sendTime) : bool ;
public function send(array $sendTypes, array $data, int $sendTime, string $redisKey='') :bool;
/**
* 取消定时消息发送
*
* @param string $redisKey
* @return bool
*/
public function cancelSend(string $redisKey):bool ;
}
\ No newline at end of file
......@@ -10,6 +10,5 @@ namespace Hdll\Services\Order\Enum;
class OrderCate
{
const TYPE_BUYER = 1;
const TYPE_SELLER = 2;
}
\ No newline at end of file
......@@ -22,6 +22,7 @@ class OrderEnum
const STATUS_CLOSED = 70; //已关闭
const STATUS_REFUNDING = 80; //退款中
const STATUS_EVALUATION = 90; //已评价
const STATUS_COLLECTION = 100; //团购进行中
//订单类型
const TYPE_GOODS = 0; //商品订单
......@@ -29,6 +30,10 @@ class OrderEnum
const TYPE_LIMIT = 2; //限时购订单
const TYPE_COLLECTION = 3; //拼团
//对账锁定
const LOCK = 1; //订单锁定
const ORDER_TYPES = [
self::TYPE_GOODS,
self::TYPE_CUT_PRICE,
......@@ -36,7 +41,20 @@ class OrderEnum
self::TYPE_COLLECTION,
];
const PAID_STATUS = [
//可以直接预约的订单类型
const CAN_RESERVE = [
self::TYPE_GOODS,
self::TYPE_CUT_PRICE,
self::TYPE_LIMIT,
];
const PAY_STATUS = [ //支付状态
self::STATUS_PAID,
self::STATUS_DELIVERY,
self::STATUS_COLLECTION
];
const PAID_STATUS = [ //支付后的所有状态数组
self::STATUS_PAID,
self::STATUS_DELIVERY,
self::STATUS_DELIVERED,
......
......@@ -15,48 +15,218 @@ use Swoft\Core\ResultInterface;
/**
* The interface of demo service
*
* @method ResultInterface deferCreateOrder( string $token,int $consignee_id,int $activity_id,int $selected_num,int $order_type,float $total,float $goods_price,string $goods_name,string $goods_image,string $activity_name,int $goodsId,string $reservation_time = '')
* @method ResultInterface deferGetOrderInfoBySn(int $storeId, string $orderSn)
* @method ResultInterface deferCreateOrder(int $buyerId,int $storeId,int $consigneeId,int $itemId,int $selectedNum,int $orderType,int $total,int $activityPrice,string $goodsName,string $goodsImage,string $activityName,int $goodsId,int $goodsPrice,string $reservation_time = '',string $message = '');
* @method ResultInterface deferGetOrderInfoBySn(int $storeId, string $orderSn, array $consigneeFields = [], array $itemFields = [])
* @method ResultInterface deferGetOrderInfo(int $storeId,int $orderId)
* @method ResultInterface deferUpdateInfoById(int $storeId,int $orderId, array $updateInfo)
* @method ResultInterface deferGetSimpleList($storeId, $condition, $fields = ['*'])
* @method ResultInterface deferUpdateInfoByIds(int $storeId,array $orderIds, array $updateInfo)
* @method ResultInterface deferCollectionClose(int $storeId, int $orderId)
* @method ResultInterface deferGetOtherInfo(int $storeId, string $orderSn, array $consigneeFields = [], array $itemFields = [])
* @method ResultInterface deferGetList(int $storeId,array $ids)
*/
interface OrderInterface
{
/**
* 创建订单
*
* @param int $buyerId
* @param int $storeId
* @param int $consignee_id
* @param int $item_id
* @param int $selected_num
* @param int $order_type
* @param float $total
* @param float $goods_price
* @param string $goods_name
* @param string $goods_image
* @param string $activity_name
* @param int $goodsId,
* @param int $consigneeId
* @param int $itemId
* @param int $selectedNum
* @param int $orderType
* @param int $total
* @param int $activityPrice
* @param string $goodsName
* @param string $goodsImage
* @param string $activityName
* @param int $goodsId
* @param int $goodsPrice
* @param string $reservation_time
* @param string $message
* @return mixed
*/
public function createOrder(
int $buyerId,
int $storeId,
int $consignee_id,
int $item_id,
int $selected_num,
int $order_type,
float $total,
float $goods_price,
string $goods_name,
string $goods_image,
string $activity_name,
int $consigneeId,
int $itemId,
int $selectedNum,
int $orderType,
int $total,
int $activityPrice,
string $goodsName,
string $goodsImage,
string $activityName,
int $goodsId,
string $reservation_time = '');
int $goodsPrice,
string $reservation_time = '',
string $message = ''
);
public function getOrderInfo(int $storeId,int $orderId);
public function getOrderInfoBySn(int $storeId, string $orderSn);
public function getOrderInfoBySn(int $storeId, string $orderSn, array $consigneeFields = [], array $itemFields = []);
public function updateInfoById(int $storeId,int $orderId, array $updateInfo);
public function closeOrder(int $storeId,int $orderId);
/**
* 获取订单数据
* 字段值
* `id`,
`orderSn`,
`paySn`,
`orderType` '订单类型:0普通商品,1活动',
`storeId`, 店铺id
`buyerId` ,买家id
`itemId` '0',
`consigneeId` '付款人(收货人)ID,当线下订单时为空',
`goodsAmount` ,
`orderAmount` '订单应付款',
`actualAmount` '订单实付款',
`refundAmount` '退款金额',
`state` '订单状态:0(已取消)10(默认):未付款;20:已付款;30:已发货/已预约;40:已收货/已核销;50-申请退款;60退款成功,70 已关闭,80,退款中,90,已评价',
`refundState` '0' COMMENT '退款状态:0是无退款,1是部分退款,2是全部退款',
`refundMsg`'退款原因',
`lockState` '锁定状态:0是正常,大于0是锁定',
`lockMsg` '订单锁定原因',
`balanceState` '对账状态:0-未对账,1-已对账',
`balanceTime` '对账时间',
`message` ,
`reservationTime` ,
`createTime` 创建时间,
`updateTime` 更新时间,
`deleteTime` 删除时间,
`sellerId` '卖家id',
`deliveredTime` '核销时间',
*
*
* @param $storeId
* @param $condition
* @param array $fields
* @return mixed
*/
public function getSimpleList($storeId, $condition, $fields = ['*']);
/**
* 退款成功
*
* @param int $storeId
* @param array $orderInfo
* @return mixed
*/
public function refundSuccess(int $storeId, array $orderInfo);
/**
* 拼团关闭订单,含退款
*
* @param int $storeId
* @param int $orderId
* @return mixed
*/
public function collectionClose(int $storeId, int $orderId);
/**
* 批量更新
*
* @param int $storeId
* @param array $orderIds
* @param array $updateInfo
* @return mixed
*/
public function updateInfoByIds(int $storeId,array $orderIds, array $updateInfo);
/**
* 获取订单联系人信息,item信息用
*
* @param int $storeId
* @param string $orderSn
* @param array $consigneeFields
* @param array $itemFields
* @return mixed
*/
public function getOtherInfo(int $storeId, string $orderSn, array $consigneeFields = [], array $itemFields = []);
/**
* 批量获取订单信息
* [5]=>
* array(28) {
["id"]=>
string(1) "1"
["orderSn"]=>
string(20) "198bSA93091872375217"
["paySn"]=>
string(28) "4200000198201809300361147593"
["orderType"]=>
string(1) "0"
["storeId"]=>
string(3) "198"
["buyerId"]=>
string(1) "1"
["itemId"]=>
string(1) "1"
["consigneeId"]=>
string(1) "1"
["goodsAmount"]=>
string(1) "1"
["orderAmount"]=>
string(1) "1"
["actualAmount"]=>
string(1) "1"
["refundAmount"]=>
string(1) "1"
["state"]=>
string(2) "60"
["refundState"]=>
string(1) "2"
["refundMsg"]=>
string(30) "身体不适,暂时不做了"
["lockState"]=>
string(1) "0"
["lockMsg"]=>
string(0) ""
["balanceState"]=>
string(1) "0"
["balanceTime"]=>
string(1) "0"
["message"]=>
string(0) ""
["reservationTime"]=>
string(1) "0"
["createTime"]=>
string(10) "1538291872"
["updateTime"]=>
string(10) "1538291953"
["deleteTime"]=>
string(1) "0"
["sellerId"]=>
string(1) "6"
["deliveredTime"]=>
string(1) "0"
["commission"]=>
string(1) "0"
["items"]=>
array(1) {
[0]=>
array(2) {
["name"]=>
string(7) "商品1"
["image"]=>
string(72) "store-198/goods/tmp_7d07ba3c8e10c3cd65de8d98d00cbd5aace9e736ddde0c59.jpg"
}
}
}
}
*
* @param int $storeId
* @param array $ids
* @return mixed
*/
public function getList(int $storeId,array $ids);
}
\ No newline at end of file
......@@ -12,13 +12,53 @@ use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferCreateOrder(int $storeId, int $orderId, int $openId)
* @method ResultInterface deferGenerateSellerSign(int $storeId, int $orderId, string $openId)
* @method ResultInterface deferRePay(int $storeId, int $orderId, int $buyerId)
* @method ResultInterface deferSellerRePay(int $storeId, int $orderId, int $sellerId)
*
* Interface PayInterface
* @package Hdll\Services\Pay\Lib
*/
interface PayInterface
{
/**
* 买家生成签名
*
* @param int $storeId
* @param int $orderId
* @param string $openId
* @return mixed
*/
public function generateSign(int $storeId, int $orderId, string $openId);
/**
* 卖家生成签名
*
* @param int $storeId
* @param int $orderId
* @param string $openId
* @return mixed
*/
public function generateSellerSign(int $storeId, int $orderId, string $openId);
/**
* 卖家重新支付生成签名
*
* @param int $storeId
* @param int $orderId
* @param int $sellerId
* @return mixed
*/
public function sellerRePay(int $storeId, int $orderId, int $sellerId);
/**
* 买家重新支付,生成签名
*
* @param int $storeId
* @param int $orderId
* @param int $buyerId
* @return mixed
*/
public function rePay(int $storeId, int $orderId, int $buyerId);
}
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/24
* Time: 15:28
*/
namespace Hdll\Services\Reservation\Enum;
class ReservEnum
{
const TYPE_ORDER = 1; // 表示从订单创建产生的预约
const TYPE_SELLER = 2; // 表示卖家自己后台添加的预约
const TYPE_AFTER = 3; // 表示订购服务的后续服务的预约
}
\ No newline at end of file
......@@ -17,8 +17,10 @@ use Swoft\Core\ResultInterface;
* The interface of Reservation service
*
* @method ResultInterface deferGetReservById(int $storeId, int $id)
* @method ResultInterface deferGetReservListByOrderId(int $storeId, int $orderId, int $state = 0, int $type = 1)
* @method ResultInterface deferIsReserved(int $storeId, int $cmanId, int $reservTime)
* @method ResultInterface deferGetReservListByOrderId(int $storeId, int $orderId, $state = null)
* @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)
......@@ -35,15 +37,26 @@ interface ReservationInterface
public function getReservById(int $storeId, int $id);
/**
* 检查指定的时间是否已被预约过
*
* @param integer $storeId 店铺id
* @param integer $cmanId 手艺人id,查询某个手艺人下的预约情况,$cmanId == 0表示不指定手艺人,
* @param integer $reservTime 要检查的时间点,时间戳格式
* @Number(name="cmanId")
* @Number(name="reservTime")
* @return boolen true:已预约,false:未预约
*/
public function isReserved(int $storeId, int $cmanId, int $reservTime);
/**
* 根据订单id,获取商家某个订单包含的所有预约
*
* @param integer $storeId
* @param integer $orderId
* @param integer $state
* @param integer $type
* @return array
*/
public function getReservListByOrderId(int $storeId, int $orderId, int $state = 0, int $type = 1);
public function getReservListByOrderId(int $storeId, int $orderId, $state = null);
/**
* 修改某个预约信息
......@@ -53,7 +66,6 @@ interface ReservationInterface
* @param array $data
* $data 字段说明:
* ['state'] => 预约状态,默认0,如果正常结束则为1
* ['type'] => 预约类型,备用
* ['reservTime'] => 预约时间,整形,时间戳格式
* ['memo'] => 预约备注
* @return int 返回成功修改的条数
......@@ -61,6 +73,16 @@ interface ReservationInterface
public function modifyReservById(int $storeId, int $id, array $data);
/**
* 根据orderId标记订单下所有预约的状态为“已完成”
*
* @param integer $storeId
* @param integer $orderId
* @Number(name="orderId")
* @return bool 返回操作结果,true操作成功
*/
public function markReservFinished(int $storeId, int $orderId);
/**
* 添加预约
*
* @param integer $storeId
......@@ -69,10 +91,10 @@ interface ReservationInterface
* @param integer $cmanId 手艺人id
* @param integer $reservTime 预约的时间
* @param string $memo 预约备注
* @param integer $type 预约类型,备用
* @param integer $type 预约类型,传值类型参加 ../Enum/ReservEnum.php
* @return integer 添加成功则返回记录id
*/
public function addReservation(int $storeId, int $orderId, int $buyerId, int $cmanId, int $reservTime, string $memo, int $type = 1);
public function addReservation(int $storeId, int $orderId, int $buyerId, int $cmanId, int $reservTime, string $memo, int $type);
/**
* 取消某个预约
......
......@@ -18,6 +18,7 @@ use Swoft\Core\ResultInterface;
* @method ResultInterface deferAddTotal($seller, $money)
* @method ResultInterface deferReduceTotal($seller, $money)
* @method ResultInterface deferAddExpectFund($seller, $money)
* @method ResultInterface deferReduceExpectFund($seller, $money)
* @method ResultInterface deferAddFund($seller, $money)
* Interface SellerInterface
* @package App\Lib
......@@ -85,6 +86,15 @@ interface SellerFundInterface
public function addExpectFund($sellerId,$money);
/**
* 减少冻结金额
* @param $sellerId
* @param $money
* @return mixed
* @author Administrator
*/
public function reduceExpectFund($sellerId, $money);
/**
* 增加金额
* @param $sellerId
* @param $balanceFund 可提现金额
......
......@@ -14,6 +14,7 @@ use Swoft\Core\ResultInterface;
* @method ResultInterface deferSave($referId, $unionId, $openId, $nickName, $headImgUrl)
* @method ResultInterface deferGet($id,$fields=['*'])
* @method ResultInterface deferGetByUnionId($unionId,$fields=['*'])
* @method ResultInterface deferGetByStoreId($storeId,$fields=['*'])
* @method ResultInterface deferUpdate($id,$data)
* Interface SellerInterface
* @package App\Lib
......@@ -65,4 +66,12 @@ interface SellerInterface
*/
public function update($condition,$data);
/**
* @param $storeId
* @param array $fields
* @return mixed
* @author Administrator
*/
public function getByStoreId($storeId, $fields = ['*']);
}
\ No newline at end of file
......@@ -13,9 +13,7 @@ use Swoft\Core\ResultInterface;
* @method ResultInterface deferGetCommission($sellerId)
* method ResultInterface deferAddBalance($sellerId, $money)
* method ResultInterface deferReduceBalance($sellerId, $money)
* method ResultInterface deferAddTotal($sellerId, $money)
* method ResultInterface deferReduceTotal($sellerId, $money)
* method ResultInterface deferListByOrderId($storeId, $orderId)
* method ResultInterface deferListByOrderId($storeId, $orderId,$sellerId)
* Interface SellerDistributionInterface
* @package App\Lib
*/
......@@ -63,30 +61,24 @@ interface SellerDistributionInterface{
*/
public function reduceBalance($sellerId, $money);
/**
* 增加累计佣金
* @param $sellerId
* @param $money
* @return mixed
* @author Administrator
*/
public function addTotal($sellerId, $money);
/**
* 减少累计佣金
* 获取分销记录
* @param $storeId
* @param $orderId
* @param $sellerId
* @param $money
* @return mixed
* @author Administrator
*/
public function reduceTotal($sellerId, $money);
public function listByOrderId($storeId, $orderId,$sellerId);
/**
* 获取分销记录
* 更细对账表
* @param $storeId
* @param $orderId
* @param $id
* @param $balanceState 0 未对帐 1 已对账
* @return mixed
* @author Administrator
*/
public function listByOrderId($storeId, $orderId);
public function updateBill($storeId,$id,$balanceState);
}
\ No newline at end of file
<?php
namespace Hdll\Services\StateLess\Lib;
use Swoft\Core\ResultInterface;
/**
* The interface of demo service
*
* @method ResultInterface deferChecktoken(string $formtoken,int $store_id)
*/
interface StatelessInterface
{
/**
* 判断formtoken 是否有效
* @param $formtoken
* @param $store_id
* @return bool // true or false
*/
public function checktoken(string $formtoken,int $store_id);
}
\ No newline at end of file
<?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-settings service
*
* @method ResultInterface deferGetSettings(int $storeId)
*/
interface SettingsInterface
{
/**
* 获取店铺基础设置项
*
* @Number(name="storeId")
* @param int $storeId
* @return array
*/
public function getSettings(int $storeId);
}
\ No newline at end of file
......@@ -16,10 +16,13 @@ use Swoft\Core\ResultInterface;
* The interface of store service
*
* @method ResultInterface deferIsCertified(int $storeId)
* @method ResultInterface deferIsNormal(int $storeId)
* @method ResultInterface deferGetStoreByStoreId(int $storeId)
* @method ResultInterface deferGetStoreBySellerId(int $sellerId)
* @method ResultInterface deferGetStoreByMobile(int $mobile, array $fields = [])
* @method ResultInterface deferUpdateStore(int $storeId, array $data)
* @method ResultInterface deferDeleteStore(int $storeId)
* @method ResultInterface deferGetWxacodeUrl(int $storeId, int $type, string $page, string $scene)
*/
interface StoreInterface
{
......@@ -27,11 +30,20 @@ interface StoreInterface
* 查询店铺是否已实名认证(企业认证)
*
* @param integer $storeId
* @return boolean
* @return bool true:认证成功 false:未认证
*/
public function isCertified(int $storeId);
/**
* 查询店铺是否正常
*
* @Number(name="storeId")
* @param integer $storeId
* @return bool true:正常,false:冻结
*/
public function isNormal(int $storeId);
/**
* 根据店铺ID获取店铺信息
*
* @param integer $storeId
......@@ -48,6 +60,15 @@ interface StoreInterface
public function getStoreBySellerId(int $sellerId);
/**
* 根据注册手机号获取店铺信息
*
* @param integer $mobile
* @param array $fields 要查询的字段列表 :['id','storeName','addTime']
* @return array
*/
public function getStoreByMobile(int $mobile, array $fields = []);
/**
* 根据店铺ID修改店铺信息
*
* @param integer $storeId
......@@ -77,4 +98,15 @@ interface StoreInterface
* @return int 成功返回删除条数
*/
public function deleteStore(int $storeId);
/**
* 生成店铺小程序码
*
* @param integer $type 指明哪小程序,1前台小程序,2后台小程序
* @param string $page 要跳转的小程序页面,如:pages/index/index
* @param string $scene 通过小程序码传递的参数
* @return string 成功返回小程序码的图片资源名(腾讯云存储的资源名,如:store_wxacode/9a414ff3b4c478a36c2ba7df563ee88b.png)
*/
public function getWxacodeUrl(int $storeId, int $type, string $page, string $scene);
}
\ No newline at end of file
<?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 weapp service
*
* @method ResultInterface deferGetWxAccessToken(string $appId, string $appSecret)
*/
interface WeappInterface
{
/**
* 根据appId获取对应的access_token
*
* @param string $appId
* @param string $appSecret
* @return string
*/
public function getWxAccessToken(string $appId, string $appSecret);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/28
* Time: 10:15
*/
namespace Hdll\Services\Transfer\Lib;
use Swoft\Core\ResultInterface;
/**
* 提现服务
*
* @method ResultInterface deferWithdraw($paySn, $openId, $realName, $amount, $type, $storeId, $withdrawId)
* Interface WithdrawInterface
* @package Hdll\Services\Transfor\Lib
*/
interface WithdrawInterface
{
public function withdraw($paySn, $openId, $realName, $amount, $type, $storeId, $withdrawId);
}
\ No newline at end of file
......@@ -11,8 +11,6 @@ class VipEnum{
const VIP_TOTAL_FEE = 10;//价格
const PAY_NOTIFY = 'http://www.baidu.com';
const STATUS_UNPAID = 10;//未支付
const STATUS_PAID = 20;//已支付
......
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