123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?php
- /**
- * Created by PhpStorm.
- * User: stanley-king
- * Date: 16/9/28
- * Time: 上午12:09
- */
- class order_helper
- {
- private $mOrders;
- private $mod_refund;
- private $mod_order;
- public function __construct($order_list)
- {
- $this->mOrders = $order_list;
- $this->mod_order = Model('order');
- $this->mod_refund = Model('refund_return');
- }
- private function action_title($key)
- {
- static $actions = array("if_cancel" => "取消订单",
- "if_refund_cancel" => "退款",
- "if_receive" => "确认收货",
- "if_deliver" => "查看物流",
- "if_evaluation" => "评价",
- "if_delete" => "删除订单",
- "if_refund_return" => "退货");
- return $actions[$key];
- }
- private function actions($order)
- {
- //显示取消订单
- $state['if_cancel'] = $this->mod_order->getOrderOperateState('buyer_cancel', $order);
- //显示退款取消订单
- $state['if_refund_cancel'] = $this->mod_order->getOrderOperateState('refund_cancel', $order);
- //显示收货
- $state['if_receive'] = $this->mod_order->getOrderOperateState('receive', $order);
- //显示物流跟踪
- $state['if_deliver'] = $this->mod_order->getOrderOperateState('deliver', $order);
- //显示评价
- $state['if_evaluation'] = $this->mod_order->getOrderOperateState('evaluation', $order);
- //显示删除
- $state['if_delete'] = $this->mod_order->getOrderOperateState('delete', $order);
- //订单是否能退货
- $state['if_refund_return'] = $this->mod_refund->getRefundState($order) == '0' ? false : true;
- $actions = [];
- foreach ($state as $key => $value) {
- if ($value == true) {
- $actions['action'] = $key;
- $actions['title'] = $this->action_title($key);
- }
- }
- return $actions;
- }
- private function order_info($order)
- {
- $result["order_id"] = intval($order["order_id"]);
- $result["order_sn"] = $order["order_sn"];
- $result["pay_sn"] = $order["pay_sn"];
- $result["add_time"] = intval($order["add_time"]);
- $result["payment_code"] = $order["payment_code"];
- $result["payment_time"] = intval($order["payment_time"]);
- $result["finnshed_time"] = intval($order["finnshed_time"]);
- $result["goods_amount"] = doubleval($order["goods_amount"]);
- $result["order_amount"] = doubleval($order["order_amount"]);
- $result["rcb_amount"] = doubleval($order["rcb_amount"]);
- $result["pd_amount"] = doubleval($order["pd_amount"]);
- $result["shipping_fee"] = doubleval($order["shipping_fee"]);
- $result["evaluation_state"] = intval($order["evaluation_state"]);
- $result["order_state"] = intval($order["order_state"]);
- $result["refund_state"] = intval($order["refund_state"]);
- $result["refund_amount"] = doubleval($order["refund_amount"]);
- $result["delay_time"] = intval($order["delay_time"]);
- $result["shipping_code"] = $order["shipping_code"];
- $result["trade_no"] = $order["trade_no"];
- $result["state_desc"] = $order["state_desc"];
- $refund_state = 0;
- $order['refund_id'] = intval($this->mod_refund->getRefundId($order,$refund_state));
- $result["refund_state"] = intval($refund_state);
- return $result;
- }
- private function order_goods($order)
- {
- $result = [];
- $order_goods = $order['extend_order_goods'];
- foreach ($order_goods as $val)
- {
- $goods["rec_id"] = intval($val["rec_id"]);
- $goods["order_id"] = intval($val["order_id"]);
- $goods["goods_id"] = intval($val["goods_id"]);
- $goods["goods_name"] = $val["goods_name"];
- $goods["goods_price"] = doubleval($val["goods_price"]);
- $goods["goods_num"] = intval($val["goods_num"]);
- $goods["goods_image"] = cthumb($val['goods_image'], 480, $val['store_id']);
- $goods["goods_pay_price"] = doubleval($val["goods_pay_price"]);
- $goods["store_id"] = intval($val["store_id"]);
- $goods["buyer_id"] = intval($val["buyer_id"]);
- $goods["goods_type"] = intval($val["goods_type"]);
- $goods["promotions_id"] = intval($val["promotions_id"]);
- $goods["gc_id"] = intval($val["gc_id"]);
- $goods["goods_spec"] = $val["goods_spec"];
- $refund_state = 0;
- $goods['refund_id'] = intval($this->mod_refund->getRefundIdForGood($val,$refund_state));
- $goods['refund_state'] = intval($refund_state);
- $result[] = $goods;
- }
- return $result;
- }
- private function reciver_info($order)
- {
- $info = $order['reciver_info'];
- $info['reciver_name'] = $order['reciver_name'];
- return $info;
- }
- public function format()
- {
- $result = [];
- foreach ($this->mOrders as $order) {
- $item['order_info'] = $this->order_info($order);
- $actions = $this->actions($order);
- $item['actions'] = $actions;
- $item['order_goods'] = $this->order_goods($order);
- $item['reciver_info'] = $this->reciver_info($order);
- $result[] = $item;
- }
- return $result;
- }
- }
|