|
@@ -259,61 +259,61 @@ class Sale extends Base
|
|
|
$temp['arrive_time']=$arrtime;
|
|
|
$vmp = Db::name('order_addr')->insert($temp,true);
|
|
|
if($vmp>0){
|
|
|
- $outCode=makeNo("CK");
|
|
|
- $out=[
|
|
|
- "orderCode"=>$orderCode,
|
|
|
- "outCode"=>$outCode,
|
|
|
- "apply_id"=>$rm,
|
|
|
- "apply_name"=>$ri,
|
|
|
- "addrid"=>$vmp,
|
|
|
- "post_name"=>"",
|
|
|
- "post_code"=>"",
|
|
|
- "post_fee"=>0,
|
|
|
- "sendtime"=>date("Y-m-d H:i:s"),
|
|
|
- "send_num"=>$value['receipt_quantity'],
|
|
|
- "check_num"=>0,
|
|
|
- "error_num"=>0,
|
|
|
- "wsm_code"=>"",
|
|
|
- "order_type"=>$order_type,
|
|
|
- "status"=>0,
|
|
|
- "addtime"=>date("Y-m-d H:i:s"),
|
|
|
- "updatetime"=>date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $ou =Db::name("order_out")->insert($out);
|
|
|
- if($ou==false){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1002,"发货地址添加创建失败");
|
|
|
- }
|
|
|
- if($is_stock==0){
|
|
|
- $order =Db::name("order_num")->where(["orderCode"=>$orderCode,"status"=>1])->where([["wsend_num",">=",0]])
|
|
|
- ->find();
|
|
|
- if($order==false){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1006,"采购单关联数据未找到");
|
|
|
- }
|
|
|
- $order['send_num']+=$value['receipt_quantity'];
|
|
|
- $order['wsend_num']-=$value['receipt_quantity'];
|
|
|
- if($order['wsend_num']<0){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1002,"发货数量已超出总数");
|
|
|
- }
|
|
|
- $ups = Db::name("order_num")->save($order);
|
|
|
- if($ups){
|
|
|
- $tep=[
|
|
|
- "cgdNo"=>$order['cgdNo'],
|
|
|
- "outCode"=>$outCode,
|
|
|
- "send_num"=>$value['receipt_quantity'],
|
|
|
- "status"=>1,
|
|
|
- "addtime"=>date("Y-m-d H:i:s"),
|
|
|
- "updatetime"=>date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $sen=Db::name("order_send")->save($tep);
|
|
|
- if($sen==false){
|
|
|
- Db::rollback();
|
|
|
- return error_show(1002,"发货地址添加创建失败");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// $outCode=makeNo("CK");
|
|
|
+// $out=[
|
|
|
+// "orderCode"=>$orderCode,
|
|
|
+// "outCode"=>$outCode,
|
|
|
+// "apply_id"=>$rm,
|
|
|
+// "apply_name"=>$ri,
|
|
|
+// "addrid"=>$vmp,
|
|
|
+// "post_name"=>"",
|
|
|
+// "post_code"=>"",
|
|
|
+// "post_fee"=>0,
|
|
|
+// "sendtime"=>date("Y-m-d H:i:s"),
|
|
|
+// "send_num"=>$value['receipt_quantity'],
|
|
|
+// "check_num"=>0,
|
|
|
+// "error_num"=>0,
|
|
|
+// "wsm_code"=>"",
|
|
|
+// "order_type"=>$order_type,
|
|
|
+// "status"=>0,
|
|
|
+// "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+// "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+// ];
|
|
|
+// $ou =Db::name("order_out")->insert($out);
|
|
|
+// if($ou==false){
|
|
|
+// Db::rollback();
|
|
|
+// return error_show(1002,"发货地址添加创建失败");
|
|
|
+// }
|
|
|
+// if($is_stock==0){
|
|
|
+// $order =Db::name("order_num")->where(["orderCode"=>$orderCode,"status"=>1])->where([["wsend_num",">=",0]])
|
|
|
+// ->find();
|
|
|
+// if($order==false){
|
|
|
+// Db::rollback();
|
|
|
+// return error_show(1006,"采购单关联数据未找到");
|
|
|
+// }
|
|
|
+// $order['send_num']+=$value['receipt_quantity'];
|
|
|
+// $order['wsend_num']-=$value['receipt_quantity'];
|
|
|
+// if($order['wsend_num']<0){
|
|
|
+// Db::rollback();
|
|
|
+// return error_show(1002,"发货数量已超出总数");
|
|
|
+// }
|
|
|
+// $ups = Db::name("order_num")->save($order);
|
|
|
+// if($ups){
|
|
|
+// $tep=[
|
|
|
+// "cgdNo"=>$order['cgdNo'],
|
|
|
+// "outCode"=>$outCode,
|
|
|
+// "send_num"=>$value['receipt_quantity'],
|
|
|
+// "status"=>1,
|
|
|
+// "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+// "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+// ];
|
|
|
+// $sen=Db::name("order_send")->save($tep);
|
|
|
+// if($sen==false){
|
|
|
+// Db::rollback();
|
|
|
+// return error_show(1002,"发货地址添加创建失败");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
}else{
|
|
|
Db::rollback();
|
|
|
return error_show(1002,"发货地址添加创建失败");
|
|
@@ -1055,50 +1055,50 @@ class Sale extends Base
|
|
|
$temp['arrive_time'] = $data['arrtime'];
|
|
|
$vmp = Db::name('order_addr')->insert($temp, true);
|
|
|
if ($vmp > 0) {
|
|
|
- $outCode = makeNo("CK");
|
|
|
- $out = [
|
|
|
- "orderCode" => $orderCode,
|
|
|
- "outCode" => $outCode,
|
|
|
- "apply_id"=>$data['rm'],
|
|
|
- "apply_name"=>$data['ri'],
|
|
|
- "addrid" => $vmp,
|
|
|
- "post_name" => "",
|
|
|
- "post_code" => "",
|
|
|
- "post_fee" => 0,
|
|
|
- "sendtime" => date("Y-m-d H:i:s"),
|
|
|
- "send_num" => $value['receipt_quantity'],
|
|
|
- "check_num" => 0,
|
|
|
- "error_num" => 0,
|
|
|
- "wsm_code" => "",
|
|
|
- "order_type" => 4,
|
|
|
- "status" => 0,
|
|
|
- "addtime" => date("Y-m-d H:i:s"),
|
|
|
- "updatetime" => date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $ou = Db::name("order_out")->insert($out);
|
|
|
- if ($ou == false) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- $order['send_num'] += $value['receipt_quantity'];
|
|
|
- $order['wsend_num'] -= $value['receipt_quantity'];
|
|
|
- if ($order['wsend_num'] < 0) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- $ups = Db::name("order_num")->save($order);
|
|
|
- if ($ups) {
|
|
|
- $tep = [
|
|
|
- "cgdNo" => $order['cgdNo'],
|
|
|
- "outCode" => $outCode,
|
|
|
- "send_num" => $value['receipt_quantity'],
|
|
|
- "status" => 1,
|
|
|
- "addtime" => date("Y-m-d H:i:s"),
|
|
|
- "updatetime" => date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $sen = Db::name("order_send")->save($tep);
|
|
|
- if ($sen == false) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
+// $outCode = makeNo("CK");
|
|
|
+// $out = [
|
|
|
+// "orderCode" => $orderCode,
|
|
|
+// "outCode" => $outCode,
|
|
|
+// "apply_id"=>$data['rm'],
|
|
|
+// "apply_name"=>$data['ri'],
|
|
|
+// "addrid" => $vmp,
|
|
|
+// "post_name" => "",
|
|
|
+// "post_code" => "",
|
|
|
+// "post_fee" => 0,
|
|
|
+// "sendtime" => date("Y-m-d H:i:s"),
|
|
|
+// "send_num" => $value['receipt_quantity'],
|
|
|
+// "check_num" => 0,
|
|
|
+// "error_num" => 0,
|
|
|
+// "wsm_code" => "",
|
|
|
+// "order_type" => 4,
|
|
|
+// "status" => 0,
|
|
|
+// "addtime" => date("Y-m-d H:i:s"),
|
|
|
+// "updatetime" => date("Y-m-d H:i:s")
|
|
|
+// ];
|
|
|
+// $ou = Db::name("order_out")->insert($out);
|
|
|
+// if ($ou == false) {
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// $order['send_num'] += $value['receipt_quantity'];
|
|
|
+// $order['wsend_num'] -= $value['receipt_quantity'];
|
|
|
+// if ($order['wsend_num'] < 0) {
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// $ups = Db::name("order_num")->save($order);
|
|
|
+// if ($ups) {
|
|
|
+// $tep = [
|
|
|
+// "cgdNo" => $order['cgdNo'],
|
|
|
+// "outCode" => $outCode,
|
|
|
+// "send_num" => $value['receipt_quantity'],
|
|
|
+// "status" => 1,
|
|
|
+// "addtime" => date("Y-m-d H:i:s"),
|
|
|
+// "updatetime" => date("Y-m-d H:i:s")
|
|
|
+// ];
|
|
|
+// $sen = Db::name("order_send")->save($tep);
|
|
|
+// if ($sen == false) {
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
} else {
|
|
|
return false;
|
|
@@ -1225,52 +1225,52 @@ class Sale extends Base
|
|
|
$temp['arrive_time'] = $data['arrtime'];
|
|
|
$vmp = Db::name('order_addr')->insert($temp, true);
|
|
|
if ($vmp > 0) {
|
|
|
- if($good['is_stock']!=1){
|
|
|
- $outCode = makeNo("CK");
|
|
|
- $out = [
|
|
|
- "orderCode" => $orderCode,
|
|
|
- "outCode" => $outCode,
|
|
|
- "apply_id"=>$data['rm'],
|
|
|
- "apply_name"=>$data['ri'],
|
|
|
- "addrid" => $vmp,
|
|
|
- "post_name" => "",
|
|
|
- "post_code" => "",
|
|
|
- "post_fee" => 0,
|
|
|
- "sendtime" => date("Y-m-d H:i:s"),
|
|
|
- "send_num" => $value['receipt_quantity'],
|
|
|
- "check_num" => 0,
|
|
|
- "error_num" => 0,
|
|
|
- "wsm_code" => "",
|
|
|
- "order_type" => 4,
|
|
|
- "status" => 0,
|
|
|
- "addtime" => date("Y-m-d H:i:s"),
|
|
|
- "updatetime" => date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $ou = Db::name("order_out")->insert($out);
|
|
|
- if ($ou == false) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- $order['send_num'] += $value['receipt_quantity'];
|
|
|
- $order['wsend_num'] -= $value['receipt_quantity'];
|
|
|
- if ($order['wsend_num'] < 0) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- $ups = Db::name("order_num")->save($order);
|
|
|
- if ($ups) {
|
|
|
- $tep = [
|
|
|
- "cgdNo" => $order['cgdNo'],
|
|
|
- "outCode" => $outCode,
|
|
|
- "send_num" => $value['receipt_quantity'],
|
|
|
- "status" => 1,
|
|
|
- "addtime" => date("Y-m-d H:i:s"),
|
|
|
- "updatetime" => date("Y-m-d H:i:s")
|
|
|
- ];
|
|
|
- $sen = Db::name("order_send")->insert($tep);
|
|
|
- if ($sen == false) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// if($good['is_stock']!=1){
|
|
|
+// $outCode = makeNo("CK");
|
|
|
+// $out = [
|
|
|
+// "orderCode" => $orderCode,
|
|
|
+// "outCode" => $outCode,
|
|
|
+// "apply_id"=>$data['rm'],
|
|
|
+// "apply_name"=>$data['ri'],
|
|
|
+// "addrid" => $vmp,
|
|
|
+// "post_name" => "",
|
|
|
+// "post_code" => "",
|
|
|
+// "post_fee" => 0,
|
|
|
+// "sendtime" => date("Y-m-d H:i:s"),
|
|
|
+// "send_num" => $value['receipt_quantity'],
|
|
|
+// "check_num" => 0,
|
|
|
+// "error_num" => 0,
|
|
|
+// "wsm_code" => "",
|
|
|
+// "order_type" => 4,
|
|
|
+// "status" => 0,
|
|
|
+// "addtime" => date("Y-m-d H:i:s"),
|
|
|
+// "updatetime" => date("Y-m-d H:i:s")
|
|
|
+// ];
|
|
|
+// $ou = Db::name("order_out")->insert($out);
|
|
|
+// if ($ou == false) {
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// $order['send_num'] += $value['receipt_quantity'];
|
|
|
+// $order['wsend_num'] -= $value['receipt_quantity'];
|
|
|
+// if ($order['wsend_num'] < 0) {
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// $ups = Db::name("order_num")->save($order);
|
|
|
+// if ($ups) {
|
|
|
+// $tep = [
|
|
|
+// "cgdNo" => $order['cgdNo'],
|
|
|
+// "outCode" => $outCode,
|
|
|
+// "send_num" => $value['receipt_quantity'],
|
|
|
+// "status" => 1,
|
|
|
+// "addtime" => date("Y-m-d H:i:s"),
|
|
|
+// "updatetime" => date("Y-m-d H:i:s")
|
|
|
+// ];
|
|
|
+// $sen = Db::name("order_send")->insert($tep);
|
|
|
+// if ($sen == false) {
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
@@ -2084,77 +2084,70 @@ class Sale extends Base
|
|
|
$order=["order_type"=>$codeinfo['order_type'] == 2?"ZXCKD":"CKD","order_code"=>$outCode,
|
|
|
"order_id"=>$codeinfo['id'],"order_status"=>$codeinfo['status']];
|
|
|
ProcessOrder::AddProcess($this->post['token'],$order);
|
|
|
-// if ($status == 3) {
|
|
|
-//
|
|
|
-// $var = Db::name('sale_info')->where(['orderCode' =>$codeinfo['orderCode'], 'wsm_code' =>$codeinfo['wsm_code']])->find();
|
|
|
-// //var_dump(Db::name('sale_info')->getLastSql());
|
|
|
-// if ($var == "") {
|
|
|
-// return error_show(1002, "未找到数据");
|
|
|
-// }
|
|
|
-//
|
|
|
-// // $send = Db::name("order_out")->where(["wsm_code" => $wsm_code, 'orderCode' => $orderCode])->sum
|
|
|
-// //("send_num");
|
|
|
-// $item =$dr['status'];
|
|
|
-// $dr['send_num'] +=$codeinfo['send_num'];
|
|
|
-// $dr['wsend_num'] -= $codeinfo['send_num'];//($der['send_num'])?$der['wsend_num'] =="" ? $der['send']
|
|
|
-// $dr['send_status'] = $dr['send_num'] == 0 ? 1 : $dr['wsend_num'] == 0 ? 3 : 2;
|
|
|
-// $dr['status'] = $dr['send_num'] == 0 ? 3 : $dr['wsend_num'] == 0 ? 5 : 4;
|
|
|
-// $dr['updatetime'] = date("Y-m-d H:i:s");
|
|
|
-// $si = Db::name('sale')->save($dr);
|
|
|
-// if ($si == false) {
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1003, "更新失败");
|
|
|
-// }
|
|
|
-// $stx = ["order_code"=>$dr['orderCode'],"status"=>$item,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
-// ActionLog::logAdd($this->post['token'],$stx,$dr['order_type'] == 2?"ZXQRD":"XSQRD",$dr['status'],
|
|
|
-// $dr);
|
|
|
-// $order=["order_type"=>$dr['order_type'] == 2?"ZXQRD":"XSQRD","order_code"=>$dr['orderCode'],"order_id"=>$dr['id'],"order_status"=>$dr['status']];
|
|
|
-// ProcessOrder::AddProcess($this->post['token'],$order);
|
|
|
-// $str = Db::name('good_stock')->where(['wsm_code' => $var['wsm_code'], 'good_type_code' => $dr['good_code']])->find();
|
|
|
-// if ($str == false) {
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1002, "商品数据未找到");
|
|
|
-// }
|
|
|
-// if ($codeinfo['send_num'] > $str['wait_out_stock']) {
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1002, "超出库存数量");
|
|
|
-// }
|
|
|
-// $str['wait_out_stock'] -= $codeinfo['send_num'];
|
|
|
-// $str['intra_stock'] += $codeinfo['send_num'];
|
|
|
-// $str['updatetime'] = date("Y-m-d H:i:s");
|
|
|
-// $stre = Db::name('good_stock')->save($str);
|
|
|
-// if ($stre == false) {
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1002, "状态更新失败");
|
|
|
-// }
|
|
|
-// $good_data[]= ["stock_id"=>$str['id'],"type"=>2,'stock'=>$codeinfo['send_num'],"stock_name"=>"wait_out_stock"];
|
|
|
-// $good_data[]= ["stock_id"=>$str['id'],"type"=>1,'stock'=>$codeinfo['send_num'],"stock_name"=>"intra_stock"];
|
|
|
-// GoodLog::LogAdd($this->post['token'],$good_data,'CKD');
|
|
|
-// }
|
|
|
-// if ($status == 2) {
|
|
|
-// $ct = Db::name('sale_info')->where(['orderCode' => $dr['orderCode'], 'wsm_code' => $codeinfo['wsm_code']])->find();
|
|
|
-// if ($ct == false) {
|
|
|
-// return error_show(1002, "未找到数据");
|
|
|
-// }
|
|
|
-// $var = Db::name('good_stock')->where(['wsm_code' => $codeinfo['wsm_code'], 'good_type_code' => $dr['good_code']])->find();
|
|
|
-// if ($var == false) {
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1002, "未找到商品数据");
|
|
|
-// }
|
|
|
-// if ($ct['num'] > $var['intra_stock']) {
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1003, "超出库存数量");
|
|
|
-// }
|
|
|
-// $var['intra_stock'] -= $codeinfo['send_num'];
|
|
|
-// $var['updatetime'] = date("Y-m-d H:i:s");
|
|
|
-// $stre = Db::name('good_stock')->save($var);
|
|
|
-// $good_data[]= ["stock_id"=>$var['id'],"type"=>2,'stock'=>$codeinfo['send_num'],"stock_name"=>"intra_stock"];
|
|
|
-// GoodLog::LogAdd($this->post['token'],$good_data,$codeinfo['order_type'] == 2?"ZXCKD":"CKD");
|
|
|
-// if ($stre == false) {
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1002, "状态更新失败");
|
|
|
-// }
|
|
|
-// }
|
|
|
+ if ($status == 1) {
|
|
|
+
|
|
|
+ $stokc =Db::name("good_stock")->where(['spuCode'=>$codeinfo['spuCode'],"wsm_code"=>$codeinfo['wsm_code'],
|
|
|
+ "is_del"=>0])->find();
|
|
|
+ if($stokc==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002, "未找库存到数据");
|
|
|
+ }else{
|
|
|
+ if ($codeinfo['send_num'] > $stokc['usable_stock']) {
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002, "超出库存数量");
|
|
|
+ }
|
|
|
+ $stokc['wait_out_stock']+=$codeinfo['send_num'];
|
|
|
+ $stokc['usable_stock']-=$codeinfo['send_num'];
|
|
|
+ $stokc['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ }
|
|
|
+ $stoc= Db::name("good_stock")->save($stokc);
|
|
|
+ if($stoc==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002, "库存更新失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ // $send = Db::name("order_out")->where(["wsm_code" => $wsm_code, 'orderCode' => $orderCode])->sum
|
|
|
+ //("send_num");
|
|
|
+ $item =$dr['status'];
|
|
|
+ $dr['send_num'] +=$codeinfo['send_num'];
|
|
|
+ $dr['wsend_num'] -= $codeinfo['send_num'];//($der['send_num'])?$der['wsend_num'] =="" ? $der['send']
|
|
|
+ $dr['send_status'] = $dr['send_num'] == 0 ? 1 : $dr['wsend_num'] == 0 ? 3 : 2;
|
|
|
+ $dr['status'] = $dr['send_num'] == 0 ? 3 : $dr['wsend_num'] == 0 ? 5 : 4;
|
|
|
+ $dr['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ $si = Db::name('sale')->save($dr);
|
|
|
+ if ($si == false) {
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1003, "更新失败");
|
|
|
+ }
|
|
|
+ $stx = ["order_code"=>$dr['orderCode'],"status"=>$item,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stx,$dr['order_type'] == 2?"ZXQRD":"XSQRD",$dr['status'],
|
|
|
+ $dr);
|
|
|
+ $order=["order_type"=>$dr['order_type'] == 2?"ZXQRD":"XSQRD","order_code"=>$dr['orderCode'],"order_id"=>$dr['id'],"order_status"=>$dr['status']];
|
|
|
+ ProcessOrder::AddProcess($this->post['token'],$order);
|
|
|
+ $good_data[]= ["stock_id"=>$stoc['id'],"type"=>1,'stock'=>$codeinfo['send_num'],"stock_name"=>"wait_out_stock"];
|
|
|
+ $good_data[]= ["stock_id"=>$stoc['id'],"type"=>2,'stock'=>$codeinfo['send_num'],"stock_name"=>"usable_stock"];
|
|
|
+ GoodLog::LogAdd($this->post['token'],$good_data,'CKD');
|
|
|
+ }
|
|
|
+ if ($status == 3) {
|
|
|
+ $var = Db::name('good_stock')->where(['wsm_code' => $codeinfo['wsm_code'], 'good_type_code' => $dr['good_code']])->find();
|
|
|
+ if ($var == false) {
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002, "未找到商品数据");
|
|
|
+ }
|
|
|
+ if ($codeinfo['send_num'] > $var['intra_stock']) {
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1003, "超出在途库存数量");
|
|
|
+ }
|
|
|
+ $var['intra_stock'] -= $codeinfo['send_num'];
|
|
|
+ $var['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ $stre = Db::name('good_stock')->save($var);
|
|
|
+ $good_data[]= ["stock_id"=>$var['id'],"type"=>2,'stock'=>$codeinfo['send_num'],"stock_name"=>"intra_stock"];
|
|
|
+ GoodLog::LogAdd($this->post['token'],$good_data,$codeinfo['order_type'] == 2?"ZXCKD":"CKD");
|
|
|
+ if ($stre == false) {
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002, "状态更新失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
Db::commit();
|
|
|
return error_show(0, "出库订单更新成功");
|
|
|
} else {
|
|
@@ -2644,17 +2637,39 @@ class Sale extends Base
|
|
|
$outinfo['sendtime'] = date("Y-m-d H:i:s");
|
|
|
$outinfo['status'] = 2;
|
|
|
$outinfo['updatetime'] = date("Y-m-d H:i:s");
|
|
|
- $up =Db::name("order_out")->save($outinfo);
|
|
|
- if($up){
|
|
|
-// $dbol =$this->RelaCgd($outinfo);
|
|
|
-// if($dbol==false){
|
|
|
-// Db::rollback();
|
|
|
-// return error_show(1004,"采购关联失败");
|
|
|
-// }
|
|
|
- return app_show(0,"发货成功");
|
|
|
- }else{
|
|
|
- return error_show(1004,"发货失败");
|
|
|
+ try{
|
|
|
+ $up =Db::name("order_out")->save($outinfo);
|
|
|
+ if($up){
|
|
|
+ $stokc =Db::name("good_stock")->where(['spuCode'=>$outinfo['spuCode'],"wsm_code"=>$outinfo['wsm_code'],
|
|
|
+ "is_del"=>0])->find();
|
|
|
+ if($stokc==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002, "未找库存到数据");
|
|
|
+ }else{
|
|
|
+ if ($outinfo['send_num'] > $stokc['wait_out_stock']) {
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002, "超出库存数量");
|
|
|
+ }
|
|
|
+ $stokc['wait_out_stock']-=$outinfo['send_num'];
|
|
|
+ $stokc['intra_stock']+=$outinfo['send_num'];
|
|
|
+ $stokc['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ }
|
|
|
+ $stoc= Db::name("good_stock")->save($stokc);
|
|
|
+ if($stoc==false){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002, "库存更新失败");
|
|
|
+ }
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,"发货成功");
|
|
|
+ }else{
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,"发货失败");
|
|
|
+ }
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,$e->getMessage());
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
public function RelaCgd($outinfo){
|
|
|
$der = Db::name('sale')->where(['orderCode' => $outinfo['orderCode']])->find();
|