|
@@ -5,7 +5,7 @@ namespace app\admin\controller;
|
|
|
use app\BaseController;
|
|
|
use think\App;
|
|
|
use think\facade\Db;
|
|
|
-
|
|
|
+use app\admin\model\ActionLog;
|
|
|
class Sale extends BaseController
|
|
|
{
|
|
|
public $post = "";
|
|
@@ -100,8 +100,11 @@ class Sale extends BaseController
|
|
|
$vat = [];
|
|
|
$inn = [];
|
|
|
if ($datainfo > 0) {
|
|
|
+ $st = ["order_code"=>$orderCode,"status"=>1,"action_remark"=>'',"action_type"=>"create"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$st,"xsd",1,$st);
|
|
|
foreach ($vi as $ion) {
|
|
|
$iten = [];
|
|
|
+ $sto = $iten['status'];
|
|
|
$iten['orderCode'] = $orderCode;
|
|
|
$iten['wsm_code'] = $ion['wsm_code'];
|
|
|
$iten['stock_id'] = "";
|
|
@@ -118,6 +121,8 @@ class Sale extends BaseController
|
|
|
// }
|
|
|
$vp = Db::name('sale_info')->insertAll($inn);
|
|
|
if ($vp == "") {
|
|
|
+ $stn = ["order_code"=>$orderCode,"status"=>$sto,"action_remark"=>'',"action_type"=>"create"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stn,"xsd",0,$stn);
|
|
|
Db::rollback();
|
|
|
return error_show(1002, "添加失败");
|
|
|
}
|
|
@@ -148,6 +153,8 @@ class Sale extends BaseController
|
|
|
}
|
|
|
$vmp = Db::name('order_addr')->insertAll($vat);
|
|
|
if ($vmp) {
|
|
|
+ $stp = ["order_code"=>$orderCode,"status"=>0,"action_remark"=>'',"action_type"=>"create"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stp,"xsd",0,$stp);
|
|
|
Db::commit();
|
|
|
return error_show(0, "销售订单创建成功");
|
|
|
}
|
|
@@ -297,9 +304,11 @@ class Sale extends BaseController
|
|
|
];
|
|
|
$datninfo = Db::name('sale')->where(['id' => $id, 'is_del' => 0])->save($datn);
|
|
|
if ($datninfo > 0) {
|
|
|
-
|
|
|
+ $stn = ["order_code"=>$good_code,"status"=>$status,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stn,"xsd",$status,$stn);
|
|
|
foreach ($vi as $ion) {
|
|
|
$iten = [];
|
|
|
+ $sto = $iten['status'];
|
|
|
isset($ion['id']) && $ion['id'] !== "" ? $iten['id'] = $ion['id'] : '';
|
|
|
$iten['orderCode'] = $etid['orderCode'];
|
|
|
$iten['wsm_code'] = $ion['wsm_code'];
|
|
@@ -311,7 +320,10 @@ class Sale extends BaseController
|
|
|
$iten['updatetime'] = date("Y-m-d H:i:s");
|
|
|
//$inn[]=$iten;
|
|
|
$vp = Db::name('sale_info')->save($iten);
|
|
|
- if ($vp == false) {
|
|
|
+ if ($vp == false)
|
|
|
+ {
|
|
|
+ $stc = ["order_code"=>$good_code,"status"=>$sto,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stc,"xsd",1,$stc);
|
|
|
Db::rollback();
|
|
|
return error_show(1002, "更新失败");
|
|
|
}
|
|
@@ -335,6 +347,8 @@ class Sale extends BaseController
|
|
|
$temp['arrive_time'] = date("Y-m-d H:i:s");
|
|
|
$dat = Db::name('order_addr')->save($temp);
|
|
|
if ($dat == false) {
|
|
|
+ $stu = ["order_code"=>$good_code,"status"=>0,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stu,"xsd",0,$stu);
|
|
|
Db::rollback();
|
|
|
return error_show(1002, "更新失败");
|
|
|
}
|
|
@@ -476,6 +490,8 @@ class Sale extends BaseController
|
|
|
}
|
|
|
$str = Db::name('sale')->update(['id' => $id, 'is_del' => 1, 'updatetime' => date("Y-m-d H:i:s")]);
|
|
|
if ($str) {
|
|
|
+ $stc = ["order_code"=>$id,"status"=>0,"action_remark"=>'',"action_type"=>"delete"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stc,"xsd",0,$stc);
|
|
|
return error_show(0, "删除成功");
|
|
|
} else {
|
|
|
return error_show(1002, "删除失败");
|
|
@@ -529,10 +545,13 @@ class Sale extends BaseController
|
|
|
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
+ $vmp =$dio['status'];
|
|
|
$dio['status'] = $status;
|
|
|
$dio['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$st = Db::name('sale')->save($dio);
|
|
|
if ($st) {
|
|
|
+ $stc = ["order_code"=>$id,"status"=>$vmp,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stc,"xsd",$dio['status'],$stc);
|
|
|
if ($status == 3) {
|
|
|
$dn = Db::name('sale_info')->where(['orderCode' => $st['orderCode']])->select();
|
|
|
foreach ($dn as $value) {
|
|
@@ -597,6 +616,8 @@ class Sale extends BaseController
|
|
|
$cgin = Db::name("purchease_order")->insert($clll);
|
|
|
// var_dump(Db::name("purchease_order")->getLastSql(),$clll);
|
|
|
if ($cgin == false) {
|
|
|
+ $stb = ["order_code"=>$cgd,"status"=> $dio['send_type'],"action_remark"=>'',"action_type"=>"create"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stb,"xsd", $dio['send_type'],$stb);
|
|
|
Db::rollback();
|
|
|
return error_show(1002, "咨询采购单创建商品失败");
|
|
|
}
|
|
@@ -625,6 +646,8 @@ class Sale extends BaseController
|
|
|
];
|
|
|
$datainfo = Db::name('order_out')->insert($data);
|
|
|
if (!$datainfo) {
|
|
|
+ $sti = ["order_code"=>$dio['orderCode'],"status"=> 0,"action_remark"=>'',"action_type"=>"create"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$sti,"xsd",0,$sti);
|
|
|
Db::rollback();
|
|
|
return error_show(1003, "创建失败");
|
|
|
}
|
|
@@ -649,6 +672,8 @@ class Sale extends BaseController
|
|
|
];
|
|
|
$win = Db::name("purchease_in")->insert($orin);
|
|
|
if (!$win){
|
|
|
+ $stv = ["order_code"=>$wsm_in_code,"status"=>4,"action_remark"=>'',"action_type"=>"create"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stv,"xsd",4,$stv);
|
|
|
Db::rollback();
|
|
|
return error_show(1003, "创建失败");
|
|
|
}
|
|
@@ -669,6 +694,8 @@ class Sale extends BaseController
|
|
|
$good['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$upd = Db::name("good_stock")->save($good);
|
|
|
if (!$upd) {
|
|
|
+ $ste = ["order_code"=> $zxinfo['cpNo'],"status"=>0,"action_remark"=>'',"action_type"=>"create"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$ste,"xsd",0,$ste);
|
|
|
Db::rollback();
|
|
|
return error_show(1003, "创建失败");
|
|
|
}
|
|
@@ -707,6 +734,8 @@ class Sale extends BaseController
|
|
|
];
|
|
|
$datainfo = Db::name('sale')->where(['id' => $id, 'is_del' => 0])->save($data);
|
|
|
if ($datainfo) {
|
|
|
+ $stx = ["order_code"=> $id,"status"=>2,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stx,"xsd",2,$stx);
|
|
|
foreach ($vr as $value) {
|
|
|
$tm = [];
|
|
|
$tm['id'] = $value['id'];
|
|
@@ -715,6 +744,8 @@ class Sale extends BaseController
|
|
|
$tm['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$dn = Db::name('order_addr')->save($tm);
|
|
|
if ($dn == false) {
|
|
|
+ $stx = ["order_code"=>$value['id'],"status"=>0,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stx,"xsd",0,$stx);
|
|
|
Db::rollback();
|
|
|
return error_show(1002, "更新失败");
|
|
|
}
|
|
@@ -812,6 +843,8 @@ class Sale extends BaseController
|
|
|
];
|
|
|
$datainfo = Db::name('order_out')->insert($data);
|
|
|
if ($datainfo) {
|
|
|
+ $stx = ["order_code"=>$orderCode,"status"=>$status,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stx,"xsd",$status,$stx);
|
|
|
if ($status == 1) {
|
|
|
|
|
|
$var = Db::name('sale_info')->where(['orderCode' => $orderCode, 'wsm_code' => $wsm_code])->find();
|
|
@@ -821,6 +854,7 @@ class Sale extends BaseController
|
|
|
}
|
|
|
// $send = Db::name("order_out")->where(["wsm_code" => $wsm_code, 'orderCode' => $orderCode])->sum
|
|
|
//("send_num");
|
|
|
+ // $item =$der['status'];
|
|
|
$der['send_num'] += $send_num;
|
|
|
$der['wsend_num'] -= $send_num;//($der['send_num'])?$der['wsend_num'] =="" ? $der['send']
|
|
|
$der['send_status'] = $der['send_num'] == 0 ? 1 : $der['wsend_num'] == 0 ? 3 : 2;
|
|
@@ -886,6 +920,7 @@ class Sale extends BaseController
|
|
|
}
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
+ $time = $codeinfo['status'];
|
|
|
$codeinfo['status'] = $status;
|
|
|
$codeinfo['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$cust = Db::name('order_out')->save($codeinfo);
|
|
@@ -907,6 +942,8 @@ class Sale extends BaseController
|
|
|
$var['intra_stock'] -= $codeinfo['send_num'];
|
|
|
$var['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$stre = Db::name('good_stock')->save($var);
|
|
|
+ $stx = ["order_code"=>$outCode,"status"=>$time,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stx,"xsd", $codeinfo['status'],$stx);
|
|
|
if ($stre == false) {
|
|
|
Db::rollback();
|
|
|
return error_show(1002, "状态更新失败");
|
|
@@ -1021,6 +1058,7 @@ class Sale extends BaseController
|
|
|
}
|
|
|
$status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "2";
|
|
|
$remark = isset($this->post['remark']) && $this->post['remark'] !== "" ? trim($this->post['remark']) : "";
|
|
|
+ $item = $info['status'];
|
|
|
$info['is_act'] = $is_act;
|
|
|
$info['customer_remark'] = $customer_remark;
|
|
|
$info['status'] = $status;
|
|
@@ -1028,6 +1066,8 @@ class Sale extends BaseController
|
|
|
$info['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$up = Db::name("sale_diff")->save($info);
|
|
|
if ($up) {
|
|
|
+ $stx = ["order_code"=>$id,"status"=>$item,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stx,"sxd", $info['status'],$stx);
|
|
|
return app_show(0, "更新成功");
|
|
|
} else {
|
|
|
return error_show(1003, "更新失败");
|
|
@@ -1052,11 +1092,14 @@ class Sale extends BaseController
|
|
|
}
|
|
|
$status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "3";
|
|
|
$remark = isset($this->post['remark']) && $this->post['remark'] !== "" ? trim($this->post['remark']) : "";
|
|
|
+ $ite=$info['status'];
|
|
|
$info['status'] = $status;
|
|
|
$info['remark'] = $remark;
|
|
|
$info['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$up = Db::name("sale_diff")->save($info);
|
|
|
if ($up) {
|
|
|
+ $stx = ["order_code"=>$id,"status"=>$ite,"action_remark"=>'',"action_type"=>"edit"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$stx,"sxd", $info['status'],$stx);
|
|
|
return app_show(0, "更新成功");
|
|
|
} else {
|
|
|
return error_show(1003, "更新失败");
|