|
@@ -13,66 +13,124 @@ class Consult extends BaseController
|
|
|
{
|
|
|
parent::__construct($app);
|
|
|
$this->post=$this->request->post();
|
|
|
- $token = isset($this->post['token']) ? trim($this->post['token']) : "";
|
|
|
- if($token==""){
|
|
|
- return error_show(101,'token不能为空');
|
|
|
- }
|
|
|
- $effetc = VerifyTokens($token);
|
|
|
- if(!empty($effetc) && $effetc['code']!=0) {
|
|
|
- return error_show($effetc['code'], $effetc['message']);
|
|
|
- }
|
|
|
+// $token = isset($this->post['token']) ? trim($this->post['token']) : "";
|
|
|
+// if($token==""){
|
|
|
+// return error_show(101,'token不能为空');
|
|
|
+// }
|
|
|
+// $effetc = VerifyTokens($token);
|
|
|
+// if(!empty($effetc) && $effetc['code']!=0) {
|
|
|
+// return error_show($effetc['code'], $effetc['message']);
|
|
|
+// }
|
|
|
}
|
|
|
- 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],["cat_id","<>",0]];
|
|
|
- $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
|
|
|
- if ($zxNo !== "") {
|
|
|
- $where[] = ['zxNo','=',$zxNo];
|
|
|
- }
|
|
|
- $sequenceNo = isset($this->post['sequenceNo']) && $this->post['sequenceNo'] !== "" ? trim($this->post['sequenceNo']) : "";
|
|
|
- if ($sequenceNo !== "") {
|
|
|
- $where[] = ['sequenceNo','like',"%$sequenceNo%"];
|
|
|
- }
|
|
|
- $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
|
|
|
- if ($salesman !== "") {
|
|
|
- //$where["salesman"] =Db::Raw("like '%$salesman%'");
|
|
|
- $where[]= ["salesman",'like',"%$salesman%"];
|
|
|
+// 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],["cat_id","<>",0]];
|
|
|
+// $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
|
|
|
+// if ($zxNo !== "") {
|
|
|
+// $where[] = ['zxNo','=',$zxNo];
|
|
|
+// }
|
|
|
+// $sequenceNo = isset($this->post['sequenceNo']) && $this->post['sequenceNo'] !== "" ? trim($this->post['sequenceNo']) : "";
|
|
|
+// if ($sequenceNo !== "") {
|
|
|
+// $where[] = ['sequenceNo','like',"%$sequenceNo%"];
|
|
|
+// }
|
|
|
+// $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
|
|
|
+// if ($salesman !== "") {
|
|
|
+// //$where["salesman"] =Db::Raw("like '%$salesman%'");
|
|
|
+// $where[]= ["salesman",'like',"%$salesman%"];
|
|
|
+// }
|
|
|
+// $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
|
|
|
+// if ($cpName !== "") {
|
|
|
+// //$where["cpName"]= Db::Raw("like '%$cpName%'");
|
|
|
+// $where[]= ["cpName",'like',"%$cpName%"];
|
|
|
+// }
|
|
|
+// $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
|
|
|
+// if ($khNo !== "") {
|
|
|
+// // $where['khNo'] = $khNo;
|
|
|
+// $where[]= ["khNo",'like',"%$khNo%"];
|
|
|
+// }
|
|
|
+// $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
|
|
|
+// if ($start !="") {
|
|
|
+// //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
|
|
|
+// $where[]= ["zxtime",'>=',$start];
|
|
|
+// }
|
|
|
+// $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
|
|
|
+// if($end !=""){
|
|
|
+// $where[]= ["zxtime",'<=',$end];
|
|
|
+// }
|
|
|
+// $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
|
|
|
+// if ($status !== "") {
|
|
|
+// $where[]= ["status",'=',$status];
|
|
|
+// }
|
|
|
+// $count = Db::name('consult')->where($where)->count();
|
|
|
+// $total = ceil($count / $size);
|
|
|
+// $page = $page >= $total ? $total : $page;
|
|
|
+// $list = Db::name('consult')->where($where)->page($page,$size)
|
|
|
+// ->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,"获取成功",['count'=>$count,'list'=>$data]);
|
|
|
+// }
|
|
|
+ public function conlist(){
|
|
|
+ $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]];
|
|
|
+ $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
|
|
|
+ if ($zxNo !== "") {
|
|
|
+ $where[] = ['a.zxNo','=',$zxNo];
|
|
|
+ }
|
|
|
+// $sequenceNo = isset($this->post['sequenceNo']) && $this->post['sequenceNo'] !== "" ? trim($this->post['sequenceNo']) : "";
|
|
|
+// if ($sequenceNo !== "") {
|
|
|
+// $where[] = ['sequenceNo','like',"%$sequenceNo%"];
|
|
|
+// }
|
|
|
+ $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
|
|
|
+ if ($salesman !== "") {
|
|
|
+ //$where["salesman"] =Db::Raw("like '%$salesman%'");
|
|
|
+ $where[]= ["b.salesman",'like',"%$salesman%"];
|
|
|
}
|
|
|
$cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
|
|
|
if ($cpName !== "") {
|
|
|
//$where["cpName"]= Db::Raw("like '%$cpName%'");
|
|
|
- $where[]= ["cpName",'like',"%$cpName%"];
|
|
|
+ $where[]= ["a.good_Name",'like',"%$cpName%"];
|
|
|
}
|
|
|
- $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
|
|
|
- if ($khNo !== "") {
|
|
|
- // $where['khNo'] = $khNo;
|
|
|
- $where[]= ["khNo",'like',"%$khNo%"];
|
|
|
+ $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
|
|
|
+ if ($khNo !== "") {
|
|
|
+ // $where['khNo'] = $khNo;
|
|
|
+ $where[]= ["b.khNo",'like',"%$khNo%"];
|
|
|
}
|
|
|
$start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
|
|
|
if ($start !="") {
|
|
|
//$where = ["zxtime"=>Db::raw(">= '{$start}'")];
|
|
|
- $where[]= ["zxtime",'>=',$start];
|
|
|
+ $where[]= ["a.addtime",'>=',$start];
|
|
|
}
|
|
|
$end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
|
|
|
if($end !=""){
|
|
|
- $where[]= ["zxtime",'<=',$end];
|
|
|
+ $where[]= ["a.addtime",'<=',$end];
|
|
|
}
|
|
|
- $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
|
|
|
- if ($status !== "") {
|
|
|
- $where[]= ["status",'=',$status];
|
|
|
+ $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
|
|
|
+ if ($status !== "") {
|
|
|
+ $where[]= ["a.status",'=',$status];
|
|
|
}
|
|
|
- $count = Db::name('consult')->where($where)->count();
|
|
|
+ $count = Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)
|
|
|
+ ->count();
|
|
|
$total = ceil($count / $size);
|
|
|
$page = $page >= $total ? $total : $page;
|
|
|
- $list = Db::name('consult')->where($where)->page($page,$size)
|
|
|
- ->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,"获取成功",['count'=>$count,'list'=>$data]);
|
|
|
+ $list =Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)->page($page,$size)
|
|
|
+ ->field("a.*,b.createrid,b.creater,b.is_project,b.projectNo,b.khNo,b.endtime,b.platform_code,b.saleid,b.salesman,b.depart")->select();
|
|
|
+ $data=[];
|
|
|
+ foreach ($list as $value){
|
|
|
+ $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
|
|
|
+ $value['khname']="";
|
|
|
+ if($value['khNo']!==""){
|
|
|
+ $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
|
|
|
+ $value['khname']= isset($kh['companyName'])?$kh['companyName']:"";
|
|
|
+ }
|
|
|
+ $data[]=$value;
|
|
|
+ }
|
|
|
+ return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
|
|
|
}
|
|
|
public function info(){
|
|
|
$id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : "";
|
|
@@ -92,7 +150,7 @@ class Consult extends BaseController
|
|
|
$id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : "";
|
|
|
$de = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find();
|
|
|
if($de==false){
|
|
|
- return error_show(1002,'咨询单编号未找到');
|
|
|
+ return error_show(1002,'咨询单信息未找到');
|
|
|
}
|
|
|
$dell= Db::name('consult')->update(['id'=>$id,'is_del'=>1,'updatetime'=>date("Y-m-d H:i:s")]);
|
|
|
if($dell){
|
|
@@ -239,12 +297,12 @@ class Consult extends BaseController
|
|
|
if($gold_price===""){
|
|
|
return error_show(1004,"参数gold_price不能为空");
|
|
|
}
|
|
|
- $budget_price = isset($this->post['budget_price'])&&$this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
|
|
|
- if($budget_price===""){
|
|
|
- return error_show(1004,"参数budget_price不能为空");
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
+ $budget_price = isset($this->post['budget_price'])&&$this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
|
|
|
+ if($budget_price===""){
|
|
|
+ return error_show(1004,"参数budget_price不能为空");
|
|
|
+ }
|
|
|
$num = isset($this->post['num'])&&$this->post['num']!==""?intval($this->post['num']):"";
|
|
|
if($num===""){
|
|
|
return error_show(1004,"参数num不能为空");
|
|
@@ -314,10 +372,11 @@ class Consult extends BaseController
|
|
|
if($zxinfo==false){
|
|
|
return error_show(1004,"未找到信息数据");
|
|
|
}
|
|
|
- $zxorder = Db::name("consilt_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
|
|
|
+ $zxorder = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
|
|
|
if($zxorder==false){
|
|
|
return error_show(1004,"未找到咨询信息数据");
|
|
|
}
|
|
|
+ $zxinfo['can']= isset($zxinfo['cat_id']) && $zxinfo['cat_id'] !=0 ? made($zxinfo['cat_id'],[]):[];
|
|
|
$zxorder['khname']="";
|
|
|
if($zxorder['khNo']!==""){
|
|
|
$kh=Db::name("customer_info")->where(['companyNo'=>$zxorder['khNo']])->find();
|
|
@@ -459,6 +518,7 @@ class Consult extends BaseController
|
|
|
"createrid"=>$createrid,
|
|
|
"creater"=>$creater,
|
|
|
"status"=>0,
|
|
|
+ "is_del"=>0,
|
|
|
"addtime"=>date("Y-m-d H:i:s"),
|
|
|
"updatetime"=>date("Y-m-d H:i:s")
|
|
|
];
|
|
@@ -512,11 +572,11 @@ class Consult extends BaseController
|
|
|
if($bidNo==""){
|
|
|
return error_show(1004,"参数bidNo不能为空");
|
|
|
}
|
|
|
- $info =Db::name("good_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
|
|
|
+ $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
|
|
|
if($info==false){
|
|
|
return error_show(1004,"未找到商品数据");
|
|
|
}
|
|
|
- $unit =Db::name("unit")->where(["id"=>$info['good_unit']])->find();
|
|
|
+ $unit =Db::name("unit")->where(["id"=>$info['unit_id']])->find();
|
|
|
$info['unit'] = isset($unit['unit'])?$unit['unit']:'';
|
|
|
$info['cat_info'] = made($info['cat_id'],[]);
|
|
|
$supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
|
|
@@ -530,7 +590,80 @@ class Consult extends BaseController
|
|
|
$info["brand_name"]="";
|
|
|
$info["brand_id"]="";
|
|
|
}
|
|
|
+ return app_show(0,"获取成功",$info);
|
|
|
+ }
|
|
|
+ public function bargain_add(){
|
|
|
+ $bidNo = isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
|
|
|
+ if($bidNo===""){
|
|
|
+ return error_show(1004,"参数bidNo不能为空");
|
|
|
+ }
|
|
|
+ $info =Db::name("good_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
|
|
|
+ if($info==false){
|
|
|
+ return error_show(1004,"未找到商品数据");
|
|
|
+ }
|
|
|
+ $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
|
|
|
+ if($token==''){
|
|
|
+ return error_show(1005,"参数token不能为空");
|
|
|
+ }
|
|
|
+ $user =GetUserInfo($token);
|
|
|
+ if(empty($user)||$user['code']!=0){
|
|
|
+ return error_show(1002,"用户数据不存在");
|
|
|
+ }
|
|
|
|
|
|
+ $type = isset($this->post['type'])&& $this->post['type']!=""?intval($this->post['type']):"";
|
|
|
+ if($type===""){
|
|
|
+ return error_show(1004,"参数type不能为空");
|
|
|
+ }
|
|
|
+ $status = isset($this->post['status'])&& $this->post['status']!==""?intval($this->post['status']):"";
|
|
|
+ if($status===""){
|
|
|
+ return error_show(1004,"参数status不能为空");
|
|
|
+ }
|
|
|
+ $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
|
|
|
+ $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
|
|
|
+ $bargainNo =makeNo("BAR");
|
|
|
+ Db::startTrans();
|
|
|
+ try{
|
|
|
+ $data=[
|
|
|
+ "bidsNo"=>$bidNo,
|
|
|
+ "bargainNo"=>$bargainNo,
|
|
|
+ "bargain_type"=>$type,
|
|
|
+ "sale_price"=>$info['sale_price'],
|
|
|
+ "cost_before_price"=>$info['cost_fee'],
|
|
|
+ "cost_after_price"=>$info['cost_fee'],
|
|
|
+ "before_rate"=>$info['cost_fee'],
|
|
|
+ "after_rate"=>$info['cost_fee'],
|
|
|
+ "after_price"=>$info['cost_fee'],
|
|
|
+ "status"=>$status,
|
|
|
+ "is_del"=>0,
|
|
|
+ "creater"=>$creater,
|
|
|
+ "createrid"=>$createrid,
|
|
|
+ "addtime"=>date("Y-m-d H:i:s"),
|
|
|
+ "updatetime"=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $int = Db::name("bargain_order")->insert($data);
|
|
|
+ if($int){
|
|
|
+ if($type===1){
|
|
|
+ $info['status']=3;
|
|
|
+ $info['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ }
|
|
|
+ if($type===2){
|
|
|
+ $info['status']=4;
|
|
|
+ $status==1?$info['sale_price']=$data['after_price']:"";
|
|
|
+ $info['updatetime']=date("Y-m-d H:i:s");
|
|
|
+ }
|
|
|
|
|
|
+ $up =Db::name("good_bids")->save($info);
|
|
|
+ if($up){
|
|
|
+ Db::commit();
|
|
|
+ return app_show(0,"审核成功");
|
|
|
+ }else{
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,"审核失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ return error_show(1004,$e->getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|