Order.php 28 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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
<?php

namespace Home;

use LibModels\Web\Home\OrderData;
use Configs\ChannelConfig;
use WebPlugin\Helpers;
use WebPlugin\Images;

/**
 * 个人中心-我的订单逻辑处理
 */
class OrderModel
{

    /**
     * 获取我的订单列表数据-分页
     * @param type $uid
     * @param type $page
     * @param type $limit
     * @param type $type 获取订单类型 type=1全部,type=2待付款,type=3待发货,type=4待收货,type=5待评论(已成功) 7取消
     */
    public static function getOrders($uid, $page, $limit, $type, $isPage = FALSE)
    {
        $orders = array();
        $orderInfo = OrderData::getUserOrders($uid, $page, $limit, $type);
        if (isset($orderInfo['data']['order_list']) && $orderInfo['data']['order_list']) {
            foreach ($orderInfo['data']['order_list'] as $orderK => $orderV) {
                $orders[$orderK]['orderNum'] = $orderV['order_code']; //订单标识
                $orders[$orderK]['orderTime'] = date("Y-m-d H:i:s", $orderV['create_time']); //下单时间
                $statusInfo = self::getOrderStatus($orderV['is_cancel'], $orderV['status'], $orderV['payment_type'], $orderV['payment_status']);
                //订单状态
                if ($statusInfo['cancel']) {
                    $orders[$orderK]['cancel'] = $statusInfo['cancel'];
                }
                else {
                    if (!empty($statusInfo['keyName'])) {
                        $orders[$orderK][$statusInfo['keyName']] = TRUE;
                        //已发货,物流信息
                        if ($statusInfo['keyName'] == 'shipped') {
                            $expressInfo = self::getExpressInfo($orderV['order_code'], $uid, $orderV['payment_type'], $orderV['create_time']);
                            $orders[$orderK]['logistics'] = $expressInfo['logistics'];
                        }
                    }
                }
                //订单商品相关信息
                $opRefundStatus = true; //订单不可操作退换货
                if (isset($orderV['order_goods']) && $orderV['order_goods']) {
                    $goods = array();
                    $refundFlag = array();
                    foreach ($orderV['order_goods'] as $gokey => $goval) {
                        $goods[$gokey]['href'] = Helpers::getUrlBySkc($goval['product_id'], $goval['goods_id'], $goval['cn_alphabet']);
                        $goods[$gokey]['thumb'] = (isset($goval['goods_image']) && $goval['goods_image']) ? Images::getImageUrl($goval['goods_image'], 100, 100) : '';
                        $goods[$gokey]['name'] = $goval['product_name'];
                        $goods[$gokey]['color'] = $goval['color_name'];
                        $goods[$gokey]['size'] = $goval['size_name'];
                        $goods[$gokey]['price'] = $goval['goods_price'];
                        $buyNum = intval($goval['buy_number']);
                        $refundNum = intval($goval['refund_num']);
                        $goods[$gokey]['count'] = $buyNum;
                        $refundStatus = ($refundNum > 0) ? true : false; //只要发生一件退换,退换过的标记
                        $goods[$gokey]['refundStatus'] = $refundStatus;
                        $refundFlag[] = (($buyNum == $refundNum) && $refundNum > 0) ? 'finished' : 'unfinished'; //某一件商品全部退换结束
                        $goods[$gokey]['arrivalDate'] = $goval['expect_arrival_time'];
                        $goodsTagName = self::getGoodsTag($orderV['attribute'], $goval['goods_type']);
                        if ($goodsTagName) {
                            $goods[$gokey][$goodsTagName] = TRUE;
                        }
                        $orders[$orderK]['goods'] = $goods;
                    }
                    if (in_array('unfinished', $refundFlag)) {
                        $opRefundStatus = false;
                    }
                    $orders[$orderK]['pay'] = $orderV['amount']; //付款数
                    $orders[$orderK]['fregit'] = $orderV['shipping_cost']; //邮费
                }
                //操作
                $orders[$orderK]['operation'] = self::getOperateInfo($orderV['attribute'], $orderV['is_cancel'], $orderV['status'], $orderV['payment_status'], $orderV['update_time'], $orderV['order_type'], $orderV['refund_status'], $orderV['payment_type'], $orderV['order_code'], $opRefundStatus);
            }
            if ($isPage) {
                $orders['pager']['total'] = $orderInfo['data']['total'];
                $orders['pager']['pageTotal'] = $orderInfo['data']['page_total'];
                $orders['pager']['page'] = $orderInfo['data']['page'];
            }
        }
        else {
            $descStr = self::getOrderDescStr($type);
            $orders = array('empty' => $descStr);
        }
        return $orders;
    }

