12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace App\Models;
- use App\Traits\ModelHelpers;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Facades\Log;
- class RefundBalanceOrder extends Model
- {
- use ModelHelpers;
-
- const NO_TAG = 'B';
- protected $table = 'refund_balance_orders';
- protected $guarded = [];
- const REFUND_TYPE_BALANCE = 1;
- const PAY_STATUS_OK = 1;
- const PAY_STATUS_NO = 0;
- public static $payStatusMaps = [
- self::PAY_STATUS_NO => '已支付',
- self::PAY_STATUS_OK => '未支付'
- ];
-
- public static $refundTypeMaps = [
- self::REFUND_TYPE_BALANCE => '支付到余额',
- ];
-
- public static function makeNo()
- {
-
- $prefix = config('bike.no_tag') . self::NO_TAG . date('YmdHis');
- for ($i = 0; $i < 10; $i++) {
-
- $no = $prefix . str_pad(random_int(0, 999999), 6, '0', STR_PAD_LEFT);
-
- if (!static::query()->where('no', $no)->exists()) {
- return $no;
- }
- }
- Log::warning('find order no failed');
- return false;
- }
- public function users(){
- return $this->belongsTo(User::class, 'user_id', 'id');
- }
- public function area()
- {
- return $this->belongsTo(Area::class, 'area_id', 'id');
- }
- public function adminUser(){
- return $this->belongsTo(AdminUser::class, 'admin_id', 'id');
- }
- }
|