'正常', self::STATUS_PAUSE => '暂停' ]; const PAY_STATUS_OK = 1; const PAY_STATUS_NO = 0; const PAY_STATUS_ERROR = 2; const PAY_STATUS_WAIT = 3; public static $payStatusMaps = [ self::PAY_STATUS_NO => '已支付', self::PAY_STATUS_OK => '未支付', self::PAY_STATUS_ERROR => '退款异常', self::PAY_STATUS_WAIT => '退款排队中', ]; const PAY_TYPE_WECHAT = 1; const PAY_TYPE_ALIPAYMINI = 2; public static $payTypeMaps = [ self::PAY_TYPE_WECHAT => '微信支付', self::PAY_TYPE_ALIPAYMINI => '支付宝小程序支付' ]; const REFUND_OK = 1; const REFUND_NO = 0; public static $refundMaps = [ self::REFUND_OK => '已退款', self::REFUND_NO => '未退款' ]; const TYPE_USER = 0; public static $typeMaps = [ self::TYPE_USER => '用户发起一般退款' ]; const CHECK_STATUS_OK = 1; const CHECK_STATUS_NO = 0; public static $checkStatusMaps = [ self::CHECK_STATUS_NO => '审核通过', self::CHECK_STATUS_OK => '审核未通过' ]; /** * 生成订单号 * @return bool|string * User: Mead */ public static function makeNo() { // 订单流水号前缀 $prefix = AdminMerchant::getOrderTag() . 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; } public function pay_order_callback() { DepositOrder::where('id', $this->attributes['deposit_id'])->update([ 'is_refund' => DepositOrder::REFUND_OK ]); // 修改用户押金状态 User::where('id', $this->attributes['user_id'])->update([ 'deposit_money' => 0, 'is_deposit' => User::DEPOSIT_NO ]); return true; } /** * 退款成功回调 * @return bool */ public function refund_order_callback() { DepositOrder::where('id', $this->attributes['deposit_id'])->update([ 'is_refund' => DepositOrder::REFUND_OK ]); $user_id = $this->attributes['user_id']; $user = User::find($user_id); $re = CouponsUserBag::query()->where('user_id', $user_id) ->where('coupon_type', CouponsUserBag::COUPON_TYPE_DEPOSIT_FREE) ->where('valid_end_time', '<=', Carbon::now()->toDateTimeString()) ->where('status', CouponsUserBag::STATUS_OK)->exists(); if ($re) { //是否有免押金劵 User::where('id', $user_id)->update([ 'deposit_money' => 0, 'is_deposit' => User::DEPOSIT_OK, 'deposit_type' => User::DEPOSIT_COUPON ]); } else { $deposit_expire_time = Carbon::parse($user->deposit_expire_time); if (Carbon::now()->gte($deposit_expire_time)) { // 免押金卡已经过期 User::where('id', $user_id)->update([ 'deposit_money' => 0, 'is_deposit' => User::DEPOSIT_NO, 'deposit_type' => User::DEPOSIT_TYPE_NO ]); } else { // 免押金卡未过期 User::where('id', $user_id)->update([ 'deposit_money' => 0, 'is_deposit' => User::DEPOSIT_OK, 'deposit_type' => User::DEPOSIT_CARD ]); } } // // 修改用户押金状态 // User::where('id', $this->attributes['user_id'])->update([ // 'deposit_money' => 0, // 'is_deposit' => User::DEPOSIT_NO // ]); return true; } }