    /**
     * 我的订单-tabs
     * @param type $type
     * @return boolean
     */
    public static function getOrderTabs($type)
    {
        $tabs = array(
            array(
                'url' => Helpers::url('/home/orders', array('page' => 1, 'type' => 1)),
                'name' => '现有订单'
            ),
            array(
                'url' => Helpers::url('/home/orders', array('page' => 1, 'type' => 5)),
                'name' => '成功订单'
            ),
            array(
                'url' => Helpers::url('/home/orders', array('page' => 1, 'type' => 7)),
                'name' => '已取消订单'
            ),
            array(
                'url' => Helpers::url('/home/orders', array('page' => 1, 'type' => 8)),
                'name' => '历史订单'
            )
        );
        switch ($type) {
            case 1:
                $tabs[0]['active'] = true;
                break;
            case 5:
                $tabs[1]['active'] = true;
                break;
            case 7:
                $tabs[2]['active'] = true;
                break;
            case 8:
                $tabs[3]['active'] = true;
                break;
            default:
                $tabs[0]['active'] = true;
                break;
        }
        return $tabs;
    }

    /**
     * 详情页
     * @param type $orderCode
     */
    public static function getOrderDetail($uid, $orderCode)
    {
        $detail = array();
        $orderInfo = OrderData::getOrderDetail($uid, $orderCode);
        //不属于这个人订单,跳转个人中心首页
        if (isset($orderInfo['code']) && $orderInfo['code'] == 400) {
            return $orderInfo;
        }
        if (isset($orderInfo['data']) && $orderInfo['data']) {
            $orderDetail = $orderInfo['data'];
            $detail['orderNum'] = $orderDetail['order_code'];
            //订单状态
            $statusInfo = self::getOrderStatus($orderDetail['is_cancel'], $orderDetail['status'], $orderDetail['payment_type'], $orderDetail['payment_status']);
            $detail['statusStr'] = $statusInfo['statusStr'];
            //订单是否已完成
            $detail['complete'] = false;
            if ($orderDetail['status'] == 6) {
                $detail['complete'] = true;
            }
            //进度条
            if ($statusInfo['cancel']) {
                $detail['progress'] = false;
            }
            else {
                //未取消订单,进度
                if ($orderDetail['attribute'] == 3) {
                    $detail['progress'] = self::getVirtualPro($orderDetail['is_cancel'], $orderDetail['status'], $orderDetail['create_time']);
                }
                else {
                    $detail['progress'] = self::getNormalPro($orderDetail['is_cancel'], $orderDetail['status'], $orderDetail['create_time']);
                }
            }
            //物流信息
            $detail['traceOrder']['orderDate'] = date('Y.m.d H:i:s', $orderDetail['create_time']);
            $expressInfo = self::getExpressInfo($orderCode, $uid, $orderDetail['payment_type'], $orderDetail['create_time'], true);
            $detail['traceOrder']['logistics'] = $expressInfo['logistics']; //物流信息
            $detail['traceOrder']['logisticsCompany'] = $expressInfo['logisticsCompany'];
            $detail['traceOrder']['courierNumbe'] = $expressInfo['courierNumbe'];
            //虚拟商品
            if ($orderDetail['attribute'] == 3) {
                $detail['virtualGoods'] = TRUE;
                $detail['virtualPayMode']['payMode'] = ChannelConfig::$payType[$orderDetail['payment_type']];
                $detail['virtualPayMode']['phone'] = substr_replace($orderDetail['mobile'], '****', 3, 4);
            }
            else {
                $detail['virtualGoods'] = FALSE;
                $detail['noramlPayMode']['payMode'] = ChannelConfig::$payType[$orderDetail['payment_type']];
                $detail['noramlPayMode']['payWay'] = $orderDetail['payment_name'];
                $detail['noramlPayMode']['deliverTime'] = (isset($orderDetail['delivery_time'])) ? $orderDetail['delivery_time'] : '';
                //配送信息
                $detail['orderInfo']['receiver'] = $orderDetail['user_name'];
                $detail['orderInfo']['address'] = $orderDetail['area'] . $orderDetail['address'];
                $detail['orderInfo']['phone'] = substr_replace($orderDetail['mobile'], '****', 3, 4) . (!empty($orderDetail['phone']) ? ',' . substr_replace($orderDetail['phone'], '****', 3, 5) : '');
            }
            //商品信息
            if ($orderDetail['order_goods']) {
                foreach ($orderDetail['order_goods'] as $gok => $gov) {
                    $detail['goods'][$gok]['url'] = Helpers::getUrlBySkc($gov['product_id'], $gov['goods_id'], $gov['cn_alphabet']);
                    $detail['goods'][$gok]['img'] = Images::getImageUrl($gov['goods_image'], 60, 60);
                    $detail['goods'][$gok]['name'] = $gov['product_name'];
                    $detail['goods'][$gok]['color'] = $gov['color_name'];
                    $detail['goods'][$gok]['size'] = $gov['size_name'];
                    $detail['goods'][$gok]['price'] = $gov['goods_price'];
                    $detail['goods'][$gok]['coin'] = $gov['yoho_give_coin'];
                    $detail['goods'][$gok]['num'] = $gov['buy_number'];
                    $detail['goods'][$gok]['sum'] = $gov['goods_amount'];
                    $detail['goods'][$gok]['sku'] = $gov['product_sku'];
                    $goodsTagName = self::getGoodsTag($orderDetail['attribute'], $gov['goods_type']);
                    if ($goodsTagName) {
                        $detail['goods'][$gok][$goodsTagName] = TRUE;
                    }
                }
            }
            //详情页-订单付费详情
            if (isset($orderDetail['promotion_formulas']) && $orderDetail['promotion_formulas']) {
                foreach ($orderDetail['promotion_formulas'] as $pricek => $pricev) {
                    $detail['orderBalance'][$pricek] = array('promotion' => $pricev['promotion'], 'account' => $pricev['promotion_amount']);
                }
                $detail['orderBalance'][] = array('promotion' => '实际应支付', 'account' => $orderDetail['amount']);
            }
            $detail['yohoCoinUrl'] = Helpers::url('/help', array('category_id' => 87)); //什么是yoho币介绍
            $detail['remark'] = $orderDetail['remark'];
            $detail['operation'] = self::getOrderDetailOp($orderDetail['order_code'], $orderDetail['payment'], $orderDetail['status'], $orderDetail['is_cancel'], $orderDetail['payment_status'], $orderDetail['payment_type'], $orderDetail['order_type'], $orderDetail['attribute'], $orderDetail['refund_status']); //,$orderDetail['order_type_value']
        }
        return $detail;
    }

