Commit 4a7fa487 authored by 杨培's avatar 杨培

新增多个红包服务功能

parent 81fbcf37
......@@ -10,5 +10,6 @@ use internalApi\ucenter\MemberRedpack;
require __DIR__.'/_init.php';
MemberRedpack::setDebug();
$info = MemberRedpack::getFirstRedpack(582);
print_r($info);
\ No newline at end of file
//$info = MemberRedpack::createRedpack(18, '12.5', 'test', '测试红包', null, true);
$info = MemberRedpack::unfreeze([134, 136]);
print_r($info);
......@@ -11,8 +11,15 @@ use internalApi\ucenter\Vip;
require __DIR__.'/_init.php';
Vip::setDebug();
$ret = Vip::getGrades();
//$ret = Vip::setInviter('844184b4016810002cde5254007c97eb', '0e150e59016910003f4c525400781c54');
print_r($ret);
try {
//$ret = Vip::getGrades();
$ret = Vip::getMembersByWxhuids('worker-74635,0e150e59016910003f4c525400781c54');
//$ret = Vip::setInviter('844184b4016810002cde5254007c97eb', '0e150e59016910003f4c525400781c54');
print_r($ret);
} catch (\internalApi\base\ApiException $e) {
echo $e->getMessage();
echo $e->getRemoteTraceString();
}
//Vip::addPending(12, 123, 1);
\ No newline at end of file
......@@ -9,6 +9,10 @@ namespace internalApi\ucenter;
use internalApi\base\Client;
/**
* 红包服务
* @package internalApi\ucenter
*/
class MemberRedpack extends Client
{
public static function getFirstRedpack($userId)
......@@ -16,4 +20,56 @@ class MemberRedpack extends Client
return self::call('memberRedpack.firstRedpack',compact('userId'));
}
/**
* 给指定用户创建一个可领红包
*
* @param int $uid
* @param float $amount 金额,最大支持99.99
* @param string $customType 红包类型枚举字符串,最大20个字节,
* @param string $desc 红包描述
* @param string $entityNo 实体编号,相同类型,且实体编号相同将不会重复创建
* @param bool $frozen 红包是否处于冻结状态,冻结状态的红包需使用 unfreeze 解冻后方可提现
* @return array 创建成功后返回数组包含 status 与 id 两个值<br>
* status 为 OK 时代表创建成功,为 ENTITY_EXISTS 代表相同的实体编号重复<br>
* id 为红包的ID<br>
* 正常为情况下不需要要根据返回值进行处理,创建是否成功应该使用 try catch 是否有异常来判断。
* 返回值仅是为了获取红包ID,或区分是否是重复实体编号编号的红包等其它逻辑。
* @throws \internalApi\base\ApiException
* @throws \internalApi\base\ClientException
*/
public static function createRedpack($uid, $amount, $customType, $desc = '', $entityNo=null, $frozen=false)
{
$p = compact('uid', 'amount', 'customType', 'desc', 'entityNo', 'frozen');
return self::call('memberRedpack.createRedpack', $p);
}
/**
* 批量创建红包
*
* @param array $data 批量创建红包数据,包含多个字段的二维数组,其中 entity_no 与 desc 可选
* uid, amount, type, entity_no, desc
* 具体参数含义 @see createRedpack
*
* @return array
* @throws \internalApi\base\ApiException
* @throws \internalApi\base\ClientException
*/
public static function createRedpackBatch(array $data)
{
return self::call('memberRedpack.createRedpack', compact('data'));
}
/**
* 解冻单个或多个红包
*
* @param array|int $redpackIds 单个红包ID或多个红包ID的数组
* @return int 解冻成功的红包数量
* @throws \internalApi\base\ApiException
* @throws \internalApi\base\ClientException
*/
public static function unfreeze($redpackIds)
{
return self::call('memberRedpack.unfreeze', compact('redpackIds'));
}
}
\ 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