select(['order_id' => $info['id']]); $this->info = Dever::load('source/order', 'place_order')->getView($info); $this->info['source_type'] = []; $tab = $this->getTab(); return ['title' => '订单详情', 'info' => $this->getInfo(), 'tab' => $tab]; } # 获取基本信息 private function getInfo() { if ($this->info['refund_status'] == 1) { $this->info['status_name'] .= '[退]'; } $info[] = [ # 类型,info介绍 desc描述 table表格,表格有head和body即可 'type' => 'info', 'name' => '资源订单', 'info' => '订单号:' . $this->info['order_num'], # 右侧按钮 'button' => $this->getButton(), # 具体内容 'content' => [ ['name' => '订单状态', 'content' => $this->info['status_name']], ['name' => '总金额', 'content' => $this->info['cash_text']], ['name' => '总数量', 'content' => $this->info['num']], ['name' => '下单时间', 'content' => $this->info['cdate_str']], ], ]; return $info; } # 获取切换列表 private function getTab() { $tab['active'] = 'view'; $tab['content']['view'] = $this->getView(); //$tab['content']['process'] = $this->getProcess(); $tab['content']['list'] = $this->getList(); if ($this->info['refund_list']) { if ($this->info['refund_status'] == 1) { $tab['active'] = 'refund'; } $tab['content']['refund'] = $this->getRefund(); } # 返利信息 $rebate = Dever::db('rebate', 'place_order')->select(['table' => 'source', 'table_id' => $this->info['id']]); if ($rebate) { $tab['content']['rebate'] = $this->getRebate($rebate); } $tab['content']['log'] = $this->getLog(); return $tab; } # 获取详情 private function getView() { $content = []; $sales = Dever::load('manage/info', 'place_channel_sales')->getInfo($this->info['sales_type'], $this->info['sales_id']); $method = Dever::db('source', 'place_order')->value('method', $this->info['method']); $content[] = [ 'type' => 'list', 'name' => '用户信息', 'content' => [ [ 'name' => '用户名称', 'content' => $this->info['user']['name'], ], [ 'name' => '用户账户', 'content' => $this->info['user']['mobile'], ], [ 'name' => '渠道信息', 'content' => $sales, ], [ 'name' => '发货方式', 'content' => $method, ], ], ]; if (isset($this->info['address']) && $this->info['address']) { $content[] = [ 'type' => 'list', 'name' => '收货信息', 'copy' => true, 'content' => [ [ 'name' => '收货人', 'content' => $this->info['address']['name'], ], [ 'name' => '收货电话', 'content' => $this->info['address']['phone'], ], [ 'name' => '城市地区', 'content' => $this->info['address']['area_string'], ], [ 'name' => '收货地址', 'content' => $this->info['address']['address'], ], ], 'button' => array ( array ( 'name' => '编辑', 'type' => 'fastadd', 'path' => 'source_manage/help', ), ), ]; } $coupon_tip = ''; if ($this->info['user_coupon_id'] > 0) { $user_coupon = Dever::db('coupon', 'place_user')->find($this->info['user_coupon_id']); $coupon = Dever::db('coupon', 'place_benefit')->find($this->info['coupon_id']); $coupon_tip = $coupon['name']; /* if ($user_coupon['coupon_code_id'] > 0) { $code = Dever::db('coupon_code', 'place_benefit')->find($user_coupon['coupon_code_id']); $coupon_tip .= '['.$code['code'].']'; }*/ if ($coupon['type'] == 3) { $user_coupon['value'] = floor($user_coupon['value']) . '折'; $coupon_tip .= ',折扣:' . $user_coupon['value'] . ',抵扣:' . $this->info['coupon_cash_text']; } elseif ($coupon['type'] == 4) { $user_coupon['value'] = floor($user_coupon['value']) . '个'; $this->info['coupon_value'] = floor($this->info['coupon_value']) . '个'; $coupon_tip .= ',总数:' . $user_coupon['value'] . ',本次使用:'.$this->info['coupon_value'].',抵扣:' . $this->info['coupon_cash_text']; } else { $user_coupon['value'] = Dever::load('info', 'place_score')->toScore($user_coupon['value'], $this->info['score']['exp']); $user_coupon['value'] = Dever::load('info', 'place_score')->getText($user_coupon['value'], $this->info['score']); $coupon_tip .= ',总面值:' . $user_coupon['value'] . ',本次使用:' . $this->info['coupon_cash_text']; } } $gift_tip = ''; if ($this->info['user_gift_id'] > 0) { $user_gift = Dever::db('gift', 'place_user')->find($this->info['user_gift_id']); $gift = Dever::db('gift', 'place_benefit')->find($this->info['gift_id']); $gift_tip = $gift['name']; /* if ($user_coupon['coupon_code_id'] > 0) { $code = Dever::db('coupon_code', 'place_benefit')->find($user_coupon['coupon_code_id']); $coupon_tip .= '['.$code['code'].']'; }*/ $user_gift['value'] = Dever::load('info', 'place_score')->toScore($user_gift['value'], $this->info['score']['exp']); $user_gift['value'] = Dever::load('info', 'place_score')->getText($user_gift['value'], $this->info['score']); $gift_tip .= ',总面值:' . $user_gift['value'] . ',本次使用:' . $this->info['gift_cash_text']; } $refund_tip = ''; if ($this->info['refund_cash'] > 0) { $cash = Dever::load('source/refund', 'place_order')->getCash($this->info, $this->info['refund_cash'], 0); $pay_cash_money = Dever::load('info', 'place_score')->toMoney($cash['pay_cash'], $this->info['score']['exp']) . $this->info['money']['unit']; list($cash['pay_cash'], $cash['wallet_cash'], $cash['coupon_cash'], $cash['gift_cash']) = Dever::load('info', 'place_score')->getText([$cash['pay_cash'], $cash['wallet_cash'], $cash['coupon_cash'], $cash['gift_cash']], $this->info['score']); $refund_tip .= '支付退款:'.$cash['pay_cash'] . '['.$pay_cash_money.']'; $refund_tip .= ',' . $this->info['score']['name'] . '退款:'.$cash['wallet_cash']; $refund_tip .= ',礼品卡退款:'.$cash['gift_cash']; $refund_tip .= ',优惠券退款:'.$cash['coupon_cash']; } $content[] = [ 'type' => 'list', 'name' => '金额信息', 'content' => [ [ 'name' => '总金额', 'content' => $this->info['cash_text'], ], [ 'name' => '优惠券抵扣', 'content' => $this->info['coupon_cash_text'], 'tip' => $coupon_tip, ], [ 'name' => '礼品卡抵扣', 'content' => $this->info['gift_cash_text'], 'tip' => $gift_tip, ], [ 'name' => $this->info['score']['name'] . '抵扣', 'content' => $this->info['wallet_cash_text'], ], [ 'name' => '支付金额', 'content' => $this->info['pay_cash_text'] . '['.$this->info['pay_money_cash_text'].']', ], [ 'name' => '退款金额', 'content' => $this->info['refund_cash_text'], 'tip' => $refund_tip, ], ], ]; if ($this->info['coupon_cash'] > 0) { # 优惠券信息 } $content[] = [ 'type' => 'list', 'name' => '备注信息', 'content' => [ [ 'name' => '买家留言', 'content' => $this->info['buy_info'] ?: '无', ], [ 'name' => '订单备注', 'content' => $this->info['sell_info'] ?: '无', ], ], ]; return [ 'type' => 'mul', 'name' => '详情', 'content' => $content ]; } # 获取进度 private function getProcess() { $timeline = []; foreach ($this->info['status_list'] as $k => $v) { $v['name'] = '['.$v['name'].']'; if ($k == 1) { $v['name'] .= ' 下单人:' . $this->info['user']['name'] . '('.$this->info['user']['mobile'].')' . ' 付款:' . $this->info['cash'] . '元 '; } elseif ($k == 2) { if (isset($this->info['address']) && $this->info['address']) { $v['name'] .= ' 收货地址:' . $this->info['address']['full']; } } elseif ($k == 3) { if (isset($this->info['express'])) { $v['name'] .= ' 已发货:' . $this->info['express']['name'] . ',' . $this->info['express']['number']; } } elseif ($k == 4) { if (isset($this->info['express']['log'][0])) { $v['name'] .= ' ' . $this->info['express']['log'][0]['status']; } } elseif ($k == 5 && $this->info['status'] > 6) { $v['name'] .= ' 订单'.$this->info['status_name'].''; } if ($v['selected']) { $v['hollow'] = true; $v['color'] = '#0bbd87'; $v['type'] = 'primary'; $v['size'] = 'large'; } $timeline[] = $v; } $content[] = [ 'name' => '', 'type' => 'timeline', 'content' => $timeline, ]; return [ 'type' => 'mul', 'name' => '进度', 'content' => [ [ 'type' => 'desc', 'name' => '', 'column' => 1, 'border' => false, # 排列方向:horizontal横向 vertical纵向 'direction' => 'vertical', 'content' => $content, ], ] ]; } # 获取清单 private function getList() { if ($this->info['detail']) { foreach ($this->info['detail'] as &$v) { $v['status'] = $this->getListStatus($v); $v['cash'] = $this->getListCash($v); $v['id'] = Dever::load('info', 'place_source')->getCode($v['id']); $this->info['source_type'][$v['source_type']] = $v['source_type']; } } return [ 'name' => '清单', 'type' => 'table', 'border' => true, # 这里配置和列表list一模一样 'head' => [ [ 'key' => 'id', 'name' => '编号', ], [ 'key' => 'name', 'name' => '名称', ], [ 'key' => 'sku_name', 'name' => '规格', ], [ 'key' => 'cash', 'name' => '单价', 'type' => 'popover', 'location' => 'right', //'tag' => true, ], [ 'key' => 'num', 'name' => '数量', ], [ 'key' => 'status', 'name' => '状态', 'type' => 'popover', 'location' => 'right', 'tag' => true, //'fixed' => 'fixed', ], ], 'button' => [], 'body' => $this->info['detail'], ]; } private function getListStatus($detail) { if (isset($detail['delivery']) && $info = $detail['delivery']) { $data['content'] = []; $data['content']['type'] = 'line'; $data['content']['content'] = []; if ($detail['source_type'] == 1) { $data['content']['content'][] = ['name' => '快递公司', 'content' => $info['name']]; $data['content']['content'][] = ['name' => '快递单号', 'content' => $info['content']]; } else { $data['content']['content'][] = ['name' => '发货类型', 'content' => $info['name']]; $data['content']['content'][] = ['name' => '发货内容', 'content' => $info['content']]; } $data['content']['content'][] = ['name' => '发货时间', 'content' => date('Y-m-d H:i:s', $detail['ddate'])]; if ($detail['qdate']) { $data['content']['content'][] = ['name' => '签收时间', 'content' => date('Y-m-d H:i:s', $detail['qdate'])]; } if (isset($info['log']) && $info['log']) { $info['log'] = $this->html($info['log']); $data['content']['content'][] = ['name' => '快递信息', 'content' => '点此查看', 'alert' => $info['log']]; } } else { $data['content'] = []; $data['content']['type'] = 'text'; $data['content']['content'] = '无'; } $data['name'] = Dever::db('source_detail', 'place_order')->value('status', $detail['status']); $result = [0 => $data]; return $result; } // 时间线 HTML public function html($log) { $html = '
'; foreach($log as $index => $item) { // 最新状态高亮 $bgColor = $index === 0 ? '#dff0d8' : '#f0f8ff'; $html .= '
'; $html .= '
' . htmlspecialchars($item['time']) . '
'; $html .= '
'; $html .= htmlspecialchars($item['status']); $html .= '
'; $html .= '
'; } $html .= '
'; return $html; } private function getListCash($detail) { $data['name'] = Dever::load('info', 'place_score')->getText($detail['cash'], $this->info['score']); $promotion = Dever::db('promotion', 'place_order')->select(['table' => 'source_detail', 'table_id' => $detail['id']]); if ($promotion) { $data['content'] = []; $data['content']['type'] = 'line'; $data['content']['content'] = []; foreach ($promotion as $k => $v) { if ($k == 0) { $v['m_price'] = Dever::load('info', 'place_score')->getText($v['m_price'], $this->info['score']); $data['content']['content'][] = ['name' => '原价', 'content' => $v['m_price']]; } $v['price'] = Dever::load('info', 'place_score')->getText($v['price'], $this->info['score']); $v['price'] = $v['price'] . '('.$v['value'].'折)'; $data['content']['content'][] = ['name' => $v['name'], 'content' => $v['price']]; } # 金额信息 list($detail['total_cash'], $detail['pay_cash'], $detail['wallet_cash'], $detail['coupon_cash'], $detail['gift_cash'], $detail['refund_cash']) = Dever::load('info', 'place_score')->getText([$detail['total_cash'], $detail['pay_cash'], $detail['wallet_cash'], $detail['coupon_cash'], $detail['gift_cash'], $detail['refund_cash']], $this->info['score']); if (empty($detail['refund_num'])) { $detail['refund_num'] = 0; } $data['content']['content'][] = ['name' => '总金额', 'content' => $detail['total_cash']]; $data['content']['content'][] = ['name' => '优惠券抵扣', 'content' => $detail['coupon_cash']]; $data['content']['content'][] = ['name' => '礼品卡抵扣', 'content' => $detail['gift_cash']]; $data['content']['content'][] = ['name' => $this->info['score']['name'] . '抵扣', 'content' => $detail['wallet_cash']]; $data['content']['content'][] = ['name' => '支付金额', 'content' => $detail['pay_cash']]; $data['content']['content'][] = ['name' => '退款金额', 'content' => $detail['refund_cash']]; $data['content']['content'][] = ['name' => '退款数量', 'content' => $detail['refund_num'] . '个']; # 返利信息 $rebate = Dever::db('rebate', 'place_order')->select(['table' => 'source_detail', 'table_id' => $detail['id']]); if ($rebate) { foreach ($rebate as $v) { if ($v['level'] == 0) { $data['content']['content'][] = ['name' => '购买返利', 'content' => $v['value_text']]; } else { $data['content']['content'][] = ['name' => '返利' . $v['level'] . '层', 'content' => $v['value_text']]; } } } } $result = [0 => $data]; return $result; } # 获取退款信息 private function getRefund() { foreach ($this->info['refund_list'] as &$v) { $v['status'] = $this->getRefundStatus($v); } return [ 'name' => '退款', 'type' => 'table', 'border' => true, #'height' => '200', 'head' => [ [ 'key' => 'utype', 'name' => '申请人品牌', 'fixed' => 'fixed', //'width' => '80px', ], [ 'key' => 'name', 'name' => '申请人名称', 'fixed' => 'fixed', ], [ 'key' => 'mobile', 'name' => '申请人电话', 'fixed' => 'fixed', ], [ 'key' => 'type_name', 'name' => '退款类型', 'fixed' => 'fixed', ], [ 'key' => 'cash_text', 'name' => '退款金额', 'fixed' => 'fixed', ], [ 'key' => 'status', 'name' => '退款状态', 'fixed' => 'fixed', 'type' => 'popover', 'location' => 'right', 'tag' => true, ], [ 'key' => 'cdate_str', 'name' => '申请时间', 'fixed' => 'fixed', ], ], 'button' => [], 'body' => $this->info['refund_list'], ]; } private function getRefundStatus($refund) { $data['name'] = $refund['status_name']; $data['content'] = []; $data['content']['type'] = 'line'; $data['content']['content'] = []; $data['content']['content'][] = ['name' => '退款方式', 'content' => $refund['method_name']]; $data['content']['content'][] = ['name' => '申请原因', 'content' => $refund['desc_type_name']]; $data['content']['content'][] = ['name' => '申请说明', 'content' => $refund['desc']]; # 获取退款明细 if ($refund['detail_str']) { $data['content']['content'][] = ['name' => '退款明细', 'content' => $refund['detail_str']]; } if ($refund['status'] == 5) { $data['content']['content'][] = ['name' => '申请驳回', 'content' => $refund['audit_desc']]; } elseif ($refund['status'] >= 2) { $data['content']['content'][] = ['name' => '申请审核', 'content' => $refund['audit_desc']]; } # 退货退款 if ($refund['type'] == 1 && $refund['status'] >= 3) { $refund = Dever::load('source/delivery', 'place_order')->getRefundInfo($refund); if (isset($refund['delivery']['name']) && $refund['delivery']['name']) { $data['content']['content'][] = ['name' => '发货类型', 'content' => $refund['delivery']['name']]; $data['content']['content'][] = ['name' => '发货内容', 'content' => $refund['delivery']['content']]; } if (isset($refund['delivery']['log']) && $refund['delivery']['log']) { $data['content']['content'][] = ['name' => '快递信息', 'content' => $refund['delivery']['log']]; } } if ($refund['status'] == 6) { $data['content']['content'][] = ['name' => '退货驳回', 'content' => $refund['delivery_audit_desc']]; } $result = [0 => $data]; return $result; } # 获取返利信息 private function getRebate($rebate) { foreach ($rebate as &$v) { //$v['status'] = $this->getRefundStatus($v); $score = Dever::load('info', 'place_score')->get($v['score_id']); $v['score_name'] = $score['name']; $v['username'] = '无'; if ($v['level'] == 0) { $user = Dever::db('info', 'place_user')->find($this->info['uid']); $v['username'] = $user['name']; } else { $parent = Dever::load('relation', 'invite')->getParent($this->info['uid'], $v['level']); if ($parent) { $user = Dever::db('info', 'place_user')->find($parent['uid']); if ($user) { $v['username'] = $user['name']; } } } $v['status_name'] = '未入账'; if ($this->info['status'] == 5 || $this->info['status'] == 6) { $v['status_name'] = '已入账'; } } return [ 'name' => '返利', 'type' => 'table', 'border' => true, #'height' => '200', 'head' => [ [ 'key' => 'name', 'name' => '名称', 'fixed' => 'fixed', ], [ 'key' => 'score_name', 'name' => '奖励积分', 'fixed' => 'fixed', ], [ 'key' => 'level', 'name' => '奖励层级', 'fixed' => 'fixed', ], [ 'key' => 'value_text', 'name' => '奖励金额', 'fixed' => 'fixed', ], [ 'key' => 'username', 'name' => '奖励领取人', 'fixed' => 'fixed', ], [ 'key' => 'status_name', 'name' => '入账状态', 'fixed' => 'fixed', ], ], 'button' => [], 'body' => $rebate, ]; } # 获取操作日志 private function getLog() { return [ 'name' => '记录', 'type' => 'table', 'border' => true, #'height' => '200', 'head' => [ [ 'key' => 'utype', 'name' => '品牌', 'fixed' => 'fixed', //'width' => '80px', ], [ 'key' => 'name', 'name' => '名称', 'fixed' => 'fixed', ], [ 'key' => 'mobile', 'name' => '电话', 'fixed' => 'fixed', ], [ 'key' => 'desc', 'name' => '详情', 'fixed' => 'fixed', ], [ 'key' => 'cdate_str', 'name' => '时间', 'fixed' => 'fixed', ], ], 'button' => [], 'body' => Dever::load('source/log', 'place_order')->getList($this->info['id']) ]; } # 操作按钮 private function getButton() { $button = []; if ($this->info['status'] == 2) { # 实物可以修改收货信息 $this->info['source_type'][1] = true; if (isset($this->info['source_type'][1]) && $this->info['address_id']) { $button[] = [ 'name' => '修改收货信息', 'type' => 'fastedit', 'path' => 'sector_place_order/source_address', 'row' => [ 'id' => $this->info['id'], ], ]; /* $button[] = [ 'name' => '快递发货', # fastedit、fastadd、oper、api、link、route 'type' => 'fastadd', 'path' => 'sector_place_order/source_express', 'row' => [ 'id' => $this->info['id'], ], 'param' => [ 'order_id' => $this->info['id'], ], ];*/ } if ($this->info['method'] <= 2) { $name = '平台发货'; if ($this->info['method'] == 2) { $name = '店铺发货'; } if ($this->info['refund_status'] == 2 && (isset($this->info['source_type'][1]) || isset($this->info['source_type'][2]))) { $button[] = [ 'name' => $name, 'type' => 'fastadd', 'path' => 'sector_place_order/source_delivery', # row必填,这里的按钮来自于列表页,需要依赖哪一行。这里就写id就行,后续优化这里吧 'row' => [], 'param' => [ 'order_id' => $this->info['id'], ], # 弹窗宽度 'width' => '60%', ]; } } } elseif ($this->info['status'] == 3 && isset($this->info['delivery_edit']) && $this->info['delivery_edit']) { # 已发货,修改发货信息 $button[] = [ 'name' => '修改发货信息', 'type' => 'fastadd', 'path' => 'sector_place_order/source_delivery', # row必填,这里的按钮来自于列表页,需要依赖哪一行。这里就写id就行,后续优化这里吧 'row' => [], 'param' => [ 'order_id' => $this->info['id'], ], # 弹窗宽度 'width' => '60%', ]; } elseif ($this->info['status'] == 3 || $this->info['status'] == 4) { if (isset($this->info['delivery_show']) && $this->info['delivery_show']) { $button[] = [ 'name' => '查看发货信息', 'type' => 'fastadd', 'path' => 'sector_place_order/source_delivery', # row必填,这里的按钮来自于列表页,需要依赖哪一行。这里就写id就行,后续优化这里吧 'row' => [], 'param' => [ 'order_id' => $this->info['id'], ], # 弹窗宽度 'width' => '60%', ]; } /* $button[] = [ 'name' => '确认收货', 'type' => 'api', 'path' => 'sector_place_order/source_delivery', # row必填,这里的按钮来自于列表页,需要依赖哪一行。这里就写id就行,后续优化这里吧 'row' => [], 'param' => [ 'order_id' => $this->info['id'], ], # 弹窗宽度 'width' => '60%', ];*/ } # 退款按钮 if (!$this->info['refund'] && $this->info['status'] >= 2 && $this->info['status'] < 7) { $button[] = [ 'name' => '退款申请', 'type' => 'fastadd', 'path' => 'sector_place_order/source_refund', 'row' => [], 'param' => [ 'order_id' => $this->info['id'], ], # 弹窗宽度 'width' => '60%', ]; } if ($this->info['refund'] && $this->info['refund']['status'] == 1) { $button[] = [ 'name' => '退款审核', 'type' => 'fastedit', 'path' => 'sector_place_order/source_refund_audit', 'row' => [ 'id' => $this->info['refund']['id'], ], 'param' => [ 'order_id' => $this->info['id'], ], ]; } if ($this->info['refund'] && $this->info['refund']['status'] == 3) { $button[] = [ 'name' => '退货审核', 'type' => 'fastedit', 'path' => 'sector_place_order/source_refund_audit_delivery', 'row' => [ 'id' => $this->info['refund']['id'], ], 'param' => [ 'order_id' => $this->info['id'], ], ]; } return $button; } }