CardRidingUseLog.php 899 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Models;
  3. class CardRidingUseLog extends Model
  4. {
  5. protected $table = 'card_riding_use_logs';
  6. protected $guarded = [];
  7. public function order(){
  8. return $this->belongsTo(Order::class);
  9. }
  10. public static function logs($card_riding_user_bags_id,$order_id,$deduction_money){
  11. self::firstOrCreate([
  12. 'card_riding_user_bags_id' => $card_riding_user_bags_id,
  13. 'order_id' => $order_id,
  14. ],[
  15. 'deduction_money' => $deduction_money,
  16. ]);
  17. }
  18. /**
  19. * 该订单是否使用过骑行卡
  20. * @param $order_id int 订单id
  21. * @param $card_id int 用户骑行卡id
  22. * @return mixed
  23. * User:Fx
  24. * */
  25. public static function isUseThisCard($order_id,$card_id){
  26. return self::query()->where('card_riding_user_bags_id',$card_id)->where('order_id',$order_id)->first();
  27. }
  28. }