1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace App\Models;
- use App\Traits\ModelHelpers;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Facades\Log;
- class CardRidingOrder extends Model
- {
- use ModelHelpers;
- const NO_TAG = 'R';
- //
- protected $table = "card_riding_orders";
- protected $guarded = [];
- public function areas()
- {
- return $this->belongsTo(Area::class, 'area_id', 'id');
- }
- public function users()
- {
- return $this->belongsTo(User::class, 'user_id', 'id');
- }
- public function cardRiding()
- {
- return $this->belongsTo(CardRiding::class, 'riding_card_id', 'id');
- }
- const PAY_TYPE_WECHAT = 1;
- const PAY_TYPE_ACCOUNT = 2;
- const PAY_TYPE_ADMIN_GIVE = 3;
- const PAY_TYPE_INVITE_NEW_USER_GIVE = 4;
- const PAY_TYPE_NEW_USER_OVER_AUTH_SERVER_GIVE = 5;
- public static $payTypeMaps = [
- self::PAY_TYPE_WECHAT => '微信支付',
- self::PAY_TYPE_ACCOUNT => '余额支付',
- self::PAY_TYPE_ADMIN_GIVE => '后台赠送',
- self::PAY_TYPE_INVITE_NEW_USER_GIVE => '邀请新用户赠送',
- self::PAY_TYPE_NEW_USER_OVER_AUTH_SERVER_GIVE => '新用户完成实名系统赠送'
- ];
- const PAY_STATUS_OK = 1;
- const PAY_STATUS_NO = 0;
- public static $payStatusMaps = [
- self::PAY_STATUS_OK => '支付成功',
- self::PAY_STATUS_NO => '支付失败',
- ];
- const STATUS_OK = 1;
- const STATUS_NO = 0;
- public static $statusMaps = [
- self::STATUS_OK => '支付成功',
- self::STATUS_NO => '支付失败'
- ];
- /**
- * 生成订单号
- * @return bool|string
- * User: Mead
- */
- public static function makeNo()
- {
- // 订单流水号前缀
- $prefix = config('bike.no_tag') . self::NO_TAG . date('YmdHis');
- for ($i = 0; $i < 10; $i++) {
- // 随机生成 6 位的数字
- $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;
- }
- }
|