You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
namespace App\Service\v3\Implementations;
use App\Model\v3\ShoppingCart;use App\Model\v3\Store;use App\Service\v3\Interfaces\ShopCartServiceInterface;use Hyperf\DbConnection\Db;
class ShopCartService implements ShopCartServiceInterface{ public function do() { $storeIds = Db::table('lanzu_shopping_cart')->where('user_id',15)->pluck('store_id')->toArray(); $res = Store::query()->with(['ShoppingCart' => function($query) { $query->with('goods'); }])->whereIn('id',$storeIds) ->get(); foreach ($res as &$k){ $k->subtotal = '99.90'; } return $res; }
public function check($goodsId) { return mt_rand(0,6); }
public function undo() { $storeIds = Db::table('lanzu_shopping_cart')->where('user_id',198)->pluck('store_id')->toArray(); $res = Store::query()->with(['ShoppingCart' => function($query) { $query->with('goods'); }])->whereIn('id',$storeIds) ->get(); foreach ($res as &$k){ $k->subtotal = '99.90'; foreach ($k->ShoppingCart as &$v){ switch (mt_rand(1,3)) { case 1: $str = '已下架'; break; case 2: $str = '已抢光'; break; case 3: $str = '已打烊'; break; } $v['goods']['invalid_cause'] = $str; }
} return $res; }
public function countGoods() { return mt_rand(1,100); }
public function getTotal() { $randomFloat = rand(100,999)/100; return $randomFloat; }}
|