    /**
     * 获取历史订单
     * @param type $uid
     * @param type $page
     * @param type $limit
     * @return type
     */
    public static function getHistoryOrders($uid, $page, $limit)
    {
        $historyOrders = array();
        $orderInfo = OrderData::getHistoryOrders($uid, $page, $limit);
        if (isset($orderInfo['data']['list']) && $orderInfo['data']['list']) {
            foreach ($orderInfo['data']['list'] as $hok => $hov) {
                $historyOrders[$hok]['orderNum'] = $hov['order_code'];
                $historyOrders[$hok]['orderTime'] = date('Y/m/d H:i:s', $hov['order_time']);
                $historyOrders[$hok]['goods'] = json_decode($hov['goods_data'], true);
                $historyOrders[$hok]['orderSum'] = $hov['amount'];
                $historyOrders[$hok]['payMode'] = $hov['payment'];
            }
            $historyOrders['pager']['total'] = $orderInfo['data']['total'];
            $historyOrders['pager']['pageTotal'] = $orderInfo['data']['total_page'];
            $historyOrders['pager']['page'] = $orderInfo['data']['page'];
        }
        else {
            $historyOrders = array('empty' => '您没有历史订单');
        }
        return $historyOrders;
    }

    public static function getTicketsInfo($orderCode)
    {
        $ret = array();
        $ticketInfo = OrderData::getTicketCode($orderCode);
        $tickets = $ticketInfo['data']['ticks'];
        if (isset($tickets) && $tickets) {
            foreach ($tickets as $tk => $tv) {
                $ret[$tk]['img'] = self::getTicketImgs('ticket', $tv['ticket_code'], 1, 9, 1);
                $ret[$tk]['desc'] = $tv['ticket_code'];
            }
        }
        return $ret;
    }

