wugg 3 years ago
parent
commit
a49e744ebf

+ 1 - 0
app/admin/controller/Goldprice.php

@@ -166,4 +166,5 @@ class Goldprice extends BaseController
             return error_show(1002,"更新失败");
         }
     }
+
 }

+ 247 - 0
app/admin/controller/Goodup.php

@@ -44,4 +44,251 @@ class Goodup extends BaseController
         $list = Db::name('good')->where($where)->page($page,$size)->order("addtime desc")->select();
         return app_show(0,"获取成功",['list'=>$list,'count'=>$count]);
     }
+
+    public function  create(){
+        $good_name= isset($this->post['good_name'])&&$this->post['good_name']!="" ? trim($this->post['good_name']):"";
+        if($good_name==""){
+            return error_show(1004,"商品名称不能为空");
+        }
+        $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? intval($this->post['cat_id']):"";
+        if($cat_id==''){
+            return error_show(1004,"商品分类不能为空");
+        }
+        $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
+        if($brandid==''){
+            return error_show(1004,"商品品牌不能为空");
+        }
+        $unit = isset($this->post['unit'])&&$this->post['unit']!=""? trim($this->post['unit']):"";
+        if($unit==''){
+            return error_show(1004,"商品单位不能为空");
+        }
+        $good_type = isset($this->post['good_type'])&&$this->post['good_type']!=""? intval($this->post['good_type']):"";
+        if($good_type==''){
+            return error_show(1004,"参数good_type不能为空");
+        }
+        $moq = isset($this->post['moq'])&&$this->post['moq']!=""? trim($this->post['moq']):"";
+        if($moq==''){
+            return error_show(1004,"商品起订量不能为空");
+        }
+        $is_exclusive = isset($this->post['is_exclusive'])&&$this->post['is_exclusive']!==""? intval($this->post['is_exclusive']):"";
+        if($is_exclusive===''){
+            return error_show(1004,"参数is_exclusive不能为空");
+        }
+        $customized = isset($this->post['customized'])&&$this->post['customized']!==""? intval($this->post['customized']):"";
+        if($customized===''){
+            return error_show(1004,"参数customized不能为空");
+        }
+        $tax = isset($this->post['tax'])&&$this->post['tax']!==""? intval($this->post['tax']):"";
+        if($tax===''){
+            return error_show(1004,"参数tax不能为空");
+        }
+        $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
+        if($supplierNo==''){
+            return error_show(1004,"参数supplierNo不能为空");
+        }
+
+        $is_auth = isset($this->post['is_auth'])&&$this->post['is_auth']!==""? intval($this->post['is_auth']):"";
+        if($is_auth===''){
+            return error_show(1004,"参数is_auth不能为空");
+        }
+        $auth_img = isset($this->post['auth_img'])&&$this->post['auth_img']!=""? trim($this->post['auth_img']):"";
+//        if($auth_img==''){
+//            return error_show(1004,"商品不能为空");
+//        }
+        $after_sales = isset($this->post['after_sales'])&&$this->post['after_sales']!=""? trim($this->post['after_sales']):"";
+        if($after_sales==""){
+            return error_show(1004,"参数after_sales不能为空");
+        }
+        $craft_desc = isset($this->post['craft_desc'])&&$this->post['craft_desc']!=""? trim($this->post['craft_desc']):"";
+
+        $good_remark = isset($this->post['good_remark'])&&$this->post['good_remark']!=""? trim($this->post['good_remark']):"";
+        if($good_remark===""){
+            return error_show(1004,"参数good_remark不能为空");
+        }
+        $weight = isset($this->post['weight'])&&$this->post['weight']!==""? floatval($this->post['weight']):"";
+        if($weight===""){
+            return error_show(1004,"参数weight不能为空");
+        }
+
+        $packing_way = isset($this->post['packing_way'])&&$this->post['packing_way']!==""? trim($this->post['packing_way'])
+            :"";
+        if($packing_way===""){
+            return error_show(1004,"参数packing_way不能为空");
+        }
+        $packing_size = isset($this->post['packing_size'])&&$this->post['packing_size']!==""? trim($this->post['packing_size']):"";
+        if($packing_size===""){
+            return error_show(1004,"参数packing_size不能为空");
+        }
+        $packing_spec = isset($this->post['packing_spec'])&&$this->post['packing_spec']!==""? trim($this->post['packing_spec']):"";
+        if($packing_spec===""){
+            return error_show(1004,"参数packing_spec不能为空");
+        }
+        $packing_weight = isset($this->post['packing_weight'])&&$this->post['packing_weight']!==""? floatval($this->post['packing_weight']):"";
+        if($packing_weight===""){
+            return error_show(1004,"参数packing_weight不能为空");
+        }
+        $packing_list = isset($this->post['packing_list'])&&$this->post['packing_list']!==""? trim($this->post['packing_list']):"";
+        if($packing_list===""){
+            return error_show(1004,"参数packing_list不能为空");
+        }
+        $good_bar = isset($this->post['good_bar'])&&$this->post['good_bar']!==""? trim($this->post['good_bar']):"";
+        $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? trim($this->post['supply_area']):"";
+        if($supply_area===""){
+            return error_show(1004,"参数supply_area不能为空");
+        }
+        $delivery_place = isset($this->post['delivery_place'])&&$this->post['delivery_place']!==""? trim($this->post['delivery_place']):"";
+        if($delivery_place===""){
+            return error_show(1004,"参数delivery_place不能为空");
+        }
+        $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!==""? trim($this->post['origin_place']):"";
+        if($origin_place===""){
+            return error_show(1004,"参数origin_place不能为空");
+        }
+        $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!==""? intval($this->post['delivery_day']):"";
+        if($delivery_day===""){
+            return error_show(1004,"参数delivery_day不能为空");
+        }
+        $lead_time = isset($this->post['lead_time'])&&$this->post['lead_time']!==""? intval($this->post['lead_time'])
+            :"0";
+//        if($lead_time===""){
+//            return error_show(1004,"参数lead_time不能为空");
+//        }
+        $sample_day = isset($this->post['sample_day'])&&$this->post['sample_day']!==""? intval($this->post['sample_day']):"0";
+//        if($sample_day===""){
+//            return error_show(1004,"参数sample_day不能为空");
+//        }
+        $sample_fee = isset($this->post['sample_fee'])&&$this->post['sample_fee']!==""? floatval($this->post['sample_fee']):"0";
+        $is_stock = isset($this->post['is_stock'])&&$this->post['is_stock']!==""? intval($this->post['is_stock']):"";
+        if($is_stock===""){
+            return error_show(1004,"参数is_stock不能为空");
+        }
+        $good_img = isset($this->post['good_img'])&&$this->post['good_img']!==""? trim($this->post['good_img']):"";
+        if($good_img===""){
+            return error_show(1004,"参数good_img不能为空");
+        }
+        $good_thumb_img = isset($this->post['good_thumb_img'])&&$this->post['good_thumb_img']!==""? trim($this->post['good_thumb_img']):"";
+        if($good_thumb_img===""){
+            return error_show(1004,"参数good_thumb_img不能为空");
+        }
+        $good_info_img = isset($this->post['good_info_img'])&&!empty($this->post['good_info_img'])? $this->post['good_info_img']:"";
+        if($good_info_img===""){
+            return error_show(1004,"参数good_info_img不能为空");
+        }
+        $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!==""? floatval($this->post['cert_fee']):"0";
+        $packing_fee = isset($this->post['packing_fee'])&&$this->post['packing_fee']!==""? floatval($this->post['packing_fee']):"0";
+        $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!==""? floatval($this->post['cost_fee']):"0";
+        $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!==""? floatval($this->post['mark_fee']):"0";
+        $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!==""? floatval($this->post['demo_fee']):"0";
+        $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!==""? floatval($this->post['open_fee']):"0";
+        $noble_metal = isset($this->post['noble_metal'])&&$this->post['noble_metal']!==""? intval($this->post['noble_metal']):"0";
+        $noble_weight = isset($this->post['noble_weight'])&&$this->post['noble_weight']!==""? floatval($this->post['noble_weight']):"0";
+        $is_gold_price= isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!==""? intval($this->post['is_gold_price']):"0";
+        $market_price = isset($this->post['market_price'])&&$this->post['market_price']!==""? floatval($this->post['market_price']):"";
+        if($market_price===""){
+            return error_show(1004,"参数market_price不能为空");
+        }
+        $nake_price = isset($this->post['nake_price'])&&$this->post['nake_price']!==""? floatval($this->post['nake_price']):"";
+        if($nake_price===""){
+            return error_show(1004,"参数nake_price不能为空");
+        }
+        $is_step = isset($this->post['is_step'])&&$this->post['is_step']!==""? intval($this->post['is_step']):"";
+        if($is_step===""){
+            return error_show(1004,"参数is_step不能为空");
+        }
+
+        $speclist = isset($this->post['speclist'])&&!empty($this->post['speclist'])? $this->post['speclist']:"";
+        $spucode=makeNo("SPU");
+        Db::startTrans();
+        try {
+            $data=[
+                "spuCode"=>$spucode,
+                "good_code"=>'',
+                "good_name"=>$good_name,
+                "cat_id"=>$cat_id,
+                'brand_id'=>$brandid,
+                "good_unit"=>$unit,
+                "good_type"=>$good_type,
+                "moq"=>$moq,
+                "is_exclusive"=>$is_exclusive,
+                "customized"=>$customized,
+                "tax"=>$tax,
+                "supplierNo"=>$supplierNo,
+                "is_auth"=>$is_auth,
+                "auth_img"=>$auth_img,
+                "after_sales"=>$after_sales,
+                "craft_desc"=>$craft_desc,
+                "good_remark"=>$good_remark,
+                "weight"=>$weight,
+                "packing_way"=>$packing_way,
+                "packing_size"=>$packing_size,
+                "packing_spec"=>$packing_spec,
+                "packing_list"=>$packing_list,
+                "packing_weight"=>$packing_weight,
+                "good_bar"=>$good_bar,
+                "supply_area"=>$supply_area,
+                "delivery_place"=>$delivery_place,
+                "origin_place"=>$origin_place,
+                "delivery_day"=>$delivery_day,
+                "lead_time"=>$lead_time,
+                "sample_day"=>$sample_day,
+                "sample_fee"=>$sample_fee,
+                "good_img"=>$good_img,
+                "good_thumb_img"=>$good_thumb_img,
+                "good_info_img"=>$good_info_img,
+                "cert_fee"=>$cert_fee,
+                "packing_fee"=>$packing_fee,
+                "cost_fee"=>$cost_fee,
+                "mark_fee"=>$mark_fee,
+                "demo_fee"=>$demo_fee,
+                "open_fee"=>$open_fee,
+                "noble_metal"=>$noble_metal,
+                "noble_weight"=>$noble_weight,
+                "is_gold_price"=>$is_gold_price,
+                "market_price"=>$market_price,
+                "nake_price"=>$nake_price,
+                "is_step"=>$is_step,
+                "is_online"=>0,
+                "status"=>0,
+                "createrid"=>0,
+                "creater"=>"",
+                "addtime"=>date("Y-m-d H:i:s"),
+                "updatetime"=>date("Y-m-d H:i:s")
+            ];
+            $in = Db::name("good_basic")->insert($data);
+            if($in){
+                if($speclist!=="" && !empty($speclist)){
+                    $temp=[];
+                    foreach ($speclist as $value){
+                        $lemp=[];
+                        $lemp['spuCode']=$spucode;
+                        $lemp['spec_id'] = $value['spec_id'];
+                        $lemp['spec_value_id'] = $value['spec_value_id'];
+                        $lemp['addtime'] = date("Y-m-d H:i:s");
+                        $lemp['updatetime'] =date("Y-m-d H:i:s");
+                        $temp[]=$lemp;
+                    }
+                    $count = Db::name("good_spec")->insertAll($temp);
+                    if($count!=0){
+                        Db::commit();
+                        return app_show(0,"创建成功",["spuCode"=>$spucode]);
+                    }else{
+                        Db::rollback();
+                        return app_show(1004,"商品规格值创建失败");
+                    }
+                }else{
+                    Db::commit();
+                    return app_show(0,"创建成功",["spuCode"=>$spucode]);
+                }
+            }else{
+                Db::rollback();
+                return app_show(1004,"商品创建失败");
+            }
+        }catch (\Exception $e){
+            Db::rollback();
+            return app_show(1004,$e->getMessage());
+        }
+    }
+
+
+
 }

