32], [['acct_number', 'acct_name'], 'string', 'max' => 64], [['status'], 'string', 'max' => 5], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'user_id' => 'User ID', 'type' => 'Type', 'withdraw_id' => 'Withdraw ID', 'order_no' => 'Order No', 'trans_amount' => 'Trans Amount', 'acct_number' => 'Acct Number', 'acct_name' => 'Acct Name', 'acct_type' => 'Acct Type', 'req_data' => 'Req Data', 'res_data' => 'Res Data', 'status' => 'Status', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * @return ActiveQueryInterface the relational query object. */ public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id', 'mall_id' => 'mall_id']); } /** * @return ActiveQueryInterface the relational query object. */ public function getWithdrawLog() { return $this->hasOne(WithdrawLog::class, ['id' => 'withdraw_id']); } /** * @return ActiveQueryInterface the relational query object. */ public function getSplitbillLog() { return $this->hasOne(SplitbillItem::class, ['id' => 'withdraw_id']); } /** * @return ActiveQueryInterface the relational query object. */ public function getStore() { return $this->hasOne(Store::class, ['id' => 'user_id', 'mall_id' => 'mall_id']); } /** * @param integer $mall_id * @param string $order_no * @return static */ public static function getOrderByNo(int $mall_id, string $order_no) { return static::find() ->where(['mall_id' => $mall_id, 'order_no' => $order_no]) ->one(); } /** * 修改状态为已审核 * * @return void */ public function agree(WithdrawLog $log, string $msg = '', $status = '102', array $notify_data = []) { $t = \Yii::$app->db->beginTransaction(); try { $this->status = $status; $this->notify_data = json_encode($notify_data); $this->save(); WithdrawLog::remit_fail($log, $msg); $t->commit(); return true; } catch (\Exception $e) { $t->rollBack(); return false; } } /** * 门店 * * @param string $status * @return void */ public function failByStore($status = '102', array $notify_data = []) { $this->status = $status; $this->notify_data = json_encode($notify_data); return $this->save(); } /** * @param string $status * @return void */ public function success(WithdrawLog $log, $status = '100', array $notify_data = []) { $t = \Yii::$app->db->beginTransaction(); try { $this->status = $status; $this->notify_data = json_encode($notify_data); $this->save(); WithdrawLog::remit_success($log); $t->commit(); return true; } catch (\Exception $e) { $t->rollBack(); return false; } } /** * 门店 * * @param string $status * @return void */ public function successByStore($status = '100', array $notify_data = []) { $this->status = $status; $this->notify_data = json_encode($notify_data); return $this->save(); } }