|
@@ -14,7 +14,7 @@ class Order
|
|
|
# 已过期,自动取消
|
|
|
$info['time'] = -1;
|
|
|
$this->cancel($info);
|
|
|
- $info['status'] = 10;
|
|
|
+ $info['status'] = 9;
|
|
|
} else {
|
|
|
$info['time'] = $m - $info['time'];
|
|
|
}
|
|
@@ -31,7 +31,7 @@ class Order
|
|
|
# 获取订单里每个商品
|
|
|
public function getDetail($id)
|
|
|
{
|
|
|
- $result = Dever::db('order_detail', 'goods')->select(array('type' => 3, 'order_id' => $id), array('col' => 'id,name,pic,sku_name,sku_id,cash,num'));
|
|
|
+ $result = Dever::db('order_detail', 'goods')->select(array('order_id' => $id), array('col' => 'id,name,pic,sku_name,sku_id,cash,num'));
|
|
|
if ($result) {
|
|
|
foreach ($result as &$v) {
|
|
|
$v['cash'] = Dever::load('price', 'place')->getText($v['cash'], 3);
|
|
@@ -44,7 +44,7 @@ class Order
|
|
|
public function getView(&$info)
|
|
|
{
|
|
|
# 收货地址
|
|
|
- $info['address'] = Dever::load('address', 'place')->getInfo($info['address_id']);
|
|
|
+ $info['address'] = Dever::load('address', 'place')->getInfo($info['address_id'], $info['uid']);
|
|
|
# 运费
|
|
|
$info['yun'] = Dever::load('price', 'place')->getText(0, 3);
|
|
|
$info['status_list'] = array
|
|
@@ -52,27 +52,32 @@ class Order
|
|
|
1 => array
|
|
|
(
|
|
|
'selected' => false,
|
|
|
- 'name' => '已拍下',
|
|
|
+ 'name' => '待付款',
|
|
|
+ 'time' => $info['cdate_str'],
|
|
|
),
|
|
|
2 => array
|
|
|
(
|
|
|
'selected' => false,
|
|
|
- 'name' => '待付款',
|
|
|
+ 'name' => '待发货',
|
|
|
+ 'time' => $info['pdate_str'] ?? '',
|
|
|
),
|
|
|
3 => array
|
|
|
(
|
|
|
'selected' => false,
|
|
|
- 'name' => '待发货',
|
|
|
+ 'name' => '待签收',
|
|
|
+ 'time' => $info['ddate_str'] ?? '',
|
|
|
),
|
|
|
4 => array
|
|
|
(
|
|
|
'selected' => false,
|
|
|
'name' => '待收货',
|
|
|
+ 'time' => $info['qdate_str'] ?? '',
|
|
|
),
|
|
|
5 => array
|
|
|
(
|
|
|
'selected' => false,
|
|
|
'name' => '已完成',
|
|
|
+ 'time' => $info['fdate_str'] ?? '',
|
|
|
),
|
|
|
);
|
|
|
foreach ($info['status_list'] as $k => &$v) {
|
|
@@ -85,9 +90,9 @@ class Order
|
|
|
} elseif ($info['status'] == 2) {
|
|
|
$info['status_msg'] = '支付成功,待发货';
|
|
|
} elseif ($info['status'] == 3) {
|
|
|
- $info['status_msg'] = '已发货,等待配送';
|
|
|
+ $info['status_msg'] = '配送中,等待签收';
|
|
|
} elseif ($info['status'] == 4) {
|
|
|
- $info['status_msg'] = '配送中,等待收货';
|
|
|
+ $info['status_msg'] = '已签收,等待确认';
|
|
|
} elseif ($info['status'] == 5 || $info['status'] == 6) {
|
|
|
$info['status_msg'] = '订单已完成';
|
|
|
} elseif ($info['status'] > 6) {
|
|
@@ -99,9 +104,10 @@ class Order
|
|
|
public function cancel($order, $status = 9)
|
|
|
{
|
|
|
if ($order['status'] == 1) {
|
|
|
- $state = Dever::db('order', 'goods')->update($order['data_id'], array('status' => $status, 'fdate' => time()));
|
|
|
+ $state = Dever::db('order', 'goods')->update($order['id'], array('status' => $status, 'fdate' => time()));
|
|
|
if ($state) {
|
|
|
# 恢复库存
|
|
|
+ $this->resell($order['id']);
|
|
|
}
|
|
|
return 'ok';
|
|
|
}
|
|
@@ -119,7 +125,217 @@ class Order
|
|
|
$state = Dever::db('order', 'goods')->update($order['id'], $update);
|
|
|
if ($state && $update['status'] == 7) {
|
|
|
# 恢复库存
|
|
|
+ $this->resell($order['id']);
|
|
|
}
|
|
|
return $state;
|
|
|
}
|
|
|
+
|
|
|
+ # 恢复库存
|
|
|
+ public function resell($id)
|
|
|
+ {
|
|
|
+ $result = Dever::db('order_detail', 'goods')->select(array('order_id' => $id));
|
|
|
+ if ($result) {
|
|
|
+ foreach ($result as $v) {
|
|
|
+ $state = Dever::load('stock', 'goods')->sell($v['info_id'], $v['sku_id'], $v['num']*-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ # 后台详情页
|
|
|
+ public function showManageView($page)
|
|
|
+ {
|
|
|
+ # 这里获取基本信息
|
|
|
+ $db = Dever::db('order', 'goods');
|
|
|
+ $address = Dever::load('address', 'place')->getInfo($page->info['address_id'], $page->info['uid']);
|
|
|
+ $user = Dever::db('member', 'place')->find($page->info['uid']);
|
|
|
+ $desc = '';
|
|
|
+ $status = $db->value('status', $page->info);
|
|
|
+ if ($page->info['info']) {
|
|
|
+ $desc = '备注:' . $page->info['info'];
|
|
|
+ }
|
|
|
+ $timeline = array();
|
|
|
+ $page->info['cdate_str'] = date('Y-m-d H:i:s', $page->info['cdate']);
|
|
|
+ if (isset($page->info['pdate']) && $page->info['pdate']) {
|
|
|
+ $page->info['pdate_str'] = date('Y-m-d H:i:s', $page->info['pdate']);
|
|
|
+ }
|
|
|
+ if (isset($page->info['ddate']) && $page->info['ddate']) {
|
|
|
+ $page->info['ddate_str'] = date('Y-m-d H:i:s', $page->info['ddate']);
|
|
|
+ }
|
|
|
+ if (isset($page->info['qdate']) && $page->info['qdate']) {
|
|
|
+ $page->info['qdate_str'] = date('Y-m-d H:i:s', $page->info['qdate']);
|
|
|
+ }
|
|
|
+ if (isset($page->info['fdate']) && $page->info['fdate']) {
|
|
|
+ $page->info['fdate_str'] = date('Y-m-d H:i:s', $page->info['fdate']);
|
|
|
+ }
|
|
|
+ $this->getView($page->info);
|
|
|
+
|
|
|
+ foreach ($page->info['status_list'] as $k => $v) {
|
|
|
+ $v['name'] = '['.$v['name'].']';
|
|
|
+ if ($k == 1) {
|
|
|
+ $v['name'] .= ' 下单人:' . $user['name'] . '('.$user['mobile'].')' . ' 付款:' . $page->info['cash'] . '元 '. $desc;
|
|
|
+ } elseif ($k == 2) {
|
|
|
+ $v['name'] .= ' 收货地址:' . $address['name'] . ',' . $address['phone'] . ',' . $address['area_string'] . ',' . $address['address'];
|
|
|
+ } elseif ($k == 3) {
|
|
|
+ $express = Dever::db('order_express', 'goods')->find(array('order_id' => $page->info['id']));
|
|
|
+ if ($express) {
|
|
|
+ $express_info = Dever::db('express', 'sector')->find($express['express_id']);
|
|
|
+ $v['name'] .= ' 已发货:' . $express_info['name'] . ',' . $express['number'];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if ($k == 5 && $page->info['status'] > 6) {
|
|
|
+ $v['name'] .= ' 订单'.$status.'';
|
|
|
+ }
|
|
|
+ if ($v['selected']) {
|
|
|
+ $v['hollow'] = true;
|
|
|
+ $v['color'] = '#0bbd87';
|
|
|
+ $v['type'] = 'primary';
|
|
|
+ $v['size'] = 'large';
|
|
|
+ }
|
|
|
+ $timeline[] = $v;
|
|
|
+ }
|
|
|
+ $content = array
|
|
|
+ (
|
|
|
+ array
|
|
|
+ (
|
|
|
+ 'name' => '订单进度',
|
|
|
+ 'type' => 'timeline',
|
|
|
+ 'content' => $timeline,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+
|
|
|
+ $button = array();
|
|
|
+
|
|
|
+ if ($page->info['status'] == 2) {
|
|
|
+ $button[] = array
|
|
|
+ (
|
|
|
+ 'name' => '修改收货信息',
|
|
|
+ 'type' => 'fastedit',
|
|
|
+ 'path' => 'sector_place_order/goods_order_address',
|
|
|
+ 'row' => array
|
|
|
+ (
|
|
|
+ 'id' => $page->info['id'],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ $button[] = array
|
|
|
+ (
|
|
|
+ 'name' => '发货',
|
|
|
+ # fastedit、fastadd、oper、api、link、route
|
|
|
+ 'type' => 'fastadd',
|
|
|
+ 'path' => 'sector_place_order/goods_order_express',
|
|
|
+ 'row' => array
|
|
|
+ (
|
|
|
+ 'id' => $page->info['id'],
|
|
|
+ ),
|
|
|
+ 'param' => array
|
|
|
+ (
|
|
|
+ 'order_id' => $page->info['id'],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ } elseif ($page->info['status'] == 3 && isset($express)) {
|
|
|
+ $button[] = array
|
|
|
+ (
|
|
|
+ 'name' => '修改快递单号',
|
|
|
+ # fastedit、fastadd、oper、api、link、route
|
|
|
+ 'type' => 'fastedit',
|
|
|
+ 'path' => 'sector_place_order/goods_order_express',
|
|
|
+ 'row' => array
|
|
|
+ (
|
|
|
+ 'id' => $express['id'],
|
|
|
+ ),
|
|
|
+ 'param' => array
|
|
|
+ (
|
|
|
+ 'order_id' => $page->info['id'],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $info[] = array
|
|
|
+ (
|
|
|
+ # 类型,desc描述 table表格,表格有head和body即可
|
|
|
+ 'type' => 'desc',
|
|
|
+ 'name' => $page->info['order_num'],
|
|
|
+ # 每行展示数量
|
|
|
+ 'column' => 1,
|
|
|
+ # 是否有边框
|
|
|
+ 'border' => true,
|
|
|
+ # 排列方向:horizontal横向 vertical纵向
|
|
|
+ 'direction' => 'horizontal',
|
|
|
+ # 右侧按钮
|
|
|
+ 'button' => $button,
|
|
|
+ # 具体内容
|
|
|
+ 'content' => $content,
|
|
|
+ );
|
|
|
+
|
|
|
+ $detail = Dever::db('order_detail', 'goods')->select(array('order_id' => $page->info['id']));
|
|
|
+ foreach ($detail as &$v) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ $detail_button = array();
|
|
|
+ if ($page->info['status'] >= 2 && $page->info['status'] <= 6) {
|
|
|
+ $detail_button[] = array
|
|
|
+ (
|
|
|
+ 'name' => '退款',
|
|
|
+ 'type' => 'fastedit',
|
|
|
+ 'load' => 'platform/role',
|
|
|
+ );
|
|
|
+ }
|
|
|
+ $tab = array
|
|
|
+ (
|
|
|
+ 'active' => 'tab2',
|
|
|
+ 'content' => array
|
|
|
+ (
|
|
|
+ 'tab2' => array
|
|
|
+ (
|
|
|
+ 'name' => '商品清单',
|
|
|
+ 'type' => 'table',
|
|
|
+ 'border' => true,
|
|
|
+ 'height' => '200',
|
|
|
+ 'head' => array
|
|
|
+ (
|
|
|
+ array
|
|
|
+ (
|
|
|
+ 'key' => 'name',
|
|
|
+ 'name' => '名称',
|
|
|
+ 'fixed' => 'fixed',
|
|
|
+ ),
|
|
|
+ array
|
|
|
+ (
|
|
|
+ 'key' => 'sku_name',
|
|
|
+ 'name' => '规格',
|
|
|
+ 'fixed' => 'fixed',
|
|
|
+ ),
|
|
|
+ array
|
|
|
+ (
|
|
|
+ 'key' => 'cash',
|
|
|
+ 'name' => '金额',
|
|
|
+ 'fixed' => 'fixed',
|
|
|
+ ),
|
|
|
+ array
|
|
|
+ (
|
|
|
+ 'key' => 'num',
|
|
|
+ 'name' => '数量',
|
|
|
+ 'fixed' => 'fixed',
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ 'button' => $detail_button,
|
|
|
+ 'body' => $detail,
|
|
|
+ ),
|
|
|
+
|
|
|
+ 'table1' => array
|
|
|
+ (
|
|
|
+ # 这里跟desc一样
|
|
|
+ 'name' => '操作记录',
|
|
|
+ 'type' => 'text',
|
|
|
+ 'content' => '内容',
|
|
|
+ 'style' => 'primary',
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ return array('info' => $info, 'tab' => $tab);
|
|
|
+ }
|
|
|
}
|