|
@@ -580,11 +580,14 @@ class Buy
|
|
|
|
|
|
public function audit()
|
|
|
{
|
|
|
- $order_id = Dever::input('id');
|
|
|
+ $order_id = Dever::input('order_id');
|
|
|
$info = Dever::db('shop/buy_order')->find($order_id);
|
|
|
|
|
|
+ if (!$info || ($info && $info['status'] != 2)) {
|
|
|
+ Dever::alert('当前订单状态无法拆单');
|
|
|
+ }
|
|
|
+
|
|
|
$goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $order_id));
|
|
|
- print_r($goods);die;
|
|
|
|
|
|
$shop = Dever::db('shop/info')->find($info['shop_id']);
|
|
|
|
|
@@ -619,42 +622,44 @@ class Buy
|
|
|
|
|
|
array_multisort($distance, SORT_ASC, SORT_NUMERIC, $factory);
|
|
|
|
|
|
- if ($store) {
|
|
|
- $num = 0;
|
|
|
- foreach ($goods as $k => $v) {
|
|
|
-
|
|
|
- $find = $this->store($order_id, $shop, $store, $v);
|
|
|
- if (!$find[1]) {
|
|
|
-
|
|
|
- if ($factory) {
|
|
|
- $find = $this->factory($order_id, $shop, $factory, $v);
|
|
|
- }
|
|
|
-
|
|
|
- if (!$find[1]) {
|
|
|
-
|
|
|
- Dever::db('shop/buy_order_goods')->update(array('where_id' => $v['id'], 'status' => 4));
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
+ print_r($store);
|
|
|
+ print_r($factory);die;
|
|
|
|
|
|
- if ($find[1]) {
|
|
|
- $num++;
|
|
|
- Dever::db('shop/buy_order_goods')->update(array('where_id' => $v['id'], 'status' => 2, 'type' => $find[0], 'type_id' => implode(',', $find[1])));
|
|
|
+ $num = 0;
|
|
|
+ foreach ($goods as $k => $v) {
|
|
|
+
|
|
|
+ $find = $this->store($order_id, $shop, $store, $v);
|
|
|
+ if (!$find[1]) {
|
|
|
+
|
|
|
+ if ($factory) {
|
|
|
+ $find = $this->factory($order_id, $shop, $factory, $v);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$find[1]) {
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if ($num > 0) {
|
|
|
- Dever::db('shop/buy_order')->update(array('where_id' => $info['id'], 'status' => 3));
|
|
|
- } else {
|
|
|
- Dever::db('shop/buy_order')->update(array('where_id' => $info['id'], 'status' => 7));
|
|
|
+ if ($find[1]) {
|
|
|
+ $num++;
|
|
|
+ Dever::db('shop/buy_order_goods')->update(array('where_id' => $v['id'], 'status' => 2, 'type' => $find[0], 'type_id' => implode(',', $find[1])));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if ($num > 0) {
|
|
|
+ Dever::db('shop/buy_order')->update(array('where_id' => $info['id'], 'status' => 3));
|
|
|
+ } else {
|
|
|
+ Dever::db('shop/buy_order')->update(array('where_id' => $info['id'], 'status' => 7));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private function store($order_id, $shop, $store, $goods, $state = 2)
|
|
|
{
|
|
|
$find = array();
|
|
|
$id = array();
|
|
|
+ if (!$store) {
|
|
|
+ return array(1, $id);
|
|
|
+ }
|
|
|
foreach ($store as $k => $v) {
|
|
|
$where['store_id'] = $v['id'];
|
|
|
$where['goods_id'] = $goods['goods_id'];
|
|
@@ -695,6 +700,9 @@ class Buy
|
|
|
{
|
|
|
$find = array();
|
|
|
$id = array();
|
|
|
+ if (!$factory) {
|
|
|
+ return array(1, $id);
|
|
|
+ }
|
|
|
foreach ($factory as $k => $v) {
|
|
|
$where['factory_id'] = $v['id'];
|
|
|
$where['goods_id'] = $goods['goods_id'];
|