zhanglinxin 1 ano atrás
pai
commit
9f3bee37ee

+ 16 - 0
application/api/controller/Approveinfo.php

@@ -5,6 +5,7 @@ namespace app\api\controller;
 use app\common\constant\CommonConstant;
 use app\common\service\ApproveService;
 use app\common\service\ApproveInfoService;
+use app\common\service\UserService;
 use hg\apidoc\annotation as Apidoc;
 use think\Db;
 use think\Exception;
@@ -23,6 +24,21 @@ class Approveinfo extends Base
     }
 
     /**
+     * 发起人列表
+     *
+     * @Apidoc\Method("POST")
+     * @Apidoc\Param("page", type="integer",require=true, desc="页数")
+     * @Apidoc\Param("page_num", type="integer", require=true, desc="每页数量")
+     **/
+    public function get_user_list(){
+        $offset = $this->off_set;
+        $length = $this->page_num;
+        $user = $this->user;
+        $list = UserService::get_list($offset, $length, $user);
+        $this->success('发起人列表', $list);
+    }
+
+    /**
      * 申请/重新发起/审批人修改
      *
      * @Apidoc\Method("POST")

+ 15 - 75
application/api/controller/Common.php

@@ -125,7 +125,6 @@ class Common extends Base
         $data = [];
         $use_data = [];
         $apply_goods_data = [];
-        $goods_list_import = [];
         try {
             if (!$PHPExcel = $reader->load($filePath)) {
                 $this->error('未知的数据格式!');
@@ -136,9 +135,9 @@ class Common extends Base
             $maxColumnNumber = Coordinate::columnIndexFromString($allColumn);
 
             if ($module == CommonConstant::MODULE_4) {
-                $fields = ['goods_no', 'goods_category_first', 'goods_category_id', 'goods_name', 'goods_sku', 'goods_sku_value', 'stock'];
+                $fields = ['goods_no', 'goods_category_first', 'goods_category_id', 'goods_name', 'goods_sku_value', 'stock'];
             } else {
-                $fields = ['goods_no', 'goods_category_first', 'goods_category_id', 'goods_brand', 'goods_name', 'goods_sku', 'goods_sku_value', 'stock', 'price', 'total_price'];
+                $fields = ['goods_no', 'goods_category_first', 'goods_category_id', 'goods_brand', 'goods_name', 'goods_sku_value', 'stock', 'price', 'total_price'];
             }
 
             for ($currentRow = 2; $currentRow <= $allRow; $currentRow++) {
@@ -158,11 +157,9 @@ class Common extends Base
                     } else {
                         $data[$values[1] . $values[2] . $values[4]][$values[5]][] = $temp;
                     }
+
                 }
             }
-//            p($insert);
-//            p($use_data);
-//            exit;
         } catch (Exception $exception) {
             $this->error('出现错误:'.$exception->getMessage());
         }
@@ -170,7 +167,7 @@ class Common extends Base
             $this->error('记录未找到');
         }
         if($use_data){
-            $msg = '导入的物品-';
+            $msg = '导入的物品';
             $error_data = [];
             foreach ($use_data as $key=>$value){
                 $arr = explode(',',$key);
@@ -184,6 +181,7 @@ class Common extends Base
                         'goodsStock',
                     ])
                     ->find();
+                p($goods_info);
                 if ($goods_info) {
                     // 商品库里有该商品
                     $goods_info = $goods_info->toArray();
@@ -192,19 +190,17 @@ class Common extends Base
                         if (array_key_exists($val['name'], $goods_stock_info)) {
                             // 商品库里有该商品规格
                             $stock = isset($val['stock']) ? $val['stock'] : 0;
-                            $price = isset($val['price']) ? $val['price'] : 0;
-                            $total_price = bcadd($total_price, $stock * $price, 2);
-                            $goods_stock_data[] = [
-                                'id' => $val['id'],
-                                'goods_id' => $goods_info['id'],
-                                'name' => $val['name'],
-                                'price' => $price,
-                                'stock' => $stock,
-                            ];
+                            $total_stock = $goods_stock_info[$val['name']]['stock'];
+                            if($stock > $total_stock){
+                                $lack_stock = bcsub($stock,$total_stock,1);
+                                $error_data[] = [
+                                    'msg'=> $msg.$goods_name.'-'.$val['name'].'库存不足,缺少'.$lack_stock.'件',
+                                ];
+                            }
                         } else {
                             // 商品库里没有该商品规格
                             $error_data[] = [
-                                'msg'=> $msg.$goods_name.'商品库不存在',
+                                'msg'=> $msg.$goods_name.'-'.$val['name'].'商品库不存在',
                             ];
                         }
                     }
@@ -215,28 +211,12 @@ class Common extends Base
                     ];
                 }
             }
-            p('1322');exit;
+            p($insert);exit;
             if($error_data){
-                $this->success('提示',$error_data,0,2);
+                $this->success('领用物品提示',$error_data,0,2);
             }
         }
         foreach ($data as $key => $value) {
-            if($module == CommonConstant::MODULE_4){
-                $arr = explode(',',$key);
-                $goods_info = Goods::field('status,is_deleted,create_at', true)
-                    ->where('goods_category_first', $arr[0])
-                    ->where('goods_category_id', $arr[1])
-                    ->where('goods_name', $arr[2])
-                    ->where('is_deleted', CommonConstant::IS_DELETED_0)
-                    ->with([
-                        'goodsStock',
-                    ])
-                    ->find();
-                if ($goods_info) {
-                    $goods_list_import[] = $goods_info->toArray();
-                }
-            }
-
             // 商品
             $goods_data = [];
             $goods_stock_data = [];
@@ -267,46 +247,6 @@ class Common extends Base
             $goods_data['goods_stock'] = $goods_stock_data;
             $apply_goods_data[] = $goods_data;
         }
-
-        if ($module == CommonConstant::MODULE_4) {
-            $msg = '导入的物品-';
-            $error_data = [];
-            $goods_object = $goods_list_import ? array_column($goods_list_import, null, 'goods_name') : [];
-            foreach ($apply_goods_data as $value){
-                if (array_key_exists($value['goods_name'], $goods_object)) {
-                    // 商品库里有该商品
-                    $goods_stock_info = array_column($goods_info['goods_stock'], null, 'name');
-                    foreach ($value['goods_stock'] as $val) {
-                        if (array_key_exists($val['id'], $goods_stock_info)) {
-                            // 商品库里有该商品规格
-                            $stock = isset($val['stock']) ? $val['stock'] : 0;
-                            $price = isset($val['price']) ? $val['price'] : 0;
-                            $total_price = bcadd($total_price, $stock * $price, 2);
-                            $goods_stock_data[] = [
-                                'id' => $val['id'],
-                                'goods_id' => $goods_info['id'],
-                                'name' => $val['name'],
-                                'price' => $price,
-                                'stock' => $stock,
-                            ];
-                        } else {
-                            // 商品库里没有该商品规格
-                            $error_data[] = [
-                                'msg'=> $msg.$value['goods_name'].'商品库不存在',
-                            ];
-                        }
-                    }
-                } else {
-                    // 商品库里没有该商品
-                    $error_data[] = [
-                        'msg'=> $msg.$value['goods_name'].'商品库不存在',
-                    ];
-                }
-            }
-            if($error_data){
-                $this->success('提示',$error_data,0,2);
-            }
-        }
         $this->success('导入成功', $apply_goods_data);
     }
 

+ 1 - 1
application/common/service/ApproveInfoService.php

@@ -361,7 +361,7 @@ class ApproveInfoService
                             ];
                         } else {
                             // 商品库里没有该商品规格
-                            $goods_stock_name .= $value['goods_name'] . $val['name'] . '、';
+                            $goods_stock_name .= $value['goods_name'] . '-'.$val['name'] . '、';
                         }
                     }
                     $apply_goods_data[] = [

+ 33 - 0
application/common/service/UserService.php

@@ -0,0 +1,33 @@
+<?php
+
+namespace app\common\service;
+
+use app\common\constant\CommonConstant;
+use app\common\model\User;
+use think\Db;
+use think\Exception;
+
+/**
+ * 用户服务类
+ */
+class UserService
+{
+
+    /**
+     * 列表
+     *
+     * @param integer $offset 起始位置
+     * @param integer $length 查询数量
+     * @param mixed $user 用户信息
+     **/
+    public static function get_list($offset, $length, $user)
+    {
+        $list = User::field('userid,name')
+            ->where('status', CommonConstant::IS_WHO_1)
+            ->where('is_deleted', CommonConstant::IS_DELETED_0)
+            ->limit($offset, $length)
+            ->select();
+        return $list;
+    }
+
+}

BIN
public/导入模板-入库物品.xlsx


BIN
public/导入模板-采购物品.xlsx


BIN
public/导入模板-领用物品.xlsx