DetailController.class.php
6.18 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
/**
* 获取订单详情
* User: yingcai
* Date: 2018/2/2
* Time: 下午3:26
*/
namespace Apicp\Controller\Order;
use Common\Common\Order;
class DetailController extends AbstractController
{
// 订单类型:订单类型(1=购买「业绩比拼」应用,2=扩充「业绩比拼」应用使用人数,3=购买「员圈直播」并发人数,4=购买「员圈」应用,5=扩充「员圈」应用使用人数,
const ORDER_TYPE_SALE_APP = 1;
const ORDER_TYPE_SALT_PEOPLE = 2;
const ORDER_TYPE_YQ_ADD_USER = 5;
const ORDER_TYPE_YQ_APP = 4;
/**
* Detail
* @author houyingcai
* @desc 订单详情接口
* @param String order_id:true 订单ID
* @return array|bool 订单详情
array(
'order_sn' => 'LC2018020118403416000131', // 订单编号
'order_status' => 1, // 订单状态(1=待支付,2=已完成,3=已取消,4=已关闭)
'addEaRealname' => '涂开', // 创建人
'addEaMobile' => '13456346545', // 创建人手机号
'order_created' => 1515340800000, // 创建时间
'order_title' => '员圈直播服务', // 产品/服务名称
'order_desc' => array( // 购买说明
'user_num' => 100, // 人数
'years' => 1, // 年数
'disk' => 1, // 购买的空间容量(购买空间时值有效)
'network' => 1, // 购买的流量(购买流量时值有效)
'desc' => '1000人及一下', // 产品描述
'level' => 1, //购买人数范围等级(购买业绩比拼时有效)
),
'order_price' => 1000, // 订单金额(单位:分)
'pay_type' => 3, // 支付方式(1=微信支付,2=支付宝支付,3=线下支付)
'order_type' => 1, // 订单类型(1=购买「业绩比拼」应用,2=扩充「业绩比拼」应用使用人数,3=购买「员圈直播」并发人数,4=购买「员圈」应用,5=扩充「员圈」应用使用人数,6=购买空间/流量扩展包)
'payEaRealname' => '涂开', // 支付人
'payEaMobile' => '13456346545', // 支付人手机号
'pay_time' => '1515340800000', // 支付成功时间
'cancelEaRealname' => '涂开', // 取消人
'cancelEaMobile' => '13456346545', // 取消人手机号
'cancel_time' => 1515340800000, // 取消时间
'close_time' => '1515340800000', // 关闭时间
'close_reason' => '7天自动过期', // 关闭原因
'end_time' => '1515340800000', // 订单截止时间(业绩比拼时生效)
)
*/
public function Index_post()
{
$order_id = I('post.order_id');
if (!$order_id) {
E('_ERR_ORDER_ID_NOT');
}
$orderService = &Order::instance();
// 获取商品列表
$result = $orderService->fetchOrder(['ordId' => $order_id]);
$ordContent = json_decode($result['ordContent'], true);
// 订单状态转换(状态为1或者100时,统一转为1)
if ($result['ordPayStatus'] == self::ORDER_STATUS_PAYING) {
$result['ordPayStatus'] = self::ORDER_STATUS_WAITING_PAY;
}
// 订单类型为业绩比拼(扩充人数)时,获取有效期截止时间
if ($result['ordType'] == self::ORDER_TYPE_SALT_PEOPLE) {
$valid_order = $orderService->FetchAllSaleValidOrder();
if (count($valid_order) > 1) {
$last_order = end($valid_order);
$end_time = $last_order['oauEnd'];
} else {
$end_time = empty($valid_order) ? 0 : $valid_order[0]['oauEnd'];
}
$result['oauEnd'] = $end_time;
// 员圈扩充人数,获取当前生效订单有效期
} elseif ($result['ordType'] == self::ORDER_TYPE_YQ_ADD_USER) {
// 可使用订单列表(包括正在生效的订单)
$list = $orderService->fetchValidOrderList(['ordType' => self::ORDER_TYPE_YQ_APP]);
// 获取当前生效订单的失效时间
if (isset($list['total']) && $list['total'] > 0) {
$orderInfo = reset($list['list']);
$result['oauEnd'] = $orderInfo['oauEnd'];
}
}
$this->_result = [
'order_sn' => $result['ordCode'],
'order_status' => $result['ordPayStatus'],
'addEaRealname' => $result['addEaRealname'],
'addEaMobile' => $result['addEaMobile'],
'order_created' => $result['ordCreated'],
'order_title' => $result['ordTitle'],
'order_desc' => [
'user_num' => isset($ordContent['personAmount']) ? $ordContent['personAmount'] : 0,
'nums' => isset($ordContent['personAmount']) ? $ordContent['personAmount'] : 0,
'years' => isset($ordContent['year']) ? $ordContent['year'] : 0,
'disk' => isset($ordContent['disk']) ? $ordContent['disk'] : 0,
'network' => isset($ordContent['network']) ? $ordContent['network'] : 0,
'desc' => isset($ordContent['desc']) ? $ordContent['desc'] : '',
'level' => isset($ordContent['level']) ? $ordContent['level'] : 0,
],
'order_price' => $result['ordTotalPrice'],
'pay_type' => $result['ordPayType'],
'order_type' => $result['ordType'],
'payEaRealname' => $result['payEaRealname'],
'payEaMobile' => $result['payEaMobile'],
'pay_time' => $result['ordPayTime'],
'cancelEaRealname' => $result['cancelEaRealname'],
'cancelEaMobile' => $result['cancelEaMobile'],
'cancel_time' => $result['ordCancelTime'],
'close_time' => $result['ordUpdated'],
'close_reason' => $result['ordCloseReason'],
'end_time' => $result['oauEnd'] ? $result['oauEnd'] : 0,
];
return true;
}
}