Quellcode durchsuchen

1.复用招标工作台的部分接口;
2.登录成功后新增一个返回字段
3.中间件校验token的返回code值优化

wufeng vor 2 Jahren
Ursprung
Commit
f377a71596

+ 484 - 0
app/abutment/controller/Consult.php

@@ -0,0 +1,484 @@
+<?php
+
+
+namespace app\abutment\controller;
+
+
+use app\admin\model\ActionLog;
+use app\BaseController;
+use think\facade\Db;
+
+class Consult extends BaseController
+{
+
+    //招标工作台列表
+    public function crontablist()
+    {
+        $this->post = $this->request->filter('trim')->post();
+
+        $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];
+
+        $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
+        if ($salesman !== "") $where[] = ["b.salesman", 'like', "%$salesman%"];
+
+        $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
+        if ($cpName !== "") $where[] = ["a.good_Name", 'like', "%$cpName%"];
+
+        $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
+        if ($khNo !== "") $where[] = ["b.khNo", 'like', "%$khNo%"];
+
+        $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];
+
+        $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
+        if ($status !== "") $where[] = ["a.status", '=', $status];
+
+        $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_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()
+            ->toArray();
+        $data = [];
+        $noble = ['0' => '', '1' => '18K', '2' => '24K', '3' => '白银'];
+        $all_cat = Db::name('cat')
+            ->whereIn('id', array_column($list, 'cat_id'))
+            ->column('order_rate', 'id');
+        $all_brand = Db::name('brand')
+            ->whereIn('id', array_column($list, 'brand_id'))
+            ->column('brand_name', 'id');
+        foreach ($list as $value) {
+            $value['can'] = isset($value['cat_id']) && $value['cat_id'] != 0 ? made($value['cat_id']) : [];
+//            $cat = Db::name("cat")->where(["id" => $value['cat_id']])->find();
+            $budget = isset($all_cat[$value['cat_id']]) ? $all_cat[$value['cat_id']] : 0;
+            $value['original_price'] = sprintf("%.2f", $value['budget_price'] * (1 - $budget / 100));
+
+//            $brand = Db::name("brand")->where(['id' => $value['brand_id']])->find();
+            $value['brand_name'] = isset($all_brand[$value['brand_id']]) && $all_brand[$value['brand_id']] != '' ? $all_brand[$value['brand_id']] : "";
+            $value['khname'] = "";
+            $value['specinfo'] = isset($value['specinfo']) && $value['specinfo'] != "" ? json_decode($value['specinfo'], true) : [];
+            if ($value['khNo'] !== "") {
+                $kh = Db::name("customer_info")
+                    ->where(['companyNo' => $value['khNo']])
+                    ->find();
+                $value['khname'] = isset($kh['companyName']) ? $kh['companyName'] : "";
+            }
+            $consult = Db::name("consult_bids")
+                ->where(["infoNo" => $value['infoNo'], "createrid" => $this->request->user['uid'], "is_del" => 0])
+                ->find();
+            $consults = Db::name("consult_bids")
+                ->where(["infoNo" => $value['infoNo'], "is_del" => 0])
+                ->find();
+            $value['is_feed'] = $consult == false ? 0 : 1;
+            $value['is_all_feed'] = $consults == false ? 0 : 1;
+            $value['metal_name'] = isset($value['metal_id']) && $value['metal_id'] != 0 ? $noble[$value['metal_id']] : "";
+            $data[] = $value;
+        }
+        return json_show(0, "获取成功", ['count' => $count, 'list' => $data]);
+    }
+
+    //招标工作台详情
+    public function zxinfo()
+    {
+        $this->post = $this->request->filter('trim')->post();
+
+        $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] != "" ? trim($this->post['infoNo']) : "";
+        if ($infoNo == "") {
+            return json_show(1004, "参数infoNo不能为空");
+        }
+        $zxinfo = Db::name("consult_info")->where(["infoNo" => $infoNo, "is_del" => 0])->find();
+        if ($zxinfo == false) {
+            return json_show(1004, "未找到信息数据");
+        }
+        $zxorder = Db::name("consult_order")->where(["zxNo" => $zxinfo['zxNo'], "is_del" => 0])->find();
+        if ($zxorder == false) {
+            return json_show(1004, "未找到咨询信息数据");
+        }
+        $cat = Db::name("cat")->where(["id" => $zxinfo['cat_id']])->find();
+        $budget = isset($cat['order_rate']) ? $cat['order_rate'] : 0;
+        $zxinfo['can'] = isset($zxinfo['cat_id']) && $zxinfo['cat_id'] != 0 ? made($zxinfo['cat_id'], []) : [];
+        $zxinfo['khname'] = "";
+        $zxinfo['original_price'] = sprintf("%.2f", $zxinfo['budget_price'] * (1 - $budget / 100));
+        $zxinfo['khNo'] = "";
+        $zxinfo['brand_id'] = $zxinfo['brand_id'] == 0 ? "" : $zxinfo['brand_id'];
+        $zxinfo['brand'] = "";
+        $zxinfo['companyNo'] = isset($zxorder['companyNo']) ? $zxorder['companyNo'] : "";
+        $zxinfo['projectNo'] = isset($zxorder['projectNo']) ? $zxorder['projectNo'] : "";
+        $zxinfo['is_project'] = isset($zxorder['is_project']) ? $zxorder['is_project'] : "";
+        $zxinfo['company'] = "";
+        $zxinfo['endtime'] = isset($zxorder['endtime']) ? $zxorder['endtime'] : "";
+        $zxinfo['platform_code'] = isset($zxorder['platform_code']) ? $zxorder['platform_code'] : "";
+        $zxinfo['salesman'] = isset($zxorder['salesman']) ? $zxorder['salesman'] : "";
+        $zxinfo['saleid'] = isset($zxorder['saleid']) ? $zxorder['saleid'] : "";
+        $zxinfo['depart'] = isset($zxorder['depart']) ? $zxorder['depart'] : "";
+        $zxinfo['project_name'] = "";
+        $zxinfo['budget_total'] = "";
+        $zxinfo['departinfo'] = [];
+        $zxinfo['unit_name'] = "";
+        $zxinfo['metal_name'] = isset($zxinfo['metal_id']) && $zxinfo['metal_id'] != 0 ? $this->noble[$zxinfo['metal_id']] : "";
+        $zxinfo['specinfo'] = json_decode($zxinfo['specinfo'], true);
+
+        if ($zxorder['khNo'] !== "") {
+            $kh = Db::name("customer_info")->where(['companyNo' => $zxorder['khNo']])->find();
+            $zxinfo['khname'] = isset($kh['companyName']) ? $kh['companyName'] : "";
+            $zxinfo['khNo'] = $zxorder['khNo'];
+        }
+        if ($zxinfo['unit'] !== "") {
+            $unit = Db::name("unit")->where(['id' => $zxinfo['unit']])->find();
+            $zxinfo['unit_name'] = isset($unit['unit']) ? $unit['unit'] : "";
+        }
+        if ($zxinfo['brand_id'] !== "") {
+            $unit = Db::name("brand")->where(['id' => $zxinfo['brand_id']])->find();
+            $zxinfo['brand'] = isset($unit['brand_name']) ? $unit['brand_name'] : "";
+        }
+        if ($zxorder['companyNo'] !== "") {
+            $kh = Db::name("business")->where(['companyNo' => $zxorder['companyNo']])->find();
+            $zxinfo['company'] = isset($kh['company']) ? $kh['company'] : "";
+        }
+        if ($zxorder['is_project'] == 1 && $zxorder['projectNo'] !== "") {
+            $project = Db::name("project")->where(["projectNo" => $zxorder['projectNo'], "is_del" => 0])->find();
+            $zxinfo['project_name'] = isset($project['project_name']) ? $project['project_name'] : "";
+            $zxinfo['budget_total'] = isset($project['budget_total']) ? $project['budget_total'] : "";
+            $zxinfo['project_use_desc'] = isset($project['use_desc']) ? $project['use_desc'] : "";
+            $projectinfo = Db::name("project_info")->where(["pgNo" => $zxinfo['pgNo']])->find();
+            $zxinfo['pgNo'] = isset($projectinfo['pgNo']) ? $projectinfo['pgNo'] : "";
+        }
+        if ($zxorder['depart'] > 0) {
+            $zxinfo['departinfo'] = GetPart($zxorder['depart']);
+        }
+        if ($zxorder['platform_code'] > 0) {
+            $palt = Db::name("platform")->where(["id" => $zxorder['platform_code']])->find();
+            $zxinfo['platform_name'] = isset($palt['platform_name']) ? $palt['platform_name'] : "";
+        }
+        return json_show(0, "获取成功", $zxinfo);
+    }
+
+    //采反商品列表
+    public function bidlist()
+    {
+        $this->post = $this->request->filter('trim')->post();
+        $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]];
+        $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
+        if ($zxNo !== "") {
+            $where[] = ['zxNo', 'like', '%' . $zxNo . '%'];
+        }
+        $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
+        if ($infoNo !== "") {
+            $where[] = ['infoNo', 'like', '%' . $infoNo . '%'];
+        }
+        $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
+        if ($bidNo !== "") {
+            $where[] = ['bidNo', 'like', '%' . $bidNo . '%'];
+        }
+        $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
+        if ($pgNo !== "") {
+            $bidinfo = Db::name("consult_info")->where([["pgNo", "=", $pgNo], ["is_del", "=", 0]])->column("infoNo");
+            $where[] = ['infoNo', 'in', $bidinfo];
+        }
+        $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
+        if ($bargain_status !== "") {
+            $bidinfo = Db::name("consult_info")->where([["bargain_status", "=", $bargain_status], ["is_del", "=", 0]])->column("infoNo");
+            $where[] = ['infoNo', 'in', $bidinfo];
+        }
+        $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
+        if ($projectNo !== "") {
+            $zxlist = Db::name("consult_order")->where(["projectNo" => $projectNo, "is_del" => 0, "is_project" => 1])->column("zxNo");
+            $where[] = ['zxNo', 'in', $zxlist];
+        }
+        $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
+        if ($is_own == 1) {
+//            $token = isset($this->post['token']) ? trim($this->post['token']) : "";
+//            if($token==""){
+//                return json_show(101,'token不能为空');
+//            }
+//            $apply_id =GetUserInfo($token);
+//            if(empty($apply_id)||$apply_id['code']!=0){
+//                return json_show(1002,"申请人数据不存在");
+//            }
+            $rm = $this->request->user['uid'];
+            $where[] = ['createrid', "=", $rm];
+        }
+
+        $count = Db::name('consult_bids')->where($where)->count();
+        $total = ceil($count / $size);
+        $page = $page >= $total ? $total : $page;
+        $list = Db::name('consult_bids')->where($where)->page($page, $size)->select()->toArray();
+        $data = [];
+        foreach ($list as $value) {
+            $catinfo = Db::name("cat")->where(["id" => $value['cat_id']])->find();
+            $value['can'] = isset($value['cat_id']) && $value['cat_id'] != 0 ? made($value['cat_id']) : [];
+            $unit = Db::name("unit")->where(["id" => $value['unit_id']])->find();
+            $value['unit'] = isset($unit['unit']) ? $unit['unit'] : '';
+            $supplier = Db::name("supplier")->where(["code" => $value['supplierNo']])->find();
+            $value['supplierName'] = isset($supplier['name']) ? $supplier['name'] : "";
+            if ($value['brand_id'] != 0) {
+                $brand = Db::name("brand")->where(["id" => $value['brand_id']])->find();
+                $value["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
+            } else {
+                $value["brand_name"] = "";
+                $value["brand_id"] = "";
+            }
+            $bidinfo = Db::name("consult_info")->where(["infoNo" => $value["infoNo"]])->find();
+            $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] : 0;
+            $god = [
+                "metal_id" => $value['metal_id'],
+                "weight" => $value["good_weight"],
+                "demo_fee" => $value["demo_fee"],
+                "delivery_fee" => $value["delivery_fee"],
+                "open_fee" => $value["open_fee"],
+                "packing_fee" => $value["pakge_fee"],
+                "mark_fee" => $value["mark_fee"],
+                "nake_fee" => $value["nake_fee"],
+                "cert_fee" => $value["cert_fee"],
+                //      "cost_fee"=>$value["cost_fee"],
+                "cost_fee" => $value["sale_cost_fee"] != $value['origin_cost_fee'] ? $value["sale_cost_fee"] : $value["cost_fee"],
+
+                "num" => $bidinfo["num"],
+            ];
+
+            $top_cat = made($value['cat_id']);
+            $top_cat_id = isset($top_cat[0]['id']) ? $top_cat[0]['id'] : 0;
+
+            if ($value['is_gold_price'] == 1 && $top_cat_id == 6) {
+                $price = GoldPrice($god, $budget / 100);
+                $value['sale_price'] = round($price, 2);
+                $value['origin_price'] = $value["sale_cost_fee"] != $value['origin_cost_fee'] ? $value["sale_price"] :
+                    $value["origin_price"];
+            }
+            $value['cost_fee'] = $value['origin_cost_fee'];
+            $value['specinfo'] = json_decode($value['specinfo'], true);
+            $value['metal_name'] = isset($value['metal_id']) && $value['metal_id'] != 0 ? $this->noble[$value['metal_id']] : "";
+            $value['bargain_status'] = $bidinfo['bargain_status'];
+
+            //reject驳回原因,status==5表示驳回
+            $value['reject'] = [];
+            if ($value['status'] >= 5) {
+                $value['reject'] = Db::name('bargain_order')
+                    ->field('id,remark,status')
+                    ->where(['infoNo' => $infoNo, 'bidsNo' => $value['bidNo']])
+                    ->whereIn('status', [3, 8, 11])->order("id desc")
+                    ->find();
+            }
+            //产地
+            $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
+            if ($value['delivery_place'] != "") {
+                list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['delivery_place']);
+            }
+            $value['delivery_place_cn'] = GetAddr(json_encode($place));
+            $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
+            if ($value['origin_place'] != "") {
+                list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['origin_place']);
+            }
+            $value['origin_addr'] = GetAddr(json_encode($place));
+//            if($value['origin_place']!=''){
+//                $code = explode(",",$value['origin_place']);
+//                $temp=[];
+//                $temp['provice_code']=isset($code[0])?$code[0]:"";
+//                $temp['city_code']=isset($code[1])?$code[1]:"";
+//                $temp['area_code']=isset($code[2])?$code[2]:"";
+//                $addr= GetAddr(json_encode($temp));
+//                $value['origin_addr'] = $addr;
+//            }
+            $data[] = $value;
+        }
+        return json_show(0, "获取成功", ['count' => $count, 'list' => $data]);
+    }
+
+    //创建采反商品
+    public function create()
+    {
+        $this->post = $this->request->filter('trim')->post();
+        $is_project = isset($this->post['is_project']) && $this->post['is_project'] !== "" ? intval($this->post['is_project']) : "";
+        if ($is_project === "") {
+            return json_show(1002, "参数is_project不能为空");
+        }
+
+        if ($is_project == 1) {
+            $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
+            if ($projectNo === "") {
+                return json_show(1002, "参数projectNo不能为空");
+            }
+        }
+        $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
+        if ($khNo === "") {
+            return json_show(1002, "参数khNo不能为空");
+        }
+        $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !== "" ? trim($this->post['companyNo']) : "";
+        if ($companyNo === "") {
+            return json_show(1002, "参数companyNo不能为空");
+        }
+        $endtime = isset($this->post['endtime']) && $this->post['endtime'] !== "" ? $this->post['endtime'] : "";
+        if ($endtime === "") {
+            return json_show(1002, "参数endtime不能为空");
+        }
+
+        $platform_code = isset($this->post['platform_code']) && $this->post['platform_code'] !== "" ? trim($this->post['platform_code']) :
+            "";
+        if ($platform_code === "") {
+            return json_show(1002, "参数platform_code不能为空");
+        }
+        $ladder = isset($this->post['ladder']) && !empty($this->post['ladder']) ? $this->post['ladder'] : "";
+        if ($ladder == "") {
+            return json_show(1005, "参数ladder不能为空");
+        }
+//        $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
+//        if($token==''){
+//            return json_show(105,"参数token不能为空");
+//        }
+
+//        $user =GetUserInfo($token);
+//        if(empty($user)||$user['code']!=0){
+//            return json_show(102,"用户数据不存在");
+//        }
+        $createrid = $this->request->user['uid'];
+        $creater = $this->request->user['nickname'];
+        $depart = Db::name("depart_user")->where(["uid" => $createrid, "status" => 1, "is_del" => 0])->find();
+        $zxNo = makeNo("ZX");
+        Db::startTrans();
+        try {
+            $data = [
+                "zxNo" => $zxNo,
+                "createrid" => $createrid,
+                "creater" => $creater,
+                "is_project" => $is_project,
+                "projectNo" => isset($projectNo) ? $projectNo : "",
+                "khNo" => $khNo,
+                "companyNo" => $companyNo,
+                "endtime" => $endtime,
+                "salesman" => $creater,
+                "platform_code" => $platform_code,
+                "saleid" => $createrid,
+                "depart" => isset($depart['itemid']) ? $depart['itemid'] : 0,
+                "status" => 0,
+                "is_del" => 0,
+                "addtime" => date("Y-m-d H:i:s"),
+                "updatetime" => date("Y-m-d H:i:s"),
+            ];
+            $zx = Db::name("consult_order")->insert($data);
+            if ($zx) {
+
+                //判断是否是项目,且该项目是否存在台账记录中
+                if ($is_project == 1) $stand_exists = Db::name('standing_book')->field('id')->where('projectNo', $projectNo)->find();
+
+                foreach ($ladder as $value) {
+                    $infoNo = makeNo("IF");
+                    $specinfo = [];
+                    if (isset($value['specinfo']) && !empty($value['specinfo'])) {
+                        foreach ($value["specinfo"] as $v) {
+                            $spec = Db::name("specs")->where(["id" => $v['specid']])->find();
+                            $spec_value = Db::name("spec_value")->where(["id" => $v['spec_value_id']])->find();
+                            $v['spec_name'] = isset($spec['spec_name']) ? $spec['spec_name'] : "";
+                            $v['spec_value_name'] = isset($spec_value['spec_value']) ? $spec_value['spec_value'] : "";
+                            $specinfo[] = $v;
+                        }
+                    }
+                    $info = [
+                        "infoNo" => $infoNo,
+                        "zxNo" => $zxNo,
+                        "spuCode" => "",
+                        "good_name" => $value['good_name'],
+                        "good_img" => $value['good_img'],
+                        "cat_id" => $value['cat_id'],
+                        "unit" => $value['unit'],
+                        "brand_id" => $value['brand_id'],
+                        "arrival_time" => $value['arrival_time'],
+                        "specinfo" => empty($specinfo) ? "" : json_encode($specinfo),
+                        "cost_desc" => isset($value['cost_desc']) ? $value['cost_desc'] : '',
+                        "is_addrs" => $value['is_addrs'],
+                        "is_custom" => $value['is_custom'],
+                        "metal_id" => $value['metal_id'],
+                        "config" => isset($value['config']) ? $value['config'] : "",
+                        "other_config" => isset($value['other_config']) ? $value['other_config'] : "",
+                        "specs_weight" => isset($value['specs_weight']) ? $value['specs_weight'] : "0",
+                        "gold_price" => isset($value['gold_price']) ? $value['gold_price'] : "0",
+                        "is_gold_price" => isset($value['is_gold_price']) ? $value['is_gold_price'] : "0",
+                        "total_weight" => isset($value['total_weight']) ? $value['total_weight'] : "0",
+                        "budget_price" => $value['budget_price'],
+                        "num" => $value['num'],
+                        "pgNo" => isset($value['pgNo']) && $value['pgNo'] !== "" ? trim($value['pgNo']) : "",
+                        "use_desc" => $value['use_desc'],
+                        "remark" => $value['remark'],
+                        "status" => 1,
+                        "is_del" => 0,
+                        "addtime" => date("Y-m-d H:i:s"),
+                        "updatetime" => date("Y-m-d H:i:s"),
+                        'enclosure_file' => isset($value['enclosure_file']) ? $value['enclosure_file'] : '',
+                    ];
+                    $up = Db::name("consult_info")->insertGetId($info);
+                    if (!$up) {
+                        Db::rollback();
+                        return json_show(1004, '添加失败');
+                    } else {
+                        //修改状态
+                        ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
+                            "order_code" => $infoNo,//咨询单详情编号
+                            "status" => 1,//这里的status是之前的值
+                            "action_remark" => '',//备注
+                            "action_type" => "create"//新建create,编辑edit,更改状态status
+                        ], "ZXD", 1, $info);
+
+                        //竞价单不走流程,不推待办已办
+//                        ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
+//                            "order_type" => 'ZXD',
+//                            "order_code" => $infoNo,//咨询单详情编号
+//                            "order_id" => $up,
+//                            "order_status" => 1,
+//                            'before_status'=>0
+//                        ]);
+
+                        //如果存在该项目编码,更新对应的第一个竞价单编码,其他竞价单编码新增(带着项目编码)
+                        if (isset($stand_exists)) {
+                            Db::name('standing_book')
+                                ->where('id', $stand_exists['id'])
+                                ->update([
+                                    'infoNo' => $infoNo,
+                                    'updatetime' => date('Y-m-d H:i:s')
+                                ]);
+                            unset($stand_exists);//后面的竞价单编码不用更新,都是新增
+                        } else {
+                            //添加台账信息
+                            Db::name('standing_book')
+                                ->insert([
+                                    'standBookNo' => makeNo("IO"),
+                                    'projectNo' => isset($projectNo) ? $projectNo : '',
+                                    'infoNo' => $infoNo,
+                                    'companyNo' => $companyNo,
+                                    'customer_code' => $khNo,
+                                    'addtime' => date('Y-m-d H:i:s'),
+                                    'updatetime' => date('Y-m-d H:i:s')
+                                ]);
+                        }
+                    }
+                }
+                Db::commit();
+                return json_show(0, "新建成功", ["zxNo" => $zxNo]);
+            } else {
+                Db::rollback();
+                return json_show(1004, "新建失败");
+            }
+        } catch (\Exception $e) {
+            Db::rollback();
+            return json_show(1003, $e->getMessage());
+        }
+
+    }
+
+}

