|
@@ -117,11 +117,15 @@ class Buy
|
|
|
$info['shop'] = Dever::db('shop/info')->getOne($info['shop_id']);
|
|
|
$info['cdate'] = date('Y-m-d H:i', $info['cdate']);
|
|
|
|
|
|
+ $info['tui'] = Dever::db('shop/buy_order_tui')->find(array('order_id' => $info['id'], 'order_goods_id' => -1));
|
|
|
+
|
|
|
$goods_status = Dever::db('shop/buy_order_goods')->config['status'];
|
|
|
if ($view) {
|
|
|
foreach ($info['goods'] as $k => $v) {
|
|
|
$info['goods'][$k]['info'] = Dever::load('goods/lib/info')->getPayInfo($v['goods_id'], $v['sku_id']);
|
|
|
$info['goods'][$k]['status_name'] = $goods_status[$v['status']];
|
|
|
+
|
|
|
+ $info['goods'][$k]['tui'] = Dever::db('shop/buy_order_tui')->find(array('order_id' => $info['id'], 'order_goods_id' => $v['id']));
|
|
|
}
|
|
|
} else {
|
|
|
foreach ($info['goods'] as $k => $v) {
|
|
@@ -129,6 +133,8 @@ class Buy
|
|
|
$info['goods'][$k]['name'] = $goods['name'];
|
|
|
$info['goods'][$k]['cover'] = $goods['cover'];
|
|
|
$info['goods'][$k]['status_name'] = $goods_status[$v['status']];
|
|
|
+
|
|
|
+ $info['goods'][$k]['tui'] = Dever::db('shop/buy_order_tui')->find(array('order_id' => $info['id'], 'order_goods_id' => $v['id']));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -230,7 +236,7 @@ class Buy
|
|
|
|
|
|
public function raction($id, $refer = '')
|
|
|
{
|
|
|
- $order = Dever::db('goods/buy_order')->find($id);
|
|
|
+ $order = Dever::db('shop/buy_order')->find($id);
|
|
|
|
|
|
if (!$order) {
|
|
|
Dever::alert('订单信息错误');
|
|
@@ -335,6 +341,42 @@ class Buy
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public function tui_yes_api()
|
|
|
+ {
|
|
|
+ $id = Dever::input('id');
|
|
|
+ $process = Dever::input('process', 3);
|
|
|
+ $info = Dever::db('shop/buy_order_tui')->find($id);
|
|
|
+
|
|
|
+ if ($info && $info['process'] == 1) {
|
|
|
+ $update['process'] = $process;
|
|
|
+ $update['where_id'] = $info['id'];
|
|
|
+ $state = Dever::db('shop/buy_order_tui')->update($update);
|
|
|
+
|
|
|
+ if ($state && $process == 2) {
|
|
|
+ $data = $this->getView($info['shop_id'], $info['order_id'], false);
|
|
|
+ if ($data) {
|
|
|
+ if ($info['order_goods_id'] > 0) {
|
|
|
+ $state = Dever::db('shop/buy_order_goods')->update(array('where_id' => $info['order_goods_id'], 'status' => 3));
|
|
|
+ $this->pay_tui($state, $data, $info['cash']);
|
|
|
+
|
|
|
+
|
|
|
+ $total = Dever::db('shop/buy_order_goods')->total(array('order_id' => $info['order_id'], 'shop_id' => $id, 'status' => 1));
|
|
|
+ if ($total <= 0) {
|
|
|
+ $state = Dever::db('shop/buy_order')->update(array('where_id' => $info['order_id'], 'status' => 8));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ $state = Dever::db('shop/buy_order')->update(array('where_id' => $info['order_id'], 'status' => 8));
|
|
|
+ $this->pay_tui($state, $data, $info['cash']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return 'ok';
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public function tui_action($shop_id, $order_id, $order_goods_id, $status, $price, $num = false, $desc = '', $pic = '')
|
|
|
{
|
|
@@ -344,7 +386,7 @@ class Buy
|
|
|
$info = Dever::db('shop/buy_order_tui')->find($data);
|
|
|
|
|
|
$data['status'] = $status;
|
|
|
- $data['price'] = $price;
|
|
|
+ $data['cash'] = $price;
|
|
|
if ($num) {
|
|
|
$data['num'] = $num;
|
|
|
}
|
|
@@ -353,8 +395,10 @@ class Buy
|
|
|
|
|
|
if ($info) {
|
|
|
$data['where_id'] = $info['id'];
|
|
|
+ $data['process'] = 1;
|
|
|
return Dever::db('shop/buy_order_tui')->update($data);
|
|
|
} else {
|
|
|
+
|
|
|
return Dever::db('shop/buy_order_tui')->insert($data);
|
|
|
}
|
|
|
}
|
|
@@ -412,19 +456,6 @@ class Buy
|
|
|
}
|
|
|
|
|
|
$state = $this->tui_action($data['shop_id'], $data['id'], $order_goods_id, $status, $info['price'], $num, $desc, $pic);
|
|
|
-
|
|
|
-
|
|
|
- if ($state) {
|
|
|
- $this->pay_tui($state, $data, $info['price']);
|
|
|
-
|
|
|
-
|
|
|
- $total = Dever::db('shop/buy_order_goods')->total(array('order_id' => $data['id'], 'shop_id' => $id, 'status' => 1));
|
|
|
- if ($total <= 0) {
|
|
|
- $status += 3;
|
|
|
- $state = Dever::db('shop/buy_order')->update(array('where_id' => $data['id'], 'status' => $status, 'tk_desc' => $desc, 'tk_cash' => $info['price'], 'tk_pic' => $pic));
|
|
|
- }
|
|
|
- }
|
|
|
- */
|
|
|
} else {
|
|
|
Dever::alert('当前订单状态不允许退货退款');
|
|
|
}
|
|
@@ -434,21 +465,25 @@ class Buy
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
public function pay_tui($state, $data, $price)
|
|
|
{
|
|
|
- return;
|
|
|
- if ($state) {
|
|
|
- $shop = Dever::db('shop/info')->one($data['shop_id']);
|
|
|
- $msg_param['type'] = 1;
|
|
|
- $msg_param['id'] = $data['id'];
|
|
|
- $msg_param['name'] = $shop['name'];
|
|
|
- $msg_param = Dever::json_encode($msg_param);
|
|
|
- $msg = '您有一笔订单已退款,退款将在3个工作日内返回原支付账户';
|
|
|
- Dever::load('message/lib/data')->push(-1, $data['uid'], '退款成功通知', $msg, 1, 1, false, $msg_param);
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function orderStatus($id)
|
|
|
+ {
|
|
|
+ $config = Dever::db('shop/buy_order')->config;
|
|
|
+
|
|
|
+ $info = Dever::db('shop/buy_order')->one($id);
|
|
|
+ $tk = Dever::db('shop/buy_order_tui')->find(array('order_id' => $info['id'], 'process' => 1));
|
|
|
+ $status = $config['status'][$info['status']];
|
|
|
+
|
|
|
+ if ($tk) {
|
|
|
+ $status = '申请退款中';
|
|
|
}
|
|
|
+ return $status;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -462,6 +497,12 @@ class Buy
|
|
|
|
|
|
$shop = Dever::db('shop/info')->find($info['shop_id']);
|
|
|
|
|
|
+ $tk_status = Dever::db('shop/buy_order_tui')->config['status'];
|
|
|
+ $tk_process = Dever::db('shop/buy_order_tui')->config['process'];
|
|
|
+
|
|
|
+ $status = $config['status'][$info['status']];
|
|
|
+
|
|
|
+ $tk = Dever::db('shop/buy_order_tui')->find(array('order_id' => $info['id'], 'order_goods_id' => -1));
|
|
|
|
|
|
$html = '[基本信息]:<table class="layui-table"><thead><tr><th style="width:20%">项目</th><th style="width:80%">详情</th></tr> </thead><tbody>';
|
|
|
|
|
@@ -477,10 +518,27 @@ class Buy
|
|
|
|
|
|
</tr>';
|
|
|
|
|
|
- $html .= '<tr>
|
|
|
- <td>订单信息</td>
|
|
|
- <td>'.$this->table(array('订单状态', '金额', '数量'), array(array($config['status'][$info['status']], $info['price'], $info['num']))).'</td>
|
|
|
- </tr>';
|
|
|
+ $url = Dever::url('lib/buy.tui_yes', 'mshop');
|
|
|
+
|
|
|
+ if ($tk && $tk['process'] == 1) {
|
|
|
+ $status = '申请' . $tk_status[$tk['status']];
|
|
|
+ $process = $tk_process[$tk['process']];
|
|
|
+ $process = '';
|
|
|
+
|
|
|
+ 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>';
|
|
|
+ }
|
|
|
+ $html .= '<tr>
|
|
|
+ <td>订单信息</td>
|
|
|
+ <td>'.$this->table(array('金额', '数量', '订单状态', '审核状态'), array(array($info['price'], $info['num'], $status, $process))).'</td>
|
|
|
+ </tr>';
|
|
|
+ } else {
|
|
|
+ $html .= '<tr>
|
|
|
+ <td>订单信息</td>
|
|
|
+ <td>'.$this->table(array('金额', '数量', '订单状态'), array(array($info['price'], $info['num'], $status))).'</td>
|
|
|
+ </tr>';
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -488,18 +546,30 @@ class Buy
|
|
|
|
|
|
$html .= '[商品清单]:';
|
|
|
|
|
|
- $head = array('商品名称', '商品属性', '商品价格', '商品数量');
|
|
|
+ $head = array('名称', '属性', '价格', '数量', '状态');
|
|
|
|
|
|
$body = array();
|
|
|
$goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $info['id']));
|
|
|
+ $goods_status = Dever::db('shop/buy_order_goods')->config['status'];
|
|
|
foreach ($goods as $k => $v) {
|
|
|
$goods_info = Dever::load('goods/lib/info')->getInfoBySku($v['goods_id'], $v['sku_id']);
|
|
|
+ $status = $goods_status[$v['status']];
|
|
|
+ $tk = Dever::db('shop/buy_order_tui')->find(array('order_id' => $info['id'], 'order_goods_id' => $v['id']));
|
|
|
+ if ($tk && $tk['process'] == 1) {
|
|
|
+ $status = '申请' . $tk_status[$tk['status']];
|
|
|
+
|
|
|
+
|
|
|
+ if ($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>';
|
|
|
+ }
|
|
|
+ }
|
|
|
$body[$k] = array
|
|
|
(
|
|
|
$goods_info['name'],
|
|
|
$v['price'],
|
|
|
$v['price'],
|
|
|
$v['num'],
|
|
|
+ $status,
|
|
|
);
|
|
|
}
|
|
|
$html .= $this->table($head, $body);
|