32], [['refund_source'], 'string', 'max' => 50], [['status'], 'string', 'max' => 10], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'refund_id' => 'Refund ID', 'order_id' => 'Order ID', 'order_no' => 'Order No', 'refund_amount' => 'Refund Amount', 'req_data' => 'Req Data', 'res_data' => 'Res Data', 'refund_params' => 'Refund Params', 'status' => 'Status', 'updated_at' => 'Updated At', 'created_at' => 'Created At', 'refund_source' => 'Refund Source', ]; } /** * @return ActiveQueryInterface the relational query object. */ public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id']); } /** * @return ActiveQueryInterface the relational query object. */ public function getRefund() { return $this->hasOne(OrderRefund::class, ['id' => 'refund_id']); } /** * 通过退款订单ID获取插件退款订单 * * @param integer $refund_id * @param string $refund_source * @return static|null */ public static function getOrderByRefundId(int $refund_id, string $refund_source = YunfastPayEnum::MALL_ORDER) { return static::find() ->where(['refund_id' => $refund_id, 'refund_source' => $refund_source]) ->one(); } /** * @return boolean */ public function isRefundOk() { return $this->status == '100' ? true : false; } /** * 修改状态 * * @param string $status * @return boolean */ public function changeStatus(string $status) { $this->status = $status; return $this->save(); } /** * 通过订单号获取订单 * * @param integer $mall_id * @param string $order_no * @return static|null */ public static function getOrderByNo(int $mall_id, string $order_no) { return static::find() ->where(['order_no' => $order_no]) ->one(); } }