    /**
     * 获取虚拟商品二维码图片
     * @param type $type
     * @param type $dataStr
     * @param type $version
     * @param type $boxSize
     * @param type $border
     * @param type $color
     * @return type
     */
    protected static function getTicketImgs($type, $dataStr, $version = 1, $boxSize = 4, $border = 1, $color = 1)
    {
        $data = $type . '-' . $dataStr;
        $nodeNum = sprintf('%u', crc32($data)) % count(ChannelConfig::$newImageServerUrl);
        $filePath = abs(crc32($data)) % 20000;
        $pathData = array(
            $data,
            $version,
            $boxSize,
            $border,
            $color
        );
        return ChannelConfig::$newImageServerUrl[$nodeNum] . '/yohood/' . $filePath . '/' . implode('-', $pathData) . '.jpg';
    }

    /**
     * 订单详情页物流
     * 
     */
    protected static function getExpressInfo($orderCode, $uid, $paymetType, $createTime, $isDetail = false)
    {
        $result['logisticsUrl'] = '';
        $result['logisticsImg'] = '';
        $result['logisticsCompany'] = '';
        $result['courierNumbe'] = '';
        if ($paymetType == 1) {
            if ($isDetail) {
                $result['logistics'][] = array(date('Y-m-d H:i:s', $createTime), ' ', '您的订单已提交,等待付款');
            }
            else {
                $result['logistics'][] = date('Y-m-d H:i:s', $createTime) . ' ' . '您的订单已提交,等待付款';
            }
        }
        if ($paymetType == 2) {
            if ($isDetail) {
                $result['logistics'][] = array(date('Y-m-d H:i:s', $createTime), ' ', '您的订单已提交,等待审核');
            }
            else {
                $result['logistics'][] = date('Y-m-d H:i:s', $createTime) . ' ' . '您的订单已提交,等待审核';
            }
        }
        //有物流
        if (isset($orderCode) && is_numeric($uid)) {
            $logistics = OrderData::getLogisticsData($orderCode, $uid);
            if (isset($logistics['data']) && $logistics['data']) {
                $result['logisticsUrl'] = isset($logistics['data']['url']) ? $logistics['data']['url'] : '';
                $result['logisticsImg'] = isset($logistics['data']['logo']) ? $logistics['data']['logo'] : '';
                $result['logisticsCompany'] = isset($logistics['data']['caption']) ? $logistics['data']['caption'] : '';
                $result['courierNumbe'] = isset($logistics['data']['express_number']) ? $logistics['data']['express_number'] : '';
                $expressDetail = isset($logistics['data']['express_detail']) ? $logistics['data']['express_detail'] : array();
                if (isset($expressDetail) && $expressDetail) {
                    foreach ($expressDetail as $value) {
                        $pos = stripos($value['accept_address'], ' ') / 3;
                        $city = mb_substr($value['accept_address'], 0, $pos, 'utf-8');
                        $exInfo = mb_substr($value['accept_address'], $pos, null, 'utf-8');
                        if ($isDetail) {
                            $result['logistics'][] = array($value['acceptTime'], $city, $exInfo);
                        }
                        else {
                            $result['logistics'][] = $value['acceptTime'] . $city . $exInfo;
                        }
                    }
                }
            }
        }
        return $result;
    }

    /**
     * 订单详情页操作步骤
     */
    protected static function getOrderDetailOp($orderCode, $payment, $status, $isCancel, $paymentStatus, $paymentType, $orderType, $attribute, $refundStatus)
    {
        $operation = array();
        //立刻付款
        if ($paymentType == 1 && $paymentStatus == 'N' && $isCancel == 'N' && isset($payment) && $payment != 19) {
            $operation +=array('goPay' => Helpers::url('/shopping/pay', array('ordercode' => $orderCode)));
        }
        //取消订单
        if ($status < 3 && $isCancel == 'N' && $paymentStatus == 'N' && $orderType != 5) {
            $operation +=array('cancelOrder' => TRUE);
        }
        //订单已支付
        if ($paymentType == 1 && $paymentStatus == 'Y' && $status < 6) {
            $operation +=array('paid' => TRUE);
        }
        //确认收货
        if ($status >= 4 && $status < 6 && $refundStatus == 0 && $attribute != 3 && $isCancel == 'N') {
            $operation += array('shipped' => TRUE);
        }
        //订单已取消
        if ($isCancel == 'Y') {
            $operation +=array('cancel' => TRUE);
        }
        //虚拟查看二维码
        if ($attribute == 3) {
            $operation+=array('checkQrCode' => Helpers::url('/home/orders/ticket', array('orderCode' => $orderCode)));
        }
        return $operation;
    }

