MiaoshaGoods.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class MiaoshaGoods extends Model
  5. {
  6. protected $connection = 'mysql';
  7. protected $pk = 'id';
  8. protected $name = 'miaosha_goods';
  9. public static function setGoodslist($goods)
  10. {
  11. if (!empty($goods)) {
  12. foreach ($goods as &$vo) {
  13. $goodsdata = Goods::find($vo['goods_id']);
  14. if (!empty($goodsdata)) {
  15. $vo['goods'] = $goodsdata->toArray();
  16. $vo['image'] = toimg($vo['goods']['image']);
  17. $vo['ptype'] = $vo['goods']['ptype'];
  18. $vo['time_amount'] = $vo['goods']['time_amount'];
  19. $vo['quantity_unit'] = $vo['goods']['quantity_unit'];
  20. $vo['is_timer'] = $vo['goods']['is_timer'];
  21. $vo['is_times'] = $vo['goods']['is_times'];
  22. $vo['timesmum'] = $vo['goods']['timesmum'];
  23. //$vo['price'] = floatval($vo['price']);
  24. $vo['price'] = floatval(Goods::setPrice($vo)["price"]);
  25. }
  26. }
  27. }
  28. return $goods;
  29. }
  30. }