Commit 8f12c142 by 王召彬

Merge branch 'master' of http://git.2b3.cn/tencent/services

parents 799956eb a2b64118
......@@ -13,7 +13,9 @@ class BargainEnum
//订单状态
const STATUS_NORMAL = 10; //待支付
const STATUS_IN_MINI_PRICE = 20; //已经到底价
const STATUS_HAVE_ORDER = 30; //已经下单
const STATUS_HAVE_BUY = 40; //已经购买
//paystatus
......
<?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: 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: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: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/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
......@@ -49,7 +49,7 @@ class LogHandler extends AbstractProcessingHandler
*/
protected function write(array $records)
{
$messageText = implode("<*|||*>", $records);
$messageText = implode(" __||__ ", $records);
if($this->topicId == ClsLog::TOPICID_ERROR) {
ClsLog::error($messageText);
......
#线上环境公共配置项:
<?php
/*
* This file is part of Swoft.
* (c) Swoft <group@swoft.org>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return [
'clsErrorLogHandler' => [
'class' => \Hdll\Services\Common\ClsLogger\LogHandler::class,
'topicId' => \Hdll\Services\Common\ClsLogger\ClsLog::TOPICID_ERROR,
'formatter' => '${lineFormatter}',
'levels' => [
\Swoft\Log\Logger::ERROR,
\Swoft\Log\Logger::WARNING,
\Swoft\Log\Logger::CRITICAL,
],
],
'clsNoticeLogHandler' => [
'class' => \Hdll\Services\Common\ClsLogger\LogHandler::class,
'topicId' => \Hdll\Services\Common\ClsLogger\ClsLog::TOPICID_NOTICE,
'formatter' => '${lineFormatter}',
'levels' => [
\Swoft\Log\Logger::NOTICE,
\Swoft\Log\Logger::INFO,
\Swoft\Log\Logger::DEBUG,
\Swoft\Log\Logger::TRACE,
],
],
'logger' => [
'name' => APP_NAME,
'enable' => true,
'flushInterval' => 100,
'flushRequest' => true,
'handlers' => [
'${clsErrorLogHandler}',
'${clsNoticeLogHandler}',
],
],
];
......@@ -93,12 +93,17 @@ class CommonEntity extends Model
//获取注解里的table
$res = new \ReflectionClass(static::class);
self::$commentString = $res->getDocComment();
if ( false !== strpos(self::$commentString,"{split}") && !App::$isInTest) {
$commentString = $res->getDocComment();
if (
(
false !== strpos($commentString,"{split}")
|| false !== strpos($commentString,"@Split")
)
&& !App::$isInTest) {
$dbNum = self::getDbNum();
$tableName = self::getTableName().'_'.$dbNum;
self::setTableName($tableName);
$tableName = self::getTableName($commentString).'_'.$dbNum;
//self::setTableName($tableName);
return $tableName;
} else {
......@@ -143,9 +148,10 @@ class CommonEntity extends Model
* 获取原始表名
* @return string
*/
protected static function getTableName()
protected static function getTableName($commentString = '')
{
preg_match('/(?<=Table\(name=").*(?="\))/', self::$commentString, $matches);
$commentString = $commentString === ''?self::$commentString:$commentString;
preg_match('/(?<=Table\(name=").*(?="\))/', $commentString, $matches);
return $tableName = isset($matches[0])?$matches[0]:'';
}
}
\ No newline at end of file
......@@ -9,9 +9,7 @@
*/
namespace Swoft\Db;
use Hdll\Services\Common\Bean\Collector\SplitCollector;
use Swoft\Core\RequestContext;
use Swoft\Db\Bean\Collector\EntityCollector;
use Hdll\Services\Common\Entity\Split;
/**
* Query
......@@ -28,41 +26,12 @@ class Query
public static function table(string $tableName, string $alias = null): QueryBuilder
{
$query = new QueryBuilder();
$collector = SplitCollector::getCollector();//分表搜集器
//如果是实体且为分表实体
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 ($map = array_flip($collector['map']) && isset($map[$tableName]) ) { //非实体
$tableName = $tableName.'_'.self::getDbNum($map[$tableName]);
}
//初始化分表
$tableName = Split::initSplit($tableName, $query);
$query = $query->table($tableName, $alias);
return $query;
}
private function getDbNum($className)
{
$splitCollector = SplitCollector::getCollector();
$splitNum = $splitCollector[$className]['num'];
$data = RequestContext::getContextData();
$storeId = $data['userInfo']['storeId'];
return $storeId % $splitNum;
}
}
<?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 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 (strpos($tableName, '\\') !== false && isset($collector[$tableName])) {
$className = $tableName;
$tableName = $collector[$tableName]['table'];
$entityCollector = EntityCollector::getCollector();
//设置分表对应的className
EntityCollector::setCollector($tableName.'_'.self::getDbNum($className), $tableName);
//获取分表名
$tableName = $tableName.'_'.self::getDbNum($className);
//设置分表类型
$query->selectInstance($entityCollector[$className]['instance']);
} elseif ( isset($map[$tableName]) ) { //非实体且分表
$className = $map[$tableName];
$defaultTbleName = $tableName;
$tableName = $tableName.'_'.self::getDbNum($className);
//设置分表对应的className
EntityCollector::setCollector($tableName, $defaultTbleName);
}
return $tableName;
}
private function getDbNum($className)
{
$splitCollector = SplitCollector::getCollector();
$splitNum = $splitCollector[$className]['num'];
$data = RequestContext::getContextData();
$storeId = $data['userInfo']['storeId'];
return $storeId % $splitNum;
}
}
\ No newline at end of file
......@@ -84,7 +84,7 @@ class User
public function setOpenId($value)
{
$this->setValue('openId', $value);
$this->setValue('openid', $value);
}
......@@ -127,7 +127,7 @@ class User
public function getOpenId()
{
return $this->getValue('openId');
return $this->getValue('openid');
}
......@@ -184,6 +184,7 @@ class User
{
$userInfo = [];
$userInfo['userInfo'][$key] = $value;
RequestContext::removeContextDataByChildKey('userInfo', $key);
RequestContext::setContextData($userInfo);
}
......
......@@ -69,7 +69,7 @@ class AuthPoolConfig extends PoolProperties
* the time of connect timeout
*
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -71,7 +71,7 @@ class BargainPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -68,7 +68,7 @@ class BuyerPoolConfig extends PoolProperties
* the time of connect timeout
*
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -70,7 +70,7 @@ class GoodsPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -69,7 +69,7 @@ class GroupBookingPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -67,7 +67,7 @@ class NoticePoolConfig extends PoolProperties
* the time of connect timeout
*
*/
protected $timeout = 50;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -33,7 +33,7 @@ class OrderPoolConfig extends PoolProperties
*
* @var int
*/
protected $minActive = 5;
protected $minActive = 15;
/**
* the maximum number of active connections
......
......@@ -67,7 +67,7 @@ class PayPoolConfig extends PoolProperties
* the time of connect timeout
*
*/
protected $timeout = 50;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -68,7 +68,7 @@ class ReservationPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 15;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -68,7 +68,7 @@ class SchedulePoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 15;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -70,7 +70,7 @@ class SellerDistributionPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -69,7 +69,7 @@ class SellerPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -66,7 +66,7 @@ class StateLessPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -68,7 +68,7 @@ class StorePoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 15;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -23,7 +23,7 @@ class TimeLimitBuyPoolConfig extends PoolProperties
{
// 区别本地和线上的RPC服务地址
$this->uri = explode(',', env('RPC_TIMELIMITBUY_URI', 'timelistbuy:8099'));
$this->uri = explode(',', env('RPC_TIMELIMITBUY_URI', 'timelimitbuy:8099'));
}
protected $name = 'timelimitname';
......@@ -68,7 +68,7 @@ class TimeLimitBuyPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -67,7 +67,7 @@ class TransferPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -70,7 +70,7 @@ class VipPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
......@@ -67,7 +67,7 @@ class WithdrawCashPoolConfig extends PoolProperties
*
* @var int
*/
protected $timeout = 5;
protected $timeout = 200;
/**
* the addresses of connection
......
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/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
......@@ -30,6 +30,10 @@ class OrderEnum
const TYPE_LIMIT = 2; //限时购订单
const TYPE_COLLECTION = 3; //拼团
//对账锁定
const LOCK = 1; //订单锁定
const ORDER_TYPES = [
self::TYPE_GOODS,
self::TYPE_CUT_PRICE,
......@@ -46,6 +50,7 @@ class OrderEnum
const PAY_STATUS = [ //支付状态
self::STATUS_PAID,
self::STATUS_DELIVERY,
self::STATUS_COLLECTION
];
......
......@@ -13,9 +13,7 @@ use Swoft\Core\ResultInterface;
* @method ResultInterface deferGetCommission($sellerId)
* method ResultInterface deferAddBalance($sellerId, $money)
* method ResultInterface deferReduceBalance($sellerId, $money)
* method ResultInterface deferAddTotal($sellerId, $money)
* method ResultInterface deferReduceTotal($sellerId, $money)
* method ResultInterface deferListByOrderId($storeId, $orderId)
* method ResultInterface deferListByOrderId($storeId, $orderId,$sellerId)
* Interface SellerDistributionInterface
* @package App\Lib
*/
......@@ -63,30 +61,24 @@ interface SellerDistributionInterface{
*/
public function reduceBalance($sellerId, $money);
/**
* 增加累计佣金
* @param $sellerId
* @param $money
* @return mixed
* @author Administrator
*/
public function addTotal($sellerId, $money);
/**
* 减少累计佣金
* 获取分销记录
* @param $storeId
* @param $orderId
* @param $sellerId
* @param $money
* @return mixed
* @author Administrator
*/
public function reduceTotal($sellerId, $money);
public function listByOrderId($storeId, $orderId,$sellerId);
/**
* 获取分销记录
* 更细对账表
* @param $storeId
* @param $orderId
* @param $id
* @param $balanceState 0 未对帐 1 已对账
* @return mixed
* @author Administrator
*/
public function listByOrderId($storeId, $orderId);
public function updateBill($storeId,$id,$balanceState);
}
\ No newline at end of file
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