wugg 3 年 前
コミット
e0912907d0
3 ファイル変更153 行追加70 行削除
  1. 121 39
      app/admin/controller/Consult.php
  2. 8 8
      app/admin/controller/Good.php
  3. 24 23
      app/admin/controller/Goodup.php

+ 121 - 39
app/admin/controller/Consult.php

@@ -257,39 +257,14 @@ class Consult extends BaseController
         if($remark===""){
             return error_show(1004,"参数remark不能为空");
         }
-        $spuCode = makeNo("SPU");
+
         Db::startTrans();
         try{
-            $data=[
-                "spuCode"=>$spuCode,
-                "good_name"=>$good_name,
-                "brand_id"=>$brand_id,
-                "good_unit"=>$unit,
-                "good_type"=>$is_custom,
-                "moq"=>1,
-                "customized"=>0,
-                "tax"=>0,
-                "supplierNo"=>0,
-                "is_auth"=>0,
-                "craft_desc"=>$cost_desc,
-                "good_remark"=>"",
-                "good_img"=>$good_img,
-                "good_thumb_img"=>"",
-                "good_info_img"=>"",
-                "status"=>0,
-                "is_del"=>0,
-                "createrid"=>0,
-                "creater"=>"",
-                "addtime"=>date("Y-m-d H:i:s"),
-                "updatetime"=>date("Y-m-d H:i:s")
-            ];
-            $good = Db::name("good_zixun")->insert($data);
-            if($good){
                 $infoNo=makeNo("INF");
                 $info=[
                     "infoNo"=>$infoNo,
                     "zxNo"=>$zxNo,
-                    "spuCode"=>$spuCode,
+                    "spuCode"=>"",
                     "good_name"=>$good_name,
                     "good_img"=>$good_img,
                     "cat_id"=>$cat_id,
@@ -319,12 +294,11 @@ class Consult extends BaseController
                 $up = Db::name("consult_info")->insert($info);
                 if($up){
                     Db::commit();
-                    return app_show(0,"添加成功");
+                    return app_show(0,"添加成功",["infoNo"=>$infoNo]);
                 }else{
                     Db::rollback();
                     return error_show(1004,'添加失败');
                 }
-            }
         }catch (\Exception $e){
             Db::rollback();
             return error_show(1004,$e->getMessage());
@@ -401,21 +375,23 @@ class Consult extends BaseController
             return error_show(1004,"参数cat_id不能为空");
         }
         $model = isset($this->post['model'])&&$this->post['model']!=""? trim($this->post['model']):"";
+        //$unit = isset($this->post['model'])&&$this->post['model']!=""? trim($this->post['model']):"";
         $material = isset($this->post['material'])&&$this->post['material']!=""? trim($this->post['material']):"";
-        $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? trim($this->post['unit_id']):"";
+        $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
         $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
-        $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? trim($this->post['work_day']):"";
-        $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? trim($this->post['delivery_day']):"";
+        $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
+        $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
         $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
-        $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? trim($this->post['expire_day']):"";
+        $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day'])
+            :"";
         $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
         $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
-        $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? trim($this->post['pay_way']):"";
+        $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):"";
         $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):"";
-        $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? trim($this->post['send_way']):"";
-        $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? trim($this->post['metal_id']):"";
-        $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? trim($this->post['is_gold_price']):"";
-        $config = isset($this->post['config'])&&$this->post['config']!=""? trim($this->post['config']):"";
+        $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):"";
+        $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):"";
+        $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):"";
+        $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:"";
         $weight = isset($this->post['weight'])&&$this->post['weight']!=""? floatval($this->post['weight']):"";
         $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!=""? floatval($this->post['demo_fee']):"";
         $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!=""? floatval($this->post['delivery_fee']):"";
@@ -430,6 +406,16 @@ class Consult extends BaseController
         $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"";
         $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
         $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):"";
+        $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,"用户数据不存在");
+        }
+        $createrid= isset($user["data"]['id']) ?  $user["data"]['id'] : "";
+        $creater= isset($user["data"]['nickname']) ?  $user["data"]['nickname'] : "";
         $bidNo=makeNo("BD");
         $spucode=makeNo("SPU");
         $data=[
@@ -447,7 +433,103 @@ class Consult extends BaseController
             "work_day"=>$work_day,
             "delivery_day"=>$delivery_day,
             "good_img"=>$good_img,
-            ""
+            "expire_day"=>$expire_day,
+            "origin_place"=>$origin_place,
+            "supplierNo"=>$supplierNo,
+            "pay_way"=>$pay_way,
+            "tax"=>$tax,
+            "send_way"=>$send_way,
+            "metal_id"=>$metal_id,
+            "is_gold_price"=>$is_gold_price,
+            "config"=>$config,
+            "weight"=>$weight,
+            "is_diff"=>$is_diff,
+            "demo_fee"=>$demo_fee,
+            "delivery_fee"=>$delivery_fee,
+            "open_fee"=>$open_fee,
+            "pakge_fee"=>$pakge_fee,
+            "nake_fee"=>$nake_fee,
+            "mark_fee"=>$mark_fee,
+            "cert_fee"=>$cert_fee,
+            "cost_fee"=>$cost_fee,
+            "total_fee"=>$total_fee,
+            "supply_area"=>$supply_area,
+            "remark"=>$remark,
+            "sale_price"=>0,
+            "createrid"=>$createrid,
+            "creater"=>$creater,
+            "status"=>0,
+            "addtime"=>date("Y-m-d H:i:s"),
+            "updatetime"=>date("Y-m-d H:i:s")
         ];
