Commit d3c23780 by liwotianname

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

parents ffaaefcb c9166136
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
namespace Hdll\Services\Common\Entity; namespace Hdll\Services\Common\Entity;
use Hdll\Services\Common\Bean\Collector\SplitCollector; 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\Core\RequestContext;
use Swoft\Db\Bean\Collector\EntityCollector; use Swoft\Db\Bean\Collector\EntityCollector;
use Swoft\Db\QueryBuilder; use Swoft\Db\QueryBuilder;
...@@ -22,32 +25,36 @@ class Split ...@@ -22,32 +25,36 @@ class Split
$map = array_flip($collector['map']); $map = array_flip($collector['map']);
} }
//如果是实体且为分表实体 if ( ! self::isTesting() ) {
if (strpos($tableName, '\\') !== false && isset($collector[$tableName])) { //如果是实体且为分表实体
$className = $tableName; if (strpos($tableName, '\\') !== false && isset($collector[$tableName])) {
$tableName = $collector[$tableName]['table']; $className = $tableName;
$tableName = $collector[$tableName]['table'];
$entityCollector = EntityCollector::getCollector(); $entityCollector = EntityCollector::getCollector();
//设置分表对应的className //设置分表对应的className
EntityCollector::setCollector($tableName.'_'.self::getDbNum($className), $tableName); EntityCollector::setCollector($tableName.'_'.self::getDbNum($className), $tableName);
//获取分表名 //获取分表名
$tableName = $tableName.'_'.self::getDbNum($className); $tableName = $tableName.'_'.self::getDbNum($className);
//设置分表类型 //设置分表类型
$query->selectInstance($entityCollector[$className]['instance']); $query->selectInstance($entityCollector[$className]['instance']);
} elseif ( isset($map[$tableName]) ) { //非实体且分表 } elseif ( isset($map[$tableName]) ) { //非实体且分表
$className = $map[$tableName]; $className = $map[$tableName];
$defaultTbleName = $tableName; $defaultTbleName = $tableName;
$tableName = $tableName.'_'.self::getDbNum($className); $tableName = $tableName.'_'.self::getDbNum($className);
//设置分表对应的className //设置分表对应的className
EntityCollector::setCollector($tableName, $defaultTbleName); EntityCollector::setCollector($tableName, $defaultTbleName);
}
} }
return $tableName; return $tableName;
} }
...@@ -57,6 +64,17 @@ class Split ...@@ -57,6 +64,17 @@ class Split
$splitNum = $splitCollector[$className]['num']; $splitNum = $splitCollector[$className]['num'];
$data = RequestContext::getContextData(); $data = RequestContext::getContextData();
$storeId = $data['userInfo']['storeId']; $storeId = $data['userInfo']['storeId'];
if ( empty($storeId) ) {
throw new CommonException(["msg" => "参数异常,获取店铺信息失败。"]);
}
return $storeId % $splitNum; 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,9 +11,11 @@ ...@@ -11,9 +11,11 @@
namespace Hdll\Services\Common\Entity; namespace Hdll\Services\Common\Entity;
use Hdll\Services\Auth\Enum\AuthError; use Hdll\Services\Auth\Enum\AuthError;
use Hdll\Services\Common\Lib\Redis; use Hdll\Services\Common\Enum\TestEnum;
use Swoft\App;
use Swoft\Bean\Annotation\Bean; use Swoft\Bean\Annotation\Bean;
use Swoft\Core\RequestContext; use Swoft\Core\RequestContext;
use Swoft\Redis\Redis;
/** /**
* 用户实体 * 用户实体
...@@ -35,6 +37,16 @@ class User ...@@ -35,6 +37,16 @@ class User
return $this->getValue('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() public function getNickname()
{ {
return $this->getValue('nickname'); return $this->getValue('nickname');
...@@ -153,12 +165,8 @@ class User ...@@ -153,12 +165,8 @@ class User
return [false,AuthError::GET_TOKEN_ERROR]; return [false,AuthError::GET_TOKEN_ERROR];
} }
/** $redis = App::getBean(Redis::class);
* @var Redis $redis $info = $redis->get("AUTH:".$token);
*/
$redis = new Redis();
$redis->setPrefix("AUTH:");
$info = $redis->get($token);
if ( empty($info) ) { if ( empty($info) ) {
return [false,AuthError::NOT_FOUND_USER]; return [false,AuthError::NOT_FOUND_USER];
......
<?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;
}
<?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
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 15:48 * Time: 15:48
*/ */
namespace App\Enum; namespace Hdll\Services\Goods\Enum;
class AuthEnum class AuthEnum
{ {
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
* Date: 2018/7/26 * Date: 2018/7/26
* Time: 16:00 * Time: 16:00
*/ */
namespace App\Enum; namespace Hdll\Services\Goods\Enum;
class GoodEnum{ class GoodsEnum{
const ON_OFFER = 0;//出售中 const ON_OFFER = 0;//出售中
const SOLD_OUT = 1;//下架 const SOLD_OUT = 1;//下架
const SELL_OUT = 2;//售完 const SELL_OUT = 2;//售完
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Date: 2018/7/26 * Date: 2018/7/26
* Time: 16:00 * Time: 16:00
*/ */
namespace App\Enum; namespace Hdll\Services\Goods\Enum;
class GoodsEvaluateEnum{ class GoodsEvaluateEnum{
const GOOD = 1;//好评 const GOOD = 1;//好评
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Time: 16:00 * Time: 16:00
*/ */
namespace App\Enum; namespace Hdll\Services\Goods\Enum;
class StarEnum class StarEnum
{ {
......
<?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
...@@ -50,6 +50,7 @@ class OrderEnum ...@@ -50,6 +50,7 @@ class OrderEnum
const PAY_STATUS = [ //支付状态 const PAY_STATUS = [ //支付状态
self::STATUS_PAID, self::STATUS_PAID,
self::STATUS_DELIVERY,
self::STATUS_COLLECTION self::STATUS_COLLECTION
]; ];
......
...@@ -18,6 +18,7 @@ use Swoft\Core\ResultInterface; ...@@ -18,6 +18,7 @@ use Swoft\Core\ResultInterface;
* @method ResultInterface deferIsCertified(int $storeId) * @method ResultInterface deferIsCertified(int $storeId)
* @method ResultInterface deferGetStoreByStoreId(int $storeId) * @method ResultInterface deferGetStoreByStoreId(int $storeId)
* @method ResultInterface deferGetStoreBySellerId(int $sellerId) * @method ResultInterface deferGetStoreBySellerId(int $sellerId)
* @method ResultInterface deferGetStoreByMobile(int $mobile, array $fields = [])
* @method ResultInterface deferUpdateStore(int $storeId, array $data) * @method ResultInterface deferUpdateStore(int $storeId, array $data)
* @method ResultInterface deferDeleteStore(int $storeId) * @method ResultInterface deferDeleteStore(int $storeId)
* @method ResultInterface deferGetWxacodeUrl(int $storeId, int $type, string $page, string $scene) * @method ResultInterface deferGetWxacodeUrl(int $storeId, int $type, string $page, string $scene)
...@@ -49,6 +50,15 @@ interface StoreInterface ...@@ -49,6 +50,15 @@ interface StoreInterface
public function getStoreBySellerId(int $sellerId); public function getStoreBySellerId(int $sellerId);
/** /**
* 根据注册手机号获取店铺信息
*
* @param integer $mobile
* @param array $fields 要查询的字段列表 :['id','storeName','addTime']
* @return array
*/
public function getStoreByMobile(int $mobile, array $fields = []);
/**
* 根据店铺ID修改店铺信息 * 根据店铺ID修改店铺信息
* *
* @param integer $storeId * @param integer $storeId
......
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