order('id', 'desc')->field($fields)->select(); } /** * 保存地址 * * @param array $data * @return AccountAddress|Base|Model */ public function saveAddress(array $data) { if ($data['is_default'] == 1) { AccountAddress::update(['is_default' => 0], ['user_id' => $data['user_id']]); } if (isset($data['id']) && !empty($data['id'])) { return AccountAddress::updateById($data['id'], $data); } return AccountAddress::create($data); } /** * 删除地址 * * @param int $id * @return bool */ public function delAddress(int $id): bool { return AccountAddress::deleteById($id); } }