Commit 2dc56c10 by liwotian name

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

parents 9740fc5f 398e497e
...@@ -6,48 +6,20 @@ ...@@ -6,48 +6,20 @@
* Time: 13:48 * Time: 13:48
*/ */
namespace Hdll\Services\BuyerDistribution\Lib; namespace Hdll\Services\Buyer\Lib;
use Swoft\Core\ResultInterface;
/** /**
* @method ResultInterface deferAddSellerFreezeMoney(int $storeId,int $money)
* @method ResultInterface deferGetBuyerCommission(int $buyerId)
* @method ResultInterface deferGetSellerFund(int $storeId)
* @method ResultInterface deferSaveBill(string $token,int $order_id,int $buyer_id,int $store_id,string $order_sn,int $money) * @method ResultInterface deferSaveBill(string $token,int $order_id,int $buyer_id,int $store_id,string $order_sn,int $money)
* Interface AgencyInterface * Interface AgencyInterface
* @package App\Lib * @package App\Lib
*/ */
interface BuyerDistributionInterface{ interface BillInterface{
/**
* 增加卖家冻结金额
* @param int $storeId
* @param int $money 冻结金额(千分)
* @return mixed
* @author Administrator
*/
public function addSellerFreezeMoney(int $storeId,int $money);
/**
* 获取买家佣金数据
* @param int $buyerId
* @return mixed
* @author Administrator
*/
public function getBuyerCommission(int $buyerId);
/**
* 获取卖家资金数据
* @param int $storeId
* @return mixed
* @author Administrator
*/
public function getSellerFund(int $storeId);
/** /**
* 保存账单数据 * 保存账单数据
* @param string $token
* @param int $order_id * @param int $order_id
* @param int $buyer_id * @param int $buyer_id
* @param int $store_id * @param int $store_id
...@@ -57,7 +29,6 @@ interface BuyerDistributionInterface{ ...@@ -57,7 +29,6 @@ interface BuyerDistributionInterface{
* @author Administrator * @author Administrator
*/ */
public function saveBill( public function saveBill(
string $token,
int $order_id, int $order_id,
int $buyer_id, int $buyer_id,
int $store_id, int $store_id,
......
...@@ -19,7 +19,7 @@ interface CommissionInterface ...@@ -19,7 +19,7 @@ interface CommissionInterface
* @param $storeId * @param $storeId
* @param $buyerId * @param $buyerId
* @param $money * @param $money
* @return bool * @return mixed|bool
*/ */
public function reduceBalanceCommission($storeId, $buyerId, $money); public function reduceBalanceCommission($storeId, $buyerId, $money);
......
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/7/17
* Time: 14:19
*/
namespace Hdll\Services\Order\Enum;
class BuyerDistributionError
{
const E101 = ['101', '金额不能小于0'];
const E102 = [102, '该数据不属于您', 403];
const E103 = [103, '请勿重复创建', 403];
const E104 = [104, '该用户不存在或属于您的团队', 403];
public function getError($code)
{
$reflect = new \ReflectionClass(self::class);
$arr = $reflect->getConstant('E' . substr($code, -3));
if (!is_array($arr)) {
return false;
}
return [
'code' => $arr[0],
'msg' => $arr[1],
'errorCode' => $arr[2],
];
}
}
\ No newline at end of file
...@@ -119,7 +119,7 @@ class CommonEntity extends Model ...@@ -119,7 +119,7 @@ class CommonEntity extends Model
$user = App::getBean(User::class); $user = App::getBean(User::class);
$store = $user->getStoreId(); $store = $user->getStoreId();
if ( empty($store) ) { if ( $store === null && $store === [] && $store === '' ) {
throw new Exception("店铺id获取失败"); throw new Exception("店铺id获取失败");
} }
......
...@@ -36,7 +36,7 @@ class CommonException extends Exception ...@@ -36,7 +36,7 @@ class CommonException extends Exception
} }
if ( isset($params['path']) ) { if ( isset($params['path']) ) {
$this->path = $params['path']; $this->path = empty($params['path'])?[]:$params['path'];
} }
......
...@@ -33,19 +33,25 @@ class ExceptionData ...@@ -33,19 +33,25 @@ class ExceptionData
$data = [ $data = [
"code" => $e->getCode(), "code" => $e->getCode(),
"msg" => $e->getMessage(), "msg" => $e->getMessage(),
"errCode" => is_callable([$e,'getErrCode'])?$e->getErrcode():'', "errCode" => is_callable([$e,'getErrCode'])?$e->getErrcode():-1,
'path' =>[], 'path' =>[],
]; ];
if ( is_callable([$e,"getPath"]) ) { if ( is_callable([$e,"getPath"]) ) {//自建异常类处理path
$data['path'] = json_decode($e->getPath(), true); $data['path'] = json_decode($e->getPath(), true);
//获取调用堆栈信息
$info = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,1)[0];
//将此次异常信息入站
array_unshift($data['path'],'Service:'.APP_NAME.' file:'.$info['file'].'('.$info['line'].')');
} else { //系统异常统一报500错误
$data['code'] = 500;
//将此次异常信息入站
array_unshift($data['path'],'Service:'.APP_NAME.' file:'.$e->getFile().'('.$e->getLine().')');
} }
//获取调用堆栈信息
$info = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS,1)[0];
//将此次异常信息入站
array_unshift($data['path'],'Service:'.APP_NAME.' file:'.$info['file'].$info['line']);
return ['msg' => json_encode($data), 'code' => $data['code']]; return ['msg' => json_encode($data), 'code' => $data['code']];
......
...@@ -21,9 +21,10 @@ class ExceptionParseData ...@@ -21,9 +21,10 @@ class ExceptionParseData
$data = json_decode($msg,true); $data = json_decode($msg,true);
} else { } else {
$data['msg'] = $e->getMessage(); $data['msg'] = $e->getMessage();
$data['code'] = $e->getCode(); $data['code'] = 500;
$data['errorCode'] = -1;
$data['file'] = $e->getFile().' '.$e->getLine(); $data['file'] = $e->getFile().' '.$e->getLine();
$data['path'] = [$e->getFile().' '.$e->getLine()]; $data['path'] = ['Service:'.APP_NAME.$e->getFile().' '.$e->getLine()];
} }
return $data; return $data;
......
...@@ -61,7 +61,7 @@ class BuyerPoolConfig extends PoolProperties ...@@ -61,7 +61,7 @@ class BuyerPoolConfig extends PoolProperties
* the time of connect timeout * the time of connect timeout
* *
*/ */
protected $timeout = 200; protected $timeout = 5;
/** /**
* the addresses of connection * the addresses of connection
......
<?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 Hdll\Services\Common\Pool\Config;
use Swoft\Bean\Annotation\Bean;
use Swoft\Pool\PoolProperties;
/**
* the config of service user
*
* @Bean()
*/
class GoodsPoolConfig extends PoolProperties
{
protected $name = 'seller';
/**
* Minimum active number of connections
*
* @var int
*/
protected $minActive = 5;
/**
* the maximum number of active connections
*
* @var int
*/
protected $maxActive = 50;
/**
* the maximum number of wait connections
*
* @var int
*/
protected $maxWait = 100;
/**
* Maximum waiting time
*
* @var int
*/
protected $maxWaitTime = 3;
/**
* Maximum idle time
*
* @var int
*/
protected $maxIdleTime = 60;
/**
* the time of connect timeout
*
* @var int
*/
protected $timeout = 5;
/**
* the addresses of connection
*
* <pre>
* [
* '127.0.0.1:88',
* '127.0.0.1:88'
* ]
* </pre>
*
* @var array
*/
protected $uri = [
'192.168.3.39:8400',
];
/**
* whether to user provider(consul/etcd/zookeeper)
*
* @var bool
*/
protected $useProvider = false;
/**
* the default balancer is random balancer
*
* @var string
*/
protected $balancer = '';
/**
* the default provider is consul provider
*
* @var string
*/
protected $provider = '';
}
...@@ -14,6 +14,7 @@ use Swoft\Bean\Annotation\Bean; ...@@ -14,6 +14,7 @@ use Swoft\Bean\Annotation\Bean;
use Swoft\Pool\PoolProperties; use Swoft\Pool\PoolProperties;
/** /**
* @Bean()
* the config of service user * the config of service user
* *
* @Bean() * @Bean()
...@@ -63,7 +64,7 @@ class OrderPoolConfig extends PoolProperties ...@@ -63,7 +64,7 @@ class OrderPoolConfig extends PoolProperties
* *
* @var int * @var int
*/ */
protected $timeout = 200; protected $timeout = 5;
/** /**
* the addresses of connection * the addresses of connection
...@@ -78,7 +79,7 @@ class OrderPoolConfig extends PoolProperties ...@@ -78,7 +79,7 @@ class OrderPoolConfig extends PoolProperties
* @var array * @var array
*/ */
protected $uri = [ protected $uri = [
'192.168.3.100:8100', '192.168.3.100:8084',
]; ];
/** /**
......
...@@ -63,7 +63,7 @@ class SellerDistributionPoolConfig extends PoolProperties ...@@ -63,7 +63,7 @@ class SellerDistributionPoolConfig extends PoolProperties
* *
* @var int * @var int
*/ */
protected $timeout = 200; protected $timeout = 5;
/** /**
* the addresses of connection * the addresses of connection
......
...@@ -63,7 +63,7 @@ class SellerPoolConfig extends PoolProperties ...@@ -63,7 +63,7 @@ class SellerPoolConfig extends PoolProperties
* *
* @var int * @var int
*/ */
protected $timeout = 200; protected $timeout = 5;
/** /**
* the addresses of connection * the addresses of connection
......
...@@ -63,7 +63,7 @@ class VipPoolConfig extends PoolProperties ...@@ -63,7 +63,7 @@ class VipPoolConfig extends PoolProperties
* *
* @var int * @var int
*/ */
protected $timeout = 200; protected $timeout = 5;
/** /**
* the addresses of connection * the addresses of connection
......
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/8
* Time: 10:43
*/
namespace Hdll\Services\Goods\Lib;
use Swoft\Core\ResultInterface;
/**
* @method ResultInterface deferGet($storeId,$id)
* @method ResultInterface deferGetList($storeId,$page,$limit)
* Interface GoodsInterface
* @package Hdll\Services\Goods\Lib
*/
interface GoodsInterface{
/**
* 获取商品
* @param $storeId
* @param $id
* @return mixed
* @author Administrator
*/
public function get($storeId,$id);
/**
* 获取商品列表
* @param $storeId
* @param $page
* @param $limit
* @return mixed
* @author Administrator
*/
public function getList($storeId,$page,$limit);
}
\ 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 demo service * The interface of demo service
* *
* @method ResultInterface deferCreateOrder( string $token,int $consignee_id,int $activity_id,int $selected_num,int $order_type,float $total,float $goods_price,string $goods_name,string $goods_image,string $activity_name,string $reservation_time = '') * @method ResultInterface deferCreateOrder( string $token,int $consignee_id,int $activity_id,int $selected_num,int $order_type,float $total,float $goods_price,string $goods_name,string $goods_image,string $activity_name,string $reservation_time = '')
* @method ResultInterface deferGetOrderInfo(int $storeId,int $orderId)
*/ */
interface OrderInterface interface OrderInterface
{ {
...@@ -46,4 +47,6 @@ interface OrderInterface ...@@ -46,4 +47,6 @@ interface OrderInterface
string $goods_image, string $goods_image,
string $activity_name, string $activity_name,
string $reservation_time = ''); string $reservation_time = '');
public function getOrderInfo(int $storeId,int $orderId);
} }
\ No newline at end of file
...@@ -14,13 +14,62 @@ namespace Hdll\Services\Reservation\Lib; ...@@ -14,13 +14,62 @@ namespace Hdll\Services\Reservation\Lib;
use Swoft\Core\ResultInterface; use Swoft\Core\ResultInterface;
/** /**
* The interface of Schedule service * The interface of Reservation service
* *
* @method ResultInterface deferGetScheduleList(int $storeId, int $month=null) * @method ResultInterface deferGetReservById(int $id)
* @method ResultInterface deferGetScheduleByDateId(int $storeId, int $dateId) * @method ResultInterface deferGetReservByDateId(int $storeId, int $dateId)
* @method ResultInterface deferUpdateSchedule(int $storeId, int $dateId, array $data) * @method ResultInterface deferGetReservListByOrderId(int $storeId, $orderId)
* @method ResultInterface deferAddSchedule(int $storeId, int $dateId, array $data) * @method ResultInterface deferModifyReservById(int $id)
* @method ResultInterface deferCancelReservById(int $id)
*/ */
interface ReservationInterface interface ReservationInterface
{ {
/**
* 获取某个预约的信息
*
* @param integer $id
* @return array
*/
public function getReservById(int $id);
/**
* 根据日期id,获取商家某一天的所有预约
*
* @param integer $storeId
* @param integer $dateId
* @return array
*/
public function getReservByDateId(int $storeId, int $dateId);
/**
* 根据订单id,获取商家某个订单包含的所有预约
*
* @param integer $storeId
* @param integer $orderId
* @return void
*/
public function getReservListByOrderId(int $storeId, int $orderId);
/**
* 修改某个预约信息
*
* @param integer $id
* @param array $data
* $data 字段说明:
* ['state'] => 预约状态,默认0,如果正常结束则为1
* ['type'] => 预约类型,备用
* ['reservTime'] => 预约时间,时间戳格式
* ['isConfirm'] => 1表示商家确认预约
* ['memo'] => 预约备注
* @return int 返回成功修改的条数
*/
public function modifyReservById(int $id, array $data);
/**
* 取消某个预约
*
* @param integer $id
* @return boolean 返回取消结果
*/
public function cancelReservById(int $id);
} }
\ No newline at end of file
...@@ -12,31 +12,24 @@ use Swoft\Core\ResultInterface; ...@@ -12,31 +12,24 @@ use Swoft\Core\ResultInterface;
/** /**
* *
* @method ResultInterface deferWithdraw($sellerId, $money) * @method ResultInterface deferGetFund($sellerId)
* @method ResultInterface deferWithdrawFail($sellerId, $money)
* Interface SellerInterface * Interface SellerInterface
* @package App\Lib * @package App\Lib
*/ */
interface SellerFundInterface interface SellerFundInterface
{ {
/**
* 提现
* @param $sellerId
* @param $money (分)
* @return mixed
* @author Administrator
*/
public function withdraw($sellerId, $money);
/** /**
* 提现失败 *
* @param $sellerId * @param $sellerId
* @param $money (分)
* @return mixed * @return mixed
* totalFund 累计资金
* balanceFund 可提现金额
* commissionFund 需要支付的佣金
* expectFund 冻结金额
* totalWithdraw 累计提现
* @author Administrator * @author Administrator
*/ */
public function withdrawFail($sellerId, $money); public function getFund($sellerId);
} }
\ No newline at end of file
...@@ -10,6 +10,11 @@ use Swoft\Core\ResultInterface; ...@@ -10,6 +10,11 @@ use Swoft\Core\ResultInterface;
/** /**
* @method ResultInterface deferSaveBill($orderId, $sellerId, $money) * @method ResultInterface deferSaveBill($orderId, $sellerId, $money)
* @method ResultInterface deferGetCommission($sellerId)
* method ResultInterface deferAddBalance($sellerId, $money)
* method ResultInterface deferReduceBalance($sellerId, $money)
* method ResultInterface deferAddTotal($sellerId, $money)
* method ResultInterface deferReduceTotal($sellerId, $money)
* Interface SellerDistributionInterface * Interface SellerDistributionInterface
* @package App\Lib * @package App\Lib
*/ */
...@@ -28,4 +33,50 @@ interface SellerDistributionInterface{ ...@@ -28,4 +33,50 @@ interface SellerDistributionInterface{
*/ */
public function saveBill($orderId, $sellerId, $money); public function saveBill($orderId, $sellerId, $money);
/**
* 获取佣金信息
* @param $sellerId
* @return mixed
* totalCommission 累计佣金
* balanceCommission 可提现佣金
* @author Administrator
*/
public function getCommission($sellerId);
/**
* 增加佣金
* @param $sellerId
* @param $money
* @return mixed
* @author Administrator
*/
public function addBalance($sellerId, $money);
/**
* 减少佣金
* @param $sellerId
* @param $money
* @return mixed
* @author Administrator
*/
public function reduceBalance($sellerId, $money);
/**
* 增加累计佣金
* @param $sellerId
* @param $money
* @return mixed
* @author Administrator
*/
public function addTotal($sellerId, $money);
/**
* 减少累计佣金
* @param $sellerId
* @param $money
* @return mixed
* @author Administrator
*/
public function reduceTotal($sellerId, $money);
} }
\ 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 Hdll\Services\Store\Lib;
use Swoft\Core\ResultInterface;
/**
* The interface of store-commission service
*
* @method ResultInterface deferGetCommSetting(int $storeId)
* @method ResultInterface deferUpdateByStoreId(int $storeId)
*/
interface CommsettingInterface
{
/**
* 获取买家分销佣金规则
*
* @Number(name="storeId")
* @param int $storeId
* @return array
* 返回内容说明:
* ['state'] => 分销佣金规则是否启用,0不启用,1启用
* ['rule'] => 分销佣金规则具体设置内容,json格式: {"1":35,"2":14.5}
* ['minWithdraw'] => 最小提现金额,单位分
* ['memo'] => 规则备注说明
*/
public function getCommSetting(int $storeId);
/**
* 根据店铺ID修改买家分销的佣金规则
*
* @Number(name="storeId")
* @param integer $storeId
* @param array $data
* 参数$data 字段说明:
* ['state'] => 分销佣金规则是否启用,0不启用,1启用
* ['rule'] => 分销佣金规则具体设置内容,json格式: {"1":35,"2":14.5}
* ['minWithdraw'] => 最小提现金额,单位分
* ['memo'] => 规则备注说明
* @return array
*/
public function updateByStoreId(int $storeId, array $data);
}
\ 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