afa před 5 měsíci
rodič
revize
62e86ac8c1

+ 11 - 7
app/api/controller/Inventory.php

@@ -26,7 +26,6 @@ class Inventory extends Base
     //添加出入库
     public function stock(StockLog $stockLog, StockService $stockService)
     {
-        
         $data = $this->request->post();
         $result = false;
         Db::startTrans();
@@ -54,13 +53,18 @@ class Inventory extends Base
     //出入库记录
     public function stocklog(StockLog $stockLog)
     {
-        
-        $data = $this->request->post();
-
-        //$result = $userEnterLog::create($data);
+        $where = [];
+        $type_id = $this->request->post('type_id/s', '');
+        if(!empty($type_id)) $where['a.type_id'] = $type_id;
 
-   
-        $this->success();
+        $list = $stockLog::alias('a')
+                ->leftjoin('stock_config b', 'a.variety_id = b.id')
+                ->where('a.user_id', $this->userinfo['id'])
+                ->where($where)
+                ->whereTime('a.createtime', '-2 days')
+                ->field('a.*,b.title')
+                ->select();
+        $this->success('ok', $list);
     }
 
 

+ 1 - 1
app/api/service/StockService.php

@@ -21,7 +21,7 @@ class StockService {
             foreach ($data['variety'] as $item) 
             {
                   if(count($item) != 3 || empty(floatval($item['num'])))  throw new \Exception('参数有误!');
-                  $weight = ($data['type']== 2) ? abs($item['num']): $item['num'];
+                  $weight = ($data['type']== '2') ? -$item['num']: $item['num'];
                   $result[] = [
                         'user_id'         => $uid, 
                         'type_id'         => $data['type_id'],