Commit 9684a6a2 by 王召彬

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

parents 414fb086 84b8784c
......@@ -9,8 +9,8 @@ namespace Hdll\Services\Auth\Enum;
class AuthError
{
const GET_TOKEN_ERROR = ["msg" => "获取token失败", "code" => 500, "errorCode" => 25103];
const NOT_FOUND_USER = ["msg" => "获取用户信息失败", "code" => 404, "errorCode" => 25104];
const GET_TOKEN_ERROR = ["msg" => "获取token失败", "code" => 401, "errorCode" => 25103];
const NOT_FOUND_USER = ["msg" => "获取用户信息失败", "code" => 401, "errorCode" => 25104];
public static function atranslate($message,$param)
......
......@@ -13,14 +13,13 @@ class BargainEnum
//订单状态
const STATUS_NORMAL = 10; //待支付
const STATUS_IN_MINI_PRICE = 20; //已经到底价
const STATUS_HAVE_ORDER = 30; //已经下单
const STATUS_HAVE_BUY = 40; //已经购买
//paystatus
const HAVE_PAY =2;
const PAY_EXCEPTION = 3;
const PAY_REFUND = 4; // 退款
}
\ No newline at end of file
......@@ -8,6 +8,9 @@
namespace Hdll\Services\Common\Entity;
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\Db\Bean\Collector\EntityCollector;
use Swoft\Db\QueryBuilder;
......@@ -22,32 +25,36 @@ class Split
$map = array_flip($collector['map']);
}
//如果是实体且为分表实体
if (strpos($tableName, '\\') !== false && isset($collector[$tableName])) {
$className = $tableName;
$tableName = $collector[$tableName]['table'];
if ( ! self::isTesting() ) {
//如果是实体且为分表实体
if (strpos($tableName, '\\') !== false && isset($collector[$tableName])) {
$className = $tableName;
$tableName = $collector[$tableName]['table'];
$entityCollector = EntityCollector::getCollector();
$entityCollector = EntityCollector::getCollector();
//设置分表对应的className
EntityCollector::setCollector($tableName.'_'.self::getDbNum($className), $tableName);
//设置分表对应的className
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]) ) { //非实体且分表
$className = $map[$tableName];
$defaultTbleName = $tableName;
$tableName = $tableName.'_'.self::getDbNum($className);
//设置分表对应的className
EntityCollector::setCollector($tableName, $defaultTbleName);
} elseif ( isset($map[$tableName]) ) { //非实体且分表
$className = $map[$tableName];
$defaultTbleName = $tableName;
$tableName = $tableName.'_'.self::getDbNum($className);
//设置分表对应的className
EntityCollector::setCollector($tableName, $defaultTbleName);
}
}
return $tableName;
}
......@@ -57,6 +64,17 @@ class Split
$splitNum = $splitCollector[$className]['num'];
$data = RequestContext::getContextData();
$storeId = $data['userInfo']['storeId'];
if ( empty($storeId) ) {
throw new CommonException(["msg" => "参数异常,获取店铺信息失败。"]);
}
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 @@
namespace Hdll\Services\Common\Entity;
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\Core\RequestContext;
use Swoft\Redis\Redis;
/**
* 用户实体
......@@ -35,6 +37,16 @@ class User
return $this->getValue('id');
}
public function setTestFlag()
{
$this->setValue('testFlag', TestEnum::TEST_STORE_ID);
}
public function getTestFlag()
{
return $this->getValue('testFlag');
}
public function getNickname()
{
return $this->getValue('nickname');
......@@ -153,12 +165,8 @@ class User
return [false,AuthError::GET_TOKEN_ERROR];
}
/**
* @var Redis $redis
*/
$redis = new Redis();
$redis->setPrefix("AUTH:");
$info = $redis->get($token);
$redis = App::getBean(Redis::class);
$info = $redis->get("AUTH:".$token);
if ( empty($info) ) {
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
<?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
......@@ -8,11 +8,8 @@ class LimitTimeOrderEnum
//订单状态
const STATUS_NORMAL = 1; //待支付 1未支付2已经支付3异常
const STATUS_HAVE_PAY =2;
const STATUS_PAY_EXCEPTION =3;
const STATUS_HAVE_PAY =2; // 已经支付
const STATUS_PAY_EXCEPTION =3; // 支付异常或过期未付
const STATUS_PAY_REFUND =4 ; // 退款
}
\ No newline at end of file
......@@ -71,7 +71,7 @@ interface LimitTimeBuyInterface
* 支付 状态 回馈接口
* @param string $store_id
* @param int $limit_id
* @param int $status // 2.LimitTimeOrderEnum::STATUS_HAVE_PAY 成功支付 3:LimitTimeOrderEnum::STATUS_PAY_EXCEPTION 未支付 (已经过期或者支付异常)
* @param int $status // 2.LimitTimeOrderEnum::STATUS_HAVE_PAY 成功支付 3:LimitTimeOrderEnum::STATUS_PAY_EXCEPTION 未支付 (已经过期或者支付异常)4 LimitTimeOrderEnum::STATUS_PAY_REFUND 退款
* @param int $orderId
* @return bool|mixed
* @throws ConException
......
......@@ -32,4 +32,6 @@ class NoticeEnum
}
\ 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