+ 0 - 11
app/admin/controller/Sale.php

@@ -54,19 +54,8 @@ class Sale extends BaseController
         }
         $rm = isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
         $ri = isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
-        // $good_name=isset($this->post['good_name']) && $this->post['good_name'] !=="" ? trim($this->post['good_name']) :"";
-        //$good_num=isset($this->post['good_num']) && $this->post['good_num'] !=="" ? intval($this->post['good_num']) :"";
-        //  if($good_num==""){
-        //    return error_show(1002,"参数good_num不能为空");
-        //}
-        // $origin_price = isset($this->post['origin_price']) && $this->post['origin_price'] !=="" ? intval($this->post['origin_price']) :"";
-        //$sale_price=isset($this->post['sale_price']) && $this->post['sale_price'] !=="" ? trim($this->post['sale_price']) :"";
-        // $total_price=isset($this->post['total_price']) && $this->post['total_price'] !=="" ? trim($this->post['total_price']) :"";
         $post_fee = isset($this->post['post_fee']) && $this->post['post_fee'] !== "" ? trim($this->post['post_fee']) : "";
         $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
-//    $send_num = isset($this->post['send_num']) && $this->post['send_num'] !=="" ? intval($this->post['send_num']) :"";
-//    $wsend_num = isset($this->post['wsend_num']) && $this->post['wsend_num'] !=="" ? intval($this->post['wsend_num']) :"";
-//    $send_status = isset($this->post['send_status']) && $this->post['send_status'] !=="" ? intval($this->post['send_status']) :"";
         $va = isset($this->post['order_addr']) && $this->post['order_addr'] !== "" ? $this->post['order_addr'] : "";
         if ($va == "") {
             return error_show(1002, "参数order_addr不能为空");

+ 1 - 20
app/admin/controller/Supplier.php

@@ -38,26 +38,7 @@ public function list(){
     if ($is_platform !== "") {
         $where[] = ['is_platform',"=", $is_platform];
     }
-//    $area = isset($this->post['area']) && $this->post['area'] !== "" ? trim($this->post['area']) : "";
-//    if ($area !== "") {
-//        $where['area'] = ["like", "%{area}%"];
-//    }
-//    $city = isset($this->post['city']) && $this->post['city'] !== "" ? trim($this->post['city']) : "";
-//    if ($city !== "") {
-//        $where['city'] = ["like", "%{city}%"];
-//    }
-//    $nature = isset($this->post['nature']) && $this->post['nature'] !== "" ? trim($this->post['nature']) : "";
-//    if ($nature !== "") {
-//        $where['nature'] = ["like", "%{nature}%"];
-//    }
-//    $legaler = isset($this->post['legaler']) && $this->post['legaler'] !== "" ? trim($this->post['legaler']) : "";
-//    if ($legaler !== "") {
-//        $where['legaler'] = ["like", "%{legaler}%"];
-//    }
-//    $addr = isset($this->post['addr']) && $this->post['addr'] !== "" ? trim($this->post['addr']) : "";
-//    if ($addr !== "") {
-//        $where['addr'] = ["like", "%{addr}%"];
-//    }
+
     $count = Db::name("supplier")->where($where)->count();
     $total = ceil($count/$size);
     $page = $page >= $total ? $total : $page;