BuyConcurrentController.class.php
2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Created by PhpStorm.
* User: yingcai
* Date: 2018/2/1
* Time: 下午4:51
*/
namespace Apicp\Controller\LiveOrder;
use Common\Common\Constant;
use Common\Common\Order;
class BuyConcurrentController extends AbstractController
{
/**
* BuyConcurrent
* @author houyingcai
* @desc 购买并发人数接口
* @return array|bool 购买规则
array(
'is_wait_pay' => 1, // 企业是否有待支付订单(1=是,2=否)
'product_id' => '008474BE7F00000175505861C25D23D2', // 产品类型
'order_id' => '008474BE7F00000175505861C25D23D2', // 订单ID
'surplus_num' => 0, // 当前剩余并发人数
'product_name' => '企业直播', // 购买产品名称
'rule' => array(
'price' => 10000, // 价格(单位:分)
'unit' => '人,年', // 单位
),
)
*/
public function Index_post()
{
$orderServ = &Order::instance();
$is_wait_pay = Constant::WAIT_PAY_ORDER_TRUE;
// 获取是否有待支付的订单
$result = $orderServ->fetchOrderList([
'ordPayStatus' => Constant::ORDER_STATUS_WAIT_PAY,
'ordType' => Constant::ORDER_TYPE_PRODUCT_LIVE,
]);
// 获取并发人数购买规则
$rule = $orderServ->fetchProductRule(['prCostKey' => 'live_cast_rule']);
// 获取购买并发人数和剩余并发人数
$liveOrder = $orderServ->getLiveCastBasic();
$surplus_num = $liveOrder['liveTotal'] - $liveOrder['liveExpend'];
if (!$result['total']) {
$is_wait_pay = Constant::WAIT_PAY_ORDER_FALSE;
}
$this->_result = [
'is_wait_pay' => $is_wait_pay,
'product_id' => $result['total'] ? $result['list'][0]['prId'] : '',
'order_id' => $result['list']['0']['ordId'],
'surplus_num' => $surplus_num,
'product_name' => $rule['prName'],
'rule' => json_decode($rule['prCostValue'], true),
];
return true;
}
}