panlumeng 3 سال پیش
والد
کامیت
ea5513b6a4
4فایلهای تغییر یافته به همراه21 افزوده شده و 23 حذف شده
  1. 4 12
      application/Admin/common.php
  2. 14 9
      application/Home/controller/Order.php
  3. 2 2
      application/config.php
  4. 1 0
      application/route.php

+ 4 - 12
application/Admin/common.php

@@ -76,23 +76,15 @@ function UploadImg($files){
     $files= !is_array($files) ? [$files] : $files;
    // var_dump($files);
     try{
-        //验证
-        //validate(['imgFile'=>['fileSize'=>10240000,'fileExt'=>'jpg,jpeg,png,bmp,gif', 'fileMime'=>'image/jpeg,image/png,image/gif']])->check(['imgFile'=>$files]);
-
-        foreach($files as $file){
-//            $url= File::disk('public')->putFile( 'topic/'.date("Ymd"), $file,function ()use($file){
-//                return str_replace('.'.$file->getOriginalExtension(),'',$file->getOriginalName()."_".date('YmdHis'));
-//            });
-//            $name = str_replace('.'.$file->getOriginalExtension(),'',$file->getOriginalName());
-
-            $info= $file->validate(['size'=>10240000,'ext'=>'jpg,jpeg,png,bmp,gif'])->move(ROOT_PATH .'public' .DS .'upload');
+       foreach($files as $file){
+        $info= $file->validate(['size'=>10240000,'ext'=>'jpg,jpeg,png,bmp,gif'])->move(ROOT_PATH .'public' .DS .'upload');
             if($info){
                 $temp = ['url'=>'upload/'. $info->getSaveName()];
                 $savename[]=$temp;
-               // echo 'upload/'. $info->getSaveName();
+
             }else{
                 return "";
-               // echo $file->getError();
+
             }
         }
 

+ 14 - 9
application/Home/controller/Order.php

@@ -54,28 +54,33 @@ class Order extends Base
      * @param  addrid
      */
     public function ist(){
-        $name = isset($this->post['name'])&&$this->post['name']!==""? intval($this->post['name']): "";
-        if($name==""){
-            return error_show(1004,'参数name');
-        }
+      $ist = Db::name('unit')->where(["is_del" => 0,"status"=>1])->field("id,name,weight")->select();
+      return app_show(0,"获取成功",["list"=>$ist]);
     }
     public function add(){
         $num = isset($this->post['num'])&&$this->post['num']!="" ? intval($this->post['num']):"";
         if($num==""){
             return error_show(1004,"参数num 不能为空或0");
         }
-        $id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['id']):"";
-        if($id==""){
-            return error_show(1004,"参数id不能为空");
+        $id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']): "";
+        if($id){
+            return error_show(1004,"unit_id不能为空");
+        }
+        $kg= Db::name('unit')->where(["is_del" => 0,"id"=>$id,"status"=>1])->field("id,name,weight")->find();
+        if(empty($kg)){
+            return error_show(1004,"单位不能为空");
         }
 
-
+        $count=$num*$kg['weight'];
+        if($count==""){
+            return error_show(1004,"购买数量不能为空");
+        }
         $addrid = isset($this->post['addrid'])&&$this->post['addrid']!="" ? intval($this->post['addrid']):"";
         if($addrid==""){
             return error_show(1004,"参数addrid 不能为空");
         }
         $stock = Db::name("account_stock")->where(['is_del'=>0,"accountid"=>$this->userinfo['id']])->find();
-        if(empty($stock) || $stock['stock_balance']<$num){
+        if(empty($stock) || $stock['stock_balance']<$count){
             return error_show(1004,"库存数量不足");
         }
         $addr =Db::name("rela_addr")->alias('a')->join("addr b","a.addrid=b.id","left")->where(["a.accountid"=>$this->userinfo['id'],

+ 2 - 2
application/config.php

@@ -15,9 +15,9 @@ return [
     // +----------------------------------------------------------------------
 
     // 应用调试模式
-    'app_debug'              => true,
+    'app_debug'              => false,
     // 应用Trace
-    'app_trace'              => true,
+    'app_trace'              => false,
     // 应用模式状态
     'app_status'             => '',
     // 是否支持多模块

+ 1 - 0
application/route.php

@@ -71,6 +71,7 @@ Route::rule("home/addredit","Home/Addr/Edit");
 Route::rule("home/addrdel","Home/Addr/Delete");
 
 Route::rule("home/orderlist","Home/Order/list");
+Route::rule("home/orderist","Home/Order/Ist");
 Route::rule("home/orderinfo","Home/Order/info");
 Route::rule("home/orderadd","Home/Order/add");
 Route::rule("home/orderstock","Home/Order/Stock");