+ 11 - 4
app/abutment/logic/Account.php

@@ -48,13 +48,20 @@ class Account
         if (!$rs) throw new Exception('更新账号token信息失败');
 
         $list = SupplierRelationUserModel::field('id,supplierNo,supplierName')
-            ->where([
-                'is_del' => $db::$is_del_normal,
-                'uid' => $res['uid'],
-            ])
+            ->where(['is_del' => $db::$is_del_normal,'uid' => $res['uid']])
             ->select()
             ->toArray();
 
+        //获取这些供应商的状态
+        $status = Db::name('supplier')
+            ->where('is_del',0)
+            ->whereIn('code',array_column($list,'supplierNo'))
+            ->column('status','code');
+
+        foreach ($list as &$value){
+            $value['status'] = $status[$value['supplierNo']];
+        }
+
         $info = [
             'uid' => $res['uid'],
             'nickname' => $res['nickname'],

+ 3 - 3
app/abutment/middleware/apiMiddleware.php

@@ -118,16 +118,16 @@ class apiMiddleware
             'token|用户token' => 'require|length:40|alphaNum',
             'supplierNo|供应商编码' => 'require|length:18|alphaNum',
         ]);
-        if (!$val->check($param)) throw new ValidateException('参数错误,' . $val->getError());
+        if (!$val->check($param)) json_show(101, '参数错误,' . $val->getError());
 
         $data = Cache::get(Config::get('redis_key.user_info_token') . $param['token']);
         $data = json_decode($data, true);
 
