|
@@ -1575,39 +1575,47 @@ class Buy
|
|
|
|
|
|
$info = Dever::db('shop/buy_order')->one($id);
|
|
|
if ($audit > 1 && $info && $info['status'] == 2) {
|
|
|
+
|
|
|
+ $shop = Dever::db('shop/info')->find($info['type_id']);
|
|
|
+ if (strstr($info['order_num'], '_')) {
|
|
|
+ $temp = explode('_', $info['order_num']);
|
|
|
+ $info['order_num'] = $temp[0];
|
|
|
+ $info['order_index'] = $temp[1];
|
|
|
+ } else {
|
|
|
+ $info['order_index'] = 0;
|
|
|
+ }
|
|
|
$goods = explode(',', $goods);
|
|
|
- $data = array();
|
|
|
+ $data = $other = array();
|
|
|
foreach ($goods as $k => $v) {
|
|
|
list($source_type, $source_id, $name, $goods_id) = explode('_', $v);
|
|
|
+ $gv = Dever::db('shop/buy_order_goods')->find($goods_id);
|
|
|
if ($source_id > 0) {
|
|
|
$key = $source_type . '_' . $source_id;
|
|
|
$data[$key][] = array
|
|
|
(
|
|
|
- 'source_id' => $source_id,
|
|
|
+ 'area' => $shop['area'],
|
|
|
+ 'order_id' => $info['id'],
|
|
|
+ 'order_type' => $info['type'],
|
|
|
+ 'order_num' => $info['order_num'],
|
|
|
+ 'order_index' => $info['order_index'],
|
|
|
+ 'type' => 1,
|
|
|
+ 'type_id' => $shop['id'],
|
|
|
'source_type' => $source_type,
|
|
|
- 'goods_id' => $goods_id,
|
|
|
+ 'source_id' => $source_id,
|
|
|
+ 'order_goods_id' => $gv['id'],
|
|
|
+ 'goods_id' => $gv['goods_id'],
|
|
|
+ 'sku_id' => $gv['sku_id'],
|
|
|
+ 'price' => $gv['price'],
|
|
|
+ 'p_price' => $gv['price'],
|
|
|
+ 'num' => $gv['num'],
|
|
|
);
|
|
|
+ } else {
|
|
|
+ $other[] = $gv;
|
|
|
}
|
|
|
}
|
|
|
- $num = count($data);
|
|
|
- if ($num <= 0) {
|
|
|
- Dever::db('shop/buy_order')->update(array('where_id' => $id, 'audit' => 1));
|
|
|
- Dever::alert('未选择供货商,该订单进入重新审核状态');
|
|
|
- } else {
|
|
|
- if ($num == 1) {
|
|
|
- foreach ($data as $k => $v) {
|
|
|
- $k = explode('_', $k);
|
|
|
-
|
|
|
- $p_price = 0;
|
|
|
- foreach ($v as $k1 => $v1) {
|
|
|
- Dever::db('shop/buy_order_goods')->update(array('where_id' => $v1['order_goods_id'], 'set_p_price' => $v1['p_price']));
|
|
|
- $p_price += $v1['p_price'];
|
|
|
- $send[$order['id']] = $v1;
|
|
|
- }
|
|
|
- Dever::db('shop/buy_order')->update(array('where_id' => $order['id'], 'status' => 3, 'source_type' => $k[0], 'source_id' => $k[1], 'p_price' => $p_price, 'operdate' => time()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ $this->audit_action($data, $other, $info, $shop);
|
|
|
+
|
|
|
Dever::db('shop/buy_order')->update(array('where_id' => $info['id'], 'audit' => $audit, 'audit_desc' => $audit_text));
|
|
|
if ($audit == 2) {
|
|
|
|
|
@@ -1642,6 +1650,14 @@ class Buy
|
|
|
$shop = Dever::db('shop/info')->find($order['type_id']);
|
|
|
|
|
|
$data = $this->assign($goods, $order, $shop);
|
|
|
+
|
|
|
+ $this->audit_action($data, $goods, $order, $shop);
|
|
|
+
|
|
|
+ return 'ok';
|
|
|
+ }
|
|
|
+
|
|
|
+ private function audit_action($data, $goods, $order, $shop, $alert = '供货商库存不足,请联系供货商备货')
|
|
|
+ {
|
|
|
$send = array();
|
|
|
|
|
|
if ($data) {
|
|
@@ -1683,7 +1699,7 @@ class Buy
|
|
|
}
|
|
|
} else {
|
|
|
Dever::db('shop/buy_order')->update(array('where_id' => $order['id'], 'audit' => 1));
|
|
|
- Dever::alert('供货商库存不足,请联系供货商备货,该订单进入重新审核状态');
|
|
|
+ Dever::alert(',该订单进入重新审核状态');
|
|
|
}
|
|
|
|
|
|
if ($send) {
|
|
@@ -1710,8 +1726,6 @@ class Buy
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- return 'ok';
|
|
|
}
|
|
|
|
|
|
public function assign(&$goods, &$order, $shop, $state = false)
|