+        Db::startTrans();
+        try{
+            $insert= Db::name("consult_bids")->insert($data);
+            if($insert){
+                $data=[
+                    "spuCode"=>$spucode,
+                    "good_name"=>$pname,
+                    "brand_id"=>$brandid,
+                    "good_unit"=>$unit_id,
+                    "good_type"=>0,
+                    "moq"=>1,
+                    "customized"=>$work_day,
+                    "tax"=>$tax,
+                    "supplierNo"=>$supplierNo,
+                    "is_auth"=>0,
+                    "craft_desc"=>$cost_desc,
+                    "good_remark"=>$remark,
+                    "good_img"=>$good_img,
+                    "good_thumb_img"=>"",
+                    "good_info_img"=>"",
+                    "status"=>0,
+                    "is_del"=>0,
+                    "createrid"=>$createrid,
+                    "creater"=>$creater,
+                    "addtime"=>date("Y-m-d H:i:s"),
+                    "updatetime"=>date("Y-m-d H:i:s")
+                ];
+                $good = Db::name("good_zixun")->insert($data);
+                if($good){
+                    Db::commit();
+                    return app_show(0,"反馈成功",["bidNo"=>$bidNo]);
+                }else{
+                    Db::rollback();
+                    return error_show(1004,"反馈失败");
+                }
+            }else{
+                Db::rollback();
+                return error_show(1004,"反馈失败");
+            }
+        }catch (\Exception $e){
+            Db::rollback();
+            return error_show(1004,$e->getMessage());
+        }
+    }
+
+    public function feadinfo(){
+       $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,"未找到商品数据");
+       }
+        $unit =Db::name("unit")->where(["id"=>$info['good_unit']])->find();
+        $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
+        $info['cat_info'] = made($info['cat_id'],[]);
+        $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
+        $info['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
+        $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
+        $info['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
+        if($info['brand_id']!=0){
+            $brand=Db::name("brand")->where(["id"=>$info['brand_id']])->find();
+            $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
+        }else{
+            $info["brand_name"]="";
+            $info["brand_id"]="";
+        }
+
     }
 }

+ 8 - 8
app/admin/controller/Good.php

@@ -31,14 +31,14 @@ class Good extends \app\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(){

+ 24 - 23
app/admin/controller/Goodup.php

@@ -556,6 +556,7 @@ class Goodup extends BaseController
                 "status"=>"3",
                 "updatetime"=>date("Y-m-d H:i:s")
             ];
+            $field = array_diff($temp,$data);
             $up = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->save($temp);
             if($up){
                 if($speclist!=="" && !empty($speclist)){
@@ -814,8 +815,8 @@ class Goodup extends BaseController
         if($spuCode===''){
             return error_show(1004,"参数codes不能为空");
         }
-        $data = Db::name("good_basic")->where(["spuCode"=>$spuCode,"is_del"=>0])->find();
-        if($data==false){
+        $datas = Db::name("good_basic")->where(["spuCode"=>$spuCode,"is_del"=>0])->select()->toArray();
+        if(empty($datas)){
             return error_show(1004,"未找到商品数据");
         }
         $online_reason = isset($this->post['online_reason'])&&$this->post['online_reason']!==""? trim($this->post['online_reason']):"";
@@ -857,28 +858,28 @@ class Goodup extends BaseController
         Db::startTrans();
         $create =Db::name("good_platform")->insertAll($data);
         if($create){
-            $iso = Db::name("good")->where(["spuCode"=>$data['spuCode'],"is_del"=>0])->find();
-            if($iso==false){
-                unset($data['id']);
-                $data['creater']=$creater;
-                $data['createrid']=$createrid;
-                $data['addtime']=date("Y-m-d H:i:s");
-                $data['updatetime']=date("Y-m-d H:i:s");
-            }else{
-                $data['id']=$iso['is'];
-                $data['creater']=$creater;
-                $data['createrid']=$createrid;
-                $data['updatetime']=date("Y-m-d H:i:s");
-            }
-            $up =Db::name("good")->save($data);
-            if($up){
-                Db::commit();
-                return app_show(0,"提交成功");
-            }else{
-                Db::rollback();
-                return error_show(1004,"提交失败");
+            foreach ($datas as $value){
+                $iso = Db::name("good")->where(["spuCode"=>$value['spuCode'],"is_del"=>0])->find();
+                if($iso==false){
+                    unset($value['id']);
+                    $value['creater']=$creater;
+                    $value['createrid']=$createrid;
+                    $value['addtime']=date("Y-m-d H:i:s");
+                    $value['updatetime']=date("Y-m-d H:i:s");
+                }else{
+                    $value['id']=$iso['is'];
+                    $value['creater']=$creater;
+                    $value['createrid']=$createrid;
+                    $value['updatetime']=date("Y-m-d H:i:s");
+                }
+                $up =Db::name("good")->save($value);
+                if(!$up){
+                    Db::rollback();
+                    return error_show(1004,"提交失败");
+                }
             }
-
+            Db::commit();
+            return app_show(0,"提交成功");
         }else{
             Db::rollback();
             return error_show(1004,"提交失败");