|
@@ -8,13 +8,13 @@ use think\facade\Db;
|
|
|
|
|
|
class Sale extends BaseController
|
|
|
{
|
|
|
-public $post="";
|
|
|
-public function __construct(App $app)
|
|
|
+ public $post="";
|
|
|
+ public function __construct(App $app)
|
|
|
{
|
|
|
parent::__construct($app);
|
|
|
$this->post=$this->request->post();
|
|
|
}
|
|
|
-public function create(){
|
|
|
+ public function create(){
|
|
|
$token = isset($this->post['token']) && $this->post['token'] !=="" ?trim($this->post['token']):"";
|
|
|
$orderCode=makeNo("CX");
|
|
|
$good_code = $this->post['good_code'] && $this->post['good_code'] !=="" ? trim($this->post['good_code']) :"";
|
|
@@ -30,6 +30,10 @@ public function create(){
|
|
|
if($customer_code==""){
|
|
|
return error_show(1002,"客户code不能为空");
|
|
|
}
|
|
|
+ $supplierNo= $this->post['supplierNo'] && $this->post['supplierNo'] !=="" ? trim($this->post['supplierNo']) :"";
|
|
|
+ if($supplierNo==""){
|
|
|
+ return error_show(1002,"参数supplierNo不能为空");
|
|
|
+ }
|
|
|
$apply_id =GetUserInfo($token);
|
|
|
if(empty($apply_id)||$apply_id['code']!=0){
|
|
|
return error_show(1002,"申请人数据不存在");
|
|
@@ -72,6 +76,7 @@ public function create(){
|
|
|
"sale_price"=>$ct['original_price'],
|
|
|
"post_fee"=>$post_fee,
|
|
|
"status"=>$status,
|
|
|
+ "supplierNo"=>$supplierNo,
|
|
|
"send_num"=>0,
|
|
|
"wsend_num"=>$good_num,
|
|
|
"send_status"=>1,
|
|
@@ -143,7 +148,7 @@ public function create(){
|
|
|
return error_show(1005,$e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
-public function list(){
|
|
|
+ public function list(){
|
|
|
$page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']):"1";
|
|
|
$size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']) :"10";
|
|
|
$where[] = ['is_del',"=",0];
|
|
@@ -174,7 +179,7 @@ public function list(){
|
|
|
}
|
|
|
return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
|
|
|
}
|
|
|
-public function edit(){
|
|
|
+ public function edit(){
|
|
|
$token = isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
|
|
|
$id = isset($this->post['id']) && $this->post['id'] !=="" ? trim($this->post['id']) :"";
|
|
|
if($id==""){
|
|
@@ -285,7 +290,7 @@ public function edit(){
|
|
|
return error_show(1005,$e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
-public function info(){
|
|
|
+ public function info(){
|
|
|
$id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
|
|
|
if($id==""){
|
|
|
return error_show(1002,"参数id不能为空");
|
|
@@ -375,7 +380,7 @@ public function info(){
|
|
|
return app_show(0,"获取成功",$einfo);
|
|
|
}
|
|
|
}
|
|
|
-public function del(){
|
|
|
+ public function del(){
|
|
|
$id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
|
|
|
if($id===""){
|
|
|
return error_show(1002,"参数id不能为空");
|
|
@@ -391,7 +396,7 @@ public function del(){
|
|
|
return error_show(1002,"删除失败");
|
|
|
}
|
|
|
}
|
|
|
-public function status(){
|
|
|
+ public function status(){
|
|
|
$id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
|
|
|
if($id==""){
|
|
|
return error_show(1002,"参数id不能为空");
|
|
@@ -443,7 +448,7 @@ public function status(){
|
|
|
return error_show(1005, $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
-public function fee(){
|
|
|
+ public function fee(){
|
|
|
$id = isset($this->post['id']) && $this->post['id'] !=="" ? trim($this->post['id']) :"";
|
|
|
if($id==""){
|
|
|
return error_show(1002,"参数id不能为空");
|
|
@@ -488,7 +493,7 @@ public function fee(){
|
|
|
return error_show(1005,$e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
-public function out(){
|
|
|
+ public function out(){
|
|
|
$token= isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
|
|
|
$outCode=makeNo("CK");
|
|
|
$orderCode = isset($this->post['orderCode']) && $this->post['orderCode'] !=="" ? trim($this->post['orderCode']) :"";
|
|
@@ -616,7 +621,7 @@ public function out(){
|
|
|
return error_show(1005, $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
-public function customer(){
|
|
|
+ public function customer(){
|
|
|
$outCode= isset($this->post['outCode']) && $this->post['outCode'] !=="" ? trim($this->post['outCode']) :"";
|
|
|
if(empty($outCode)){
|
|
|
return error_show(1002,"销售订单编号不能为空");
|
|
@@ -676,4 +681,117 @@ public function customer(){
|
|
|
return error_show(1005, $e->getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public function difflist(){
|
|
|
+ $page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']):"1";
|
|
|
+ $size = isset($this->post['size']) && $this->post['size'] !==""? intval($this->post['size']):"10";
|
|
|
+ $where = [['a.is_del',"=",0],['b.is_del',"=",0]];
|
|
|
+ $cgdNo = isset($this->post['orderCode']) && $this->post['orderCode']!="" ? trim($this->post['orderCode']):"";
|
|
|
+ if($cgdNo!=""){
|
|
|
+ $where[]=['a.orderCode',"like", "%$cgdNo%"];
|
|
|
+ }
|
|
|
+ $diffNo = isset($this->post['diffCode']) && $this->post['diffCode']!="" ? trim($this->post['diffCode']):"";
|
|
|
+ if($diffNo!=""){
|
|
|
+ $where[]=['a.diffCode',"like", "%$diffNo%"];
|
|
|
+ }
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']):"";
|
|
|
+ if($status!==""){
|
|
|
+ $where[]=['a.status',"=",$status];
|
|
|
+ }
|
|
|
+ $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
|
|
|
+ if ($start !="") {
|
|
|
+ $where[]= ["a.addtime",'>=',$start];
|
|
|
+ }
|
|
|
+ $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
|
|
|
+ if($end !=""){
|
|
|
+ $where[]= ["a.addtime",'<=',$end];
|
|
|
+ }
|
|
|
+// $apply_name = isset($this->post['apply_name']) && $this->post['apply_name'] !==""? intval($this->post['apply_name']):"";
|
|
|
+// if($apply_name!==""){
|
|
|
+// $where[]=['a.apply_name',"like","%$apply_name%"];
|
|
|
+// }
|
|
|
+ $count = Db::name('sale_diff')->alias('a')->join("good b","b.good_code=a.good_code","left")
|
|
|
+ ->where($where)->count();
|
|
|
+ $total = ceil($count/$size);
|
|
|
+ $page = $page >= $total ? $total : $page;
|
|
|
+ $list = Db::name('sale_diff')->alias('a')->join("good b","b.good_code=a.good_kode","left")
|
|
|
+ ->where($where)->page($page,$size)->field("a.*,b.cat_id")->order("a.addtime desc")->select();
|
|
|
+ $data=[];
|
|
|
+ foreach ($list as $value){
|
|
|
+ $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
|
|
|
+ $data[]=$value;
|
|
|
+ }
|
|
|
+ return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return \think\response\Json|void
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ */
|
|
|
+ public function diffcheck(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']):"";
|
|
|
+ if($id===""){
|
|
|
+ return error_show(1004,"参数id不能为空");
|
|
|
+ }
|
|
|
+ $info = Db::name("sale_diff")->where(["id"=>$id])->find();
|
|
|
+ if(empty($info)){
|
|
|
+ return error_show(1004,"订单数据未找到");
|
|
|
+ }
|
|
|
+ $is_act = isset($this->post['is_act']) && $this->post['is_act'] !==""? intval($this->post['is_act']):"";
|
|
|
+ if($is_act===''){
|
|
|
+ return error_show(1004,"参数is_act不能为空");
|
|
|
+ }
|
|
|
+ $customer_remark = isset($this->post['customer_remark']) && $this->post['customer_remark'] !==""? trim($this->post['customer_remark']):"";
|
|
|
+ if($customer_remark===''){
|
|
|
+ return error_show(1004,"参数customer_remark不能为空");
|
|
|
+ }
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']):"";
|
|
|
+ $remark = isset($this->post['remark']) && $this->post['remark'] !==""? trim($this->post['remark']):"";
|
|
|
+ $info['is_act'] =$is_act;
|
|
|
+ $info['customer_remark'] =$customer_remark;
|
|
|
+ $info['status'] =$status;
|
|
|
+ $info['remark'] =$remark;
|
|
|
+ $info['updatetime'] =date("Y-m-d H:i:s");
|
|
|
+ $up = Db::name("sale_diff")->save($info);
|
|
|
+ if($up){
|
|
|
+ return app_show(0,"更新成功");
|
|
|
+ }else{
|
|
|
+ return error_show(1003,"更新失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function diffstatus(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']):"";
|
|
|
+ if($id===""){
|
|
|
+ return error_show(1004,"参数id不能为空");
|
|
|
+ }
|
|
|
+ $info = Db::name("sale_diff")->where(["id"=>$id])->find();
|
|
|
+ if(empty($info)){
|
|
|
+ return error_show(1004,"订单数据未找到");
|
|
|
+ }
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']):"";
|
|
|
+ $remark = isset($this->post['remark']) && $this->post['remark'] !==""? trim($this->post['remark']):"";
|
|
|
+ $info['status'] =$status;
|
|
|
+ $info['remark'] =$remark;
|
|
|
+ $info['updatetime'] =date("Y-m-d H:i:s");
|
|
|
+ $up = Db::name("sale_diff")->save($info);
|
|
|
+ if($up){
|
|
|
+ return app_show(0,"更新成功");
|
|
|
+ }else{
|
|
|
+ return error_show(1003,"更新失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public function diffinfo(){
|
|
|
+ $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']):"";
|
|
|
+ if($id===""){
|
|
|
+ return error_show(1004,"参数id不能为空");
|
|
|
+ }
|
|
|
+ $info = Db::name("sale_diff")->where(["id"=>$id])->find();
|
|
|
+ if(empty($info)){
|
|
|
+ return error_show(1004,"订单数据未找到");
|
|
|
+ }
|
|
|
+ return app_show(0,"获取成功",$info);
|
|
|
+ }
|
|
|
}
|