-        if (!$data) throw new Exception('token已过期');
+        if (!$data) return json_show(102, 'token已过期');
 
         $supplierNames = array_column($data['supplier_list'], 'supplierName', 'supplierNo');
 
-        if (!isset($supplierNames[$param['supplierNo']])) throw new Exception('你尚未绑定当前供应商');
+        if (!isset($supplierNames[$param['supplierNo']])) json_show(103, '你尚未绑定当前供应商');
 
         return array_merge($data, ['supplierNo' => $param['supplierNo'], 'supplierName' => $supplierNames[$param['supplierNo']]]);
     }

+ 6 - 0
app/abutment/route/app.php

@@ -34,4 +34,10 @@ route::rule('saleOutInfo', 'abutment/Sale/saleOutInfo');//发货单详情
 route::rule('outSend', 'abutment/Sale/outSend');//发货单库管发货
 route::rule('outSendBatchByImport', 'abutment/Sale/saleOutInfo');//发货单库管批量发货
 
+//竞价单
+route::rule('crontabList', 'abutment/Consult/crontablist');//招标工作台列表
+route::rule('consultZxInfo', 'abutment/Consult/zxinfo');//招标工作台详情
+route::rule('consultBidList', 'abutment/Consult/bidlist');//招标工作台商品列表
+route::rule('consultCreate', 'abutment/Consult/create');//创建采反商品
+