|
@@ -59,14 +59,44 @@ class Buy
|
|
|
$where = $this->where($id);
|
|
|
$status = Dever::input('status');
|
|
|
if ($status) {
|
|
|
+ if ($status == 'refund') {
|
|
|
+ $where['refund_status'] = 2;
|
|
|
+ }
|
|
|
$where['status'] = $status;
|
|
|
}
|
|
|
|
|
|
+ $order_num = Dever::input('order_num');
|
|
|
+ if ($order_num) {
|
|
|
+ $where['order_num'] = $order_num;
|
|
|
+ }
|
|
|
+
|
|
|
+ $refund_status = Dever::input('refund_status');
|
|
|
+ if ($refund_status) {
|
|
|
+ $where['refund_status'] = $refund_status;
|
|
|
+ }
|
|
|
+
|
|
|
$result['search_value'] = $where;
|
|
|
$result['search_value']['day'] = $day = Dever::input('day');
|
|
|
if ($day) {
|
|
|
- $where['start'] = Dever::maketime($day . ' 00:00:00');
|
|
|
- $where['end'] = Dever::maketime($day . ' 23:59:59');
|
|
|
+ if ($this->type > 10) {
|
|
|
+ $where['start_o'] = Dever::maketime($day . ' 00:00:00');
|
|
|
+ $where['end_o'] = Dever::maketime($day . ' 23:59:59');
|
|
|
+ } else {
|
|
|
+ $where['start'] = Dever::maketime($day . ' 00:00:00');
|
|
|
+ $where['end'] = Dever::maketime($day . ' 23:59:59');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $result['search_value']['start'] = $start = Dever::input('start');
|
|
|
+ $result['search_value']['end'] = $end = Dever::input('end');
|
|
|
+ if ($start && $end) {
|
|
|
+ if ($this->type > 10) {
|
|
|
+ $where['start_o'] = Dever::maketime($start);
|
|
|
+ $where['end_o'] = Dever::maketime($end);
|
|
|
+ } else {
|
|
|
+ $where['start'] = Dever::maketime($start);
|
|
|
+ $where['end'] = Dever::maketime($end);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$result['order'] = Dever::db($this->table)->getAll($where);
|
|
@@ -452,6 +482,8 @@ class Buy
|
|
|
{
|
|
|
$id = Dever::input('order_id');
|
|
|
|
|
|
+ $type = Dever::input('type', 1);
|
|
|
+
|
|
|
$config = Dever::db('shop/buy_order')->config;
|
|
|
|
|
|
$info = Dever::db('shop/buy_order')->one($id);
|
|
@@ -462,59 +494,61 @@ class Buy
|
|
|
$status = $config['status'][$info['status']];
|
|
|
|
|
|
$tk = Dever::db('shop/buy_order_refund')->find(array('order_id' => $info['id'], 'type' => 1));
|
|
|
+
|
|
|
+ $opertime = date('Y-m-d H:i', $info['operdate']);
|
|
|
|
|
|
$html = '[基本信息]:<table class="layui-table"><thead><tr><th style="width:20%">项目</th><th style="width:80%">详情</th></tr> </thead><tbody>';
|
|
|
|
|
|
$html .= '<tr>
|
|
|
- <td>订单号</td>
|
|
|
- <td>'.$this->table(false, array(array($info['order_num']))).'</td>
|
|
|
+ <td>基本信息</td>
|
|
|
+ <td>'.$this->table(false, array(array('订单号:' . $info['order_num'], '金额:' . $info['price'], '数量:' . $info['num']))).'</td>
|
|
|
+
|
|
|
+ </tr>';
|
|
|
+
|
|
|
+ if ($type == 1 && $tk && $tk['process'] == 1) {
|
|
|
+ $status = '申请' . $tk_status[$tk['status']];
|
|
|
+ }
|
|
|
+
|
|
|
+ $html .= '<tr>
|
|
|
+ <td>订单状态</td>
|
|
|
+ <td>'.$this->table(false, array(array($status))).'</td>
|
|
|
+
|
|
|
+ </tr>';
|
|
|
+
|
|
|
+ $html .= '<tr>
|
|
|
+ <td>订货时间</td>
|
|
|
+ <td>'.$this->table(false, array(array($opertime))).'</td>
|
|
|
|
|
|
</tr>';
|
|
|
|
|
|
if ($info['type'] == 1) {
|
|
|
$type_info = Dever::db('shop/info')->find($info['type_id']);
|
|
|
- $html .= '<tr>
|
|
|
- <td>门店信息</td>
|
|
|
- <td>'.$this->table(false, array(array('门店名称:' . $type_info['name'], '联系人:' . $type_info['truename'], '联系电话:' . $type_info['mobile']))).'</td>
|
|
|
-
|
|
|
- </tr>';
|
|
|
} elseif ($info['type'] == 2) {
|
|
|
$type_info = Dever::db('store/info')->find($info['type_id']);
|
|
|
- $html .= '<tr>
|
|
|
- <td>仓库信息</td>
|
|
|
- <td>'.$this->table(false, array(array('仓库名称:' . $type_info['name'], '联系人:' . $type_info['truename'], '联系电话:' . $type_info['mobile']))).'</td>
|
|
|
-
|
|
|
- </tr>';
|
|
|
} elseif ($info['type'] == 3) {
|
|
|
$type_info = Dever::db('store/info')->find($info['type_id']);
|
|
|
- $html .= '<tr>
|
|
|
- <td>工厂信息</td>
|
|
|
- <td>'.$this->table(false, array(array('工厂名称:' . $type_info['name'], '联系人:' . $type_info['truename'], '联系电话:' . $type_info['mobile']))).'</td>
|
|
|
-
|
|
|
- </tr>';
|
|
|
}
|
|
|
-
|
|
|
|
|
|
- if ($info['source_id'] > 0) {
|
|
|
- if ($info['source_type'] == 2) {
|
|
|
-
|
|
|
- $store = Dever::db('store/info')->find($info['source_id']);
|
|
|
+ $html .= '<tr>
|
|
|
+ <td>配送信息</td>
|
|
|
+ <td>'.$this->table(false, array(array($type_info['name'] . ',' . $type_info['truename'] . ',' . $type_info['mobile'] . ',' . $type_info['address']))).'</td>
|
|
|
|
|
|
- $html .= '<tr>
|
|
|
- <td>供应商信息</td>
|
|
|
- <td>'.$this->table(false, array(array('仓库名称:' . $store['name'], '联系人:' . $store['truename'], '联系电话:' . $store['mobile']))).'</td>
|
|
|
+ </tr>';
|
|
|
|
|
|
- </tr>';
|
|
|
+
|
|
|
+ if ($type == 1 && $info['source_id'] > 0) {
|
|
|
+ if ($info['source_type'] == 2) {
|
|
|
+
|
|
|
+ $source_info = Dever::db('store/info')->find($info['source_id']);
|
|
|
} elseif ($info['source_type'] == 3) {
|
|
|
|
|
|
- $factory = Dever::db('factory/info')->find($info['source_id']);
|
|
|
-
|
|
|
- $html .= '<tr>
|
|
|
+ $source_info = Dever::db('factory/info')->find($info['source_id']);
|
|
|
+ }
|
|
|
+ $html .= '<tr>
|
|
|
<td>供应商信息</td>
|
|
|
- <td>'.$this->table(false, array(array('工厂名称:' . $factory['name'], '联系人:' . $factory['truename'], '联系电话:' . $factory['mobile']))).'</td>
|
|
|
+ <td>'.$this->table(false, array(array($source_info['name'] . ',' . $source_info['truename'] . ',' . $source_info['mobile']))).'</td>
|
|
|
|
|
|
</tr>';
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
if ($info['info']) {
|
|
@@ -525,52 +559,44 @@ class Buy
|
|
|
</tr>';
|
|
|
}
|
|
|
|
|
|
+ $html .= '</tbody></table>';
|
|
|
+
|
|
|
$url = Dever::url('lib/buy.refund', 'mshop');
|
|
|
if (!$info['refund_cash']) {
|
|
|
$info['refund_cash'] = 0;
|
|
|
}
|
|
|
|
|
|
- if ($info['refund_cash'] > 0) {
|
|
|
+ if ($info['refund_cash'] > 0 && $tk) {
|
|
|
|
|
|
- if ($tk) {
|
|
|
+ if ($tk['process'] == 1) {
|
|
|
+ $process = '<a href="javascript:;" onclick="audit('.$tk['id'].', 2, \''.$url.'\')" class="layui-btn">通过</a><a href="javascript:;" onclick="audit('.$tk['id'].', 3, \''.$url.'\')" class="layui-btn layui-btn-danger">驳回</a>';
|
|
|
+ } else {
|
|
|
$process = $tk_process[$tk['process']];
|
|
|
- $process = '';
|
|
|
-
|
|
|
- if ($tk['process'] == 1) {
|
|
|
- $status = '申请' . $tk_status[$tk['status']];
|
|
|
- $process .= ' <a href="javascript:;" onclick="audit('.$tk['id'].', 2, \''.$url.'\')" class="layui-btn">通过</a><a href="javascript:;" onclick="audit('.$tk['id'].', 3, \''.$url.'\')" class="layui-btn layui-btn-danger">驳回</a>';
|
|
|
-
|
|
|
- }
|
|
|
- $desc = array();
|
|
|
- $desc['原因'] = $tk['desc'];
|
|
|
- if ($tk['pic']) {
|
|
|
- $desc['图片'] = '';
|
|
|
- $pic = explode(',', $tk['pic']);
|
|
|
- foreach ($pic as $k => $v) {
|
|
|
- $desc['图片'] .= '<a href="'.$v.'" target="_blank"><img src="'.$v.'" width="100"/></a>';
|
|
|
- }
|
|
|
+ }
|
|
|
+ $desc = array();
|
|
|
+ $desc['退款原因'] = $tk['desc'];
|
|
|
+ if ($tk['pic']) {
|
|
|
+ $desc['退款图片'] = '';
|
|
|
+ $pic = explode(',', $tk['pic']);
|
|
|
+ foreach ($pic as $k => $v) {
|
|
|
+ $desc['图片'] .= '<a href="'.$v.'" target="_blank"><img src="'.$v.'" width="100"/></a>';
|
|
|
}
|
|
|
- $tk['desc'] = '<a href="javascript:layer.alert($(\'#desc_content\').html());">查看</a><span id="desc_content" style="display:none">'.Dever::table($desc).'</span>';
|
|
|
}
|
|
|
+ $tk['desc'] = '<a href="javascript:showAlert($(\'#desc_content\').html());">查看</a><span id="desc_content" style="display:none">'.Dever::table($desc).'</span>';
|
|
|
|
|
|
- $html .= '<tr>
|
|
|
- <td>订单信息</td>
|
|
|
- <td>'.$this->table(array('金额', '数量', '订单状态', '退款金额', '退款原因', '退款审核'), array(array($info['price'], $info['num'], $status, $info['refund_cash'], $tk['desc'], $process))).'</td>
|
|
|
- </tr>';
|
|
|
+ $html .= '[退款信息]:';
|
|
|
|
|
|
- } else {
|
|
|
- $html .= '<tr>
|
|
|
- <td>订单信息</td>
|
|
|
- <td>'.$this->table(array('金额', '数量', '订单状态'), array(array($info['price'], $info['num'], $status))).'</td>
|
|
|
- </tr>';
|
|
|
- }
|
|
|
-
|
|
|
+ $head = array('退款金额', '数量', '退款进度', '退款原因');
|
|
|
|
|
|
- $html .= '</tbody></table>';
|
|
|
+ $body = array(array($info['refund_cash'], $info['num'], $process, $tk['desc']));
|
|
|
+
|
|
|
+ $html .= $this->table($head, $body);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
$info['ps_info'] = Dever::db('shop/buy_order_ps')->find(array('order_id' => $info['id']));
|
|
|
if ($info['ps_info']) {
|
|
|
- $info['ps_info']['service_name'] = '商家自送';
|
|
|
+ $info['ps_info']['service_name'] = '供应商自送';
|
|
|
$info['ps_info']['cdate'] = date('Y-m-d H:i', $info['ps_info']['cdate']);
|
|
|
if ($info['ps_info']['ydate']) {
|
|
|
$info['ps_info']['ydate'] = date('Y-m-d H:i', $info['ps_info']['ydate']);
|
|
@@ -585,7 +611,7 @@ class Buy
|
|
|
$info['ps_info']['service_name'] = $service['name'];
|
|
|
}
|
|
|
|
|
|
- $html .= '[配送信息]:';
|
|
|
+ $html .= '[物流信息]:';
|
|
|
|
|
|
$head = array('名称', '单号', '费用', '数量', '重量', '体积', '配货员', '打包员', '状态');
|
|
|
|
|
@@ -619,7 +645,7 @@ class Buy
|
|
|
}
|
|
|
$status .= ' <a href="javascript:layer.alert($(\'#desc_content\').html());">查看原因</a><span id="desc_content" style="display:none">'.Dever::table($desc).'</span>';
|
|
|
|
|
|
- if ($tk['process'] == 1) {
|
|
|
+ if ($type == 1 && $tk['process'] == 1) {
|
|
|
$status .= ' <a href="javascript:;" onclick="audit('.$tk['id'].', 2, \''.$url.'\')" class="layui-btn">通过</a><a href="javascript:;" onclick="audit('.$tk['id'].', 3, \''.$url.'\')" class="layui-btn layui-btn-danger">驳回</a>';
|
|
|
}
|
|
|
}
|
|
@@ -778,7 +804,7 @@ class Buy
|
|
|
|
|
|
if ($this->order_num > 0) {
|
|
|
if ($this->order_num == 1) {
|
|
|
- Dever::db('shop/buy_order')->update(array('where_id' => $order['id'], 'status' => 3, 'source_type' => $find[0], 'source_id' => implode('', $find[1])));
|
|
|
+ Dever::db('shop/buy_order')->update(array('where_id' => $order['id'], 'status' => 3, 'source_type' => $find[0], 'source_id' => implode('', $find[1]), 'p_price' => $find[3][0], 'operdate' => time()));
|
|
|
|
|
|
Dever::db('shop/buy_order')->delete($find[2][0]);
|
|
|
Dever::db('shop/buy_order_goods')->delete(array('order_id' => $find[2][0]));
|
|
@@ -814,8 +840,9 @@ class Buy
|
|
|
$find = array();
|
|
|
$type_id = array();
|
|
|
$id = array();
|
|
|
+ $p_price = array();
|
|
|
if (!$store) {
|
|
|
- return array(2, $type_id, $id);
|
|
|
+ return array(2, $type_id, $id, $p_price);
|
|
|
}
|
|
|
foreach ($store as $k => $v) {
|
|
|
$where['store_id'] = $v['id'];
|
|
@@ -826,22 +853,24 @@ class Buy
|
|
|
if ($sku) {
|
|
|
if ($goods['num'] <= $sku['total']) {
|
|
|
|
|
|
- $state = $this->createOrder($order_id, $order_num, 1, $shop['id'], 2, $where['store_id'], $goods['price'], $goods['num'], $where['goods_id'], $where['sku_id']);
|
|
|
+ $state = $this->createOrder($order_id, $order_num, 1, $shop['id'], 2, $where['store_id'], $goods['price'], $goods['price'], $goods['num'], $where['goods_id'], $where['sku_id']);
|
|
|
if ($state) {
|
|
|
$type_id[] = $where['store_id'];
|
|
|
$id[] = $state;
|
|
|
+ $p_price[] = $goods['price'];
|
|
|
break;
|
|
|
}
|
|
|
} elseif ($state == 1 && $sku['total'] > 0) {
|
|
|
|
|
|
$goods['num'] = $goods['num'] - $sku['total'];
|
|
|
|
|
|
- $state = $this->createOrder($order_id, $order_num, 1, $shop['id'], 2, $where['store_id'], $goods['price'], $sku['total'], $where['goods_id'], $where['sku_id']);
|
|
|
+ $state = $this->createOrder($order_id, $order_num, 1, $shop['id'], 2, $where['store_id'], $goods['price'], $goods['price'], $sku['total'], $where['goods_id'], $where['sku_id']);
|
|
|
if (!$state) {
|
|
|
$goods['num'] = $goods['num'] + $sku['total'];
|
|
|
} else {
|
|
|
$type_id[] = $where['store_id'];
|
|
|
$id[] = $state;
|
|
|
+ $p_price[] = $goods['price'];
|
|
|
}
|
|
|
continue;
|
|
|
|
|
@@ -852,7 +881,7 @@ class Buy
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return array(2, $type_id, $id);
|
|
|
+ return array(2, $type_id, $id, $p_price);
|
|
|
}
|
|
|
|
|
|
private function factory($order_id, $order_num, $shop, $factory, $goods)
|
|
@@ -860,8 +889,9 @@ class Buy
|
|
|
$find = array();
|
|
|
$type_id = array();
|
|
|
$id = array();
|
|
|
+ $p_price = array();
|
|
|
if (!$factory) {
|
|
|
- return array(3, $type_id, $id);
|
|
|
+ return array(3, $type_id, $id, $p_price);
|
|
|
}
|
|
|
|
|
|
foreach ($factory as $k => $v) {
|
|
@@ -871,10 +901,11 @@ class Buy
|
|
|
$sku = Dever::db('factory/goods_sku')->select($where);
|
|
|
|
|
|
if ($sku) {
|
|
|
- $state = $this->createOrder($order_id, $order_num, 1, $shop['id'], 3, $where['factory_id'], $goods['price'], $goods['num'], $where['goods_id'], $where['sku_id']);
|
|
|
+ $state = $this->createOrder($order_id, $order_num, 1, $shop['id'], 3, $where['factory_id'], $goods['price'], $sku['p_price'], $goods['num'], $where['goods_id'], $where['sku_id']);
|
|
|
if ($state) {
|
|
|
$type_id[] = $where['factory_id'];
|
|
|
$id[] = $state;
|
|
|
+ $p_price[] = $sku['p_price'];
|
|
|
break;
|
|
|
}
|
|
|
} else {
|
|
@@ -882,11 +913,11 @@ class Buy
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return array(3, $type_id, $id);
|
|
|
+ return array(3, $type_id, $id, $p_price);
|
|
|
}
|
|
|
|
|
|
|
|
|
- private function createOrder($order_id, $order_num, $type, $type_id, $source_type, $source_id, $price, $num, $goods_id, $sku_id)
|
|
|
+ private function createOrder($order_id, $order_num, $type, $type_id, $source_type, $source_id, $price, $p_price, $num, $goods_id, $sku_id)
|
|
|
{
|
|
|
$where['parent_order_id'] = $order_id;
|
|
|
$where['type'] = $type;
|
|
@@ -904,6 +935,7 @@ class Buy
|
|
|
$data['operdate'] = time();
|
|
|
$data['status'] = 3;
|
|
|
$data['price'] = $price;
|
|
|
+ $data['p_price'] = $p_price;
|
|
|
$data['num'] = $num;
|
|
|
$id = $state = Dever::db('shop/buy_order')->insert($data);
|
|
|
} else {
|
|
@@ -911,6 +943,7 @@ class Buy
|
|
|
|
|
|
$data['where_id'] = $id;
|
|
|
$data['price'] = $info['price'] + $price;
|
|
|
+ $data['p_price'] = $info['p_price'] + $p_price;
|
|
|
$data['num'] = $info['num'] + $num;
|
|
|
$state = Dever::db('shop/buy_order')->update($data);
|
|
|
}
|
|
@@ -922,6 +955,7 @@ class Buy
|
|
|
$goods['goods_id'] = $goods_id;
|
|
|
$goods['sku_id'] = $sku_id;
|
|
|
$goods['price'] = $price;
|
|
|
+ $goods['p_price'] = $p_price;
|
|
|
$goods['num'] = $num;
|
|
|
Dever::db('shop/buy_order_goods')->insert($goods);
|
|
|
}
|