作者 何书鹏

api更新

@@ -210,6 +210,7 @@ class Index extends Api @@ -210,6 +210,7 @@ class Index extends Api
210 "price": "100.00", 价格 210 "price": "100.00", 价格
211 "line_price": "1000.00", 划线价 211 "line_price": "1000.00", 划线价
212 "image_text": "图片地址" 212 "image_text": "图片地址"
  213 + "stock_num": 68, 商品总库存
213 } 214 }
214 ] 215 ]
215 }) 216 })
@@ -236,6 +237,8 @@ class Index extends Api @@ -236,6 +237,8 @@ class Index extends Api
236 ->find(); 237 ->find();
237 $item['price'] = $goods_spec['goods_price']; 238 $item['price'] = $goods_spec['goods_price'];
238 $item['line_price'] = $goods_spec['line_price']; 239 $item['line_price'] = $goods_spec['line_price'];
  240 + // 总库存
  241 + $item->append(['stock_num']);
239 }); 242 });
240 }else{ 243 }else{
241 $list = $model->where('keywords','like','%'.$text.'%') 244 $list = $model->where('keywords','like','%'.$text.'%')
@@ -250,15 +253,18 @@ class Index extends Api @@ -250,15 +253,18 @@ class Index extends Api
250 ->find(); 253 ->find();
251 $item['price'] = $goods_spec['goods_price']; 254 $item['price'] = $goods_spec['goods_price'];
252 $item['line_price'] = $goods_spec['line_price']; 255 $item['line_price'] = $goods_spec['line_price'];
  256 + // 总库存
  257 + $item->append(['stock_num']);
253 }); 258 });
254 } 259 }
255 // 搜索记录 260 // 搜索记录
256 - $search_text = UserSearch::where(['user_id'=>$this->auth->id,'text'=>$text])->find(); 261 + $user_id = $this->auth->isLogin() ? $this->auth->id : 0;
  262 + $search_text = UserSearch::where(['user_id'=>$user_id,'text'=>$text])->find();
257 if($search_text){ 263 if($search_text){
258 $search_text->save(['updatetime' => time()]); 264 $search_text->save(['updatetime' => time()]);
259 }else{ 265 }else{
260 UserSearch::create([ 266 UserSearch::create([
261 - 'user_id' => $this->auth->id, 267 + 'user_id' => $user_id,
262 'text' => $text 268 'text' => $text
263 ]); 269 ]);
264 } 270 }