...
|
...
|
@@ -68,86 +68,20 @@ class OrderModel |
|
|
}
|
|
|
//检查数据返回是否正常,正常则处理数据
|
|
|
if (!empty($data['data']['order_list'])) {
|
|
|
// 订单的状态列表
|
|
|
//$orderStatus = Helpers::getOrderStatus();
|
|
|
$count = 0;
|
|
|
foreach ($data['data']['order_list'] as $key => $vo) {
|
|
|
// if ($vo['payment_status'] == 'Y' && $vo['status'] == 0) {
|
|
|
// $vo['status'] = 1;
|
|
|
// }
|
|
|
// 订单件数清零
|
|
|
$count = 0;
|
|
|
//根据订单status判断订单处于什么状态。
|
|
|
$result[$key] = self::getOrderStatus($vo);
|
|
|
//订单号,支付状态,订单商品数量,订单总价格
|
|
|
$result[$key]['orderNum'] = $vo['order_code'];
|
|
|
//$result[$key]['orderStatus'] = ($vo['is_cancel'] === 'Y') ? '已取消' : $orderStatus[ $vo['payment_type'] ][ $vo['status'] ];
|
|
|
$result[$key]['orderStatus'] = $vo['status_str'];
|
|
|
$result[$key]['sumCost'] = $vo['amount'];
|
|
|
//类内调用格式化订单商品数据方法
|
|
|
$result[$key]['goods'] = Helpers::formatOrderGoods($vo['order_goods'], $count);
|
|
|
$result[$key]['detailUrl'] = Helpers::url('/home/orders/detail', array('order_code' => $vo['order_code'], 't' => time()));
|
|
|
$result[$key]['count'] = $count;
|
|
|
//根据订单status判断订单处于什么状态。
|
|
|
do {
|
|
|
//订单取消状态 = Y 时,跳出判断订单状态循环,并设置订单状态为已取消。
|
|
|
if ($vo['is_cancel'] === 'Y') {
|
|
|
$result[$key]['canceled'] = true;
|
|
|
break;
|
|
|
}
|
|
|
/* 先判断订单付款方式,根据不同的付款方式计算订单状态。(注:货到付款没有待付款状态)
|
|
|
* 付款方式:1 => 在线支付,2 => 货到付款,3 => 现金支付,4 => 抵消支付;
|
|
|
*/
|
|
|
//支付方式为非货到付款时,计算订单状态。
|
|
|
if ($vo['payment_type'] != 2) {
|
|
|
switch ($vo['status']) {
|
|
|
case 0: // 待付款
|
|
|
$result[$key]['unpaid'] = true;
|
|
|
$result[$key]['payUrl'] = Helpers::url('/home/pay', array('order_code' => $vo['order_code']));
|
|
|
break;
|
|
|
//未发货&未收货 状态,统一合并到待收货状态。
|
|
|
case 1:
|
|
|
case 2:
|
|
|
case 3:
|
|
|
//已付款状态不给查看物流URL
|
|
|
$result[$key]['unreceived'] = true;
|
|
|
break;
|
|
|
case 4:
|
|
|
case 5:
|
|
|
//已发货状态,给查看物流URL
|
|
|
$result[$key]['unreceived'] = true;
|
|
|
$result[$key]['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $vo['order_code']));
|
|
|
break;
|
|
|
case 6:
|
|
|
$result[$key]['completed'] = true;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
//订单为货到付款订单时,计算订单状态。(货到付款没有待付款状态)
|
|
|
switch ($vo['status']) {
|
|
|
case 0: // 备货中
|
|
|
$result[$key]['unpaid'] = true;
|
|
|
break;
|
|
|
case 1:
|
|
|
case 2:
|
|
|
case 3:
|
|
|
//备货中、已付款状态不给查看物流链接
|
|
|
$result[$key]['unreceived'] = true;
|
|
|
break;
|
|
|
case 4:
|
|
|
case 5:
|
|
|
//待收货状态,给查看物流url
|
|
|
$result[$key]['unreceived'] = true;
|
|
|
$result[$key]['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $vo['order_code']));
|
|
|
break;
|
|
|
case 6:
|
|
|
$result[$key]['completed'] = true;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
} while (false);
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -155,16 +89,6 @@ class OrderModel |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获得支付链接
|
|
|
*/
|
|
|
public static function payment($gender, $yh_channel)
|
|
|
{
|
|
|
$code = self::CODE_PAYMENT;
|
|
|
$data = OrderData::paymentData($gender, $yh_channel, $code);
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查看物流
|
|
|
*
|
|
|
* @param int $orderCode 订单编号
|
...
|
...
|
@@ -196,6 +120,43 @@ class OrderModel |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取订单详情信息
|
|
|
*
|
|
|
* @param string $orderCode 订单号
|
|
|
* @param int $uid 用户ID
|
|
|
* @param string $sessionKey 用户的会话
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function orderDetail($orderCode, $uid, $sessionKey)
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if (is_numeric($orderCode) && is_numeric($uid) && is_string($sessionKey)) {
|
|
|
$orderDetail = OrderData::viewOrderData($orderCode, $uid, $sessionKey);
|
|
|
if (isset($orderDetail['data']['order_code'])) {
|
|
|
$count = 0;
|
|
|
|
|
|
$result = self::getOrderStatus($orderDetail['data'], true); // 订单状态
|
|
|
$result['name'] = $orderDetail['data']['user_name'];
|
|
|
$result['phoneNum'] = $orderDetail['data']['mobile'];
|
|
|
$result['address'] = $orderDetail['data']['area'] . $orderDetail['data']['address'];
|
|
|
$result['orderStatus'] = $orderDetail['data']['status_str'];
|
|
|
$result['orderNum'] = $orderDetail['data']['order_code'];
|
|
|
$result['orderTime'] = date('Y-m-d H:i:s', $orderDetail['data']['create_time']);
|
|
|
$result['goods'] = Helpers::formatOrderGoods($orderDetail['data']['order_goods'], $count, true);
|
|
|
$result['sumPrice'] = $orderDetail['data']['goods_total_amount']; // 商品总金额
|
|
|
$result['salePrice'] = $orderDetail['data']['promotion_amount']; // 活动金额
|
|
|
$result['freight'] = $orderDetail['data']['shipping_cost']; // 运费
|
|
|
$result['coupon'] = $orderDetail['data']['coupons_amount']; // 优惠券
|
|
|
$result['yohoCoin'] = $orderDetail['data']['yoho_coin_num']; // YOHO币
|
|
|
$result['price'] = $orderDetail['data']['amount']; // 实付金额
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据type值设置nav属性
|
|
|
*/
|
|
|
public static function getNavs($type)
|
...
|
...
|
@@ -218,4 +179,89 @@ class OrderModel |
|
|
return $nav;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取订单状态
|
|
|
*
|
|
|
* @param array $order 订单
|
|
|
* @param bool $showLogistics 控制是否显示物流信息
|
|
|
* @return array
|
|
|
*/
|
|
|
private static function getOrderStatus($order, $showLogistics = false)
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
//根据订单status判断订单处于什么状态。
|
|
|
do {
|
|
|
//订单取消状态 = Y 时,跳出判断订单状态循环,并设置订单状态为已取消。
|
|
|
if ($order['is_cancel'] === 'Y') {
|
|
|
$result['canceled'] = true;
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// 先判断订单付款方式,根据不同的付款方式计算订单状态。(注:货到付款没有待付款状态)
|
|
|
// 支付方式为非货到付款时,计算订单状态。
|
|
|
if ($order['payment_type'] != 2) {
|
|
|
switch ($order['status']) {
|
|
|
case 0: // 待付款
|
|
|
$result['unpaid'] = true;
|
|
|
$result['payUrl'] = Helpers::url('/home/pay', array('order_code' => $order['order_code']));
|
|
|
break;
|
|
|
//未发货&未收货 状态,统一合并到待收货状态。
|
|
|
case 1:
|
|
|
case 2:
|
|
|
case 3:
|
|
|
//已付款状态不给查看物流URL
|
|
|
$result['unreceived'] = true;
|
|
|
break;
|
|
|
case 4:
|
|
|
case 5:
|
|
|
//已发货状态,给查看物流URL
|
|
|
$result['unreceived'] = true;
|
|
|
$result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
|
|
|
if ($showLogistics) {
|
|
|
$result['logisticsCompany'] = $order['caption'];
|
|
|
$result['logisticsNum'] = $order['express_number'];
|
|
|
}
|
|
|
break;
|
|
|
case 6:
|
|
|
$result['completed'] = true;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// 订单为货到付款订单时,计算订单状态。(货到付款没有待付款状态)
|
|
|
switch ($order['status']) {
|
|
|
case 0: // 备货中
|
|
|
$result['unpaid'] = true;
|
|
|
break;
|
|
|
case 1:
|
|
|
case 2:
|
|
|
case 3:
|
|
|
//备货中、已付款状态不给查看物流链接
|
|
|
$result['unreceived'] = true;
|
|
|
break;
|
|
|
case 4:
|
|
|
case 5:
|
|
|
//待收货状态,给查看物流url
|
|
|
$result['unreceived'] = true;
|
|
|
$result['logisticsUrl'] = Helpers::url('/home/logistic', array('order_code' => $order['order_code']));
|
|
|
if ($showLogistics) {
|
|
|
$result['logisticsCompany'] = isset($order['caption']) ? $order['caption'] : '';
|
|
|
$result['logisticsNum'] = isset($order['express_number']) ? $order['express_number'] : '';
|
|
|
}
|
|
|
break;
|
|
|
case 6:
|
|
|
$result['completed'] = true;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
} while (false);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|