Commit 2a9764f8 by 王召彬

test

parent 4fb4595c
.buildpath
.settings/
.project
*.patch
.idea/
.git/
runtime/
vendor/
temp/
*.lock
.phpintel/
.env
.DS_Store
/vendor
{
"name": "hdll/services",
"description": "test",
"authors": [
{
"name": "fly",
"email": "fly@qq.com"
}
],
"require": {
"qcloud/cos-sdk-v5": ">=1.0"
},
"autoload": {
"psr-4": {
"Hdll\\Services\\": "src/"
}
}
}
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/20
* Time: 11:13
*/
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];
public static function atranslate($message,$param)
{
if ( empty($param) ) {
return $message;
}
array_unshift($param,$message);
return sprintf(...$param);
}
public static function getError($code) {
$reflect = new \ReflectionClass(StoreError::class);
return $reflect->getConstant('E'.$code);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/27
* Time: 14:47
*/
namespace Hdll\Services\Auth\Exception;
use Hdll\Services\Common\Exception\CommonException;
class AuthException extends CommonException
{
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/5
* Time: 15:47
*/
namespace Hdll\Services\Auth\Lib;
use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferUpdateInfo($token, $info)
* Interface BuyerInterface
* @package App\Lib
*/
interface AuthInterface
{
/**
* 要更新redis中的实体信息
*
* @param $token
* @param $info
* @return bool
*/
public function updateInfo($token, $info);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/30
* Time: 11:34
*/
namespace Hdll\Services\Buyer\Enum;
class BuyerEnum
{
const SCORE = 0;
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/20
* Time: 11:13
*/
namespace Hdll\Services\Buyer\Enum;
class BuyerError
{
const PARAMETER_ERR = ["msg" => "参数错误", "code" => 400, "errorCode" => 24001];
const REGISTERED = ["msg" => "用户已存在,无需创建", "code" => 400, "errorCode" => 24101];
const DB_ERROR = ["msg" => "数据库操作错误", "code" => 500, "errorCode" => 24102];
const SCORE_ERR = ["msg" => "你无权创建该用户", "code" => 403, "errorCode" => 24103];
const NOT_FOUND_COMMISSION = ["msg" => "获取佣金信息失败", "code" => 404, "errorCode" => 24104];
const INSUFFICIENT_COMMISSION = ["msg" => "可提现金额不足,无法提现", "code" => 400, "errorCode" => 24105];
const NOT_FOUND_BUYER = ["msg" => "未找到用户信息", "code" => 404, "errorCode" => 24106];
public static function atranslate($message,$param)
{
if ( empty($param) ) {
return $message;
}
array_unshift($param,$message);
return sprintf(...$param);
}
public static function getError($code) {
$reflect = new \ReflectionClass(BuyerError::class);
return $reflect->getConstant('E'.$code);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/2
* Time: 13:48
*/
namespace Hdll\Services\Buyer\Lib;
use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferSaveBill(string $token,int $order_id,int $buyer_id,int $store_id,string $order_sn,int $money)
* Interface AgencyInterface
* @package App\Lib
*/
interface BillInterface{
/**
* 保存账单数据
* @param int $order_id
* @param int $buyer_id
* @param int $store_id
* @param string $order_sn
* @param int $money
* @return mixed
* @author Administrator
*/
public function saveBill(
int $order_id,
int $buyer_id,
int $store_id,
string $order_sn,
int $money
);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/5
* Time: 15:47
*/
namespace Hdll\Services\Buyer\Lib;
use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferGetUser(string $token)
* @method ResultInterface deferUpdateProfile(string $token, array $data)
* Interface BuyerInterface
* @package App\Lib
*/
interface BuyerInterface
{
public function getUser(int $storeId, int $buyerId);
public function updateProfile(string $token, array $data);
public function hasUser($storeId,$unionid);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/2
* Time: 9:49
*/
namespace Hdll\Services\Buyer\Lib;
/**
* Interface CommissionInterface
* @package Hdll\Services\Buyer\Lib
*/
interface CommissionInterface
{
/**
* 扣除可提现金额
*
* @param $storeId
* @param $buyerId
* @param $money
* @return mixed|bool
*/
public function reduceBalanceCommission($storeId, $buyerId, $money);
/**
* 增加可提现金额
*
* @param $storeId
* @param $buyerId
* @param $money
* @return bool
*/
public function addBalanceCommission($storeId, $buyerId, $money);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/16
* Time: 11:09
*/
$basePath = dirname(__DIR__,3);
/**
* 用于自建组件扫描路径配置(键值是方便开发人员理解,代码中无意义)
* [
* 'commonPath' => $basePath.'/Common',
* 'orderEnum' => $basePath.'/Order/Enum',
*
* ];
*/
return [
'commonPath' => $basePath.'/Common',
];
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/16
* Time: 9:32
*/
$scanPaths = include __DIR__.'/PathConfig.php';
$data = [];
foreach ($scanPaths as $basePath) {
$files = \Swoft\Helper\DirHelper::glob($basePath,'*.php');
$baseNamespace = "Hdll\Services\\";
foreach ( $files as $file ) {
$pathSpace = str_replace("/var/www/swoft/vendor/hdll/services/src/","",$file);
$pathSpace = dirname($pathSpace);
$pathSpace = str_replace("/","\\",$pathSpace);
$namespace = $baseNamespace.$pathSpace;
$fileName = basename($file,'.php');
$className = $namespace.'\\'.$fileName;
try {
include_once $file;
if ( ! class_exists($className,false) ) {
continue;
}
//获取注解里的table
$res = new \ReflectionClass($className);
$commentString = $res->getDocComment();
if ( strpos($commentString,'@Bean()') === false ) {
continue;
}
$data[$className] = ['class' => $className];
}catch (Exception $e) {
}
}
}
return $data;
\ No newline at end of file
<?php
return [
'qCloud' => [
'Bucket' => 'hdll-1257143824',
'APPID' => '1257143824',
'SecretId' => 'AKIDseHj18kua0KTSJ4g9SadbVEnEUZVjvPj',
'SecretKey' => 'IPL5g5PaaSAzd6NSO8gEmLxcN4pTzJSQ',
'Region' => 'ap-shanghai'
],
'alisms' => [
'accessKeyId' => 'EjBn9zQxyEkKHyAA',
'accessKeySecret' => 'AN276rwCcqCkFUVt1GLCbAy8jnj52t',
]
];
\ No newline at end of file
<?php
namespace Hdll\Services\Common\Controller;
/**
* 活动啦啦Controller基类
*
*/
class CommonController
{
/**
* 业务层-正确时响应
*
* @param mixed $data
* @param string $msg
* @return array
*/
public function success($data=[], string $msg='') {
return [
'data' => $data,
'msg' => $msg,
'errorCode' => 0,
];
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/2
* Time: 13:49
*/
namespace Hdll\Services\Common\Entity;
use Swoft\App;
use Swoft\Core\RequestContext;
use Swoft\Db\Bean\Collector\EntityCollector;
use Swoft\Db\Model;
use Swoft\Exception\Exception;
use Swoole\Http\Request;
class CommonEntity extends Model
{
private static $commentString;
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
//获取注解里的table
$res = new \ReflectionClass(static::class);
self::$commentString = $res->getDocComment();
//分表逻辑
$this->split();
$this->init();
}
/**
* 初始化
*/
public function init()
{
}
public static function getDb()
{
//获取注解里的table
$res = new \ReflectionClass(static::class);
self::$commentString = $res->getDocComment();
//分表逻辑
self::split();
return new static;
}
/**
* 设置分表表名
* @throws Exception
*/
protected function split()
{
if ( empty(RequestContext::getContextData()) ) {//初始化不做处理
return;
}
if ( false === strpos(self::$commentString,"{split}") || App::$isInTest ) {
return;
}
$dbNum = self::getDbNum();
$tableName = self::getTableName();
self::setTableName($tableName.'_'.$dbNum);
}
/**
* 获取分库表名
*
* @return string|void
* @throws Exception
* @throws \ReflectionException
*/
public static function tableName()
{
if ( empty(RequestContext::getContextData()) ) {//初始化不做处理
return;
}
$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) {
$dbNum = self::getDbNum();
$tableName = self::getTableName().'_'.$dbNum;
self::setTableName($tableName);
return $tableName;
} else {
return self::getTableName();
}
}
/**
* 获取数据库id
* @return int
* @throws Exception
*/
private static function getDbNum()
{
$user = App::getBean(User::class);
$store = $user->getStoreId();
if ( $store === null && $store === [] && $store === '' ) {
throw new Exception("店铺id获取失败");
}
return $store % 100;
}
/**
* 设置表名
* @param $dbNum
*/
protected static function setTableName($tableName)
{
EntityCollector::collect(
static::class,
new \Swoft\Db\Bean\Annotation\Table(['name' => $tableName])
);
}
/**
* 获取原始表名
* @return string
*/
protected static function getTableName()
{
preg_match('/(?<=Table\(name=").*(?="\))/', self::$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 Hdll\Services\Common\Entity;
use Hdll\Services\Auth\Enum\AuthError;
use Hdll\Services\Auth\Exception\AuthException;
use Swoft\App;
use Swoft\Bean\Annotation\Bean;
use Swoft\Cache\Cache;
use Swoft\Redis\Redis;
/**
* 用户实体
* @Bean()
* @uses User
* @version 2017年08月23日
* @author stelin <phpcrazy@126.com>
* @copyright Copyright 2010-2016 Swoft software
* @license PHP Version 7.x {@link http://www.php.net/license/3_0.txt}
*/
class User
{
private $id;
private $nickname;
private $storeId;
private $headImg;
private $token;
private $cmId;
private $sessionKey;
private $scope;
private $referId;
private $unionid;
private $openId;
public function __construct($token='')
{
}
public function getId()
{
return $this->id;
}
public function getNickname()
{
return $this->nickname;
}
public function getStoreId()
{
return $this->storeId;
}
public function getHeadImg()
{
return $this->headImg;
}
public function getToken()
{
return $this->token;
}
public function setId($value)
{
return $this->id = $value;
}
public function setNickname($value)
{
return $this->nickname = $value;
}
public function setStoreId($value)
{
return $this->storeId = $value;
}
public function setHeadImg($value)
{
return $this->headImg = $value;
}
public function setSessionKey($value)
{
$this->sessionKey = $value;
}
public function setOpenId($value)
{
$this->openId = $value;
}
public function setUnionid($value)
{
$this->unionid = $value;
}
public function setReferId($value)
{
$this->referId = $value;
}
public function setScope($value)
{
$this->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;
}
public function setCmId($value)
{
$this->cmId = $value;
}
public function getCmId()
{
return $this->cmId;
}
public function fill($arr)
{
foreach ($arr as $name => $value) {
$methodName = sprintf('set%s', ucfirst($name));
if (method_exists($this, $methodName)) {
$this->$methodName($value);
}
}
}
public function getSessionKey()
{
return $this->sessionKey;
}
public function getOpenId()
{
return $this->openId;
}
public function getUnionid()
{
return $this->unionid;
}
public function getReferId()
{
return $this->referId;
}
public function getScope()
{
return $this->scope;
}
}
<?php
namespace Hdll\Services\Common\Exception;
use Swoft\Exception\Exception;
class CommonException extends Exception
{
// HTTP 状态码 404,200
public $code = 500;
// 错误具体信息
public $message = '服务器异常';
// 业务错误码
public $errorCode = -1;
//异常调用路径
protected $path=[];
public function __construct($params = [])
{
if(isset($params['code'])){
$this->code = $params['code'];
}
if(isset($params['msg'])){
$this->message = $params['msg'];
}
// 参数errCode 等效于 传参errorCode
if(isset($params['errCode'])){
$params['errorCode'] = $params['errCode'];
}
if(isset($params['errorCode'])) {
$this->errorCode = $params['errorCode'];
}
if ( isset($params['path']) ) {
$this->path = empty($params['path'])?[]:$params['path'];
}
//将此次异常信息入栈
array_unshift($this->path,'Service:'.APP_NAME.' file:'.$this->file.$this->line)//将本次错误调用加入path
//json序列化path
&& $this->path = json_encode($this->path);
parent::__construct($this->message, $this->code);
}
public function getErrcode(){
return $this->errorCode;
}
public function getPath()
{
return $this->path;
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/3
* Time: 17:21
*/
namespace Hdll\Services\Common\Exception;
class ExceptionData
{
public static function getExceptionData($errData, array $param= [])
{
return [
"code" => $errData['code'],
"msg" => $errData['msg'],
"errorCode" => $errData["errCode"],
"data" => $errData['data'],
"path" => $errData['path']
];
}
/**
* 组装抛出的rpc信息
* @param \Throwable $e
* @return array
*/
public static function getRpcErrData(\Throwable $e)
{
//初始化异常数据
$data = [
"code" => $e->getCode(),
"msg" => $e->getMessage(),
"errCode" => is_callable([$e,'getErrCode'])?$e->getErrcode():-1,
'path' =>[],
];
if ( is_callable([$e,"getPath"]) ) {//自建异常类处理path
$data['path'] = json_decode($e->getPath(), true);
//获取调用堆栈信息
$info = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,1)[0];
//将此次异常信息入站
array_unshift($data['path'],'Service:'.APP_NAME.' file:'.$info['file'].'('.$info['line'].')');
} else { //系统异常统一报500错误
$data['code'] = 500;
//将此次异常信息入站
array_unshift($data['path'],'Service:'.APP_NAME.' file:'.$e->getFile().'('.$e->getLine().')');
}
return ['msg' => json_encode($data), 'code' => $data['code']];
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/6
* Time: 10:16
*/
namespace Hdll\Services\Common\Exception;
class ExceptionParseData
{
public static function parseData(\Exception $e)
{
if ( is_callable([$e,'getResponse']) ) {
$response = $e->getResponse();
preg_match("/{.*}/",$response['msg'],$data);
$msg = isset($data['0'])?$data['0']:'';
$data = json_decode($msg,true);
} else {
$data['msg'] = $e->getMessage();
$data['code'] = 500;
$data['errorCode'] = -1;
$data['file'] = $e->getFile().' '.$e->getLine();
$data['path'] = ['Service:'.APP_NAME.$e->getFile().' '.$e->getLine()];
}
return $data;
}
}
\ No newline at end of file
<?php
namespace Hdll\Services\Common\Lib;
use Flc\Dysms\Client;
use Flc\Dysms\Request\SendSms;
/**
* 阿里云发送短信工具类
* 使用:
* $alisms = new Alisms(Alisms::SN_01,'SMS_101145139',['code' => $vcode]);
* 或:
* $alisms = (new Alisms)->setSignName(Alisms::SN_01)
* ->setTemplateCode(Alisms::TPL_01)
* ->setTemplateParam(['code' => $vcode]);
* $response = $alisms->send(15825290203);
*/
class Alisms
{
// 阿里云注册的签名列表:
// 目前只有一个
const SN_01 = '活动啦啦'; // 签名1
// 阿里云注册的短信模板列表:
// 目前只有一个
const TPL_01 = 'SMS_101145139'; // 模板1
protected $config;
protected $templateCode;
protected $templateParam;
protected $signName;
public function __construct($signName=null, $templateCode=null, $templateParam=[])
{
// 短信签名,示例:活动啦啦
$this->signName = $signName ?? self::SN_01;
// 短信模板编号
$this->templateCode = $templateCode ?? self::TPL_01;
// 短信模板预设参数
$this->templateParam = $templateParam;
$configurator = \Swoft\App::getBean('config');
$configurator->load('@vendor/hdll/services/src/Common/Config');
$this->config = $configurator->get('alisms');
}
/**
* 发送短信(发送预设置的短信模板)
* @param $phone
* @return mixed
*/
public function send($phone)
{
$client = new Client($this->config);
$sendSms = new SendSms();
$sendSms->setPhoneNumbers($phone);
$sendSms->setSignName($this->signName);
$sendSms->setTemplateCode($this->templateCode);
$sendSms->setTemplateParam($this->templateParam);
$sendSms->setOutId('hdll');
return $client->execute($sendSms);
}
public function setSignName($signName){
$this->signName = $signName;
return $this;
}
public function setTemplateCode($templateCode){
$this->templateCode = $templateCode;
return $this;
}
public function setTemplateParam($templateParam){
$this->templateParam = $templateParam;
return $this;
}
}
\ No newline at end of file
<?php
namespace Hdll\Services\Common\Lib;
use Swoft\App;
use Hdll\Services\Common\Entity\User;
/**
* 手机验证码 工具类
* 发送验证码:
* $err = (new Smscode)->send($mobile); // $mobile 接收验证码的手机号
* if($err) {
* throw .... // 错误处理
* }
* 校验验证码:
* $check = (new Smscode)->check($mobile,$smscode); // 前台传入的手机号和验证码
* if(!$check) {
* throw .... // 错误处理
* }
*
*/
class Smscode
{
protected $sellerId;
public function __construct()
{
$this->sellerId = App::getBean(User::class)->getId();
}
/**
* 发送验证码,可指定短信签名和使用哪个短信模块
*
* @param integer $mobile
* @param [type] $signName
* @param [type] $templateCode
* @return null|string 返回错误信息,正确时返回null
*/
public function send(int $mobile, $signName = null, $templateCode = null)
{
$key = $this->getKey($mobile);
$val = cache()->get($key);
if ($val) {
list(, $time, $count) = explode(',', $val);
if ($count >= 3) {
return '验证码发送次数超限,请稍后再试';
}
if (time() - $time < 60) {
return '发送验证码请求过于频繁';
}
$count += 1;
} else {
$count = 1;
}
$vcode = mt_rand(10000, 99999);
$alisms = new Alisms(
$signName ?? Alisms::SN_01,
$templateCode ?? Alisms::TPL_01,
['code' => $vcode]
);
$response = $alisms->send($mobile);
if ($response->Code == 'OK') {
$vdata = sprintf("%d,%d,%d", $vcode, time(), $count);
$result = cache()->set($key, $vdata, 300); // 验证码有效期5分钟
if (!$result) {
return '验证码存储失败';
}
} else {
return '验证码发送失败:' . $response->Message;
}
}
/**
* 校验验证码
*
* @param integer $mobile
* @param integer $smscode
* @return bool 验证码正确时返回true
*/
public function check(int $mobile, int $smscode)
{
$key = $this->getKey($mobile);
$val = cache()->get($key);
if ($val) {
list($vcode,, ) = explode(',', $val);
if ($vcode == $smscode) {
return true;
}
}
return false;
}
private function getKey($mobile)
{
return 'smscode:' . md5($this->sellerId . '|' . $mobile);
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/23
* Time: 11:21
*/
namespace Hdll\Services\Common\Lib;
use Hdll\Services\Common\Exception\CommonException;
use Qcloud\Cos\Client;
use Swoft\App;
use Swoft\Core\Config;
class Upload
{
private $Bucket;
private $APPID;
private $SecretId;
private $SecretKey;
private $Region;
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');
}
$this->Bucket = $config['Bucket'];
$this->Region = $config['Region'];
$this->APPID = $config['APPID'];
$this->SecretId = $config['SecretId'];
$this->SecretKey = $config['SecretKey'];
}
/**
* 腾讯OS
* @param string $localPath 本地路径
* @param string $name 文件名
* @return mixed
* @throws CommonException
* @author Administrator
*/
public function upload($localPath = '', $name = '')
{
$cosClient = new Client(
[
'region' => $this->Region,
'credentials' => [
'secretId' => $this->SecretId,
'secretKey' => $this->SecretKey,
]
]
);
try {
$result = $cosClient->Upload(
$this->Bucket,
$name,
fopen($localPath, 'rb')
);
} 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\Bean\Annotation\Value;
use Swoft\Pool\PoolProperties;
/**
* the config of service user
*
* @Bean()
*/
class BuyerPoolConfig extends PoolProperties
{
/**
* the name of pool
*
*/
protected $name = 'buyer';
/**
* 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 = 5;
/**
* the addresses of connection
*
* <pre>
* [
* '127.0.0.1:88',
* '127.0.0.1:88'
* ]
* </pre>
*
*/
protected $uri = [
"192.168.3.100:8101"
];
/**
* 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;
/**
* @Bean()
* the config of service user
*/
class OrderPoolConfig extends PoolProperties
{
protected $name = 'buyer';
/**
* 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 = 5;
/**
* the addresses of connection
*
* <pre>
* [
* '127.0.0.1:88',
* '127.0.0.1:88'
* ]
* </pre>
*
* @var array
*/
protected $uri = [
'192.168.3.100:8084',
];
/**
* 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 SellerDistributionPoolConfig extends PoolProperties
{
protected $name = 'sellerDistribution';
/**
* 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:8100',
];
/**
* 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 SellerPoolConfig extends PoolProperties
{
protected $name = 'seller';
/**
* 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: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 user
*
* @Bean()
*/
class StorePoolConfig extends PoolProperties
{
protected $name = 'storeId';
/**
* 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.23:8098',
];
/**
* 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 VipPoolConfig extends PoolProperties
{
protected $name = 'seller';
/**
* 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\FlowMetering\Lib;
use Swoft\Core\ResultInterface;
/**
* The interface of demo service
*
* @method ResultInterface deferOrderMark(string $token, int $orderType, int $orderId, float $money)
*/
interface FlowMeteringInterface
{
/**
* @param string $token
* @param int $orderType
* @param int $orderId
* @param float $money
* @return mixed
*/
public function OrderMark(
string $token,
int $orderType,
int $orderId,
float $money);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: lwt
* Date: 2018/7/10
* Time: 13:15
*/
namespace Hdll\Services\LimitTimeBuy\Enum;
class LimitTimeBuyEnum
{
//订单状态
const STATUS_NORMAL = 10; //待支付
}
\ 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\LimitTimeBuy\Lib;
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
{
/**
*
* 补回 未支付 限购活动 库存
* @param string $token
* @param int $consignee_id
* @param int $limit_id
* @param int $selected_num
* @param int $order_type
* @param int $goods_id
* @param string $reservation_time
* @return mixed
*/
public function backNum(
string $token,
int $consignee_id,
int $limit_id,
int $selected_num,
int $order_type,
int $goods_id,
string $reservation_time = '');
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/5
* Time: 13:15
*/
namespace Hdll\Services\Order\Enum;
class OrderEnum
{
//订单状态
const STATUS_UNPAID = 10; //待支付
const STATUS_PAID = 20; //已支付
const STATUS_DELIVERY = 30; //已发货/已预约
const STATUS_DELIVERED = 40; //已收获/已核销
const STATUS_REFUND = 50; //申请退款
const STATUS_REFUNDED = 60; //已退款
const STATUS_CANCEL = 0; //已取消
const STATUS_CLOSED = 70; //已关闭
const STATUS_REFUNDING = 80; //退款中
//订单类型
const TYPE_GOODS = 0; //商品订单
const TYPE_KANJIA = 1; //砍价订单
const TYPE_LIMIT = 2; //限时购订单
//对账状态
const BALANCE_STATE_FALSE = 0; //未对账
const BALANCE_STATE_TRUE = 1;//已对账
}
\ No newline at end of file
<?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
/**
* 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\Order\Lib;
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 deferGetOrderInfo(int $storeId,int $orderId)
*/
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 string $reservation_time
* @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 = '');
public function getOrderInfo(int $storeId,int $orderId);
}
\ 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\Reservation\Lib;
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)
*/
interface ReservationInterface
{
/**
* 获取某个预约的信息
*
* @param integer $id
* @return array
*/
public function getReservById(int $id);
/**
* 根据日期id,获取商家某一天的所有预约
*
* @param integer $storeId
* @param integer $dateId
* @return array
*/
public function getReservByDateId(int $storeId, int $dateId);
/**
* 根据订单id,获取商家某个订单包含的所有预约
*
* @param integer $storeId
* @param integer $orderId
* @return void
*/
public function getReservListByOrderId(int $storeId, int $orderId);
/**
* 修改某个预约信息
*
* @param integer $id
* @param array $data
* $data 字段说明:
* ['state'] => 预约状态,默认0,如果正常结束则为1
* ['type'] => 预约类型,备用
* ['reservTime'] => 预约时间,时间戳格式
* ['isConfirm'] => 1表示商家确认预约
* ['memo'] => 预约备注
* @return int 返回成功修改的条数
*/
public function modifyReservById(int $id, array $data);
/**
* 取消某个预约
*
* @param integer $id
* @return boolean 返回取消结果
*/
public function cancelReservById(int $id);
}
\ No newline at end of file
<?php
/**
* This file is part of Swoft.
*
* @link https://swoft.org
* @document https://doc.swoft.org
* @contact group@swoft.org
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE
*/
namespace Hdll\Services\Schedule\Lib;
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)
*/
interface ScheduleInterface
{
/**
* 获取店铺所有日程列表
*
* @param integer $storeId
* @param integer $month 可选参数 指定要查哪个月份的日程列表,格式如:201810
* @return array 空数组表示没有查询到记录
*/
public function getScheduleList(int $storeId, int $month = null);
/**
* 获取某天的日程信息
*
* @param integer $storeId
* @param integer $dateId 要查询的日期id,格式要求如:20180803
* @return array 空数组表示没有查询到记录
*/
public function getScheduleByDateId(int $storeId, int $dateId);
/**
* 根据dateId修改某个日程的信息
*
* @param integer $storeId
* @param integer $dateId 要修改的日期id,格式要求如:20180803
* @param array $data
* 参数 $data 字段说明:
* ['offday'] => 是否是休息日,0不是,1是
*
* @return int 成功更新的条数
*/
public function updateSchedule(int $storeId, int $dateId, array $data);
/**
* 添加一个日程安排
*
* @param integer $storeId
* @param integer $dateId 要添加的日期id,格式要求如:20180803
* @param array $data
* 参数 $data 字段说明:
* ['offday'] => 是否是休息日,0不是,1是
*
* @return int
*/
public function addSchedule(int $storeId, int $dateId, array $data);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/17
* Time: 14:19
*/
namespace Hdll\Services\Seller\Enum;
class SellerError
{
const E101 = [101, '金额不能小于0'];
const E102 = [102, '该数据不属于您', 403];
const E103 = [103, '请勿重复创建', 403];
const E104 = [104, '该用户不存在或属于您的团队', 403];
public function getError($code)
{
$reflect = new \ReflectionClass(self::class);
$arr = $reflect->getConstant('E' . substr($code, -3));
if (!is_array($arr)) {
return false;
}
return [
'code' => $arr[0],
'msg' => $arr[1],
'errorCode' => $arr[2],
];
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/27
* Time: 16:28
*/
namespace Hdll\Services\Seller\Lib;
use Swoft\Core\ResultInterface;
/**
*
* @method ResultInterface deferGetFund($sellerId)
* Interface SellerInterface
* @package App\Lib
*/
interface SellerFundInterface
{
/**
*
* @param $sellerId
* @return mixed
* totalFund 累计资金
* balanceFund 可提现金额
* commissionFund 需要支付的佣金
* expectFund 冻结金额
* totalWithdraw 累计提现
* @author Administrator
*/
public function getFund($sellerId);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/27
* Time: 16:28
*/
namespace Hdll\Services\Seller\Lib;
use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferSave($referId, $unionId, $openId, $nickName, $headImgUrl, $realName, $phoneNumber)
* @method ResultInterface deferGet($id,$fields=['*'])
* @method ResultInterface deferUpdate($id)
* Interface SellerInterface
* @package App\Lib
*/
interface SellerInterface
{
/**
* @param $referId
* @param $unionId
* @param $openId
* @param $nickName
* @param $headImgUrl
* @param string $realName
* @param string $phoneNumber
* @return mixed
* @author Administrator
*/
public function save($referId, $unionId, $openId, $nickName, $headImgUrl, $realName = '', $phoneNumber = '');
/**
* @param $id
* @param array $fields
* @return mixed
* @author Administrator
*/
public function get($id,$fields=['*']);
/**
* @param $condition
* @param $data
* $data['referId']=>'来源ID'
* $data['unionId']=>'unionId'
* $data['openId']=>'openId'
* $data['nickName']=>'昵称'
* $data['headImgUrl']=>'头像URL'
* $data['realName']=>'真实姓名'
* $data['phoneNumber']=>'手机号'
* @return mixed
* @author Administrator
*/
public function update($condition,$data);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/17
* Time: 14:19
*/
namespace Hdll\Services\SellerDistribution\Enum;
class SellerDistributionEnum
{
const SETTING = [1 => 0.2, 2 => 0.1];
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/17
* Time: 14:19
*/
namespace Hdll\Services\SellerDistribution\Enum;
class SellerDistributionError
{
const E101 = [101, '店铺不存在'];
const E102 = [102, '该数据不属于您', 403];
const E103 = [103, '请勿重复创建', 403];
const E104 = [104, '该用户不存在或属于您的团队', 403];
const E105 = [105, '未开启分销', 200];
const E106 = [106, '分销上级不存在', 404];
public function getError($code)
{
$reflect = new \ReflectionClass(self::class);
$arr = $reflect->getConstant('E' . substr($code, -3));
if (!is_array($arr)) {
return false;
}
return [
'code' => $arr[0],
'msg' => $arr[1],
'errorCode' => $arr[2],
];
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/25
* Time: 14:00
*/
namespace Hdll\Services\SellerDistribution\Lib;
use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferSaveBill($orderId, $sellerId, $money)
* @method ResultInterface deferGetCommission($sellerId)
* Interface SellerDistributionInterface
* @package App\Lib
*/
interface SellerDistributionInterface{
/**
* 保存账单
* @param $orderId
* @param $sellerId
* @param $money
* @param $level
* @param string $memo
* @return mixed
* @author Administrator
*/
public function saveBill($orderId, $sellerId, $money);
/**
* 获取佣金信息
* @param $sellerId
* @return mixed
* totalCommission 累计佣金
* balanceCommission 可提现佣金
* @author Administrator
*/
public function getCommission($sellerId);
}
\ 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-commission service
*
* @method ResultInterface deferGetCommSetting(int $storeId)
* @method ResultInterface deferUpdateByStoreId(int $storeId)
*/
interface CommsettingInterface
{
/**
* 获取买家分销佣金规则
*
* @Number(name="storeId")
* @param int $storeId
* @return array
* 返回内容说明:
* ['state'] => 分销佣金规则是否启用,0不启用,1启用
* ['rule'] => 分销佣金规则具体设置内容,json格式: {"1":35,"2":14.5}
* ['minWithdraw'] => 最小提现金额,单位分
* ['memo'] => 规则备注说明
*/
public function getCommSetting(int $storeId);
/**
* 根据店铺ID修改买家分销的佣金规则
*
* @Number(name="storeId")
* @param integer $storeId
* @param array $data
* 参数$data 字段说明:
* ['state'] => 分销佣金规则是否启用,0不启用,1启用
* ['rule'] => 分销佣金规则具体设置内容,json格式: {"1":35,"2":14.5}
* ['minWithdraw'] => 最小提现金额,单位分
* ['memo'] => 规则备注说明
* @return array
*/
public function updateByStoreId(int $storeId, array $data);
}
\ 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 deferIsCertified(int $storeId)
* @method ResultInterface deferGetStoreByStoreId(int $storeId)
* @method ResultInterface deferGetStoreBySellerId(int $sellerId)
* @method ResultInterface deferUpdateStore(int $storeId, array $data)
* @method ResultInterface deferDeleteStore(int $storeId)
*/
interface StoreInterface
{
/**
* 查询店铺是否已实名认证(企业认证)
*
* @param integer $storeId
* @return boolean
*/
public function isCertified(int $storeId);
/**
* 根据店铺ID获取店铺信息
*
* @param integer $storeId
* @return array 空数组表示没有查询到记录
*/
public function getStoreByStoreId(int $storeId);
/**
* 根据卖家ID获取店铺信息
*
* @param integer $sellerId
* @return array
*/
public function getStoreBySellerId(int $sellerId);
/**
* 根据店铺ID修改店铺信息
*
* @param integer $storeId
* @param array $data
* 参数 $data 字段说明:
* ['storeName'] => 店铺名称
* ['mobile'] => 店铺绑定的手机号
* ['wechat'] => 店铺绑定的微信号
* ['edition'] => 订购版本,1普通版,2VIP版
* ['storeAddr'] => 店铺地址
* ['lntLat'] => 店铺地址,坐标信息
* ['logoUrl'] => 店铺logo图片url
* ['bannerUrl'] => 店铺banner 图片Url
* ['templateId'] => 当前使用的个性模板id
* ['storeIntro'] => 店铺介绍
* ['storeHours'] => 店铺营业时间,示例:"9-22" 表示从9点到22点
* ['vipStartTime'] => VIP订购周期,开始时间,整数类型
* ['vipEndTime'] => VIP订购周期,结束时间,整数类型
* @return int 成功更新的条数
*/
public function updateStore(int $storeId, array $data);
/**
* 根据店铺id删除一个店铺记录
*
* @param integer $storeId
* @return int 成功返回删除条数
*/
public function deleteStore(int $storeId);
}
\ 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-template service
*
* @method ResultInterface deferGetTemplateList(int $onshelf = 1)
* @method ResultInterface deferGetTemplate(int $tplId)
* @method ResultInterface deferDelTemplate(int $tplId)
* @method ResultInterface deferUpdateTemplate(int $tplId, array $data)
* @method ResultInterface deferAddTemplate($data)
*/
interface TemplateInterface
{
/**
* 获取所有可用的个性模板列表
* onshelf=1表示查询已上架的模板
* onshelf=2表示查询已下架的模板
*
* @Number(name="onshelf")
* @param int $onshelf
* @return array
*/
public function getTemplateList(int $onshelf = 1);
/**
* 根据模板ID获取单个模板信息
*
* @Number(name="tplId")
* @param integer $tplId
* @return array
*/
public function getTemplate(int $tplId);
/**
* 根据模板id删除一个模板
*
* @Number(name="tplId")
* @param integer $tplId
* @return int 返回删除成功的条数
*/
public function delTemplate(int $tplId);
/**
* 根据模板id更新一个模板
* $data 字段说明:
* ['tplThumb'] => 模板缩略图地址
* ['title'] => 模板标题
* ['onshelf'] => 是否上架,1上架,2下架,下架的模板用户看不到
* ['memo'] => 备注信息,此信息用户看不到
* ['orderby'] => 排序值,值越大,越靠前
*
* @Number(name="tplId")
* @param integer $tplId
* @param array $data
* @return int 返回更新成功的条数
*/
public function updateTemplate(int $tplId, array $data);
/**
* 添加一个模板
* $data 字段说明:
* ['tplThumb'] => 模板缩略图地址
* ['title'] => 模板标题
* ['onshelf'] => 是否上架,1上架,2下架,下架的模板用户看不到
* ['memo'] => 备注信息,此信息用户看不到
* ['orderby'] => 排序值,值越大,越靠前
*
* @param array $data
* @return int 返回新建模板id
*/
public function addTemplate($data);
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/30
* Time: 10:32
*/
namespace Hdll\Services\Vip\Enum;
class VipEnum{
const VIP_TOTAL_FEE = 10;//价格
const PAY_NOTIFY = 'http://www.baidu.com';
const STATUS_UNPAID = 10;//未支付
const STATUS_PAID = 20;//已支付
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/27
* Time: 16:28
*/
namespace Hdll\Services\Vip\Lib;
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 update($storeId,$condition, $data);
}
\ 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