Commit 16429991 by liwotianname

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

parents d2c84da9 c3486a12
<?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\AccountBook\Lib;
use Swoft\Core\ResultInterface;
/**
* The interface of demo service
*
* @method ResultInterface deferIncome(int $storeId, int $money,int $orderId)
* @method ResultInterface deferExpense(int $storeId, int $money,int $orderId)
*/
interface AccountInterface
{
/**
* 流水增加
* @param $storeId
* @param $money
* @param $ordirId
* @return bool
*/
public function Income($storeId, $money, $ordirId);
/**
* 流水减少
* @param $storeId
* @param $money
* @param $ordirId
* @return bool
*/
public function Expense($storeId, $money, $ordirId);
}
\ No newline at end of file
<?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_EMPLOYEE = 2; //手艺人
const SCOPE_SELLER = 3; //卖家
const SCOPE_ADMIN = 4;//管理员
const AUTH_BACKEND = 100;
const AUTH_FRONTEND = 101;
const AUTH_TYPE_SELLER = 200; //卖家授权
const AUTH_TYPE_EMPLOYEE = 201; //员工授权
const AUTH_TYPE_E_AND_S = 203; //选择授权(用户自己选择进行员工授权还是卖家授权)
const AUTH_TYPE_BUYER = 204; //买家授权
}
\ No newline at end of file
......@@ -9,14 +9,8 @@ namespace Hdll\Services\Auth\Enum;
class AuthError
{
const PARAMETER_ERR = ["msg" => "参数错误", "code" => 500, "errorCode" => 25001];
const TOKEN_ERROR = ["msg" => "token写入失败", "code" => 500, "errorCode" => 25100];
const WX_ERROR = ["msg" => "获取信息失败", "code" => 500, "errorCode" => 25101];
const CONFIG_ERROR = ["msg" => "配置不正确", "code" => 500, "errorCode" => 25102];
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)
......
<?php
/**
* Created by PhpStorm.
* User: lwt
* Date: 2018/7/10
* Time: 13:15
*/
namespace Hdll\Services\Bargain\Enum;
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
<?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\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)
*/
interface BargainInterface
{
/**
* 获取砍价商品的 商品信息
* @param int $bargain_id
* @return {
* "name" 名称
* "image" 图片
* "price" 价格
* "activityName" 活动名称
* }
*/
public function getGoodsInfo(
int $stordId, int $bargain_id
);
/**
* 通过商品id 获取是否 有砍价活动
* @param int $storeId
* @param int $goodsId
* @return bool
*
*/
public function getBargainInfo(
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);
}
\ No newline at end of file
<?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
......@@ -11,4 +11,8 @@ class BuyerEnum
{
const SCORE = 0;
//state
const STATE_NORMAL = 0;
const STATE_FREEZE = 1;
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferSaveBill(string $token,int $order_id,int $buyer_id,int $store_id,string $order_sn,int $money)
* @method ResultInterface deferGetListByOrderId(int $storeId, int $orderId)
* Interface AgencyInterface
* @package App\Lib
*/
......@@ -20,21 +21,34 @@ interface BillInterface{
/**
* 保存账单数据
* @param int $order_id
* @param int $buyer_id
* @param int $store_id
* @param string $order_sn
* @param int $money
* @param int $orderId //订单id
* @param int $buyerId // 买家id
* @param int $storeId // 店铺id
* @param string $orderSn //订单号
* @param int $money //订单金额
* @return mixed
* @author Administrator
*/
public function saveBill(
int $order_id,
int $buyer_id,
int $store_id,
string $order_sn,
int $orderId,
int $buyerId,
int $storeId,
string $orderSn,
int $money
);
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
......@@ -17,9 +17,64 @@ use Swoft\Core\ResultInterface;
*/
interface BuyerInterface
{
/**
* 获取用户信息
*
* @param int $storeId
* @param int $buyerId
* @return mixed
array(8) {
["id"]=> int(1) //买家id
["unionId"]=>string(28) "oyDnT5OYVCQUC9X9ErkDHBNrad90"
["storeId"]=>int(0)//店铺id
["referId"]=>int(0)//推荐人ID
["state"]=>int(0)//买家状态
["nickName"]=>string(0) ""//买家昵称
["openId"]=>string(0) ""//买家openId
["profile"]=>
array(4) {
["realName"]=>string(12) "真实姓名"
["gender"]=>int(1)//性别
["phoneNumber"]=>string(11) "18812345678"//手机号
["birthday"]=>int(0) //生日
}
["commission"]=>
array(3) {
["totalCommission"]=>int(10)//总共提现
["balanceCommission"]=>int(10)//可提现金额
["expectCommission"]=>int(20)//冻结提现金额
}
}
*
*/
public function getUser(int $storeId, int $buyerId);
public function updateProfile(string $token, array $data);
/**
* 更新用户信息
* $updateInfo = [
"realName" => "真实姓名",
"gender" => "性别",
"phoneNumber" => "手机号",
"birthday" => "生日"
];
* @param int $storeId
* @param array $data
* @return mixed
*/
public function updateProfile(int $storeId, array $data);
/**
* 是否已经注册用户
* @param $storeId
* @param $unionid
* @return mixed
*
* 返回值:
* array(3) {
["id"]=> int(1)//买家id
["storeId"]=> int(1) //店铺id
["referId"]=> int(0) //推荐人id
}
*/
public function hasUser($storeId,$unionid);
}
\ No newline at end of file
......@@ -19,10 +19,9 @@ interface CommissionInterface
* @param $storeId
* @param $buyerId
* @param $money
* @return mixed|bool
* @return bool
*/
public function reduceBalanceCommission($storeId, $buyerId, $money);
/**
* 增加可提现金额
*
......@@ -33,4 +32,33 @@ interface CommissionInterface
*/
public function addBalanceCommission($storeId, $buyerId, $money);
/**
* 增加可提现金额(仅限于对账服务使用,切记!!!)
*
* @param $storeId
* @param $buyerId
* @param $money
* @return bool
*/
public function addBalanceCommissionCompare($storeId, $buyerId, $money);
/**
* 增加累计现金额
*
* @param $storeId
* @param $buyerId
* @param $money
* @return bool
*/
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 {daoName}
* @package App\Models\Dao
*/
class {daoName}
{
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(array $condition, array $option)
{
return {entityName}::findAll($condition, $option)->getResult();
}
public function getInfoByCondition(array $condition, array $option)
{
return {entityName}::findOne($condition, $option)->getResult();
}
/**
* 根据条件更新信息
* @param $condition
* @param $updateInfo
* @return mixed
*/
public function updateByCondition(array $condition, array $updateInfo)
{
return {entityName}::updateAll($updateInfo, $condition)->getResult();
}
/**
* 更新一条记录
*
* @param $condition
* @param $updateInfo
* @return mixed
*/
public function updateOne(array $condition, array $updateInfo)
{
return {entityName}::updateOne($updateInfo, $condition)->getResult();
}
public function delOne(array $condition)
{
return {entityName}::deleteOne($condition)->getResult();
}
public function delAll(array $condition)
{
return {entityName}::deleteAll($condition)->getResult();
}
}
\ No newline at end of file
<?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
* -en,--en 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);
preg_match_all('/(?<={)\w+(?=})/', $content, $vars);
$vars = isset($vars[0])?$vars[0]:[];
foreach ( $vars as $var ) {
if ( strpos($var, 'var') !== false ) {
$name = str_replace('var', '', $var);
$name = lcfirst($name);
$$var = lcfirst($$name);
var_dump($var, $$var);
}
$content = str_replace("{{$var}}", $$var,$content);
}
$dataPath = file_exists($dataPath)?$dataPath.'.gen':$dataPath;
file_put_contents($dataPath, $content);
}
private function generateDao($output,$daoName, $entityName)
{
if ( empty($entityName) ) {
$output->writeln("the entity name 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);
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);
}
$daoPath = file_exists($daoPath)?$daoPath.'.gen':$daoPath;
file_put_contents($daoPath,$content);
}
/**
* 解析模板中变量
*
* @param string $content
* @return string
*/
private function parseVar(string $content):string
{
preg_match_all('/(?<={)\w+(?=})/', $content, $vars);
$vars = isset($vars[0])?$vars[0]:[];
foreach ( $vars as $var ) {
if ( strpos($var, 'var') !== false ) {
$name = str_replace('var', '', $var);
$name = lcfirst($name);
$$var = lcfirst($$name);
var_dump($var, $$var);
}
$content = str_replace("{{$var}}", $$var,$content);
}
return $content;
}
}
\ No newline at end of file
<?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}',
],
],
];
......@@ -90,16 +90,20 @@ class CommonEntity extends Model
}
$request = RequestContext::getRequest();
$testFlag = $request->query('flag');
//获取注解里的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 {
......@@ -144,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];
$defaultTableName = $tableName;
$tableName = $tableName.'_'.self::getDbNum($className);
//设置分表对应的className
EntityCollector::setCollector($tableName, $defaultTableName);
}
}
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,10 +11,10 @@
namespace Hdll\Services\Common\Entity;
use Hdll\Services\Auth\Enum\AuthError;
use Hdll\Services\Auth\Exception\AuthException;
use Hdll\Services\Common\Enum\TestEnum;
use Swoft\App;
use Swoft\Bean\Annotation\Bean;
use Swoft\Cache\Cache;
use Swoft\Core\RequestContext;
use Swoft\Redis\Redis;
/**
......@@ -28,139 +28,110 @@ use Swoft\Redis\Redis;
*/
class User
{
private $id=2;
private $nickname;
private $storeId;
private $headImg;
private $token="3333E";
private $cmId;
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)
{
if ( empty($value) ) {
return [false,AuthError::GET_TOKEN_ERROR];
}
/**
* @var Redis $redis
*/
$redis = App::getBean(Redis::class);
$info = $redis->get('AUTH:'.$value);
if ( empty($info) ) {
return [false,AuthError::NOT_FOUND_USER];
}
$info = json_decode($info, true);
$this->fill($info);
$this->token = $value;
return true;
$this->setValue('token', $value);
}
public function setCmId($value)
public function setSubStoreId($value)
{
$this->cmId = $value;
$this->setValue('subStoreId', $value);
}
public function getCmId()
public function getSubStoreId()
{
return $this->cmId;
return $this->getValue('subStoreId')??0;
}
public function fill($arr)
{
foreach ($arr as $name => $value) {
......@@ -174,31 +145,67 @@ 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');
}
public function initUser($token)
{
if ( empty($token) ) {
return [false,AuthError::GET_TOKEN_ERROR];
}
$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);
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;
}
......@@ -9,7 +9,7 @@ namespace Hdll\Services\Common\Exception;
class ExceptionParseData
{
public static function parseData(\Exception $e)
public static function parseData(\Throwable $e)
{
if ( is_callable([$e,'getResponse']) ) {
$response = $e->getResponse();
......@@ -19,6 +19,7 @@ class ExceptionParseData
$msg = isset($data['0'])?$data['0']:'';
$data = json_decode($msg,true);
$data = empty($data)?$response:$data;
} else {
$data['msg'] = $e->getMessage();
$data['code'] = 500;
......
......@@ -39,10 +39,8 @@ class Alisms
// 短信模板预设参数
$this->templateParam = $templateParam;
$configurator = \Swoft\App::getBean('config');
$configurator->load('@vendor/hdll/services/src/Common/Config');
$this->config = $configurator->get('alisms');
$commonConfigs = include dirname(__FILE__, 2).'/Config/config.php';
$this->config = $commonConfigs['alisms'];
}
/**
......
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/20
* Time: 16:34
*/
namespace Hdll\Services\Common\Lib;
use Swoft\App;
use Swoft\Redis\Operator\Processor\PrefixProcessor;
class Redis extends \Swoft\Redis\Redis
{
private $prefix;
/**
* 设置redis前缀
* @param $prefix
*/
public function setPrefix($prefix)
{
$this->prefix = $prefix;
}
public function call(string $method, array $params)
{
$config = App::getBean(PrefixProcessor::class);
$config->setPrefix($this->prefix);
$res = parent::call($method, $params);
$config->setPrefix(config("redis.prefix",''));
return $res;
}
public function __destruct()
{
$config = App::getBean(PrefixProcessor::class);
$config->setPrefix(config("redis.prefix",''));
}
}
\ No newline at end of file
......@@ -21,11 +21,15 @@ use Hdll\Services\Common\Entity\User;
class Smscode
{
protected $sellerId;
protected $number;
public function __construct()
public function __construct($number = null)
{
$this->sellerId = App::getBean(User::class)->getId();
if($number !== null) {
$this->number = $number;
} else {
$this->number = App::getBean(User::class)->getId();
}
}
/**
......@@ -53,7 +57,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,
......@@ -93,7 +97,7 @@ class Smscode
private function getKey($mobile)
{
return 'smscode:' . md5($this->sellerId . '|' . $mobile);
return 'smscode:' . md5($this->number . '|' . $mobile);
}
}
\ No newline at end of file
......@@ -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
<?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 AccountBookPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_ACCOUNTBOOK_URI', 'accountbook:8099'));
}
protected $name = 'accountbook';
/**
* 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 = [
'timelimtbuy: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 = '';
}
<?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\Bean\Annotation\Value;
use Swoft\Pool\PoolProperties;
/**
* the config of service user
*
* @Bean()
*/
class AuthPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_AUTH_URI', 'auth:8099'));
}
/**
* the name of pool
*
*/
protected $name = 'auth';
/**
* Minimum active number of connections
*
*/
protected $minActive = 5;
/**
* the maximum number of active connections
*
*/
protected $maxActive = 50;
/**
* the maximum number of wait connections
*
*/
protected $maxWait = 100;
/**
* Maximum waiting time
*
*/
protected $maxWaitTime = 3;
/**
* Maximum idle time
*
*/
protected $maxIdleTime = 60;
/**
* the time of connect timeout
*
*/
protected $timeout = 200;
/**
* the addresses of connection
*
* <pre>
* [
* '127.0.0.1:88',
* '127.0.0.1:88'
* ]
* </pre>
*
*/
protected $uri = [
"auth:8099",
// "172.21.0.19:8099",
// "172.16.255.39:8099"
];
/**
* whether to user provider(consul/etcd/zookeeper)
*
*/
protected $useProvider = false;
/**
* the default balancer is random balancer
*
*/
protected $balancer = '';
/**
* the default provider is consul provider
*
*/
protected $provider = '';
}
<?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 BargainPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_BARGAIN_URI', 'bargain:8099'));
}
protected $name = 'bargain';
/**
* 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 = [
'bargain: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 = '';
}
......@@ -21,6 +21,13 @@ use Swoft\Pool\PoolProperties;
*/
class BuyerPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_BUYER_URI', 'buyer:8099'));
}
/**
* the name of pool
*
......@@ -61,7 +68,7 @@ class BuyerPoolConfig extends PoolProperties
* the time of connect timeout
*
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......@@ -75,8 +82,7 @@ class BuyerPoolConfig extends PoolProperties
*
*/
protected $uri = [
"172.21.0.12:8099",
"172.16.255.33:8099"
"buyer: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 coupon
*
* @Bean()
*/
class CouponPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_COUPON_URI', 'coupon:8099'));
}
protected $name = 'coupon';
/**
* 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 = '';
}
<?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 craftsman
*
* @Bean()
*/
class CraftsmanPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_CRAFTSMAN_URI', 'craftsman:8099'));
}
protected $name = 'craftsman';
/**
* 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 = '';
}
......@@ -20,6 +20,13 @@ use Swoft\Pool\PoolProperties;
*/
class GoodsPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
// $this->uri = explode(',', env('RPC_GOODS_URI', '172.21.0.47:8099,172.16.255.235:8099'));
$this->uri = explode(',', env('RPC_GOODS_URI', 'goods:8099'));
}
protected $name = 'seller';
......@@ -63,7 +70,7 @@ class GoodsPoolConfig 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;
/**
* the config of service user
*
* @Bean()
*/
class GroupBookingPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
// $this->uri = explode(',', env('RPC_GROUPBOOKING_URI', '172.21.0.38:8099,172.16.255.27:8099'));
$this->uri = explode(',', env('RPC_GROUPBOOKING_URI', 'group-booking:8099'));
}
protected $name = 'groupBooking';
/**
* 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 = [
'192.168.3.39:8200',
];
/**
* 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 = '';
}
<?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\Bean\Annotation\Value;
use Swoft\Pool\PoolProperties;
/**
* the config of service user
*
* @Bean()
*/
class NoticePoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_NOTICE_URI', 'notice:8099'));
}
/**
* the name of pool
*
*/
protected $name = 'pay';
/**
* Minimum active number of connections
*
*/
protected $minActive = 5;
/**
* the maximum number of active connections
*
*/
protected $maxActive = 50;
/**
* the maximum number of wait connections
*
*/
protected $maxWait = 100;
/**
* Maximum waiting time
*
*/
protected $maxWaitTime = 3;
/**
* Maximum idle time
*
*/
protected $maxIdleTime = 60;
/**
* the time of connect timeout
*
*/
protected $timeout = 200;
/**
* the addresses of connection
*
* <pre>
* [
* '127.0.0.1:88',
* '127.0.0.1:88'
* ]
* </pre>
*
*/
protected $uri = [
"192.168.3.100:8102",
];
/**
* whether to user provider(consul/etcd/zookeeper)
*
*/
protected $useProvider = false;
/**
* the default balancer is random balancer
*
*/
protected $balancer = '';
/**
* the default provider is consul provider
*
*/
protected $provider = '';
}
......@@ -19,6 +19,12 @@ use Swoft\Pool\PoolProperties;
*/
class OrderPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_ORDER_URI', 'order:8099'));
}
protected $name = 'order';
......@@ -27,7 +33,7 @@ class OrderPoolConfig extends PoolProperties
*
* @var int
*/
protected $minActive = 5;
protected $minActive = 15;
/**
* the maximum number of active connections
......@@ -62,7 +68,7 @@ class OrderPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......@@ -77,7 +83,7 @@ class OrderPoolConfig extends PoolProperties
* @var array
*/
protected $uri = [
'192.168.3.100:8084',
'order: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\Bean\Annotation\Value;
use Swoft\Pool\PoolProperties;
/**
* the config of service user
*
* @Bean()
*/
class PayPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_PAY_URI', 'pay:8099'));
}
/**
* the name of pool
*
*/
protected $name = 'pay';
/**
* Minimum active number of connections
*
*/
protected $minActive = 5;
/**
* the maximum number of active connections
*
*/
protected $maxActive = 50;
/**
* the maximum number of wait connections
*
*/
protected $maxWait = 100;
/**
* Maximum waiting time
*
*/
protected $maxWaitTime = 3;
/**
* Maximum idle time
*
*/
protected $maxIdleTime = 60;
/**
* the time of connect timeout
*
*/
protected $timeout = 200;
/**
* the addresses of connection
*
* <pre>
* [
* '127.0.0.1:88',
* '127.0.0.1:88'
* ]
* </pre>
*
*/
protected $uri = [
"192.168.3.100:8102",
];
/**
* whether to user provider(consul/etcd/zookeeper)
*
*/
protected $useProvider = false;
/**
* the default balancer is random balancer
*
*/
protected $balancer = '';
/**
* the default provider is consul provider
*
*/
protected $provider = '';
}
<?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 user
*
* @Bean()
*/
class ReservationPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_RESERVATION_URI', 'reservation:8099'));
}
protected $name = 'reservation';
/**
* 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 = '';
}
<?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 user
*
* @Bean()
*/
class SchedulePoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_SCHEDULE_URI', 'schedule:8099'));
}
protected $name = 'schedule';
/**
* 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 = '';
}
......@@ -21,6 +21,13 @@ use Swoft\Pool\PoolProperties;
class SellerDistributionPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_SELLER_DISTRIBUTION_URI', 'seller-distribution:8099'));
// $this->uri = explode(',', env('RPC_SELLER_DISTRIBUTION_URI', '172.21.0.17:8099,172.16.255.34:8099'));
}
protected $name = 'sellerDistribution';
/**
......@@ -63,7 +70,7 @@ class SellerDistributionPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -21,6 +21,12 @@ use Swoft\Pool\PoolProperties;
class SellerPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_SELLER_URI', 'seller:8099'));
}
protected $name = 'seller';
/**
......@@ -63,7 +69,7 @@ class SellerPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......@@ -78,7 +84,7 @@ class SellerPoolConfig extends PoolProperties
* @var array
*/
protected $uri = [
'192.168.3.39:8099',
'192.168.3.39: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;
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 = '';
}
......@@ -20,6 +20,11 @@ use Swoft\Pool\PoolProperties;
*/
class StorePoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_STORE_URI', 'store:8099'));
}
protected $name = 'storeId';
......@@ -63,7 +68,7 @@ class StorePoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......@@ -74,12 +79,9 @@ class StorePoolConfig extends PoolProperties
* '127.0.0.1:88'
* ]
* </pre>
*
* @var array
*/
protected $uri = [
'192.168.3.23:8098',
];
protected $uri = [];
/**
* whether to user provider(consul/etcd/zookeeper)
......
<?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 TimeLimitBuyPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_TIMELIMITBUY_URI', 'timelimitbuy:8099'));
}
protected $name = 'timelimitname';
/**
* 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 = [
'timelimtbuy: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 = '';
}
<?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 = '';
}
......@@ -21,6 +21,13 @@ use Swoft\Pool\PoolProperties;
class VipPoolConfig extends PoolProperties
{
public function __construct()
{
// 区别本地和线上的RPC服务地址
// $this->uri = explode(',', env('RPC_VIP_URI', '172.21.0.10:8099,172.16.255.196:8099'));
$this->uri = explode(',', env('RPC_VIP_URI', 'vip:8099'));
}
protected $name = 'seller';
/**
......@@ -63,7 +70,7 @@ class VipPoolConfig 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;
/**
* the config of service WithdrawCash
*
* @Bean()
*/
class WithdrawCashPoolConfig extends PoolProperties
{
public function __construct()
{
$this->uri=explode(',',env('RPC_WITHDRAWCASH_URI','draw-money:8099'));
}
protected $name = 'withdrawCash';
/**
* 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 = '';
}
<?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/8/24
* Time: 15:28
*/
namespace Hdll\Services\Coupon\Enum;
class CouponEnum
{
// 优惠券状态:
const STATE_NOT_USED = 1; // 表示优惠券还未使用
const STATE_ORDER_HOLD = 2; // 表示订单下单时已占用,但还未真正使用
const STATE_USED = 3; // 表示优惠券已被使用
}
\ 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\Coupon\Lib;
use Swoft\Core\ResultInterface;
/**
* The interface of coupon service
*
* @method ResultInterface deferCheckCoupon(int $buyerId, int $storeId, int $couponId, int $itemId)
* @method ResultInterface deferGetCouponRecvdList(int $buyerId, int $storeId, int $subStoreId = 0, int $itemId = 0)
* @method ResultInterface deferGetDataByCouponId(int $buyerId, int $storeId, int $couponId)
*/
interface CouponInterface
{
// 优惠券服务的字段说明:
// storeId
// subStoreId
// buyerId 买家ID
// state 状态,1未使用,2已下单还未付款,3已使用过
// couponId 当时领取的原始优惠券Id
// couponName 当时领取的原始优惠券名字
// parValue 优惠券面值
// allowItems 优惠券允许使用的商品列表
// addTime 领取时间
// usedTime 被使用的时间
/**
* 校验优惠券是否可用
*
* @param integer $buyerId
* @param integer $storeId
* @param integer $couponId
* @param integer $itemId
* @return int|boolen 如果可用返回优惠券的面值,不可用返回false
*/
public function checkCoupon(int $buyerId, int $storeId, int $couponId, int $itemId);
/**
* 更新优惠券状态
*
* @param integer $buyerId
* @param integer $storeId
* @param integer $couponId
* @param integer $state 优惠券的状态
* @return int 返回受影响的行数
*/
public function updateCouponState(int $buyerId, int $storeId, int $couponId, int $state);
/**
* 获取顾客领取的优惠券列表
*
* @param integer $buyerId
* @param integer $storeId
* @param integer $subStoreId
* @param integer $itemId
* @return array
*/
public function getCouponRecvdList(int $buyerId, int $storeId, int $subStoreId = 0, int $itemId = 0);
/**
* 根据优惠券ID获取信息
*
* @param integer $buyerId
* @param integer $storeId
* @param integer $couponId
* @return array
*/
public function getDataByCouponId(int $buyerId, int $storeId, int $couponId);
}
\ 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\Craftsman\Lib;
use Swoft\Core\ResultInterface;
/**
* The interface of craftsman service
*
* @method ResultInterface deferGetCraftsmenList(int $storeId, int $subStoreId = 0, int $itemId = 0)
* @method ResultInterface deferGetCraftsmenByUnionId(string $unionId)
* @method ResultInterface deferGetCraftsmenById(int $storeId, int $cmanId)
*/
interface CraftsmanInterface
{
// 店员服务的字段说明:
// name 店员名字
// sex 性别
// mobile 店员手机
// inReview 审核状态,1审核中,2审核通过
// headimg 店员头像
// items 服务项目id列表,逗号隔开
// subStores 子店铺id列表,逗号隔开
// motto 个人签名
// adept 个人擅长说明
// wechat 店员微信号
/**
* 获取店员列表
*
* @param integer $storeId
* @param integer $subStoreId 子店铺Id
* @param integer $itemId 服务项目(商品)id
*
* @return array
*/
public function getCraftsmenList(int $storeId, int $subStoreId = 0, int $itemId = 0);
/**
* 根据unionId获取店员信息
*
* @param string $unionId
* @return array
*/
public function getCraftsmenByUnionId(string $unionId);
/**
* 根据店铺Id和店员Id获取店员信息
*
* @param integer $storeId
* @param integer $cmanId
* @return array
*/
public function getCraftsmenById(int $storeId, int $cmanId);
}
\ 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
......@@ -11,29 +11,76 @@ namespace Hdll\Services\Goods\Lib;
use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferGet($storeId,$id)
* @method ResultInterface deferGetList($storeId,$page,$limit)
* @method ResultInterface deferGet($storeId, $id)
* @method ResultInterface deferIncSales($storeId, $goodsId)
* @method ResultInterface deferDecSales($storeId, $goodsId)
* @method ResultInterface deferGetServiceByGoodsId($storeId, $goodsId)
* @method ResultInterface deferGetReturnVisitByGoodsId($storeId, $goodsId)
* Interface GoodsInterface
* @package Hdll\Services\Goods\Lib
*/
interface GoodsInterface{
interface GoodsInterface
{
/**
* 获取商品
* @param $storeId
* @return [
* 'gcId' 商品类ID
* 'asId' 服务ID
* 'stock' 库存
* 'name' 名称
* 'image' 图片
* 'price' 价格
* 'state' 状态
* 'body' 描述
* 'originalPrice' 原价
* 'sales' 销量
* ]
* @param $id
* @return mixed
* @author Administrator
*/
public function get($storeId,$id);
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);
/**
* 获取商品列表
* 获取用户回访
* @param $storeId
* @param $page
* @param $limit
* @param $goodsId
* @return mixed
* @author Administrator
*/
public function getList($storeId,$page,$limit);
public function getReturnVisitByGoodsId($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
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/8
* Time: 10:43
*/
namespace Hdll\Services\GroupBooking\Lib;
use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferPaySuccess($orderId)
* @method ResultInterface deferHasActivity($storeId,$goodsId)
* Interface GoodsInterface
* @package Hdll\Services\Goods\Lib
*/
interface GroupBookingInterface{
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,13 +10,13 @@
namespace Hdll\Services\LimitTimeBuy\Lib;
use Hdll\Services\LimitTimeBuy\Enum\LimitTimeOrderEnum;
use Swoft\Core\ResultInterface;
/**
* The interface of demo service
*
* @method ResultInterface deferBackNum(string $token, int $consignee_id, int $limit_id, int $selected_num, int $order_type, int $goods_id, string $reservation_time = '')
*/
interface LimitTimeBuyInterface
{
......@@ -39,5 +39,46 @@ interface LimitTimeBuyInterface
int $selected_num,
int $order_type,
int $goods_id,
string $reservation_time = '');
string $reservation_time);
/**
* 获取限时购商品的 商品信息
* @param int $limit_id
* @return {
* "name" 名称
* "image" 图片
* "price" 价格
* "activityName" 活动名称
* }
*/
public function getLimitGoods(
int $storeId, int $limitId
);
/**
* 通过商品id 获取是否 有限时购活动
* @param int $storeId
* @param int $goodsId
* @return bool
*
*/
public function getLimitInfo(
int $storeId, int $goodsId
);
/**
* 支付 状态 回馈接口
* @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
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/24
* Time: 11:09
*/
namespace Hdll\Services\Notice\Enum;
class FormIdEnum
{
const TYPE_FORM = 1;
const TYPE_PAY = 2;
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/5
* Time: 13:15
*/
namespace Hdll\Services\Notice\Enum;
class NoticeEnum
{
//商家小程序发送
const TYPE_MINI_BACKEND_SEND= 100;
//腾讯sms发送
const TYPE_TENCENT_SMS = 150;
//买家小程序消息推送
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_MP_SEND,
];
}
\ 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
<?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_";
const ORDER_RESERVATION_NOTICE = self::PREFIX."order_reservation_notice_";
}
\ 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 === null?[]:$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 === null?[]:$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 === null?[]:$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;
private $storeId;
public function __construct(string $phone, string $template, array $param, int $storeId)
{
$this->phone = $phone;
$this->template = $template;
$this->param = $param;
$this->storeId = $storeId;
}
public function format()
{
$this->data[$this->sendType] = [
[
'storeId' => $this->storeId,
'templateId' => $this->template,
'phoneNumber' => $this->phone,
'param' => $this->param,
]
];
}
public function getData()
{
return $this->data === null?[]:$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 $sendTime
* @param mixed ...$senders
* @return bool|mixed
*/
public function send($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 = array_merge($sender->getSendType(), $sendType);
}
return $this->notice->send($sendType, $data, $sendTime);
}
}
\ 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\Notice\Lib;
use Swoft\Core\ResultInterface;
/**
* The interface of demo service
*
* @method ResultInterface deferSend(int $storeId, array $sendTypes, array $data, $sendTime, string $redisKey) :bool
* @method ResultInterface deferCancelSend(string $redisKey):bool
*/
interface NoticeInterface
{
/**
* 参数说明
*
* 微信发送消息数据结构
* $data[NoticeEnum::TYPE_MINI_BACKEND_SEND] = [
"uid" => 1, //用户的id
* "storeId" => 1, //店铺id
"template_id" => "1kZ_RkkWfRrpufXNdmJYBpIhgk7ccCtPrypeJQ9WRwM",//消息模板id
"page" => "index", //消息模板页面
"data" => [ //消息模板数据
"keyword1" => [
"value" => "商品名称",
],
"keyword2" => [
"value" => "A8204427546131350100",
],
"keyword3" => [
"value" => "¥30",
],
"keyword4" => [
"value" => date('Y-m-d'),
]
]
];
*
* 短信发送消息数据结构
$data[NoticeEnum::TYPE_TENCENT_SMS] = [
[
'storeId' => 198
"templateId" => "178822", //模板id
"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 $sendTime //如果需要多个时间段发送则填写时间戳数组例如:[15800000,1580000]
* @param string $redisKey //发送事件的redis key(如果定时发送消息,中途需要取消则需要传入此项)
* @return mixed
*/
public function send(array $sendTypes, array $data, $sendTime, string $redisKey='') :bool;
/**
* 取消定时消息发送
*
* @param string $redisKey
* @return bool
*/
public function cancelSend(string $redisKey):bool ;
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/23
* Time: 13:42
*/
namespace Hdll\Services\Order\Enum;
class ConsigneeEnum
{
const DEFAULT_ENABLE = 1;
const DEFAULT_DISABLE = 0;
const DEFAULT_ALLOW_VALUE = [
self::DEFAULT_DISABLE,
self::DEFAULT_ENABLE
];
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/24
* Time: 15:28
*/
namespace Hdll\Services\Order\Enum;
class OrderCate
{
const TYPE_BUYER = 1;
const TYPE_SELLER = 2;
}
\ No newline at end of file
......@@ -21,11 +21,45 @@ class OrderEnum
const STATUS_CANCEL = 0; //已取消
const STATUS_CLOSED = 70; //已关闭
const STATUS_REFUNDING = 80; //退款中
const STATUS_EVALUATION = 90; //已评价
const STATUS_COLLECTION = 100; //团购进行中
//订单类型
const TYPE_GOODS = 0; //商品订单
const TYPE_KANJIA = 1; //砍价订单
const TYPE_CUT_PRICE = 1; //砍价订单
const TYPE_LIMIT = 2; //限时购订单
const TYPE_COLLECTION = 3; //拼团
//对账锁定
const LOCK = 1; //订单锁定
const ORDER_TYPES = [
self::TYPE_GOODS,
self::TYPE_CUT_PRICE,
self::TYPE_LIMIT,
self::TYPE_COLLECTION,
];
//可以直接预约的订单类型
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,
self::STATUS_EVALUATION
];
//对账状态
const BALANCE_STATE_FALSE = 0; //未对账
......
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/20
* Time: 11:13
*/
namespace Hdll\Services\Order\Enum;
class OrderError
{
//common
const PARAMETER_ERR = ["msg" => "参数错误", "code" => 400, "errorCode" => 22001];
const PERMISSION_DENIED = ["msg" => "没有权限,%s", "code" => 401, "errorCode" => 22104];
//validator
const UNDEFINED_VALIDATOR = ["msg" => "未定义验证其验证器%s","code" => 500, "errorCode" => 22100];
const EMPTY_COMPARE_VALUE = ["msg" => "对比数值不能为空", "code" => 500, "errorCode" => 22101];
const UNKONW_OPERATION = ["msg" => "未知操作符%s", "code" => 500, "errorCode" => 22102];
//联系人
const NO_FOUND_CONSIGNEE = ["msg" => "未找到联系人信息", "code" => 404, "errorCode" => 22103];
//预约
const RESERVATION_OVERRUN = ["msg" => "预约时间不能早于当前时间", "code" => 400, "errorCode" => 22105];
const RES_IS_REST = ["msg" => "休息日不能添加预约", "code" => 400, "errorCode" => 22106];
//买家
const FREEZE = ["msg" => "休息日不能添加预约", "code" => 400, "errorCode" => 22107];
//order
const O_PRICE_ABNORMAL = ["msg" => "价格异常,请重新购买", "code" => 400, "errorCode" => 22108];
const O_TYPE_ERR = ["msg" => "订单类型不正确", "code" => 400, "errorCode" => 22109];
const O_CREATE_ERR = ["msg" => "创建订单失败", "code" => 500, "errorCode" => 22110];
const O_GOODS_SAVE_ERR = ["msg" => "商品订单存入失败", "code" => 500, "errorCode" => 22111];
const O_CUT_PRICE_SAVE_ERR = ["msg" => "砍价订单存入失败", "code" => 500, "errorCode" => 22115];
const O_NOT_FOUND = ["msg" => "订单不存在", "code" => 404, "errorCode" => 22116];
const O_STATUS_ERR = ["msg" => "订单状态错误,无法操作", "code" => 400, "errorCode" => 22117];
const DB_ERROR = ["msg" => "数据库操作错误", "code" => 500, "errorCode" => 22118];
public static function atranslate($message,$param)
{
if ( empty($param) ) {
return $message;
}
array_unshift($param,$message);
return sprintf(...$param);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/17
* Time: 16:23
*/
namespace Hdll\Services\Order\Enum;
class OrderItemEnum
{
const NORMAL = 1; //正常
const CLOSED = 2;//关闭
const DELIVERED = 3;//核销
const LOCKED = 4;//锁定
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/24
* Time: 13:56
*/
namespace Hdll\Services\Order\Enum;
class SellerOrderEnum
{
const TYPE_VALUE_ADDED_SERVICE = 1; //增值服务
//订单状态
const STATUS_UNPAID = 10; //待支付
const STATUS_PAID = 20; //已支付
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/17
* Time: 9:37
*/
namespace Hdll\Services\Order\Enum;
class ValueAddedServiceEnum
{
const VIP = 1; //vip服务
}
\ No newline at end of file
......@@ -15,38 +15,233 @@ 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,string $reservation_time = '')
* @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)
* @method ResultInterface deferUnconfirmedCount(int $storeId)
*/
interface OrderInterface
{
/**
* 创建订单
* @param string $token
* @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 $buyerId
* @param int $storeId
* @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(
string $token,
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,
string $reservation_time = '');
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 = ''
);
public function getOrderInfo(int $storeId,int $orderId);
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);
/**
* 统计核销
*
* array(2) {
["money"]=>
string(1) "8"
["orders"]=>
string(1) "6"
}
* @param int $storeId
* @return mixed
*/
public function unconfirmedCount(int $storeId);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/24
* Time: 13:57
*/
namespace Hdll\Services\Order\Lib;
interface SellerOrderInterface
{
public function sellerCreateOrder(
int $sellerId,
int $storeId,
int $itemId,
int $selectedNum,
int $orderType,
float $total,
float $goodsPrice,
string $goodsName
);
public function getOrderInfo(int $storeId,int $orderId);
public function getOrderInfoBySn(int $storeId, string $orderSn);
public function updateInfoById(int $storeId,int $orderId, array $updateInfo);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/9
* Time: 13:44
*/
namespace Hdll\Services\Pay\Lib;
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; // 表示订购服务的后续服务的预约
const TYPE_BUYER = 4; // 表示买家自己手动添加的预约
}
\ No newline at end of file
......@@ -16,60 +16,93 @@ use Swoft\Core\ResultInterface;
/**
* The interface of Reservation service
*
* @method ResultInterface deferGetReservById(int $id)
* @method ResultInterface deferGetReservByDateId(int $storeId, int $dateId)
* @method ResultInterface deferGetReservListByOrderId(int $storeId, $orderId)
* @method ResultInterface deferModifyReservById(int $id)
* @method ResultInterface deferCancelReservById(int $id)
* @method ResultInterface deferGetReservById(int $storeId, int $id)
* @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 deferCancelReservByOrderId(int $storeId, int $orderId, string $memo)
*/
interface ReservationInterface
{
/**
* 获取某个预约的信息
*
* @param integer $storeId,
* @param integer $id
* @return array
*/
public function getReservById(int $id);
public function getReservById(int $storeId, int $id);
/**
* 根据日期id,获取商家某一天的所有预约
* 检查指定的时间是否已被预约过
*
* @param integer $storeId
* @param integer $dateId
* @return array
* @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 getReservByDateId(int $storeId, int $dateId);
public function isReserved(int $storeId, int $cmanId, int $reservTime);
/**
* 根据订单id,获取商家某个订单包含的所有预约
*
* @param integer $storeId
* @param integer $orderId
* @return void
* @param integer $state
* @return array
*/
public function getReservListByOrderId(int $storeId, int $orderId);
public function getReservListByOrderId(int $storeId, int $orderId, $state = null);
/**
* 修改某个预约信息
*
* @param integer $storeId,
* @param integer $id
* @param array $data
* $data 字段说明:
* ['state'] => 预约状态,默认0,如果正常结束则为1
* ['type'] => 预约类型,备用
* ['reservTime'] => 预约时间,时间戳格式
* ['isConfirm'] => 1表示商家确认预约
* ['reservTime'] => 预约时间,整形,时间戳格式
* ['memo'] => 预约备注
* @return int 返回成功修改的条数
*/
public function modifyReservById(int $id, array $data);
public function modifyReservById(int $storeId, int $id, array $data);
/**
* 取消某个预约
* 根据orderId标记订单下所有预约的状态为“已完成”
*
* @param integer $id
* @param integer $storeId
* @param integer $orderId
* @Number(name="orderId")
* @return bool 返回操作结果,true操作成功
*/
public function markReservFinished(int $storeId, int $orderId);
/**
* 添加预约
*
* @param integer $storeId
* @param integer $orderId
* @param integer $buyerId
* @param integer $cmanId 手艺人id
* @param integer $reservTime 预约的时间
* @param string $memo 预约备注
* @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);
/**
* 根据订单id取消该订单下的所有预约
*
* @param integer $storeId
* @param integer $orderId
* @param string $memo
* @return boolean 返回取消结果
*/
public function cancelReservById(int $id);
public function cancelReservByOrderId(int $storeId, int $orderId, string $memo = '');
}
\ No newline at end of file
......@@ -16,10 +16,10 @@ use Swoft\Core\ResultInterface;
/**
* The interface of Schedule service
*
* @method ResultInterface deferGetScheduleList(int $storeId, int $month=null)
* @method ResultInterface deferGetScheduleByDateId(int $storeId, int $dateId)
* @method ResultInterface deferUpdateSchedule(int $storeId, int $dateId, array $data)
* @method ResultInterface deferAddSchedule(int $storeId, int $dateId, array $data)
* @method ResultInterface deferGetScheduleList(int $storeId, int $month, int $cmanId = 0)
* @method ResultInterface deferGetScheduleByDateId(int $storeId, int $dateId, int $cmanId = 0)
* @method ResultInterface deferUpdateSchedule(int $storeId, int $cmanId, int $dateId, array $data)
* @method ResultInterface deferAddSchedule(int $storeId, int $cmanId, int $dateId, array $data)
*/
interface ScheduleInterface
{
......@@ -27,24 +27,26 @@ interface ScheduleInterface
* 获取店铺所有日程列表
*
* @param integer $storeId
* @param integer $month 可选参数 指定要查哪个月份的日程列表,格式如:201810
* @param integer $month 指定要查哪个月份的日程列表,格式如:201810
* @return array 空数组表示没有查询到记录
*/
public function getScheduleList(int $storeId, int $month = null);
public function getScheduleList(int $storeId, int $month, int $cmanId = 0);
/**
* 获取某天的日程信息
*
* @param integer $storeId
* @param integer $dateId 要查询的日期id,格式要求如:20180803
* @param integer $cmanId 手艺人ID,可查询指定手艺人的日程安排,为0时表示店铺级别的日程
* @return array 空数组表示没有查询到记录
*/
public function getScheduleByDateId(int $storeId, int $dateId);
public function getScheduleByDateId(int $storeId, int $dateId, int $cmanId = 0);
/**
* 根据dateId修改某个日程的信息
*
* @param integer $storeId
* @param integer $cmanId 手艺人ID,可修改指定手艺人的日程安排,$cmanId==0 时表示修改店铺级别的日程
* @param integer $dateId 要修改的日期id,格式要求如:20180803
* @param array $data
* 参数 $data 字段说明:
......@@ -52,12 +54,13 @@ interface ScheduleInterface
*
* @return int 成功更新的条数
*/
public function updateSchedule(int $storeId, int $dateId, array $data);
public function updateSchedule(int $storeId, int $cmanId, int $dateId, array $data);
/**
* 添加一个日程安排
*
* @param integer $storeId
* @param integer $cmanId 手艺人ID,给指定的手艺人添加日程安排,$cmanId==0 时表示添加店铺级别的日程
* @param integer $dateId 要添加的日期id,格式要求如:20180803
* @param array $data
* 参数 $data 字段说明:
......@@ -65,5 +68,6 @@ interface ScheduleInterface
*
* @return int
*/
public function addSchedule(int $storeId, int $dateId, array $data);
public function addSchedule(int $storeId, int $cmanId, int $dateId, array $data);
}
\ No newline at end of file
......@@ -12,13 +12,57 @@ use Swoft\Core\ResultInterface;
/**
*
* @method ResultInterface deferGetFund($sellerId)
* @method ResultInterface deferGetFund($seller)
* @method ResultInterface deferAddBalance($seller, $money)
* @method ResultInterface deferReduceBalance($seller, $money)
* @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
*/
interface SellerFundInterface
{
/**
* 增加提现金额
* @param $seller
* @param $money
* @return mixed
* @author Administrator
*/
public function addBalance($seller, $money);
/**
* 减少提现金额
* @param $seller
* @param $money
* @return mixed
* @author Administrator
*/
public function reduceBalance($seller, $money);
/**
* 增加总提现金额
* @param $seller
* @param $money
* @return mixed
* @author Administrator
*/
public function addTotal($seller, $money);
/**
* 减少总提现金额
* @param $seller
* @param $money
* @return mixed
* @author Administrator
*/
public function reduceTotal($seller, $money);
/**
*
* @param $sellerId
......@@ -32,4 +76,31 @@ interface SellerFundInterface
*/
public function getFund($sellerId);
/**
* 增加冻结金额
* @param $sellerId
* @param $money
* @return mixed
* @author Administrator
*/
public function addExpectFund($sellerId,$money);
/**
* 减少冻结金额
* @param $sellerId
* @param $money
* @return mixed
* @author Administrator
*/
public function reduceExpectFund($sellerId, $money);
/**
* 增加金额
* @param $sellerId
* @param $balanceFund 可提现金额
* @param $commissionFund 佣金
* @return mixed
* @author Administrator
*/
public function addFund($sellerId, $balanceFund, $commissionFund);
}
\ No newline at end of file
......@@ -11,9 +11,12 @@ namespace Hdll\Services\Seller\Lib;
use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferSave($referId, $unionId, $openId, $nickName, $headImgUrl, $realName, $phoneNumber)
* @method ResultInterface deferSave($referId, $unionId, $openId, $nickName, $headImgUrl)
* @method ResultInterface deferGet($id,$fields=['*'])
* @method ResultInterface deferUpdate($id)
* @method ResultInterface deferGetByUnionId($unionId,$fields=['*'])
* @method ResultInterface deferGetByStoreId($storeId,$fields=['*'])
* @method ResultInterface deferUpdate($id,$data)
* @method ResultInterface deferCountDistributionNum($sellerId)
* Interface SellerInterface
* @package App\Lib
*/
......@@ -31,7 +34,7 @@ interface SellerInterface
* @return mixed
* @author Administrator
*/
public function save($referId, $unionId, $openId, $nickName, $headImgUrl, $realName = '', $phoneNumber = '');
public function save($referId, $unionId, $openId, $nickName, $headImgUrl);
/**
* @param $id
......@@ -42,6 +45,14 @@ interface SellerInterface
public function get($id,$fields=['*']);
/**
* @param $unionId
* @param array $fields
* @return mixed
* @author Administrator
*/
public function getByUnionId($unionId,$fields=['*']);
/**
* @param $condition
* @param $data
* $data['referId']=>'来源ID'
......@@ -56,4 +67,14 @@ interface SellerInterface
*/
public function update($condition,$data);
/**
* @param $storeId
* @param array $fields
* @return mixed
* @author Administrator
*/
public function getByStoreId($storeId, $fields = ['*']);
public function countDistributionNum($sellerId);
}
\ No newline at end of file
......@@ -13,8 +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,$sellerId)
* Interface SellerDistributionInterface
* @package App\Lib
*/
......@@ -62,21 +61,24 @@ interface SellerDistributionInterface{
*/
public function reduceBalance($sellerId, $money);
/**
* 增加累计佣金
* 获取分销记录
* @param $storeId
* @param $orderId
* @param $sellerId
* @param $money
* @return mixed
* @author Administrator
*/
public function addTotal($sellerId, $money);
public function listByOrderId($storeId, $orderId,$sellerId);
/**
* 减少累计佣金
* @param $sellerId
* @param $money
* 更细对账表
* @param $storeId
* @param $id
* @param $balanceState 0 未对帐 1 已对账
* @return mixed
* @author Administrator
*/
public function reduceTotal($sellerId, $money);
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
......@@ -23,7 +23,6 @@ interface CommsettingInterface
/**
* 获取买家分销佣金规则
*
* @Number(name="storeId")
* @param int $storeId
* @return array
* 返回内容说明:
......@@ -37,7 +36,6 @@ interface CommsettingInterface
/**
* 根据店铺ID修改买家分销的佣金规则
*
* @Number(name="storeId")
* @param integer $storeId
* @param array $data
* 参数$data 字段说明:
......
<?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)
* @method ResultInterface deferGetNoticeSwitch(int $storeId)
*/
interface SettingsInterface
{
/**
* 获取店铺基础设置项
*
* @param int $storeId
* @return array
*/
public function getSettings(int $storeId);
/**
* 获取消息通知的开关设置项
*
* @param int $storeId
* @return array
* array(5) {
* ["pay_notice"]=> // 付款通知,1表示允许发送通知
* int(0)
* ["refund_notice"]=> // 退款通知,1表示允许发送通知
* int(1)
* ["reserv_notice"]=> // 预约通知,1表示允许发送通知
* int(0)
* ["cancel_reserv_notice"]=> // 取消预约通知,1表示允许发送通知
* int(0)
* ["delivered_notice"]=> // 核销通知,1表示允许发送通知
* int(1)
* ["cancel_order_notice"]=> // 订单取消的通知,1表示允许发送通知
* int(1)
* ["withdraw_notice"]=> // 提现申请的通知,1表示允许发送通知
* int(1)
* ["grant_comm_notice"]=> // 下级升级vip产生新的佣金的通知,1表示允许发送通知
* int(1)
* }
*/
public function getNoticeSwitch(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,19 @@ interface StoreInterface
* 查询店铺是否已实名认证(企业认证)
*
* @param integer $storeId
* @return boolean
* @return bool true:认证成功 false:未认证
*/
public function isCertified(int $storeId);
/**
* 查询店铺是否正常
*
* @param integer $storeId
* @return bool true:正常,false:冻结
*/
public function isNormal(int $storeId);
/**
* 根据店铺ID获取店铺信息
*
* @param integer $storeId
......@@ -48,6 +59,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
......@@ -63,7 +83,7 @@ interface StoreInterface
* ['bannerUrl'] => 店铺banner 图片Url
* ['templateId'] => 当前使用的个性模板id
* ['storeIntro'] => 店铺介绍
* ['storeHours'] => 店铺营业时间,示例:"9-22" 表示从9点到22点
* ['storeHours'] => 店铺营业时间,示例:"09:00-22:00" 表示从9点到22点
* ['vipStartTime'] => VIP订购周期,开始时间,整数类型
* ['vipEndTime'] => VIP订购周期,结束时间,整数类型
* @return int 成功更新的条数
......@@ -77,4 +97,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 store service
*
* @method ResultInterface deferGetSubStore(int $storeId, int $subStoreId)
* @method ResultInterface deferGetSubStoreList(int $storeId, int $state = 0)
* @method ResultInterface deferUpdateSubStore(int $storeId, int $subStoreId, array $data)
*/
interface SubStoreInterface
{
/**
* 获取子店铺信息
*
* @param int $storeId
* @param int $subStoreId
* @return array
*/
public function getSubStore(int $storeId, int $subStoreId);
/**
* 获取storeId获取所有子店铺列表
*
* @param int $storeId
* @param int $state 子店铺状态筛选,1表示正常,2表示关闭,0表示列出所有
* @return array
*/
public function getSubStoreList(int $storeId, int $state = 1);
/**
* 修改子店铺信息
*
* @param integer $storeId
* @param integer $subStoreId
* @param array $data
* $data字段说明:
* subStoreName // 门店名称
* mobile // 门店联系手机
* state // 1表示正常状态,2关闭状态
* storeAddr // 店铺地址
* lntLat // 店铺坐标
* storeHours // 营业时间
* reservSpan // 单次预约时长
* reservMax // 同一时间段最大预约次数
*
* @return int 成功更新的条数
*/
public function updateSubStore(int $storeId, int $subStoreId, array $data);
}
\ No newline at end of file
......@@ -28,7 +28,6 @@ interface TemplateInterface
* onshelf=1表示查询已上架的模板
* onshelf=2表示查询已下架的模板
*
* @Number(name="onshelf")
* @param int $onshelf
* @return array
*/
......@@ -37,7 +36,6 @@ interface TemplateInterface
/**
* 根据模板ID获取单个模板信息
*
* @Number(name="tplId")
* @param integer $tplId
* @return array
*/
......@@ -46,7 +44,6 @@ interface TemplateInterface
/**
* 根据模板id删除一个模板
*
* @Number(name="tplId")
* @param integer $tplId
* @return int 返回删除成功的条数
*/
......@@ -61,7 +58,6 @@ interface TemplateInterface
* ['memo'] => 备注信息,此信息用户看不到
* ['orderby'] => 排序值,值越大,越靠前
*
* @Number(name="tplId")
* @param integer $tplId
* @param array $data
* @return int 返回更新成功的条数
......
<?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/10
* Time: 14:14
*/
namespace Hdll\Services\Transfer\Enum;
class TransferEnum
{
const SUCCESS = 0;
const FAIL = 1;
const RETRY = 2;
}
\ 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;//已支付
......
......@@ -12,16 +12,13 @@ use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferOpenVip($storeId,$orderId,$money)
* @method ResultInterface deferUpdate($storeId,$condition, $data)
* Interface SellerInterface
* @package App\Lib
*/
interface VipInterface
{
public function openVip($storeId,$orderId,$money);
public function openVip($storeId,$orderId);
public function update($storeId,$condition, $data);
}
\ No newline at end of file
<?php
/**
* 买家佣金提现接口
*
* @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\WithdrawCash\Lib;
use Swoft\Core\ResultInterface;
/**
* The interface of WithdrawCashInterface service
*
* @method ResultInterface deferPaySuccess(int $type,int $storeId,int $id,string $wxOrderSn,int $fee)
* @method ResultInterface deferPayFailed(int $type,int $storeId,int $id,string $message)
*/
interface WithdrawCashInterface{
/**
* 支付成功接口
*
* @param integer $type 提现类型
* @param integer $storeId 店铺ID
* @param integer $id 提现记录ID
* @param string $wxOrderSn 微信支付订单号
* @param integer $fee 手续费
* @return boolean
*/
public function paySuccess(int $type,int $storeId,int $id,string $wxOrderSn,int $fee);
/**
* 支付失败接口
*
* @param integer $type 提现类型
* @param integer $storeId 店铺ID
* @param integer $id 提现记录ID
* @param string $message 失败信息
* @return boolean
*/
public function payFailed(int $type,int $storeId,int $id,string $message);
}
\ No newline at end of file
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