123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Models;
- class CardRidingUseLog extends Model
- {
- protected $table = 'card_riding_use_logs';
- protected $guarded = [];
- public function order(){
- return $this->belongsTo(Order::class);
- }
- public static function logs($card_riding_user_bags_id,$order_id,$deduction_money){
- self::firstOrCreate([
- 'card_riding_user_bags_id' => $card_riding_user_bags_id,
- 'order_id' => $order_id,
- ],[
- 'deduction_money' => $deduction_money,
- ]);
- }
- /**
- * 该订单是否使用过骑行卡
- * @param $order_id int 订单id
- * @param $card_id int 用户骑行卡id
- * @return mixed
- * User:Fx
- * */
- public static function isUseThisCard($order_id,$card_id){
- return self::query()->where('card_riding_user_bags_id',$card_id)->where('order_id',$order_id)->first();
- }
- }
|