Kirin 2 years ago
parent
commit
06e2a7268c
2 changed files with 25 additions and 20 deletions
  1. 1 0
      app/admin/controller/company/Goods.php
  2. 24 20
      app/models/system/SystemStoreStockBill.php

+ 1 - 0
app/admin/controller/company/Goods.php

@@ -152,6 +152,7 @@ class Goods extends AuthController
         $info = $info->toarray();
         $info['in_stock'] = $where['in_stock'];
         $info['admin_id'] = $this->adminId;
+        $info['type'] = $where['type'] == 1 ? 1 : 2;
         if (SystemStoreStockBill::order_create($this->adminInfo['store_id'], $info)) {
             return Json::successful('入库成功');
         } else {

+ 24 - 20
app/models/system/SystemStoreStockBill.php

@@ -1,23 +1,27 @@
 <?php
+
 namespace app\models\system;
+
 use crmeb\basic\BaseModel;
 use crmeb\traits\ModelTrait;
 
 class SystemStoreStockBill extends BaseModel
 {
     use ModelTrait;
+
     public static function getAddTimeAttr($value)
     {
-        return date("Y-m-d H:i:s",$value);
+        return date("Y-m-d H:i:s", $value);
     }
+
     public static function getAuditTimeAttr($value)
     {
-        return $value?date("Y-m-d H:i:s",$value):'-';
+        return $value ? date("Y-m-d H:i:s", $value) : '-';
     }
+
     public static function getStatusAttr($value)
     {
-        switch ($value)
-        {
+        switch ($value) {
             case 0:
                 return '待审核';
                 break;
@@ -33,14 +37,14 @@ class SystemStoreStockBill extends BaseModel
     /**
      *创建记录
      */
-    public static function order_create($store_id,$data)
+    public static function order_create($store_id, $data)
     {
         if ($data['product_id'] > 0 && $data['in_stock'] > 0) {
 
-                $data['add_time'] = time();
-                $data['store_id'] = $store_id;
-                self::create($data);
-                return true;
+            $data['add_time'] = time();
+            $data['store_id'] = $store_id;
+            self::create($data);
+            return true;
         }
         return false;
     }
@@ -51,19 +55,19 @@ class SystemStoreStockBill extends BaseModel
     public static function lst($where)
     {
         $model = new self;
-        $model = $model->alias("a")->join("store_product b","a.product_id=b.id","right");
-        if(isset($where['store_id']) && $where['store_id']>0)  $model = $model->where('a.store_id',$where['store_id']);
-        if(isset($where['status']) && $where['status']>-2)  $model = $model->where('a.status',$where['status']);
-        if(isset($where['key']) && $where['key']) $model = $model->wherelike('b.store_name',"%".$where['key']."%");
-        if(isset($where['product_id']) && $where['product_id']) $model = $model->wherelike('a.product_id',$where['product_id']);
-        $model = $model->where('a.id','>',0);
+        $model = $model->alias("a")->join("store_product b", "a.product_id=b.id", "right");
+        if (isset($where['store_id']) && $where['store_id'] > 0) $model = $model->where('a.store_id', $where['store_id']);
+        if (isset($where['status']) && $where['status'] > -2) $model = $model->where('a.status', $where['status']);
+        if (isset($where['key']) && $where['key']) $model = $model->wherelike('b.store_name', "%" . $where['key'] . "%");
+        if (isset($where['product_id']) && $where['product_id']) $model = $model->wherelike('a.product_id', $where['product_id']);
+        $model = $model->where('a.id', '>', 0);
         $model = $model->field('a.*,b.image,b.is_show,b.is_del,b.store_name');
         $count = $model->count();
-        $data = $model->page($where['page'],$where['limit'])->order("id desc")->select()->toarray();
-        foreach ($data as &$v)
-        {
-            $v['store'] = SystemStore::where('id',$v['store_id'])->value('name');
+        $data = $model->page($where['page'], $where['limit'])->order("id desc")->select()->toarray();
+        foreach ($data as &$v) {
+            $v['store'] = SystemStore::where('id', $v['store_id'])->value('name');
+            $v['type'] = $v['type'] == 1 ? '<b style="color: #00aa00">+</b>' : '<b style="color: #aa0000">+</b>';
         }
-        return compact('count','data');
+        return compact('count', 'data');
     }
 }