|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
+use app\admin\model\ActionLog;
|
|
|
use app\BaseController;
|
|
|
use think\facade\Db;
|
|
|
use think\App;
|
|
@@ -83,7 +84,10 @@ class Purchin extends BaseController
|
|
|
try{
|
|
|
$win = Db::name("purchease_in")->insert($orin);
|
|
|
if($win){
|
|
|
+ $order = ["order_code"=>$wsm_in_code,"status"=>$status,"action_remark"=>'',"action_type"=>"create"];
|
|
|
+ ActionLog::logAdd($this->post['token'],$order,"rkd",$status,$this->post);
|
|
|
if($status==1){
|
|
|
+ $order = ["order_code"=>$cgdNo,"status"=>$cgdinfo['status'],"action_remark"=>'',"action_type"=>"edit"];
|
|
|
$cgdinfo['wsend_num']-=$send_num;
|
|
|
$cgdinfo['send_num']+=$send_num;
|
|
|
$cgdinfo['send_status']=$cgdinfo['wsend_num']==0 ? 3:($cgdinfo['send_num']==0 ?1:2);
|
|
@@ -91,6 +95,7 @@ class Purchin extends BaseController
|
|
|
$cgdinfo['updatetime']=date("Y-m-d H:i:s");
|
|
|
$up=Db::name("purchease_order")->save($cgdinfo);
|
|
|
if($up){
|
|
|
+ ActionLog::logAdd($this->post['token'],$order,"cgd", $cgdinfo['status'],$cgdinfo);
|
|
|
Db::commit();
|
|
|
return app_show(0,'新建成功',["wsm_in_code"=>$wsm_in_code]);
|
|
|
}else{
|
|
@@ -153,11 +158,11 @@ class Purchin extends BaseController
|
|
|
}
|
|
|
$error_list = isset($this->post['error_list']) && $this->post['error_list']!==''?$this->post['error_list']:"";
|
|
|
|
|
|
- $wait_num = isset($this->post['wait_num']) && $this->post['wait_num']!==''?intval($this->post['wait_num'])
|
|
|
- :"";
|
|
|
- if($wait_num===''){
|
|
|
- return error_show(1004,"参数 wait_num 不为空");
|
|
|
- }
|
|
|
+// $wait_num = isset($this->post['wait_num']) && $this->post['wait_num']!==''?intval($this->post['wait_num'])
|
|
|
+// :"";
|
|
|
+// if($wait_num===''){
|
|
|
+// return error_show(1004,"参数 wait_num 不为空");
|
|
|
+// }
|
|
|
$result = GetUserInfo($this->post['token']);
|
|
|
if((!empty($result) && $result['code']!=0) ||empty($result) ){
|
|
|
return error_show($result['code'],$result['message']);
|
|
@@ -165,8 +170,9 @@ class Purchin extends BaseController
|
|
|
$userinfo = $result['data'];
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
+ $order = ["order_code"=>$incode,"status"=>$info['status'],"action_remark"=>'',"action_type"=>"edit"];
|
|
|
$info['wsm_num'] = $order_num;
|
|
|
- $info['wait_num'] = $wait_num;
|
|
|
+ $info['wait_num'] = $info['send_num'];
|
|
|
$info['checkid'] = $userinfo['id'];
|
|
|
$info['check_name'] = $userinfo['nickname'];
|
|
|
$info['status'] =2;
|
|
@@ -174,6 +180,7 @@ class Purchin extends BaseController
|
|
|
$info['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$up =Db::name("purchease_in")->save($info);
|
|
|
if($up){
|
|
|
+ ActionLog::logAdd($this->post['token'],$order,"rkd",2,$this->post);
|
|
|
if(!empty($error_list)){
|
|
|
$data=[];
|
|
|
foreach ($error_list as $value ){
|
|
@@ -228,17 +235,20 @@ class Purchin extends BaseController
|
|
|
$remark = isset($this->post['remark'])&&$this->post['remark']!="" ? trim($this->post['remark']) :"";
|
|
|
Db::rollback();
|
|
|
try{
|
|
|
+ $order = ["order_code"=>$incode,"status"=>$info['status'],"action_remark"=>'',"action_type"=>"status"];
|
|
|
$info['status'] = $status;
|
|
|
$info['remark'] = $remark;
|
|
|
$info['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$update = Db::name("purchease_in")->save($info);
|
|
|
if($update){
|
|
|
+ ActionLog::logAdd($this->post['token'],$order,"rkd",$status,$this->post);
|
|
|
if($status==0){
|
|
|
$cgdinfo=Db::name("purchease_order")->where(['cgdNo'=>$info['cgdNo'],"is_del"=>0])->find();
|
|
|
if(empty($cgdinfo)){
|
|
|
Db::rollback();
|
|
|
return error_show(1002,"未找到采购单数据");
|
|
|
}
|
|
|
+ $order = ["order_code"=>$info['cgdNo'],"status"=>$cgdinfo['status'],"action_remark"=>'',"action_type"=>"edit"];
|
|
|
$cgdinfo['wsend_num']+=$info['send_num'];
|
|
|
$cgdinfo['send_num']-=$info['send_num'];
|
|
|
$cgdinfo['send_status']=$cgdinfo['wsend_num']==0 ? 3:($cgdinfo['send_num']==0 ?1:2);
|
|
@@ -246,6 +256,7 @@ class Purchin extends BaseController
|
|
|
$cgdinfo['updatetime']=date("Y-m-d H:i:s");
|
|
|
$up=Db::name("purchease_order")->save($cgdinfo);
|
|
|
if($up){
|
|
|
+ ActionLog::logAdd($this->post['token'],$order,"cgd", $cgdinfo['status'],$cgdinfo);
|
|
|
Db::commit();
|
|
|
return app_show(0,'取消成功');
|
|
|
}else{
|
|
@@ -259,6 +270,7 @@ class Purchin extends BaseController
|
|
|
Db::rollback();
|
|
|
return error_show(1002,"未找到采购单数据");
|
|
|
}
|
|
|
+ $order = ["order_code"=>$info['cgdNo'],"status"=>$cgdinfo['status'],"action_remark"=>'',"action_type"=>"edit"];
|
|
|
$cgdinfo['wsend_num']-=$info['send_num'];
|
|
|
$cgdinfo['send_num']+=$info['send_num'];
|
|
|
$cgdinfo['send_status']=$cgdinfo['wsend_num']==0 ? 3:($cgdinfo['send_num']==0 ?1:2);
|
|
@@ -266,6 +278,7 @@ class Purchin extends BaseController
|
|
|
$cgdinfo['updatetime']=date("Y-m-d H:i:s");
|
|
|
$up=Db::name("purchease_order")->save($cgdinfo);
|
|
|
if($up){
|
|
|
+ ActionLog::logAdd($this->post['token'],$order,"cgd", $cgdinfo['status'],$cgdinfo);
|
|
|
Db::commit();
|
|
|
return app_show(0,'发货成功');
|
|
|
}else{
|
|
@@ -273,13 +286,14 @@ class Purchin extends BaseController
|
|
|
return error_show(1002,"发货失败");
|
|
|
}
|
|
|
}
|
|
|
- if($status==3){
|
|
|
+ if($status==4){
|
|
|
$cgdinfo=Db::name("purchease_order")->where(['cgdNo'=>$info['cgdNo'],"is_del"=>0])->find();
|
|
|
if(empty($cgdinfo)){
|
|
|
Db::rollback();
|
|
|
return error_show(1002,"未找到采购单数据");
|
|
|
}
|
|
|
- $good = Db::name("good_stock")->where(["wsm_code"=>$info['wsm_code'],"good_type_code"=>$cgdinfo['good_type_code'],"is_del"=>0])->find();
|
|
|
+ $good = Db::name("good_stock")->where(["wsm_code"=>$info['wsm_code'],"good_type_code"=>$cgdinfo['good_type_code'],"is_del"=>0])->find();
|
|
|
+
|
|
|
if(empty($good)) {
|
|
|
$good=[
|
|
|
"good_type_code"=>$cgdinfo['good_type_code'],
|
|
@@ -290,12 +304,17 @@ class Purchin extends BaseController
|
|
|
"addtime"=>date("Y-m-d H:i:s"),
|
|
|
"updatetime"=>date("Y-m-d H:i:s"),
|
|
|
];
|
|
|
+ $order = ["order_code"=>$good['good_type_code'],"status"=>1,"action_remark"=>'',"action_type"=>"create"];
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $order = ["order_code"=>$good['good_type_code'],"status"=>1,"action_remark"=>'', "action_type"=>"edit"];
|
|
|
}
|
|
|
$good['usable_stock']+=$info['send_num'];
|
|
|
$good['total_stock']=$good['usable_stock']+$good['wait_out_stock'];
|
|
|
$good['updatetime'] = date("Y-m-d H:i:s");
|
|
|
$upd= Db::name("good_stock")->save($good);
|
|
|
if($upd){
|
|
|
+ ActionLog::logAdd($this->post['token'],$order,"gst", 1,$info );
|
|
|
Db::commit();
|
|
|
return app_show(0,'商品入库成功');
|
|
|
}else{
|
|
@@ -316,6 +335,12 @@ class Purchin extends BaseController
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return \think\response\Json|void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
public function ReturnAdd(){
|
|
|
$incode = isset($this->post['wsm_in_code'])&&$this->post['wsm_in_code']!="" ? trim($this->post['wsm_in_code']) :"";
|
|
|
if($incode==""){
|
|
@@ -352,31 +377,81 @@ class Purchin extends BaseController
|
|
|
return error_show($result['code'],$result['message']);
|
|
|
}
|
|
|
$userinfo = $result['data'];
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+
|
|
|
+ $info['status'] = 3;
|
|
|
+ $info['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ $up= Db::name("purchease_in")->save($info);
|
|
|
+ if($up){
|
|
|
+ $data=[
|
|
|
+ "wsm_in_code"=>$incode,
|
|
|
+ "wsm_num"=>$wsm_num,
|
|
|
+ "reissue_num"=>$reissue_num,
|
|
|
+ "return_num"=>$return_num,
|
|
|
+ "return_contactor"=>$contactor,
|
|
|
+ "return_addr"=>$addr,
|
|
|
+ "return_mobile"=>$mobile,
|
|
|
+ "error_remark"=>$error_remark,
|
|
|
+ "post_code"=>$post_code,
|
|
|
+ "post_company"=>$post_company,
|
|
|
+ "remark"=>$remark ,
|
|
|
+ "apply_id"=>$userinfo['id'],
|
|
|
+ "apply_name"=>$userinfo['nickname'],
|
|
|
+ "status"=>$return_num>0?0:1,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $res = Db::name("purchease_return")->insert($data);
|
|
|
+ if($res){
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,"验货审核完成");
|
|
|
+ }else{
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002,"验货审核失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1002,$e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public function ReturnSend(){
|
|
|
+ $incode = isset($this->post['wsm_in_code'])&&$this->post['wsm_in_code']!="" ? trim($this->post['wsm_in_code']) :"";
|
|
|
+ if($incode==""){
|
|
|
+ return error_show(1004,"参数wsm_in_code 不为空");
|
|
|
+ }
|
|
|
+ $info = Db::name("purchease_in")->where(['wsm_in_code'=>$incode,"is_del"=>0])->find();
|
|
|
+ if(empty($info)){
|
|
|
+ return error_show(1004,"未找到发货单数据");
|
|
|
+ }
|
|
|
+ $return = Db::name("purchease_return")->where(['wsm_in_code'=>$incode,"is_del"=>0])->find();
|
|
|
+ if(empty($return)){
|
|
|
+ return error_show(1004,"未找到退货单数据");
|
|
|
+ }
|
|
|
+ $post_code = isset($this->post['post_code']) &&$this->post['post_code']!=="" ? trim($this->post['post_code']):"" ;
|
|
|
+ if($post_code==""){
|
|
|
+ return error_show(1004,"参数 post_code 不能为空");
|
|
|
+ }
|
|
|
+ $post_company = isset($this->post['post_company']) &&$this->post['post_company']!=="" ? trim($this->post['post_company']):"" ;
|
|
|
+ if($post_company==""){
|
|
|
+ return error_show(1004,"参数 post_company 不能为空");
|
|
|
+ }
|
|
|
+ $remark = isset($this->post['remark']) &&$this->post['remark']!=="" ? trim($this->post['remark']):"" ;
|
|
|
$data=[
|
|
|
- "wsm_in_code"=>$incode,
|
|
|
- "wsm_num"=>$wsm_num,
|
|
|
- "reissue_num"=>$reissue_num,
|
|
|
- "return_num"=>$return_num,
|
|
|
- "return_contactor"=>$contactor,
|
|
|
- "return_addr"=>$addr,
|
|
|
- "return_mobile"=>$mobile,
|
|
|
- "error_remark"=>$error_remark,
|
|
|
"post_code"=>$post_code,
|
|
|
"post_company"=>$post_company,
|
|
|
- "remark"=>$remark ,
|
|
|
- "apply_id"=>$userinfo['id'],
|
|
|
- "apply_name"=>$userinfo['nickname'],
|
|
|
- "status"=>0,
|
|
|
- "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "remark"=>$remark,
|
|
|
+ "status"=>1,
|
|
|
"updatetime"=>date("Y-m-d H:i:s")
|
|
|
];
|
|
|
- $res = Db::name("purchease_return")->insert($data);
|
|
|
- if($res){
|
|
|
- Db::commit();
|
|
|
- return app_show(0,"退货新建完成");
|
|
|
+ $up =Db::name("purchease_return")->where($return)->save($data);
|
|
|
+ if($up){
|
|
|
+ return app_show(0,"退货发货完成");
|
|
|
}else{
|
|
|
- Db::rollback();
|
|
|
- return error_show(1002,"退货新建失败");
|
|
|
+ return error_show(0,"退货发货失败");
|
|
|
}
|
|
|
}
|
|
|
}
|