Product.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Modules\Product\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Product extends Model
  5. {
  6. protected $table = 'products';
  7. protected $fillable = ['price', 'type', 'given', 'is_default', 'is_enabled', 'sequence', 'switch_to','qapp_charge_template_id'];
  8. public static function getChargeProduct($template_type)
  9. {
  10. return self::whereIn('products.type', ['TICKET_RECHARGE', 'YEAR_ORDER',"MONTH_ORDER", "",'NEW_USER'])
  11. ->where('is_enabled', 1)
  12. ->where('template_type', $template_type)
  13. ->select(
  14. 'products.id',
  15. 'products.price',
  16. 'products.type',
  17. 'products.given',
  18. 'products.is_default',
  19. 'products.sequence',
  20. 'products.switch_to'
  21. )
  22. ->orderBy('sequence')->get();
  23. }
  24. /**
  25. * 获取id下对应的充值和赠送额
  26. * @param $product_id
  27. * @return mixed
  28. */
  29. public static function getProductGivenAmount($product_id)
  30. {
  31. return self::where('id', $product_id)->select('given', 'price')->first();
  32. }
  33. static function detail($id)
  34. {
  35. return self::find($id);
  36. }
  37. public static function getProductsByIds($ids)
  38. {
  39. $result = self::whereIn('id', $ids)->get();
  40. return $result ? $result->toArray() : [];
  41. }
  42. }