Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
services
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tencent
services
Commits
106a74d1
Commit
106a74d1
authored
Oct 23, 2018
by
王召彬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优惠券接口开发
parent
c846c15d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
205 additions
and
0 deletions
+205
-0
src/Common/Pool/Config/CouponPoolConfig.php
+106
-0
src/Coupon/Enum/CouponEnum.php
+17
-0
src/Coupon/Lib/CouponInterface.php
+82
-0
No files found.
src/Common/Pool/Config/CouponPoolConfig.php
0 → 100644
View file @
106a74d1
<?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 coupon
*
* @Bean()
*/
class
CouponPoolConfig
extends
PoolProperties
{
public
function
__construct
()
{
// 区别本地和线上的RPC服务地址
$this
->
uri
=
explode
(
','
,
env
(
'RPC_COUPON_URI'
,
'coupon:8099'
));
}
protected
$name
=
'coupon'
;
/**
* 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
=
200
;
/**
* the addresses of connection
*
* <pre>
* [
* '127.0.0.1:88',
* '127.0.0.1:88'
* ]
* </pre>
* @var array
*/
protected
$uri
=
[];
/**
* 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
=
''
;
}
src/Coupon/Enum/CouponEnum.php
0 → 100644
View file @
106a74d1
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2018/8/24
* Time: 15:28
*/
namespace
Hdll\Services\Coupon\Enum
;
class
CouponEnum
{
// 优惠券状态:
const
STATE_NOT_USED
=
1
;
// 表示优惠券还未使用
const
STATE_ORDER_HOLD
=
2
;
// 表示订单下单时已占用,但还未真正使用
const
STATE_USED
=
3
;
// 表示优惠券已被使用
}
\ No newline at end of file
src/Coupon/Lib/CouponInterface.php
0 → 100644
View file @
106a74d1
<?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\Coupon\Lib
;
use
Swoft\Core\ResultInterface
;
/**
* The interface of coupon service
*
* @method ResultInterface deferCheckCoupon(int $buyerId, int $storeId, int $couponId, int $itemId)
* @method ResultInterface deferGetCouponRecvdList(int $buyerId, int $storeId, int $subStoreId = 0, int $itemId = 0)
* @method ResultInterface deferGetDataByCouponId(int $buyerId, int $storeId, int $couponId)
*/
interface
CouponInterface
{
// 优惠券服务的字段说明:
// storeId
// subStoreId
// buyerId 买家ID
// state 状态,1未使用,2已下单还未付款,3已使用过
// couponId 当时领取的原始优惠券Id
// couponName 当时领取的原始优惠券名字
// parValue 优惠券面值
// allowItems 优惠券允许使用的商品列表
// addTime 领取时间
// usedTime 被使用的时间
/**
* 校验优惠券是否可用
*
* @param integer $buyerId
* @param integer $storeId
* @param integer $couponId
* @param integer $itemId
* @return int|boolen 如果可用返回优惠券的面值,不可用返回false
*/
public
function
checkCoupon
(
int
$buyerId
,
int
$storeId
,
int
$couponId
,
int
$itemId
);
/**
* 更新优惠券状态
*
* @param integer $buyerId
* @param integer $storeId
* @param integer $couponId
* @param integer $state 优惠券的状态
* @return int 返回受影响的行数
*/
public
function
updateCouponState
(
int
$buyerId
,
int
$storeId
,
int
$couponId
,
int
$state
);
/**
* 获取顾客领取的优惠券列表
*
* @param integer $buyerId
* @param integer $storeId
* @param integer $subStoreId
* @param integer $itemId
* @return array
*/
public
function
getCouponRecvdList
(
int
$buyerId
,
int
$storeId
,
int
$subStoreId
=
0
,
int
$itemId
=
0
);
/**
* 根据优惠券ID获取信息
*
* @param integer $buyerId
* @param integer $storeId
* @param integer $couponId
* @return array
*/
public
function
getDataByCouponId
(
int
$buyerId
,
int
$storeId
,
int
$couponId
);
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment