save([ 'is_paid' => self::COMMON_ON, 'paid_at' => date('Y-m-d H:i:s') ]); } /** * 订单相关信息取消(软删除) * * @param string $orderCoding * @return bool */ public static function cancel(string $orderCoding): bool { return self::where('coding', $orderCoding)->save([ 'status' => Order::STATUS_CANCEL, 'deleted_at' => date('Y-m-d H:i:s') ]); } /** * 历史记录 * * @param array $where * @param array $field * @return OrderActivity[]|array|Collection * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException */ public static function history(array $where, array $field = []) { return self::where($where)->field($field)->select(); } /** * 订单信息 * * @return HasOne */ public function orderInfo(): HasOne { return $this->hasOne(Order::class, 'coding', 'coding'); } /** * 用户信息 * * @return HasOne */ public function account(): HasOne { return $this->hasOne(Account::class, 'id', 'account_id')->withField(['id', 'nickname', 'real_name']); } }