Commit 2c2ff9f0 by xmy

Merge remote-tracking branch 'origin/master'

parents 8c33d1b2 e3934500
...@@ -9,8 +9,8 @@ namespace Hdll\Services\Auth\Enum; ...@@ -9,8 +9,8 @@ namespace Hdll\Services\Auth\Enum;
class AuthError class AuthError
{ {
const GET_TOKEN_ERROR = ["msg" => "获取token失败", "code" => 500, "errorCode" => 25103]; const GET_TOKEN_ERROR = ["msg" => "获取token失败", "code" => 401, "errorCode" => 25103];
const NOT_FOUND_USER = ["msg" => "获取用户信息失败", "code" => 404, "errorCode" => 25104]; const NOT_FOUND_USER = ["msg" => "获取用户信息失败", "code" => 401, "errorCode" => 25104];
public static function atranslate($message,$param) public static function atranslate($message,$param)
......
...@@ -13,14 +13,13 @@ class BargainEnum ...@@ -13,14 +13,13 @@ class BargainEnum
//订单状态 //订单状态
const STATUS_NORMAL = 10; //待支付 const STATUS_NORMAL = 10; //待支付
const STATUS_IN_MINI_PRICE = 20; //已经到底价
const STATUS_HAVE_ORDER = 30; //已经下单
const STATUS_HAVE_BUY = 40; //已经购买
//paystatus //paystatus
const HAVE_PAY =2; const HAVE_PAY =2;
const PAY_EXCEPTION = 3; const PAY_EXCEPTION = 3;
const PAY_REFUND = 4; // 退款
} }
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/30
* Time: 9:50
*/
namespace Hdll\Services\Buyer\Lib;
use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferDelByStoreId(int $storeId)
* Interface Footprint
* @package Hdll\Services\Buyer\Lib
*/
interface FootprintInterface
{
public function delByStoreId(int $storeId) : bool;
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Argericy
* Date: 2018/7/23
* Time: 15:54
*/
namespace App\Models\Dao;
use App\Models\Entity\{entityName};
use Swoft\Bean\Annotation\Bean;
use Hdll\Services\Common\Exception\CommonException;
/**
* @Bean()
* Class {className}
* @package App\Models\Dao
*/
class {className}
{
public function create(array $info) : {entityName}
{
${varEntityName} = new {entityName}($info);
$res = ${varEntityName}->save()->getResult();
if ( $res === false ) {
throw new CommonException(["msg" => "数据库操作错误", "code" => 500]);
}
return ${varEntityName};
}
public function selectInfoByCondition($condition, $field)
{
return {entityName}::findAll($condition, ['fields' => $field])->getResult();
}
public function getInfoByCondition($condition, $field)
{
return {entityName}::findOne($condition, ['fields' => $field])->getResult();
}
/**
* 根据条件更新信息
* @param $condition
* @param $updateInfo
* @return mixed
*/
public function updateByCondition($condition, $updateInfo)
{
return {entityName}::updateAll($updateInfo, $condition)->getResult();
}
/**
* 更新一条记录
*
* @param $condition
* @param $updateInfo
* @return mixed
*/
public function updateOne($condition, $updateInfo)
{
return {entityName}::updateOne($updateInfo, $condition)->getResult();
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Argericy
* Date: 2018/9/29
* Time: 11:35
*/
namespace App\Models\Data;
use App\Models\Dao\{daoName};
use Swoft\Bean\Annotation\Bean;
use Swoft\Bean\Annotation\Inject;
/**
* @Bean()
*
* Class {dataName}
* @package App\Models\Data
*/
class {dataName}
{
/**
* @Inject()
* @var {daoName}
*/
private ${varDaoName};
}
\ 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 App\Commands\Common;
use Swoft\Console\Bean\Annotation\Command;
use Swoft\Console\Bean\Annotation\Mapping;
use Swoft\Console\Input\Input;
use Swoft\Console\Output\Output;
/**
* generate dao,data layer commands
*
* @Command(coroutine=false)
*/
class GenerateCommand
{
/**
* this generate command
*
* @Usage
* generate:dao [options]
*
* @Options
* -n,--n the dao name
* -e,--e the entity name
*
* @Example
* php swoft generate:dao -e entityName [-n daoName]
*
* @param Input $input
* @param Output $output
*
* @Mapping("dao")
*/
public function Dao(Input $input, Output $output)
{
$className = $input->getOpt('n');
$entityName = $input->getOpt('e');
$this->generateDao($output, $className, $entityName);
}
/**
* this generate command
*
* @Usage
* generate:all [options]
*
* @Options
* -n,--n the dao name
* -e,--e the entity name
*
* @Example
* php swoft generate:dao -e entityName [-n dataName] [--dao-name daoName]
*
* @param Input $input
* @param Output $output
*
* @Mapping("all")
*/
public function all(Input $input, Output $output)
{
$dataName = $input->getOpt('n');
$entityName = $input->getOpt('e');
$daoName = $input->getOpt('dao-name');
$appPath = alias('@app');
$dataName = empty($dataName)?$entityName.'Data':$dataName;
//generateDao
$daoName = empty($daoName)?$entityName.'Dao':$daoName;
$this->generateDao($output, $daoName, $entityName);
//generateData
$dataPath = $appPath.'/Models/Data/'.$dataName.'.php';
$templatePath = $appPath.'/Commands/Common/ClassTemplate/Data/ClassTemplate';
$content = file_get_contents($templatePath);
$content = str_replace('{dataName}', $dataName, $content);
$content = str_replace("{daoName}", $daoName, $content);
$content = str_replace("{varDaoName}", lcfirst($daoName), $content);
file_put_contents($dataPath, $content);
}
private function generateDao($output,$daoName, $entityName)
{
if ( empty($entityName) ) {
$output->writeln("the en option is required", true, true);
}
$daoName = empty($daoName)?$entityName.'Dao':$daoName;
$daoPath = alias("@app").'/Models/Dao/'.$daoName.'.php';
$templatePath = alias("@app").'/Commands/Common/ClassTemplate/Dao/ClassTemplate';
$content = file_get_contents($templatePath);
$content = str_replace("{className}", $daoName,$content);
$content = str_replace("{entityName}", $entityName, $content);
$content = str_replace("{varEntityName}", lcfirst($entityName), $content);
file_put_contents($daoPath,$content);
}
}
\ No newline at end of file
...@@ -38,7 +38,6 @@ class LogHandler extends AbstractProcessingHandler ...@@ -38,7 +38,6 @@ class LogHandler extends AbstractProcessingHandler
} }
$lines = array_column($records, 'formatted'); $lines = array_column($records, 'formatted');
$this->write($lines); $this->write($lines);
} }
...@@ -77,6 +76,11 @@ class LogHandler extends AbstractProcessingHandler ...@@ -77,6 +76,11 @@ class LogHandler extends AbstractProcessingHandler
} }
$record = $this->processRecord($record); $record = $this->processRecord($record);
$search1 = strpos($record['messages'], '[http://testapi.2b3.cn:80/]');
$search2 = strpos($record['messages'], '[http://api.2b3.cn:80/]');
if($search1 !== false || $search2 !== false) {
continue;
}
$record['formatted'] = $this->getFormatter()->format($record); $record['formatted'] = $this->getFormatter()->format($record);
$messages[] = $record; $messages[] = $record;
......
...@@ -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,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
<?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 ...@@ -8,11 +8,8 @@ class LimitTimeOrderEnum
//订单状态 //订单状态
const STATUS_NORMAL = 1; //待支付 1未支付2已经支付3异常 const STATUS_NORMAL = 1; //待支付 1未支付2已经支付3异常
const STATUS_HAVE_PAY =2; const STATUS_HAVE_PAY =2; // 已经支付
const STATUS_PAY_EXCEPTION =3; const STATUS_PAY_EXCEPTION =3; // 支付异常或过期未付
const STATUS_PAY_REFUND =4 ; // 退款
} }
\ No newline at end of file
...@@ -71,7 +71,7 @@ interface LimitTimeBuyInterface ...@@ -71,7 +71,7 @@ interface LimitTimeBuyInterface
* 支付 状态 回馈接口 * 支付 状态 回馈接口
* @param string $store_id * @param string $store_id
* @param int $limit_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 * @param int $orderId
* @return bool|mixed * @return bool|mixed
* @throws ConException * @throws ConException
......
...@@ -32,4 +32,6 @@ class NoticeEnum ...@@ -32,4 +32,6 @@ class NoticeEnum
} }
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/9/28
* Time: 14:50
*/
namespace Hdll\Services\Notice\Enum;
class RedisKeyEnum
{
const PREFIX = "notice:";
const ORDER_RESERVATION = self::PREFIX."order_reservation_";
}
\ No newline at end of file
...@@ -15,7 +15,8 @@ use Swoft\Core\ResultInterface; ...@@ -15,7 +15,8 @@ use Swoft\Core\ResultInterface;
/** /**
* The interface of demo service * The interface of demo service
* *
* @method ResultInterface deferSend(int $storeId, array $sendTypes, array $data, int $sendTime) :bool * @method ResultInterface deferSend(int $storeId, array $sendTypes, array $data, int $sendTime, string $redisKey) :bool
* @method ResultInterface deferCancelSend(int $storeId, array $sendTypes, array $data, int $sendTime, string $redisKey) :bool
*/ */
interface NoticeInterface interface NoticeInterface
{ {
...@@ -60,7 +61,7 @@ interface NoticeInterface ...@@ -60,7 +61,7 @@ interface NoticeInterface
* *
* 微信公众号发送实例 * 微信公众号发送实例
$data[NoticeEnum::TYPE_MP_SEND] = [ $data[NoticeEnum::TYPE_MP_SEND] = [
'touser' => 'o3lFcs8xoWfQUlhzTiP5uZI6A7Hc', //这里要填写公众号的openId 'unionId' => 'o3lFcs8xoWfQUlhzTiP5uZI6A7Hc', //填写用户的unionId
'template_id' => 'zwUBuoKVRJkumLwGkippA46XfmLsmwJD906HC-wqOks', 'template_id' => 'zwUBuoKVRJkumLwGkippA46XfmLsmwJD906HC-wqOks',
'miniprogram' => [ 'miniprogram' => [
'appid' => 'wx3b3b2df942634cdd', //小程序appid 'appid' => 'wx3b3b2df942634cdd', //小程序appid
...@@ -80,7 +81,17 @@ interface NoticeInterface ...@@ -80,7 +81,17 @@ interface NoticeInterface
* @param array $sendTypes * @param array $sendTypes
* @param array $data * @param array $data
* @param int $sendTime //发送时间,立即返送填0 * @param int $sendTime //发送时间,立即返送填0
* @param string $redisKey //发送事件的redis key(如果定时发送消息,中途需要取消则需要传入此项)
* @return mixed * @return mixed
*/ */
public function send(array $sendTypes, array $data, int $sendTime) :bool; public function send(array $sendTypes, array $data, int $sendTime, string $redisKey='') :bool;
/**
* 取消定时消息发送
*
* @param string $redisKey
* @return bool
*/
public function cancelSend(string $redisKey):bool ;
} }
\ No newline at end of file
...@@ -16,6 +16,7 @@ use Swoft\Core\ResultInterface; ...@@ -16,6 +16,7 @@ use Swoft\Core\ResultInterface;
* The interface of store service * The interface of store service
* *
* @method ResultInterface deferIsCertified(int $storeId) * @method ResultInterface deferIsCertified(int $storeId)
* @method ResultInterface deferIsNormal(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 deferGetStoreByMobile(int $mobile, array $fields = [])
...@@ -29,11 +30,20 @@ interface StoreInterface ...@@ -29,11 +30,20 @@ interface StoreInterface
* 查询店铺是否已实名认证(企业认证) * 查询店铺是否已实名认证(企业认证)
* *
* @param integer $storeId * @param integer $storeId
* @return boolean * @return bool true:认证成功 false:未认证
*/ */
public function isCertified(int $storeId); public function isCertified(int $storeId);
/** /**
* 查询店铺是否正常
*
* @Number(name="storeId")
* @param integer $storeId
* @return bool true:正常,false:冻结
*/
public function isNormal(int $storeId);
/**
* 根据店铺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