    /**
     * 详情页进度条-普通商品
     * @param type $isCancel
     * @param type $status
     * @param type $createTime
     * @return boolean
     */
    protected static function getNormalPro($isCancel, $status, $createTime)
    {
        $process['middleStatus'] = array(
            array(
                'name' => '1. 提交订单',
                'date' => date('Y.m.d H:i:s', $createTime),
            ),
            array(
                'name' => '2. 商品出库'
            ),
            array(
                'name' => '3. 等待收货'
            ),
            array(
                'name' => '4. 交易完成'
            )
        );
        //订单已取消
        if ($isCancel == 'N') {
            if ($status == 0) {
                $process['percent'] = '25%';
                $process['middleStatus'][0]['cur'] = TRUE;
            }
            else if ($status > 0 && $status < 4) {
                $process['percent'] = '50%';
                $process['middleStatus'][1]['cur'] = TRUE;
            }
            else if ($status >= 4 && $status < 6) {
                $process['percent'] = '75%';
                $process['middleStatus'][2]['cur'] = TRUE;
            }
            elseif ($status == 6) {
                $process['percent'] = '100%';
                $process['middleStatus'][3]['cur'] = TRUE;
            }
        }
        return $process;
    }

    /**
     * 详情页进度条-虚拟商品
     * @param type $isCancel
     * @param type $status
     * @param type $createTime
     * @return boolean
     */
    protected static function getVirtualPro($isCancel, $status, $createTime)
    {
        $process['middleStatus'] = array(
            array(
                'name' => '1. 提交订单',
                'date' => date('Y.m.d H:i:s', $createTime),
            ),
            array(
                'name' => '2. 已发货'
            ),
            array(
                'name' => '3. 交易完成'
            )
        );
        //订单已取消
        if ($isCancel == 'N') {
            if ($status == 0) {
                $process['percent'] = '30%';
                $process['middleStatus'][0]['cur'] = TRUE;
            }
            else if ($status > 0 && $status < 6) {
                $process['percent'] = '80%';
                $process['middleStatus'][1]['cur'] = TRUE;
            }
            elseif ($status == 6) {
                $process['percent'] = '100%';
                $process['middleStatus'][3]['cur'] = TRUE;
            }
        }
        return $process;
    }

    /**
     * 订单状态
     * @param type $isCancel
     * @param type $status
     * @param type $payType
     * @param type $payStatus
     * @return string
     */
    protected static function getOrderStatus($isCancel, $status, $payType, $payStatus)
    {
        //初始化:未取消,待付款
        $ret = array('cancel' => FALSE, 'keyName' => 'noPay', 'statusStr' => '订单已成功,等待付款');
        //订单已取消
        if ($isCancel == 'Y') {
            $ret = array('cancel' => TRUE,'statusStr' => '订单已取消');
        }
        else {
            switch ($status) {
                case 0:
                    //'订单已成功,等待付款'
                    if ($payType != 2 && $payStatus == 'N') {
                        $ret['keyName'] = 'noPay';
                        $ret['statusStr'] = '订单已成功,等待付款';
                    }
                    //'订单已付款,等待备货中'
                    elseif ($payType != 2 && $payStatus == 'Y') {
                        $ret['keyName'] = 'paid';
                        $ret['statusStr'] = '订单已付款,等待备货中';
                    }
                    //'订单已成功,等待备货中'-货到付款
                    elseif ($payType == 2 && $payStatus == 'N') {
                        $ret['keyName'] = 'complete';
                        $ret['statusStr'] = '订单已成功,等待备货中';
                    }
                    break;
                case 1:
                case 2:
                case 3:
                    //'订单已付款,等待备货中'
                    $ret['keyName'] = 'paid';
                    $ret['statusStr'] = '订单已付款,等待备货中';
                    break;
                case 4:
                case 5:
                    //'订单已发货'
                    $ret['keyName'] = 'shipped';
                    $ret['statusStr'] = '订单已发货';
                    break;
                case 6:
                    //'交易完成';
                    $ret['keyName'] = 'reback';
                    $ret['statusStr'] = '交易完成';
                    break;
            }
        }
        return $ret;
    }

