Commit 18b640e4 by liwotian name
parents 2f59f225 24dc3c02
......@@ -12,6 +12,8 @@ class AuthError
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)
......@@ -23,4 +25,9 @@ class AuthError
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/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];
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
......@@ -8,7 +8,7 @@
namespace Hdll\Services\Order\Enum;
class BuyerDistributionEnum
class BuyerDistributionError
{
const E101 = ['101', '金额不能小于0'];
......
......@@ -10,7 +10,12 @@
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;
/**
* 用户实体
......@@ -34,17 +39,20 @@ class User
private $token;
private $cmId;
private $sessionKey;
private $scope;
private $referId;
private $unionid;
private $openId;
public function __construct($token='')
{
$this->setHeadImg("test");
$this->setId(1);
$this->setNickName("zhangsan");
$this->setStoreId("2");
$this->setToken($token);
}
public function getId()
......@@ -92,9 +100,54 @@ class User
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)
{
return $this->token = $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)
......@@ -106,5 +159,46 @@ class User
{
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;
}
}
......@@ -93,7 +93,7 @@ class Smscode
private function getKey($mobile)
{
return 'smscode-' . md5($this->sellerId . '|' . $mobile);
return 'smscode:' . md5($this->sellerId . '|' . $mobile);
}
}
\ 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;
/**
* 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 = '';
}
......@@ -78,7 +78,7 @@ class SellerPoolConfig extends PoolProperties
* @var array
*/
protected $uri = [
'192.168.3.100:8101',
'192.168.3.39:8099',
];
/**
......
......@@ -8,10 +8,10 @@
namespace Hdll\Services\Order\Enum;
class SellerDistributionEnum
class SellerError
{
const E101 = ['101', '金额不能小于0'];
const E101 = [101, '金额不能小于0'];
const E102 = [102, '该数据不属于您', 403];
const E103 = [103, '请勿重复创建', 403];
const E104 = [104, '该用户不存在或属于您的团队', 403];
......
......@@ -6,13 +6,14 @@
* Time: 16:28
*/
namespace Hdll\Services\Store\Lib;
namespace Hdll\Services\Seller\Lib;
use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferSave($referId, $unionId, $openId, $nickName, $headImgUrl, $realName, $phoneNumber)
* @method ResultInterface deferGet($id)
* @method ResultInterface deferUpdate($id)
* Interface SellerInterface
* @package App\Lib
*/
......@@ -39,4 +40,19 @@ interface SellerInterface
*/
public function get($id);
/**
* @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 App\Exception;
class SellerDistributionError
{
const E001 = [001, '参数非法',400];
const E002 = [002, '无效的Token',403];
const E003 = [003, '无权限操作',403];
const E004 = [004, '数据不存在',404];
const E101 = [101, '微信支付错误', 500];
const E102 = [102, '订单不存在或状态异常', 404];
const E103 = [103, '升级VIP失败,没有找到对应的店铺', 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, $level, $memo = '')
* @method ResultInterface deferSaveCommission($sellerId, $orderId, $money)
* 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, $level, $memo = '');
/**
* 保存佣金记录
* @param $sellerId
* @param $orderId
* @param $money
* @return mixed
* @author Administrator
*/
public function saveCommission($sellerId, $orderId, $money);
}
\ No newline at end of file
......@@ -34,7 +34,7 @@ interface StoreInterface
* 根据店铺ID获取店铺信息
*
* @param integer $storeId
* @return null|array
* @return array 空数组表示没有查询到记录
*/
public function getStore(int $storeId);
......
<?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
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