Commit d14cc342 by xmy

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

parents 55e10d24 b1ba4950
...@@ -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,6 +25,7 @@ class Split ...@@ -22,6 +25,7 @@ class Split
$map = array_flip($collector['map']); $map = array_flip($collector['map']);
} }
if ( ! self::isTesting() ) {
//如果是实体且为分表实体 //如果是实体且为分表实体
if (strpos($tableName, '\\') !== false && isset($collector[$tableName])) { if (strpos($tableName, '\\') !== false && isset($collector[$tableName])) {
$className = $tableName; $className = $tableName;
...@@ -48,6 +52,9 @@ class Split ...@@ -48,6 +52,9 @@ class Split
} }
}
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,6 +11,7 @@ ...@@ -11,6 +11,7 @@
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\Enum\TestEnum;
use Hdll\Services\Common\Lib\Redis; use Hdll\Services\Common\Lib\Redis;
use Swoft\Bean\Annotation\Bean; use Swoft\Bean\Annotation\Bean;
use Swoft\Core\RequestContext; use Swoft\Core\RequestContext;
...@@ -35,6 +36,16 @@ class User ...@@ -35,6 +36,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');
......
<?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;
}
...@@ -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