    /**
     * 操作栏
     * @param type $attribute 订单属性
     * @param type $isCancel 是否取消
     * @param type $status 订单状态
     * @param type $payStatus 付款状态
     * @param type $updateTime 更新时间
     * @param type $orderType 订单类型
     * @param type $refundStatus 是否退换
     * @param type $paymentType 付款类型
     * @param type $orderCode 订单号
     * @param type $opRefundStatus 退换操作是否灰化 true 灰化 false 可用
     * @return string
     */
    protected static function getOperateInfo($attribute, $isCancel, $status, $payStatus, $updateTime, $orderType, $refundStatus, $paymentType, $orderCode, $opRefundStatus)
    {
        //查看订单
        $orderDetailUrl = Helpers::url('/home/orders/detail', array('orderCode' => $orderCode));
        //查看二维码
        $ticketUrl = Helpers::url('/home/orders/tickets', array('orderCode' => $orderCode));
        //立即付款
        $payUrl = Helpers::url('/shopping/pay', array('ordercode' => $orderCode));
        //取消订单
        $cancelOrderUrl = 'javascript:void(0)';
        //确认订单
        $confirmOrderUrl = 'javascript:void(0)';
        //申请换货
        $exchangeUrl = Helpers::url('/home/returns/exchangeRequest', array('orderCode' => $orderCode));
        //申请退货
        $refundUrl = Helpers::url('/home/returns/refundrequest', array('orderCode' => $orderCode));
        //立即付款
        if ($payStatus == 'N' && $paymentType != 2 && $isCancel == 'N') {
            $operation[] = array('payNow' => true, 'href' => $payUrl);
        }

        $operation[] = array('href' => $orderDetailUrl, 'name' => '查看订单');
        //查看订单,虚拟订单查看二维码
        if ($attribute == 3) {
            if ($payStatus == 'Y') {
                $operation[] = array('href' => $ticketUrl, 'name' => '查看二维码');
            }
        }

        //取消订单
        if ($status < 3 && $isCancel == 'N' && $orderType != 5 && $payStatus == 'N') {
            $operation[] = array('href' => $cancelOrderUrl, 'name' => '取消订单', 'cancelOrder' => true);
        }
        //确认收货
        if ($status >= 4 && $status < 6 && $refundStatus == 0 && $attribute != 3 && $isCancel == 'N') {
            $operation[] = array('href' => $confirmOrderUrl, 'name' => '确认收货', 'confirmReceived' => true);
        }
        //换货
        $time = (time() - $updateTime);
        $orderExchangeLimitTime = ChannelConfig::$exchangeDay;
        if ($status >= 6 && $time < 86400 * $orderExchangeLimitTime && $attribute != 3 && $isCancel == 'N') {
            $operation[] = array('href' => $exchangeUrl, 'name' => '申请换货', 'optDis' => $opRefundStatus);
        }
        //退货
        $orderRefundLimitTime = ChannelConfig::$refundDay;
        if ($status >= 6 && $time < 86400 * $orderRefundLimitTime && $attribute != 3 && $isCancel == 'N') {
            $operation[] = array('href' => $refundUrl, 'name' => '申请退货', 'optDis' => $opRefundStatus);
        }
        return $operation;
    }

    /**
     * 商品属性标签
     * @param type $attribute
     * @param type $goodsType
     * @return string
     */
    protected static function getGoodsTag($attribute, $goodsType)
    {
        $goodsTagName = '';
        switch ($goodsType) {
            //赠品
            case 'gift':
                $goodsTagName = 'freebie';
                break;
            //加价购
            case 'price_gift':
                $goodsTagName = 'advanceBuy';
                break;
            //预售
            case 'advance':
                $goodsTagName = 'preSaleGood';
                break;
            //outlet
            case 'outlet':
                $goodsTagName = '';
                break;
            //免单
            case 'free':
                $goodsTagName = '';
                break;
            //电子
            case 'ticket':
                $goodsTagName = '';
                break;
            default:
                break;
        }
        //虚拟
        if ($attribute == 3) {
            $goodsTagName = 'virtualGood';
        }
        return $goodsTagName;
    }

    /**
     * 空订单数据提示
     * @param type $type
     * @return string
     */
    protected static function getOrderDescStr($type)
    {
        switch ($type) {
            case 1:
                $str = '您还没有任何订单';
                break;
            case 5:
                $str = '您目前还没有成功的订单';
                break;
            case 7:
                $str = '您还没有任何取消的订单';
                break;
            default:
                $str = '';
                break;
        }
        return $str;
    }

}