|
@@ -191,6 +191,7 @@ class OrderOutChild extends Base
|
|
|
'wsm_code' => '',
|
|
|
'supplierNo' => '',
|
|
|
'skuCode' => '',
|
|
|
+ 'good_name' => '',
|
|
|
'apply_id' => '',
|
|
|
'apply_name' => '',
|
|
|
'order_type' => '',
|
|
@@ -209,6 +210,7 @@ class OrderOutChild extends Base
|
|
|
if ($param['outChildCode'] != '') $where[] = ['a.outChildCode', 'like', '%' . $param['outChildCode'] . '%'];
|
|
|
if ($param['companyNo'] != '') $where[] = ['a.companyNo', 'like', '%' . $param['companyNo'] . '%'];
|
|
|
if ($param['spuCode'] != '') $where[] = ['a.spuCode', 'like', '%' . $param['spuCode'] . '%'];
|
|
|
+ if ($param['good_name'] != '') $where[] = ['a.good_name', 'like', '%' . $param['good_name'] . '%'];
|
|
|
if ($param['outCode'] != '') $where[] = ['a.outCode', 'like', '%' . $param['outCode'] . '%'];
|
|
|
if ($param['order_source'] != '') $where[] = ['a.order_source', '=', $param['order_source']];
|
|
|
if ($param['wsm_code'] != '') $where[] = ['a.wsm_code', 'like', '%' . $param['wsm_code'] . '%'];
|
|
@@ -405,10 +407,10 @@ class OrderOutChild extends Base
|
|
|
GoodStockInfo::ChildAddBn($item['outChildCode'], $wsm[$value['wsm_code']]);//维护bn号
|
|
|
}
|
|
|
|
|
|
- Db::name('order_out')
|
|
|
+ $up= Db::name('order_out')
|
|
|
->where(['id' => $info['id'], 'is_del' => 0, 'outCode' => $param['outCode'], 'send_status' => 1])
|
|
|
- ->update(['send_status' => 2, 'status' => 1]);
|
|
|
-
|
|
|
+ ->update(['send_status' => 2, 'status' => 1,"updatetime"=>date("Y-m-d H:i:s")]);
|
|
|
+ if($up==false) throw new \Exception("发货单更新失败");
|
|
|
Db::commit();
|
|
|
return json_show(0, '分单完成');
|
|
|
} catch (Exception $exception) {
|
|
@@ -427,10 +429,18 @@ class OrderOutChild extends Base
|
|
|
|
|
|
$info = Db::name('order_out_child')
|
|
|
->alias('a')
|
|
|
- ->field('a.*,b.name wsm_name,b.contactor,b.contactor_name')
|
|
|
+ ->field('a.*,b.name wsm_name,b.contactor,b.contactor_name,c.addr,c.addr_code,c.contactor addr_contactor,c.mobile addr_mobile')
|
|
|
->leftJoin('warehouse_info b', 'b.wsm_code=a.wsm_code')
|
|
|
+ ->leftJoin('order_addr c', 'c.id=a.addrid')
|
|
|
->where(['a.is_del' => 0, 'a.outChildCode' => $outChildCode])
|
|
|
->findOrEmpty();
|
|
|
+
|
|
|
+ if ($info['addr_code'] != "") {
|
|
|
+ $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
|
|
|
+ list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $info['addr_code']);
|
|
|
+ $addr = GetAddr(json_encode($place));
|
|
|
+ $info['addr'] = $addr.$info['addr'];
|
|
|
+ }
|
|
|
//校验是否开通了供应商账号
|
|
|
$supp_account = checkHasAccountBySupplierNos([$info['supplierNo']]);
|
|
|
$info['remark'] = Db::name("sale")->where(["orderCode"=>$info['orderCode']])->value("remark",'');
|
|
@@ -541,7 +551,7 @@ class OrderOutChild extends Base
|
|
|
//工单
|
|
|
if (!isset($child[$value['outChildCode']])) throw new Exception($value['outChildCode'] . '工单不存在或状态不允许发货');
|
|
|
|
|
|
- Db::name('order_out_child')
|
|
|
+ $up= Db::name('order_out_child')
|
|
|
->where(['id' => $child[$value['outChildCode']]['id'], 'is_del' => 0, 'status' => 1])
|
|
|
->update([
|
|
|
'post_name' => $value['post_name'],
|
|
@@ -551,7 +561,7 @@ class OrderOutChild extends Base
|
|
|
'sendtime' => $date,
|
|
|
'updatetime' => $date,
|
|
|
]);
|
|
|
-
|
|
|
+ if($up==false) throw new \Exception("发货工单更新失败");
|
|
|
//修改状态,添加待办
|
|
|
ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
|
|
|
"order_code" => $value['outChildCode'],//单号
|
|
@@ -584,7 +594,7 @@ class OrderOutChild extends Base
|
|
|
}
|
|
|
//发货单
|
|
|
//send_status 3部分发货,4全部发货
|
|
|
- Db::name('order_out')
|
|
|
+ $our_up= Db::name('order_out')
|
|
|
->where(['id' => $order_out[$child[$value['outChildCode']]['outCode']]['id']])
|
|
|
->update([
|
|
|
'send_status' => $order_out[$child[$value['outChildCode']]['outCode']]['already_send_num'] >= $order_out[$child[$value['outChildCode']]['outCode']]['send_num'] ? 4 : 3,
|
|
@@ -595,7 +605,7 @@ class OrderOutChild extends Base
|
|
|
'updatetime' => $date,
|
|
|
'sendtime' => $date
|
|
|
]);
|
|
|
-
|
|
|
+ if($our_up==false) throw new \Exception("发货单更新失败");
|
|
|
$sale[$child[$value['outChildCode']]['orderCode']]['send_num'] += $child[$value['outChildCode']]['num'];
|
|
|
$sale[$child[$value['outChildCode']]['orderCode']]['wsend_num'] -= $child[$value['outChildCode']]['num'];
|
|
|
|
|
@@ -631,10 +641,10 @@ class OrderOutChild extends Base
|
|
|
elseif ($sale_update_data['send_num'] == 0) $sale_update_data['status'] = 0;
|
|
|
else $sale_update_data['status'] = 1;
|
|
|
|
|
|
- Db::name('sale')
|
|
|
+ $sale_up = Db::name('sale')
|
|
|
->where(['is_del' => 0, 'id' => $sale[$child[$value['outChildCode']]['orderCode']]['id']])
|
|
|
->update($sale_update_data);
|
|
|
-
|
|
|
+ if($sale_up==false) throw new \Exception("销售单更新失败");
|
|
|
if ($sale[$child[$value['outChildCode']]['orderCode']]['order_source'] == 5 && $send_status == 3) {
|
|
|
$yz_tmp[] = [
|
|
|
'post_name' => $value['post_name'],
|
|
@@ -662,12 +672,12 @@ class OrderOutChild extends Base
|
|
|
]);
|
|
|
|
|
|
//库存
|
|
|
- Db::name('good_stock')
|
|
|
+ $stock_up= Db::name('good_stock')
|
|
|
->data(['updatetime' => $date])
|
|
|
->where(['is_del' => 0, 'spuCode' => $sale[$child[$value['outChildCode']]['orderCode']]['good_code'], 'wsm_code' => $child[$value['outChildCode']]['wsm_code']])
|
|
|
->dec('wait_out_stock', $child[$value['outChildCode']]['num'])
|
|
|
->update();
|
|
|
-
|
|
|
+ if($stock_up==false) throw new \Exception("商品库存数更新失败");
|
|
|
}
|
|
|
|
|
|
//日志、待办已办……
|